Note
Go to the end to download the full example code.
Calculate the GOES-XRS temperature and emission measure during a flare#
This example shows you how to estimate the GOES-XRS isothermal temperature and emission measure during a solar flare. This is done using the observed flux ratio of the short (0.5-4 angstrom) to long (1-8 angstrom) channels, based on the methods described in White et al. (2005). The functionality available here is the same as the functionality available in SSWIDL.
import matplotlib.pyplot as plt
from sunpy import timeseries as ts
from sunpy.data.sample import GOES_XRS_TIMESERIES
from sunkit_instruments import goes_xrs
Let’s begin by creating a GOES-XRS timeseries. We can use the sample data here to load in an example of a flare.
goes_ts = ts.TimeSeries(GOES_XRS_TIMESERIES)
goes_ts.plot()
<Axes: ylabel='Watts m$^{-2}$'>
The estimation is only valid for large fluxes (i.e. during a flare), so let’s truncate the timeseries over the time of the flare.
goes_flare = goes_ts.truncate("2011-06-07 06:15", "2011-06-07 09:00")
Now let’s calculate the temperature and emission measure estimates from
these channel fluxes. We can do this by using the function
sunkit_instruments.goes_xrs.calculate_temperature_emiss()
which
takes a sunpy.timeseries.XRSTimeSeries and returns a new GenericTimeSeries
which contains both the respective temperature and emission measure values.
goes_temp_em = goes_xrs.calculate_temperature_em(goes_flare)
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/sunkit-instruments/checkouts/stable/examples/calculate_goes_temperature_and_emission_measure.py", line 38, in <module>
goes_temp_em = goes_xrs.calculate_temperature_em(goes_flare)
File "/home/docs/checkouts/readthedocs.org/user_builds/sunkit-instruments/envs/stable/lib/python3.9/site-packages/sunkit_instruments/goes_xrs/goes_chianti_tem.py", line 124, in calculate_temperature_em
output = _chianti_temp_emiss(
File "/home/docs/checkouts/readthedocs.org/user_builds/sunkit-instruments/envs/stable/lib/python3.9/site-packages/sunpy/data/data_manager/manager.py", line 92, in wrapper
raise RuntimeError(
RuntimeError: Hash of local file (cb00c05850e3dc3bbd856eb07c1a372758d689d0845ee591d6e2531afeab0382) does not match expected hash (4ca9730fb039e8a04407ae0aa4d5e3e2566b93dfe549157aa7c8fc3aa1e3e04d). File may have changed on the remote server.
We can see that goes_temp_em is now a timeseries that contains the temperature and emission measure by printing out the column names.
print(goes_temp_em.columns)
Now let’s plot these all together.
fig, (ax1, ax2, ax3) = plt.subplots(3, sharex=True)
goes_flare.plot(axes=ax1)
goes_temp_em.plot(columns=["temperature"], axes=ax2)
goes_temp_em.plot(columns=["emission_measure"], axes=ax3)
ax3.set_yscale("log")
plt.show()
Total running time of the script: (0 minutes 2.926 seconds)