Hi everyone. I tried plotting RHESSI Hard X-Ray emission light curves using the codes below but getting an error. I am beginner level Python programmer with no experience in RHESSI or sunpy. I’m just learning. Please guide to solve this. Thank you in advance.
Input:
import glob
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from sunpy import timeseries as ts
from sunpy.net import Fido
from sunpy.net import attrs as a
from sunpy.net.dataretriever.sources.rhessi import RHESSIClient as RC
Data File Directory
outdir=‘/Users/A/Desktop/Filename’
Search for the data with Fido
trange=a.Time(“2010-11-05 12:00:26”,“2010-11-05 17:00:00”)
result = Fido.search(trange, a.Instrument.rhessi, a.Physobs.summary_lightcurve)
Get the file from Fido - can obviously skip this step if already downloaded (Not Working)
fg15 = Fido.fetch(result,path=outdir)
If already downloaded can skip above step and just load back in (Data files are detected correctly and displayed as output since I downloaded the data files manually)
fg15=glob.glob(outdir+‘hsi20101105*.fits’)
Good idea to always cancatenate incase more than one file
rhessi = ts.TimeSeries(fg15,concatenate=True)
What did timeseries load in
rhessi.meta
Quick peek at what timeseries loaded in
rhessi.peek()
Output:
IndexError Traceback (most recent call last)
Cell In[6], line 6
1 # My Random Comments
2 # My Random Comments
3 # My Random Comments
4
5 # Good idea to always cancatenate in case more than one file
----> 6 rhessi = ts.TimeSeries(fg15,concatenate=True)
8 # What did timeseries load in
9 rhessi.meta
File ~\anaconda3\Lib\site-packages\sunpy\timeseries\timeseries_factory.py:430, in TimeSeriesFactory.call(self, silence_errors, *args, **kwargs)
410 “”"
411 Method for running the factory. Takes arbitrary arguments and keyword
412 arguments and passes them to a sequence of pre-registered types to
(…)
427 Extra keyword arguments are passed through to sunpy.io.read_file
such as memmap
for FITS files.
428 “”"
429 self.silence_errors = silence_errors
→ 430 new_timeseries = self._parse_args(*args, **kwargs)
432 # Concatenate the timeseries into one if specified.
433 concatenate = kwargs.get(‘concatenate’, False)
File ~\anaconda3\Lib\site-packages\sunpy\timeseries\timeseries_factory.py:328, in TimeSeriesFactory._parse_args(self, *args, **kwargs)
326 for arg in args:
327 try:
→ 328 all_ts += self._parse_arg(arg, **kwargs)
329 except (NoMatchError, MultipleMatchError, ValidationFunctionError):
330 if self.silence_errors:
File ~\anaconda3\Lib\site-packages\sunpy\util\functools.py:18, in seconddispatch..wrapper(*args, **kwargs)
17 def wrapper(*args, **kwargs):
—> 18 return dispatcher.dispatch(args[1].class)(*args, **kwargs)
File ~\anaconda3\Lib\site-packages\sunpy\timeseries\timeseries_factory.py:394, in TimeSeriesFactory._parse_path(self, path, **kwargs)
390 raise MultipleMatchError(“Multiple HDUs return multiple matching classes.”)
392 cls = types[0]
→ 394 data_header_unit_tuple = cls._parse_hdus(pairs)
395 all_ts += self._parse_arg(data_header_unit_tuple)
397 return all_ts
File ~\anaconda3\Lib\site-packages\sunpy\timeseries\sources\rhessi.py:233, in RHESSISummaryTimeSeries._parse_hdus(cls, hdulist)
223 @classmethod
224 def _parse_hdus(cls, hdulist):
225 “”"
226 Parses a RHESSI astropy.io.fits.HDUList
from a FITS file.
227
(…)
231 A HDU list.
232 “”"
→ 233 header, d = parse_observing_summary_hdulist(hdulist)
234 # The time of dict d
is astropy.time, but dataframe can only take datetime
235 d[‘time’] = d[‘time’].datetime
File ~\anaconda3\Lib\site-packages\sunpy\timeseries\sources\rhessi.py:73, in parse_observing_summary_hdulist(hdulist)
58 “”"
59 Parse a RHESSI observation summary file.
60
(…)
69 Returns a dictionary.
70 “”"
71 header = hdulist[0].header
—> 73 reference_time_ut = parse_time(hdulist[5].data.field(‘UT_REF’)[0],
74 format=‘utime’)
75 time_interval_sec = hdulist[5].data.field(‘TIME_INTV’)[0]
76 # label_unit = fits[5].data.field(‘DIM1_UNIT’)[0]
77 # labels = fits[5].data.field(‘DIM1_IDS’)
IndexError: list index out of range