Jupyter Notebook for turning in solutions to the problems in the Essentials of Paleomagnetism Textbook by L. Tauxe

Problems in Chapter 2

Problem 1a: WRITE YOUR DESCRIPTION HERE


In [4]:
# You will need these things!
import numpy as np
import pandas as pd

Let's write a little function to do the conversion.


In [5]:
# the structure of a function is like this:
def dir2cart(dec,inc,R):  # first line starts with 'def', has the name and the input parameters (data)
     # all subsequent lines are indented
    #   continue this function here.......
    pass # this line does nothing - replace it with something that does!
    cart=[1.,1.,1.] # obviously this is not what you want.... 
    return cart # returns the stuff you calculated (x,y,z) or (n,e,d)

Now let's read in a data file with some geomagnetic field vectors in it.


In [8]:
# read in the data and transpose it to rows of dec, inc, int
# you have to change the file name to reflect where you put the data....   
data=np.loadtxt('ps2_prob1_data.txt').transpose() # this line will read in data
 # now send these data to your function....    and print out the x,y,z

Problem 1b: Read in locations from 10 random spots on Earth and calculate the IGRF vectors at each place.

First we have to understand how the function pmag.get_unf() works. To do this, we need to tell the notebook where the pmag module lives, import it and print out the doc string for get_unf():


In [11]:
import pmagpy.pmag as pmag # this makes the PmagPy module pmag.py available to you
print pmag.get_unf.__doc__
pmag.get_unf(10) # now you need to assign this to an array variable name and use it in the following.


    Called with get_unf(N).
 subroutine to retrieve N uniformly distributed directions
 using the way described in Fisher et al. (1987).
    
Out[11]:
array([[  48.79862281,  -42.7912137 ],
       [ 254.20814435,   29.76836608],
       [   5.13710564,  -30.52215226],
       [ 340.77085585,  -17.93811227],
       [ 263.57383863,    8.21116531],
       [ 100.80277122,    1.73260053],
       [ 141.48219414,   -1.3747035 ],
       [  13.56169561,  -38.28824633],
       [ 339.67863846,   41.48404555],
       [ 338.27864251,   -9.47637191]])

use that function to generate a list of random points on the Earth's surface.


In [6]:
# write your code here.

Now let's find out about ipmag.igrf()


In [1]:
import pmagpy.ipmag as ipmag # this makes the PmagPy module ipmag.py available to you
print ipmag.igrf.__doc__


    Prints out Declination, Inclination, Intensity from the IGRF model.

    Arguments
    ----------
    input_list : list with format [Date, Altitude, Latitude, Longitude]
    Date must be in format XXXX.XXXX with years and decimals of a year (A.D.)
    

In [7]:
# figure out how to send your places to ipmag.igrf.  do the calculation for 2015.

Problem 1c: Take the output from 1b and call ``dir2cart''.


In [7]:
#

Problem 2:

Take the output from Problem 1band plot as an equal area projection (first by hand and then with ipmag functions). The ipmag functions call pmagplotlib and use matplotlib, so these will have to be imported as well.


In [16]:
# this line lets you make plots inside the notebook:
%matplotlib inline

In [17]:
ipmag.plot_net(1) # make an equal angle net
# figure out how to use ipmag.plot_di() and plot the points.


Problem 3


In [10]:
# code it up here!

Let's use the pmag function dia_vgp. First let's figure out what it does:


In [13]:
print pmag.dia_vgp.__doc__


    converts declination, inclination, alpha95 to VGP, dp, dm
    takes input as (Decs, Incs, a95, Site latitudes, Site Longitudes).  
    These can be lists or individual values.
    

Now we can use it to convert our directions to VGPs. Note that alpha95 is required but is not given so supply a zero in its place. Note also that westward longitudes are indicated by minus signs...


In [11]:
# you figure it out.

In [ ]: