meta data for this page
This is an old revision of the document!
Use of the online exposure age calculators as a web service
In addition to just responding to browser requests with web pages, the online exposure age calculators are more general “web services.” This means you can send them a HTTP request as if you were a web browser submitting a form, and they will respond with either a web page (a string of text in HTML format) or, alternatively, a string of text in XML format that is simpler for a program to extract desired information from.
For programmatic use, you most likely want the XML output. Nearly all programming languages have XML parsers that you can use to unpack the XML object and get useful information out of it.
The URLs for use of the calculators as a web service are http://hess.ess.washington.edu/cgi-bin/matweb for the original server at UW, or http://stoneage.ice-d.org/cgi-bin/matweb for the mirror.
This page is incomplete.
Online exposure age calculator for mostly-spallogenic nuclides
The normal version of the online exposure age calculator computes exposure ages for He-3 in pyroxene or olivine as well as He-3, Be-10, C-14, Ne-21, and Al-26 in quartz. The fields that can be attached to an HTTP request to this calculator are as follows:
Field name | Description |
---|---|
text_block | A text string containing input text in calculators v3 input format |
mlmfile | 'age_input+v3' (identifies script to be used on server) |
reportType | 'HTML' or 'XML' to control output format |
plotFlag | 'yes' or 'no' to enable or disable plot generation |
resultType | 'short' returns only results with time-constant ('St') scaling; 'long' includes time-dependent scaling results |
summary | 'yes' or 'no' to enable or disable outlier detection, averaging, and summary plot generation |
For example, suppose the request has the following field values (the single quotes are not part of the field values, they are just indicating that they are text strings):
text_block | 'PH-1 41.3567 -70.7348 91 std 4.5 2.65 1 0.00008 1999; PH-1 Be-10 quartz 123453 3717 KNSTD; PH-1 Al-26 quartz 712408 31238 KNSTD;' |
mlmfile | 'age_input_v3' |
reportType | 'XML' |
plotFlag | 'no' |
resultType | 'long' |
summary | 'no' |
The XML response will be as follows:
<calcs_v3_age_data> <exposureAgeResult> <sample_name>PH-1</sample_name> <t10quartz_St>28196</t10quartz_St> <delt10quartz_int_St>871</delt10quartz_int_St> <delt10quartz_ext_St>2446</delt10quartz_ext_St> <Nnorm10quartz_St>27491</Nnorm10quartz_St> <delNnorm10quartz_int_St>828</delNnorm10quartz_int_St> <delNnorm10quartz_ext_St>2287</delNnorm10quartz_ext_St> <t10quartz_Lm>26948</t10quartz_Lm> <delt10quartz_int_Lm>832</delt10quartz_int_Lm> <delt10quartz_ext_Lm>2232</delt10quartz_ext_Lm> <Nnorm10quartz_Lm>26296</Nnorm10quartz_Lm> <delNnorm10quartz_int_Lm>792</delNnorm10quartz_int_Lm> <delNnorm10quartz_ext_Lm>2125</delNnorm10quartz_ext_Lm> <t10quartz_LSDn>28857</t10quartz_LSDn> <delt10quartz_int_LSDn>892</delt10quartz_int_LSDn> <delt10quartz_ext_LSDn>1963</delt10quartz_ext_LSDn> <Nnorm10quartz_LSDn>28110</Nnorm10quartz_LSDn> <delNnorm10quartz_int_LSDn>846</delNnorm10quartz_int_LSDn> <delNnorm10quartz_ext_LSDn>1862</delNnorm10quartz_ext_LSDn> <t26quartz_St>25713</t26quartz_St> <delt26quartz_int_St>1162</delt26quartz_int_St> <delt26quartz_ext_St>2990</delt26quartz_ext_St> <Nnorm26quartz_St>24975</Nnorm26quartz_St> <delNnorm26quartz_int_St>1095</delNnorm26quartz_int_St> <delNnorm26quartz_ext_St>2761</delNnorm26quartz_ext_St> <t26quartz_Lm>24607</t26quartz_Lm> <delt26quartz_int_Lm>1110</delt26quartz_int_Lm> <delt26quartz_ext_Lm>2626</delt26quartz_ext_Lm> <Nnorm26quartz_Lm>23921</Nnorm26quartz_Lm> <delNnorm26quartz_int_Lm>1049</delNnorm26quartz_int_Lm> <delNnorm26quartz_ext_Lm>2481</delNnorm26quartz_ext_Lm> <t26quartz_LSDn>26056</t26quartz_LSDn> <delt26quartz_int_LSDn>1178</delt26quartz_int_LSDn> <delt26quartz_ext_LSDn>2592</delt26quartz_ext_LSDn> <Nnorm26quartz_LSDn>25288</Nnorm26quartz_LSDn> <delNnorm26quartz_int_LSDn>1109</delNnorm26quartz_int_LSDn> <delNnorm26quartz_ext_LSDn>2441</delNnorm26quartz_ext_LSDn> </exposureAgeResult> <diagnostics> No diagnostics </diagnostics> <version> <wrapper>3.0.2</wrapper> <validate>validate_v3_input.m - 3.0</validate> <get_age>3.0.2</get_age> <muons>1A, alpha = 1</muons> <consts>2020-08-26</consts> </version> </calcs_v3_age_data>
The content of the XML response may vary depending on (i) the contents of the 'summarize' field; (ii) how many samples are present; (iii) whether there are multiple-nuclide data for any samples; and (iv) possibly other factors. It's probably a good idea to try out the expected possibilities that your code is expected to generate to make sure that you are getting the right information out of the XML.
Elements that are always present:
<exposureAgeResult>…</exposureAgeResult> elements. Each one of these blocks contains all the exposure-age results, for all scaling methods, with uncertainties, for one sample. In the example above, there is one sample with two measurements, and resultType was set to 'long', so there are three scaling methods. Each scaling method generates an age with internal and external uncertainties, so the exposure age results comprise 2 x 3 x 3 = 18 XML elements. The element tags contain the nuclide/mineral pair (t10quartz or t26quartz in this case), the scaling method ('St,' 'Lm,' 'LSDn') and what it is ('t' for age, 'del…int' for internal uncertainties, etc.). In this case there is one set of t10quartz results and one set of t26quartz results. If two Be-10 measurements were submitted for the same sample there would be two sets of t10quartz elements. In most cases, the <exposureAgeResult> element will also include normalized nuclide concentrations (the <Nnorm…> blocks for each scaling method), which can be used for plotting on a two-nuclide diagram.
<diagnostics>…</diagnostics> element. Contains either 'no diagnostics' or the error text that you would see in the normal exposure age calculator output.
<version>…</version> element. Contains identifying information for the various bits of code that were used for the calculation.
Elements that are sometimes present:
Blocks having to do with images generated on the remote server. If plotFlag is set, the XML will contain elements that look like this:
<ploturlstub>http://hess.ess.washington.edu/scratch/splotv3_355173</ploturlstub>
These contain URL stubs for plots that have been generated on the remote server. Add '.ps', '.gmt', or '.png' to the end to obtain the complete URL for the GMT script, Postscript image, or PNG image. These are the same plots that are normally generated by the online exposure age calculator. Note that they only live on the server for an hour before being deleted.
A block reporting summary data is present if 'summary' is set. Here is an example of what this would look like if you sent the input text from here with resultType = 'short' and summary = 'yes.'
<summary> <all> <St> <mean>1.7729e+04</mean> <sd>2.1628e+02</sd> <ewmean>1.7737e+04</ewmean> <ewse>1.5711e+02</ewse> <chi2>1.9938e+00</chi2> <dof>9.0000e+00</dof> <pchi2>9.9157e-01</pchi2> <text>All data: mean 17729; SD 216; chi-squared p-value is 0.9916....Pruned 0 outliers. ...Remaining data have p greater than 0.05; using error-weighted mean. ... Summary value is 17737 +/- 157 (1416)....If this is a moraine, the probability that it is Younger Dryas age is 0.00....The probability it belongs to the Antarctic Cold Reversal is 0.02.</text> <strip> <mean>1.7729e+04</mean> <sd>2.1628e+02</sd> <ewmean>1.7737e+04</ewmean> <ewse>1.5711e+02</ewse> <chi2>1.9963e+00</chi2> <dof>9.0000e+00</dof> <pchi2>9.9153e-01</pchi2> </strip> <sumval>1.7737e+04</sumval> <sumdel_int>1.5711e+02</sumdel_int> <sumdel_ext>1.4162e+03</sumdel_ext> <prob_ACR>1.5582e-02</prob_ACR> <prob_YD>3.0815e-04</prob_YD> </St> </all> <N10quartz> <St> <mean>1.7729e+04</mean> <sd>2.1628e+02</sd> <ewmean>1.7737e+04</ewmean> <ewse>1.5711e+02</ewse> <chi2>1.9938e+00</chi2> <dof>9.0000e+00</dof> <pchi2>9.9157e-01</pchi2> <text>All data: mean 17729; SD 216; chi-squared p-value is 0.9916....Pruned 0 outliers. ...Remaining data have p greater than 0.05; using error-weighted mean. ... Summary value is 17737 +/- 157 (1416)....If this is a moraine, the probability that it is Younger Dryas age is 0.00....The probability it belongs to the Antarctic Cold Reversal is 0.02.</text> <strip> <mean>1.7729e+04</mean> <sd>2.1628e+02</sd> <ewmean>1.7737e+04</ewmean> <ewse>1.5711e+02</ewse> <chi2>1.9963e+00</chi2> <dof>9.0000e+00</dof> <pchi2>9.9153e-01</pchi2> </strip> <sumval>1.7737e+04</sumval> <sumdel_int>1.5711e+02</sumdel_int> <sumdel_ext>1.4162e+03</sumdel_ext> <prob_ACR>1.5582e-02</prob_ACR> <prob_YD>3.0815e-04</prob_YD> </St> </N10quartz> </summary>
To get an idea of what is in all these blocks, you can enter the same data into this page with the 'These data are from a single landform' box checked, and match the XML up with the grouped and labeled results. Setting summary to 'yes' and plotFlag to 'yes' should return URLs for the camel plots.
XML object if an error is encountered:
If the calculator code encounters an error in the input data, it should return a lot of zeros in the exposure age fields and a description of the error in the diagnostics field. Note that there may be a bug in which the XML tags containing zeros get scrambled, or only the diagnostics element might be present. A sensible fix would be to set an <error>…</error> block that would be easily recognized, but that has not been done. In any case, if you process the XML and you can't find any exposure ages greater than zero, that should be interpreted as an error and one would want to look in the diagnostics block to see what happened. In addition, there are some errors that will just cause the calculator to fail and return nothing, so there should be a timeout.
Example of how to do this in MATLAB
This example uses the MATLAB 'webread' function to interact with the web service. Of course, the calculations code is already written in MATLAB, so if you want to do this a lot (like hundreds or thousands of calculations at once) you could install that locally, which would be much faster. However, that can be kind of a pain in the neck for various reasons, so if you don't need to calculate exposure ages all that often, it is easy to use the web service.
Note that the example uses a hokey regular expression match to get the needed information out of the XML object. Recent versions of MATLAB have a real XML processor.
% Text string in version 3 format text_string = ['PH-1 41.3567 -70.7348 91 std 4.5 2.65 1 0.00008 1999;' ... 'PH-1 Be-10 quartz 123453 3717 KNSTD;' ... 'PH-1 Al-26 quartz 712408 31238 KNSTD;']; % URL of service calc_url = 'http://hess.ess.washington.edu/cgi-bin/matweb'; % Script to run calc_mfile = 'age_input_v3'; % Use webread with other inputs as name,value pairs ages_xml = webread(calc_url,'mlmfile',calc_mfile,'text_block',text_string, ... 'reportType','XML','resultType','long','plotFlag','no','summary','no'); % Hokey string matching to extract ages from XML t10_string = regexp(ages_xml,['<t10quartz_St>(.*?)</t10quartz_St>'],'tokens'); t26_string = regexp(ages_xml,['<t26quartz_St>(.*?)</t26quartz_St>'],'tokens'); t10_string = t10_string{1}{1}; t26_string = t26_string{1}{1}; % Report disp(['Be-10 exposure age is ' sprintf('%0.0f',str2num(t10_string))]) disp(['Al-26 exposure age is ' sprintf('%0.0f',str2num(t26_string))])
Example of how to do this in Python
The below uses urllib to talk to the calculator web service and then xml.etree to parse the XML. Works in Python 3.
import urllib.parse import urllib.request import xml.etree.ElementTree as et # assemble form data # s is a string in calculator input format s = """PH-1 41.3567 -70.7348 91 std 4.5 2.65 1 0.00008 1999; PH-1 Be-10 quartz 123453 3717 KNSTD; PH-1 Al-26 quartz 712408 31238 KNSTD;""" form_fields = { "mlmfile" : "age_input_v3", "reportType" : "XML", "resultType" : "long", "summary" : "no", "plotFlag" : "no", "text_block" : s } # Encode request form_data = urllib.parse.urlencode(form_fields) form_data = form_data.encode('ascii') full_url = "http://hess.ess.washington.edu/cgi-bin/matweb" # Send request result = urllib.request.urlopen(full_url,form_data) # Extract result result_XML = result.read() # Parse XML tree = et.fromstring(result_XML) # Spit out some results for item in tree[0]: print(item.tag + ": " + item.text)
Online exposure age calculator for Cl-36
This is structured similarly to the other one. You may get some additional plots.
Example in MATLAB
This is only installed on stoneage.ice-d.org. Not installed on hess.ess.washington.edu.
Online erosion rate calculator for mostly-spallogenic nuclides
Again, this is structured quite similarly to the exposure-age calculator. In fact, the input is the same. The XML output has some different stuff in it.
Differences in the XML blocks
Example in MATLAB
Online exposure age calculator for mostly-spallogenic nuclides used for production rate calibration
The (non-Cl-36) exposure age calculator can also be used in reverse mode for production rate calibration.
This requires different input that includes the independent age information.
This also generates different output.
Example in MATLAB that obtains a production rate estimate from calibration data and then uses it to compute exposure ages of unknowns.