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
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.
Out[11]:
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__
In [7]:
# figure out how to send your places to ipmag.igrf. do the calculation for 2015.
In [7]:
#
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.
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__
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 [ ]: