Pandas : a library for data manipulation: https://pandas.pydata.org
Write your feedback to nds.contact-point@iaea.org
## API Quick how-to
The service URL is <b>nds.iaea.org/relnsd/v0/data?</b>
followed by parameters. For example:
<br> nds.iaea.org/relnsd/v0/data?<b>fields=decay_rads&nuclides=241am&rad_types=g</b>.<br>
The <a href=//nds.iaea.org/relnsd/vcharthtml/api_v0_guide.html><b>API v0 guide</b></a> gives the detailed description, here a short summary
<br><br>
<b>`fields=`</b> specifies what is retrieved (at the bottom of this notebook there is the list of the columns for each choice)
<br> these are the possible options<br><br>
_ground_states <br> levels <br> gammas <br> decay_rads <br> cumulative_fy <br> independent_fy_
<br><br>
for _ground_states, levels, gammas, decay_rads_ it is mandatory to add the <b>nuclide</b> parameter<br>
`fields=levels&nuclides=135xe`
<br><br>
for _decay_rads_ also the parameter <b>rad_types</b> is mandatory. Values are a, bp, bm, g, e, x (alpha, beta+, beta-, gamma, electron, X-ray)
<br>
`fields=decay_rads&nuclides=135xe&rad_types=bm`
<br>Be aware e aware of the fields <b>"p_energy" and
"decay"</b>. For
the same nuclide there can
be more than one decay mode, and, in case of metastable states, more states than the simple ground
state. This might result in gamma lines having the
same energy, but emitted by different decays
<br><br>
for _cumulative_fy, independent_fy_ one has to specify the <b>parent</b> and/or the <b>product</b>. Parents are _232th, 233u, 235u, 238u, 237np, 239pu, 241pu, 241am_
<br>
`fields=cumulative_fy&parents=233u&product=135xe `
<div style="margin-top:10px;font-size:18pt;font-weight:bold;"> Examples</div>
<br>
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
# the service URL
livechart = "https://nds.iaea.org/relnsd/v0/data?"
# There have been cases in which the service returns an HTTP Error 403: Forbidden
# use this workaround
import urllib.request
def lc_pd_dataframe(url):
req = urllib.request.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0')
return pd.read_csv(urllib.request.urlopen(req))
fields=decay_rads specifies to retrieve the decay radiations, nuclides=241am specifies the parent of the decay (241am), rad_types=g for the radiation type (gamma).
# load data into a dataframe
df = lc_pd_dataframe(livechart + "fields=decay_rads&nuclides=241am&rad_types=g")
df = df[pd.to_numeric(df['intensity'],errors='coerce').notna()] # remove blanks (unknown intensities)
df.intensity = df['intensity'].astype(float) # convert to numeric. Note how one can specify the field by attribute or by string
fig = px.scatter(df, x="energy", y="intensity", log_y=True) # plot in log scale
fig.show()