<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Jupyter Notebook for turning in solutions to the problems in the Essentials of Paleomagnetism Textbook by L. Tauxe
Problems in Chapter 2
Problem 1a
Step1:  Let's write a little function to do the conversion.
Step2:  Now let's read in a data file with some geomagnetic field vectors in it.
Step3:  Problem 1b
Step4:  use that function to generate a list of random points on the Earth's surface.
Step5:  Now let's find out about ipmag.igrf()
Step6:  Problem 1c
Step7:  Problem 2
Step8:  Problem 3
Step9:  Let's use the pmag function dia_vgp.  First let's figure out what it does
Step10:  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...
<ASSISTANT_TASK:>
Python Code:
# You will need these things!
import numpy as np
import pandas as pd
Explanation: 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
End of explanation
# 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)
Explanation: Let's write a little function to do the conversion.
End of explanation
# 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
Explanation: Now let's read in a data file with some geomagnetic field vectors in it.
End of explanation
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.
Explanation: 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():
End of explanation
# write your code here.
Explanation: use that function to generate a list of random points on the Earth's surface.
End of explanation
import pmagpy.ipmag as ipmag # this makes the PmagPy module ipmag.py available to you
print ipmag.igrf.__doc__
# figure out how to send your places to ipmag.igrf.  do the calculation for 2015.   
Explanation: Now let's find out about ipmag.igrf()
End of explanation
# 
Explanation: Problem 1c:  Take the output from 1b and call ``dir2cart''.
End of explanation
# this line lets you make plots inside the notebook:
%matplotlib inline
ipmag.plot_net(1) # make an equal angle net
# figure out how to use ipmag.plot_di() and plot the points. 
Explanation: 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.
End of explanation
# code it up here!
Explanation: Problem 3
End of explanation
print pmag.dia_vgp.__doc__
Explanation: Let's use the pmag function dia_vgp.  First let's figure out what it does:
End of explanation
# you figure it out.
Explanation: 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...
End of explanation
<END_TASK>