ecpi.common.io.events module

Section author: ECLAIRs GP team

Class to manage events

Summary

Classes:

EclairsCalEvtData

Standard container for ECLAIRs' calibrated event data

XEvtData

standard container for ECLAIRs' event or data file

Class diagram:

Reference

class EclairsCalEvtData(nb_line=None)[source]

Bases: ecpi.common.io.events.XEvtData

Standard container for ECLAIRs’ calibrated event data

add_evt(eced)[source]
extract_image(t_1, t_2, energy_range=[0, 1023], val='PHA')[source]

extract one image from the data event table

extract image by summing the PHA of photons in the pixels of the image

Parameters
  • t_1 (float in 'time' format) – start time to integrate the image

  • t_2 (float in "time" format) – end time for the integration

  • energy_range ([int, int]) – energy band to sum the photon within. Default is [0, 1023].

Returns

the image integrated between t_1 and t_2, and within the energy range

Return type

float array

extract_images(t_1, t_2, energy_ranges, val='PHA')[source]

extract images according to the time and energy ranges in input

Parameters
  • t_1 (float in 'time' format) – start time to integrate the image

  • t_2 (float in "time" format) – end time for the integration

  • energy_ranges ([[int, int]]) – different energy ranges (in PI) to extract the images [[low_energy, high_energy],[]]

Returns

extracted images between t_1 and t_2, and within the energy ranges

Return type

list(array)

read(filename, add_data=False)[source]

read an event from a fits file (in IJdet convention) and save it into the tb_evts attribute

Parameters
  • filename (string) – PATH/name of the event file to read

  • add_data (bool) – replace or add to precedent data. Default is False

set_evt_from_std_array(data_table)[source]

set the data event table with the input array (time, y, z, pha)

Parameters

data_table (array) – input data table [time, y, z, pha]

write_L1(filename, creator='ECPI/APC', t_start=0, t_stop=0, proc_id='01')[source]

save the event in a ECLAIRs single event energy coded fits file

Common keywords are added to the header.

Parameters
  • filename (string) – PATH/name of the file to save to

  • start_time (float) – events start time in s from MJDREF

  • t_stop (float) – events end time in s from MJDREF

  • creator (string (default='unknown')) – program that generated the file

class XEvtData[source]

Bases: object

standard container for ECLAIRs’ event or data file

construct_images(t_window, t_step, method='sliding_window')[source]

construct a suite of images from the data event table

images integrated during time = t_window with time step = t_step
  • if t_window == t_step: images are successives

  • if t_window == t_max - t_min: return one stacked array

2 construct methodssliding_window or cumulative
  • sliding_window : images are independently computed

  • cumulative : images are added with the precedent one

Note

may be some data not included from the end of the event file

Parameters
  • t_window (float) – integration window of the images, in ‘time’ format. Must be < t_max - t_min

  • t_step (float) – step between two beginning time of windows in ‘time’ format

  • method (string) – construction method: ‘sliding_window’ or ‘cumulative’. Default=’sliding_window’

Returns

constructed images

Return type

float np.array

create_movie(name_file, erase_images=True)[source]
extract_image(t_1, t_2, energy_band=[0, 1023], photon_sum='energy')[source]

extract one image from the data event table

The image is build with photons between t_1 and t_2, and within ‘energy_band’.

Parameters
  • t_1 (float in 'time' format) – start time to integrate the image

  • t_2 (float in "time" format) – end time for the integration

  • photon_sum (string) – column name to use to sum photons in the pixels image. Default=’energy’.

  • energy_band ([int, int]) – energy band to sum the photon within. Default is [0, 1023].

Returns

the image integrated between t_1 and t_2, within ‘energy_band’

Return type

float array

property nb_row
read(filename, add_data=False)[source]

read an event from a fits file and save it into the tb_evts attribute

the events are sorted according to arrival time

Parameters
  • filename (string) – PATH/name of the event file to read

  • add_data (bool) – replace or add to precedent data. Default is False

save_images(images_path, t_window=1.0, t_step=0.5, method='sliding_window', title='')[source]

construct and save a suite of images from the data event table

2 construct methodssliding_window or cumulative
  • sliding_window : images are independently computed

  • cumulativeintegration time of images increase of t_step

    each step (t_window == size of the initial time window)

images integrated during time = t_window with time step = t_step
  • if t_window == t_step: images are successives

  • if t_window == t_max: return one stacked array

Parameters
  • t_window (float) – integration window of the images, in ‘time’ format. Must be < t_max - t_min.

  • t_step (float) – step between two beginning time of windows in ‘time’ format

  • images_path (string (PATH)) – path to the directory to save images into

  • method (string) – construction method: ‘sliding_window’ or ‘cumulative’. Default=’sliding_window’

set_evt(data_table)[source]

set the data event table with the input array

Parameters

data_table (array) – input data array to read from

sort_with_time()[source]

sort the event table according to the arrival time of each photon

write(filename, creator='unkowwn', t_start=0, t_stop=0)[source]

save the event in a fits file

Parameters
  • filename (string) – PATH/name of the file to save to

  • start_time (float) – events start time in s from MJDREF

  • t_stop (float) – events end time in s from MJDREF

  • creator (string (default='unknown')) – program that generated the file