irfpy.imacommon.imascipac

IMA science packet emulation

IMA packet is either 192s or 32s. See also How to handle IMA science data.

32s packet

Not yet supported (since we have not run this mode for nominal operations)

192s packet

192s is the default mode for IMA. In the usual mode, the energy is swept every 12s over 96 steps. Then, the deflection is swept, if sweeping mode, over 16 steps. Thus, each 12s data represent the 2-D data (cone-shaped). This 2-D data is CntMatrix2D.

class irfpy.imacommon.imascipac.CntMatrix(t, matrix, mode, mode_data=None, name='unknown', hk=None)[source]

Bases: object

Represent a single 192s packet with deflection sweeping.

Constructor of count matrix for 192s packet.

Parameters
  • t – (datetime) The start time of the packet

  • matrix – The matrix in MAEP order. This will be modified by operation.

  • matrix_data – The matrix in MAEP order, the original matrix. This should be kept for any further operations.

  • mode – The mode. (irfpy.imacommon.imamode.Mode object)

  • mode_data – The mode at observation.

  • name – The name of the sensor. Default is ‘unknown’.

  • hk – The HK object. Default is HK object with all variables filled by None.

class irfpy.imacommon.imascipac.TimeSeriesCntMatrix[source]

Bases: irfpy.util.tdict.TimeDict

Container for time series of CntMatrix.

Instance of this class preserves the time series of the CntMatrix member. Users do not need to instance any object, but helper functions will generate those objects.

This class is an extension from util:irfpy.util.tdict.TimeDict.

append(t, data)[source]

Append the data.

Append the data. Users do not need to add the data.

getarray()[source]

Return the matrix as a big numpy array.

Returns

(M32, A16, E96, P16, Tn) masked numpy array.

Raises

Exception raised if the mode changed in the dataset. (Consider using emulation mode to read such data.)

class irfpy.imacommon.imascipac.CntMatrix2D(t, matrix, polar, mode, mode_data=None, name='unknown', hk=None)[source]

Bases: object

Container for 2-D slice of IMA science count.

Instance of this class preserves the 2D information of the IMA count data together with some aux data. Users do not need to instance the object. This is mostly used as a member of TimeSeriesCntMatrix2D.

The data is accessed via the attributes:

  • t for time

  • matrix for matrix (counts) in np.ma.masked_array.

  • matrix_data for matrix (counts) in np.ma.masked_array.

  • polar polar index (start, stop) inclusive.

  • mode mode (irfpy.imacommon.imamode.Mode object).

  • mode_data for the original mode (for emulation functionality)

  • name for the name of the sensor

  • hk for HK, the housekeeping data

IMA science data is obtained “simultaneously” in 2D velocity space, namely energy (velocity) and azimuth. Additionally, mass direction data is appended.

The shape of the matrix depends on the mode. Two commonly used modes are mode 24 and mode 25 and the corresponding shapes are the same (M32, A16, E96). The difference is the time resolution and elevation coverage.

  • For mode 24,

    the time resolution is 12sec and elevation coverage is every 1 step.

  • For mode 25,

    the time resolution is 24sec and elevation coverage is every 2 steps.

Note that the energy direction information is obtained from the sweep of high voltage. Thus, in the reality the obtained data is not “instantly” observed. However, this class assums the observations are done at the time of the start.

class irfpy.imacommon.imascipac.TimeSeriesCntMatrix2D[source]

Bases: irfpy.util.tdict.TimeDict

Container for time series of CntMatrix2D.

Instance of this class preserves the time series of the CntMatrix2D member. Users do not need to instance any object, but helper functions will generate those objects.

This class is an extensin from util:irfpy.util.tdict.TimeDict.

append(t, data)[source]

Append the data.

Append the data.

This is a developer’s code, so that users do not need to add the data by themselves.

getarray()[source]

Return the matrix as a big numpy array.

Returns

(M32, A16, E96, Tn) shaped masked numpy array.

Raises

Exception raised if the mode changed in the dataset. (Consider using emulation mode to read such data.)

irfpy.imacommon.imascipac.timeseries2d_to_energytime_simple(timeser2d, azim=None)[source]

Convert TimeSeriesCntMatrix2D object to (96, N_t) matrix.

Parameters
  • timeser2dTimeSeriesCntMatrix2D object

  • azim – Azimuthal angle to be accounted. A list/tuple of the number should be given. For example, (1,) will give the azimuth channel 1 only. (0, 4, 7, 9) will give the azimuth channels 0, 4, 7, and 9 (although this is non-sense for physics point of view). If None is given, all the channels are used.

Returns

Simply add over the mass and the azimuth, and returns (96, N_t) shaped matrix.

irfpy.imacommon.imascipac.timeseries2d_to_energytime_max(timeser2d, azim=None)[source]

Convert TimeSeriesCntMatrix2D object to (96, N_t) matrix.

Parameters
  • timeser2dTimeSeriesCntMatrix2D object

  • azim – Azimuthal angle to be accounted. A list/tuple of the number should be given. For example, (1,) will give the azimuth channel 1 only. (0, 4, 7, 9) will give the azimuth channels 0, 4, 7, and 9 (although this is non-sense for physics point of view). If None is given, all the channels are used.

Returns

Simply take the maximum of the azimuth channle, after the sum over the mass index, and returns (96, N_t) shaped matrix.

irfpy.imacommon.imascipac.convert2to3(timeser_cntmat2d, emulate_full=False)[source]

Convert 2D time series to 3D.

Parameters

timeser_cntmat2dTimeSeriesCntMatrix2D object

Keywrod emulate_full

Data is emulated to represent the full matrix, namely (M32, A16, E96, P16) size matrix. To use this functionality, the 2D object should be full size, or emulated full size (i.e. the shape should be (M32, A16, E96)). For mode such as 28, where the original data is (M32, A8, E96) is not accepted. It should be the mode 27 (using emulation functionality) where (M32, A16, E96) sized 2D object is available. For mode 27, the original shape of (M32, A16, E96, P2) will be expanded to (M32, A16, E96, P16) with each value 1/8.

Returns

TimeSeriesCntMatrix object

The first and last data could contain a partial data, unless the first data of 2D array is synchronized to the start of the measurement (i.e. polar[0] == 0).

irfpy.imacommon.imascipac.convert2to3_noemu(timeser_cntmat2d)[source]
irfpy.imacommon.imascipac.convert2to3_emu(timeser_cntmat2d)[source]
class irfpy.imacommon.imascipac.HK[source]

Bases: object

Represents HK data embedded in science data.

HK data is stored. This is very primitive class and the user can directly access the variable from the attirbutes.

  • mode The mode

  • pacclevel PAC level

  • promsection (EE)PROM section

  • fifofill FIFO fill

  • More. TBC

Note

This is for embedded HK data. For real HK data, also stored in full dataset has not yet been implemented. This is obtained in different time than the science data packet.