Providing a straightforward way to analyse data, these packages are widely used in machine learning.
Pandas is one of the most used libraries for data manipulation:
https://pandas.pydata.org
Plotly http://plotly.com is a package for interactive data
visualization,
here how to get it work
with jupyter lab
The service URL is nds.iaea.org/relnsd/v0/data?
followed by parameters. For example:
nds.iaea.org/relnsd/v0/data?fields=decay_rads&nuclides=241am&rad_types=g.
The API v0 guide gives the detailed
description, but the examples below are self explanatory
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
In this case use the following workaround
import urllib.request
def lc_read_csv(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).
On the plot below, mouseover the points to see the data. Zoom an pan are enabled, and the
option to save as png is is activated when the mouse is over the top-right
# load data into a dataframe
# this loading might not work, then use the line below
#df = pd.read_csv(livechart + "fields=decay_rads&nuclides=241am&rad_types=g")
df = lc_read_csv(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()