I went to the website: http://earthref.org/doi/10.1002/2016GC006307 and downloaded the data file. I put that into something called _Chapter_10/Problem1 in my working folder.
In [1]:
import pmagpy.ipmag as ipmag
help(ipmag.download_magic)
Now I need to unpack it with ipmag.download_magic(). But first I made a working directory named 'Myfiles'.
In [73]:
ipmag.download_magic('magic_contribution_12848.txt',dir_path='Chapter_10/Myfiles',input_dir_path='Chapter_10/Problem_1',print_progress=False)
Out[73]:
I can establish the specimen hierarchy using the pmagpy.contribution_builders (nb) add_sites_to_meas_table() function. Here I import contribution_builder and get the help message:
In [1]:
import pmagpy.contribution_builder as cb
help(cb.add_sites_to_meas_table)
Ah, I can just do this!
In [75]:
# read in the measurements with sites, samples added
status,meas=cb.add_sites_to_meas_table('Chapter_10/Myfiles')
In the _PmagPy_nb notebook I learned that I can convert the dataframe to a list of dictionaries with the command df.to_dict('records') and then use pmag.magic_write().
In [76]:
import pmagpy.pmag as pmag
help(pmag.magic_write)
In [78]:
# uncomment the mkdir command to make a directory.
# or you can do this with your operating system, e.g. in the Finder on Macs
#!mkdir Myfiles
HW1960_dict=HW1960.to_dict('records')
pmag.magic_write('Chapter_10/Myfiles/measurements.txt',HW1960_dict,'measurements')
Out[78]:
I used Thellier GUI and looked through the data. Some are pretty bad! I think the selection criteria of Cromwell et al. (2015) work very well (ccrit_criteria.txt in the Chapter_10/Problem_1 directory.
In [25]:
ipmag.download_magic('magic_contribution_14132.txt',dir_path='Chapter_10/Myfiles2',input_dir_path='Chapter_10/Problem_2',print_progress=False)
Out[25]:
Read in the measurements.txt file and get a unique list of method codes. While we are at it, we might as well read in the whole specimen hierarchy (because we will need it later):
In [26]:
status,meas=cb.add_sites_to_meas_table('Chapter_10/Myfiles2')
methods=meas.method_codes.unique()
methods
Out[26]:
Looking at the MagIC Method Codes website, these are:
So we can get the ARM and IRM data out like this:
In [27]:
ARMs=meas[meas.method_codes.str.contains('LT-AF-I')]
ARMs=ARMs.dropna(subset=['magn_mass'])
IRMs=meas[meas.method_codes.str.contains('LT-IRM')]
IRMs=IRMs.dropna(subset=['magn_mass'])
RMRMs=pd.merge(ARMs,IRMs, on='specimen',how='inner')
RMRMs.columns
Out[27]:
and to plot, we need to import matplotlib and to tell the notebook to show the plots in the notebook.
In [28]:
import matplotlib.pyplot as plt
%matplotlib inline
and plot:
In [30]:
plt.plot(RMRMs.magn_mass_x,RMRMs.magn_mass_y,'ro',markeredgecolor='black');
For this problem we need to:
In [31]:
import pandas as pd
In [32]:
specimens=pd.read_csv('Chapter_10/Myfiles2/specimens.txt',sep='\t',header=1)
specimens=specimens[specimens.citations.str.contains('Yamazaki')]
sites=pd.read_csv('Chapter_10/Myfiles2//sites.txt',sep='\t',header=1)
specimens['site']=specimens['specimen']
RPI=pd.merge(specimens,sites,on='site')
RPI.columns
Out[32]:
In [33]:
plt.figure(1,(10,5))
plt.plot(RPI.age,RPI.int_rel,'b-');
It looks like the age data are not in order, so we should sort by age
In [34]:
RPI=RPI.sort_values('age')
In [35]:
plt.figure(1,(10,5))
plt.plot(RPI.age,RPI.int_rel,'b-');
That's better!.
The minimal criteria would be a linear relationship between IRM and ARM and a range in concentrations that does not exceed 10. These data pass these minimal criteria. But it would be nice to replicate the data somewhere else too. And Yamazaki has done this recently....