meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
pluginto:calculators [2021/10/26 01:04] – gregbalco | pluginto:calculators [2022/05/03 00:22] (current) – gregbalco | ||
---|---|---|---|
Line 5: | Line 5: | ||
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. | 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:// | + | The URLs for use of the calculators as a web service are < |
- | This page is incomplete. | + | ==== Online exposure age calculator for mostly-spallogenic nuclides |
- | + | ||
- | ==== 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: | 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: | ||
Line 15: | Line 13: | ||
^ Field name ^ Description ^ | ^ Field name ^ Description ^ | ||
|text_block|A text string containing input text in [[http:// | |text_block|A text string containing input text in [[http:// | ||
- | |mlmfile|' | + | |mlmfile|' |
|reportType|' | |reportType|' | ||
|plotFlag|' | |plotFlag|' | ||
Line 95: | Line 93: | ||
**Elements that are always present:** | **Elements that are always present:** | ||
- | < | + | < |
< | < | ||
Line 176: | Line 174: | ||
** XML object if an error is encountered: | ** 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. | + | 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. |
- | |||
=== Example of how to do this in MATLAB === | === Example of how to do this in MATLAB === | ||
Line 215: | Line 212: | ||
===Example of how to do this in Python === | ===Example of how to do this in Python === | ||
- | This uses urllib and urllib2 | + | The below uses urllib |
+ | |||
+ | < | ||
+ | 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 Be-10 quartz 123453 3717 KNSTD; | ||
+ | PH-1 Al-26 quartz 712408 31238 KNSTD;""" | ||
+ | |||
+ | |||
+ | form_fields = { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | |||
+ | # Encode request | ||
+ | form_data = urllib.parse.urlencode(form_fields) | ||
+ | form_data = form_data.encode(' | ||
+ | |||
+ | full_url = " | ||
+ | |||
+ | # Send request | ||
+ | result = urllib.request.urlopen(full_url, | ||
+ | |||
+ | # 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 ==== | ==== Online exposure age calculator for Cl-36 ==== | ||
- | This is structured similarly to the other one. You may get some additional plots. | + | This is structured similarly to the above. The main differences in input fields are (i) of course the format for the input data is different; (ii) there is no ' |
- | Example | + | ^ Field name ^ Description ^ |
+ | |text_block|A text string containing input text in valid input form for Cl-36 data. This is explained [[http:// | ||
+ | |mlmfile|' | ||
+ | |reportType|' | ||
+ | |plotFlag|' | ||
+ | |summary|' | ||
- | This is only installed on stoneage.ice-d.org. Not installed on hess.ess.washington.edu. | + | The main difference in output |
- | ==== Online erosion rate calculator for mostly-spallogenic nuclides ===== | + | Note: this is only installed on stoneage.ice-d.org. It is not installed on hess.ess.washington.edu, |
- | 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 | + | ==== Online erosion rate calculator for mostly-spallogenic nuclides (not Cl-36) ===== |
- | Example | + | Again, this is similar to the exposure age calculations described |
- | ==== Online exposure age calculator for mostly-spallogenic nuclides used for production | + | ^ Field name ^ Description ^ |
+ | |text_block|A text string containing input text in valid v3 calculator | ||
+ | |mlmfile|' | ||
+ | |reportType|' | ||
+ | |resultType|' | ||
+ | |plotFlag|' | ||
- | The (non-Cl-36) exposure age calculator can also be used in reverse mode for production | + | The XML output |
- | This requires different input that includes the independent age information. | + | < |
+ | 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; | ||
+ | </ | ||
- | This also generates different output. | + | The XML result is as follows: |
- | Example | + | |
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | The main difference is that each result from a different nuclide concentration measurement is in its own < | ||
+ | |||
+ | This only returns results as mass erosion rates with units of g/ | ||
+ | |||
+ | At the moment this doesn' | ||
+ | |||
+ | Note: there is no erosion rate calculation service for Cl-36. | ||
+ | |||
+ | ==== Online exposure age calculator for mostly-spallogenic nuclides (not Cl-36), used for production rate calibration ==== | ||
+ | |||
+ | The (non-Cl-36) exposure age calculator can also be used in reverse mode for production rate calibration by setting the mlmfile field to ' | ||
+ | |||
+ | This requires different input that includes the independent age information. Suitable calibration data in the correct input format can be obtained | ||
+ | |||
+ | Note: you can only calibrate the production rate for one nuclide at a time. So the input data can only have measurements of one nuclide; otherwise generates an error. | ||
+ | |||
+ | Here is an example in MATLAB that (i) scrapes calibration data in the appropriate input form from the ICE-D: | ||
+ | |||
+ | This is somewhat complicated but if you are familiar with how the exposure age calculators work, and have gotten through all the previous examples, | ||
+ | |||
+ | < | ||
+ | % This gets calibration data from the ICE-D: | ||
+ | % calibrated production rate parameters with it, and uses those calibrated | ||
+ | % production rate parameters | ||
+ | % site. | ||
+ | |||
+ | clear all; | ||
+ | |||
+ | % Get some calibration data from the calibration website | ||
+ | |||
+ | cal_page_html = webread(' | ||
+ | |||
+ | % Note: this input data must include data for only one nuclide | ||
+ | |||
+ | % Scrape the formatted text block out of the HTML | ||
+ | startindex = strfind(cal_page_html,'< | ||
+ | endindex = strfind(cal_page_html,'</ | ||
+ | cal_input_text = cal_page_html(startindex: | ||
+ | |||
+ | %% Send that to the online calculator and get calibration results | ||
+ | |||
+ | url = " | ||
+ | cal_xml_result = webread(url,' | ||
+ | |||
+ | % Extract calibration information from XML. This is a stupid regexp | ||
+ | % matching scheme. In MATLAB R2021 you can use the proper XML parser. | ||
+ | |||
+ | % First, get the name of the nuclide -- eventually you will have to send this to the | ||
+ | % calibration code, because you can only do a calibration for one nuclide | ||
+ | % at a time. | ||
+ | |||
+ | temp = regexp(cal_xml_result, | ||
+ | nuclide_string = temp{1}{1}; | ||
+ | |||
+ | % Get calibrated production rate parameters | ||
+ | % Obviously, the below could be shortened by looping over scaling methods | ||
+ | temp = regexp(cal_xml_result, | ||
+ | value_St_string = temp{1}{1}; | ||
+ | temp = regexp(cal_xml_result, | ||
+ | uncert_St_string = temp{1}{1}; | ||
+ | temp = regexp(cal_xml_result, | ||
+ | value_Lm_string = temp{1}{1}; | ||
+ | temp = regexp(cal_xml_result, | ||
+ | uncert_Lm_string = temp{1}{1}; | ||
+ | temp = regexp(cal_xml_result, | ||
+ | value_LSDn_string = temp{1}{1}; | ||
+ | temp = regexp(cal_xml_result, | ||
+ | uncert_LSDn_string = temp{1}{1}; | ||
+ | |||
+ | %% Now we have the production rate parameters obtained from the calibration | ||
+ | % data. | ||
+ | |||
+ | % Get some data from ICE-D: | ||
+ | |||
+ | unknowns_page_html = webread(' | ||
+ | |||
+ | % Get the formatted text out of the HTML | ||
+ | |||
+ | startindex = strfind(unknowns_page_html,'< | ||
+ | endindex = strfind(unknowns_page_html,'</ | ||
+ | unknowns_input_text = unknowns_page_html(startindex: | ||
+ | |||
+ | |||
+ | %% Send sample info to exposure age calculator with additional options to | ||
+ | % force non-default Be-10 production rate | ||
+ | |||
+ | url = " | ||
+ | |||
+ | unknowns_xml_result_calibrated = webread(url,' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | %% Here is what it would look like if we omit the additional calibration | ||
+ | % parameters. In this case we get the results using the normal default | ||
+ | % production rate calibration. | ||
+ | |||
+ | unknowns_xml_result_default = webread(url,' | ||
+ | ' | ||
+ | |||
+ | % We leave it as an exercise for the student to extract the exposure ages | ||
+ | % from unknowns_xml_result_calibrated and unknowns_xml_result_default, | ||
+ | % verify that they are different. | ||
+ | </ | ||