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.

This page is still 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_blockA 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
summaryFlag'yes' or 'no' to enable or disable outlier detection, averaging, and summary plot generation

For example, suppose the request has the following field values:

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'
summaryFlag'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, leading to 18 elements with exposure age results. 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 t2quartz 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. These are present if plotFlag is set.

A block reporting summary data. Present if 'summarize' set. To get an idea of what is in all these blocks, look at the summary results for the same data entered using a browser. Should be fairly easy to figure it out.

XML object if an error is encountered:

If the calculator code encounters an error in the input data it returns an XML object describing the error (a detectable error, that is…some errors can cause it to crash completely and return nothing). Thus, your software may consider checking to make sure an error is not present before trying to process the XML results. Here is an example of an XML error structure.

Insert error XML

Nearly all programming languages have XML parsers that you can use to unpack the XML object and get useful information out of it.

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 string matching scheme to get the needed information out of the XML object. Recent versions of MATLAB have a real XML processor, as noted in the comments.

Insert MATLAB example here.

Example of how to do this in Python

This uses urllib and urllib2 in Python. Check Python 2 to 3?

Online exposure age calculator for Cl-36

This is structured similarly to the other one. You may get some additional plots.

Example in MATLAB

Online erosion rate calculator for mostly-spallogenic nuclides

I think that's it.

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.