padre_meddea.spectrum.raw#

Provides support for parsing raw event list and spectrum files

Functions

clean_spectra_data(ts, spectra, ids)

Given raw spectrum packet data, perform a cleaning operation that removes bad data.

packet_definition_hist()

Return the packet definition for the histogram packets.

packet_definition_hist2()

Return the packet definition for the histogram packets.

packet_definition_ph()

Return the packet definition for the photon packets.

parse_ph_packets(filename)

Given a binary file, read only the photon packets and return an event list.

parse_spectrum_packets(filename)

Given a binary file, read only the spectrum packets and return the data.

padre_meddea.spectrum.raw.clean_spectra_data(ts: TimeSeries, spectra: Spectrum1D, ids: ndarray) tuple[TimeSeries, Spectrum1D, ndarray][source]#

Given raw spectrum packet data, perform a cleaning operation that removes bad data. The most common cause of which are bits that are turned to zero when they should not be.

This function finds unphysical times (before 2022-01-01) and replaces the time with an estimated time by using the median time between spectra. It also replaces all pixel ids with the median pixel id set.

Parameters:
  • ts (TimeSeries) – A TimeSeries object containing the time and other metadata.

  • spectra (Spectrum1D) – A Spectrum1D object containing the spectral data.

  • ids (np.ndarray) – An array of pixel ids corresponding to the spectra.

Returns:

tuple[TimeSeries, Spectrum1D, np.ndarray] – A tuple containing the cleaned TimeSeries, Spectrum1D, and pixel ids.

padre_meddea.spectrum.raw.packet_definition_hist()[source]#

Return the packet definition for the histogram packets.

padre_meddea.spectrum.raw.packet_definition_hist2()[source]#

Return the packet definition for the histogram packets.

padre_meddea.spectrum.raw.packet_definition_ph()[source]#

Return the packet definition for the photon packets.

padre_meddea.spectrum.raw.parse_ph_packets(filename: Path)[source]#

Given a binary file, read only the photon packets and return an event list.

Photon packets consist of 15 header words which includes a checksum. Each photon adds 3 words.

Photon packet format is (words are 16 bits) described below.

#

Description

0

CCSDS header 1 (0x00A0)

1

CCSDS header 2 (0b11 and sequence count)

2

CCSDS header 3 payload size (remaining packet size - 1 octet)

3

time_stamp_s 1

4

time_stamp_s 2

5

time_stamp_clocks 1

6

time_stamp_clocks 2

7

integration time in clock counts

8

live time in clock counts

9

flags, drop counter ([15] Int.Time Overflow, [14:12] decimation level, [11:0] # dropped photons)

10

checksum

11

start of pixel data (each is 16 bit field)

pixel time step in clock count

pixel_id (ASIC # bits[7:5], pixel num bits[4:0])

pixel_data ADC count

pixel_data baseline 12 bit baseline value (optional)

Parameters:

filename (Path) – A file to read

Returns:

ph_list (astropy.time.TimeSeries or None) – A photon list

padre_meddea.spectrum.raw.parse_spectrum_packets(filename: Path)[source]#

Given a binary file, read only the spectrum packets and return the data.

Parameters:

filename (Path) – A file to read

Returns:

hk_list (astropy.time.TimeSeries or None) – A list of spectra data or None if no spectrum packets are found.