sunpy / sunkit-instruments

A SunPy-affiliated package for solar instrument-specific tools.
https://docs.sunpy.org/projects/sunkit-instruments/
BSD 3-Clause "New" or "Revised" License
11 stars 15 forks source link

Add SAA, eclipse and flare flag in RHESSISummaryTimeSeries #124

Open somusset opened 5 months ago

somusset commented 5 months ago

Describe the feature

It would be useful, when accessing the count rates from the RHESSI Summary observation files, to also get the most useful flags (to my opinion those are the SAA, eclipse and flare flags).

Proposed solution

As far as I understood the reading of this info will be done in the function parse_observing_summary_hdulist and this is how I accessed it (by imitation of the way the countrates are read):

    # calculate time array
    flag_reference_time_ut = parse_time(hdulist[14].data.field("UT_REF")[0], format="utime")
    flag_time_interval_sec = hdulist[14].data.field("TIME_INTV")[0]
    dim = hdulist[14].data.field("N_TIME_INTV")[0]

    flag_time_array = parse_time(flag_reference_time_ut) + TimeDelta(
        flag_time_interval_sec * np.arange(dim) * u.second)

    # extract flag arrays for SAA, ECLIPSE, FLARE
    flag_names = hdulist[14].data.field("FLAG_IDS")[0] 

    saa_flag = hdulist[15].data.field("FLAGS")[:,np.where(flag_names == "SAA_FLAG")[0][0]]
    eclipse_flag = hdulist[15].data.field("FLAGS")[:,np.where(flag_names == "ECLIPSE_FLAG")[0][0]]
    flare_flag = hdulist[15].data.field("FLAGS")[:,np.where(flag_names == "FLARE_FLAG")[0][0]]

One thing to note is that the time is redefined for the flags - I imagine that it should be the same time array as the one defined for the countrates, but since it is defined again for the flag, I guess that should be checked. Or maybe providing the two time arrays is not a problem.