pygama.raw.fc package#

This subpackage overloads decoding utilities defined in pygama.raw to read files produced by the FlashCam acquisition system.

Submodules#

pygama.raw.fc.fc_config_decoder module#

class pygama.raw.fc.fc_config_decoder.FCConfigDecoder(*args, **kwargs)#

Bases: DataDecoder

Decode FlashCam config data.

Note

Derives from DataDecoder in anticipation of possible future functionality. Currently the base class interface is not used.

Example

>>> import fcutils
>>> from pygama.raw.fc.fc_config_decoder import FCConfigDecoder
>>> fc = fcutils.fcio('file.fcio')
>>> decoder = FCConfigDecoder()
>>> config = decoder.decode_config(fc)
>>> type(config)
pygama.lgdo.struct.Struct
buffer_is_full(rb: RawBuffer) bool#

Returns whether the buffer is too full to read in another packet.

Return type:

bool

decode_config(fcio: fcio) Struct#
Return type:

Struct

make_lgdo(key: Optional[int] = None, size: Optional[int] = None) Struct#

Make an LGDO for this DataDecoder to fill.

This default version of this function allocates a Table using the decoded_values for key. If a different type of LGDO object is required for this decoder, overload this function.

Parameters:
  • key (Optional[int]) – used to initialize the LGDO for a particular key (e.g. to have different trace lengths for different channels of a piece of hardware). Leave as None if such specialization is not necessary.

  • size (Optional[int]) – the size to be allocated for the LGDO, if applicable.

Returns:

data_obj – the newly allocated LGDO.

Return type:

Struct

pygama.raw.fc.fc_event_decoder module#

class pygama.raw.fc.fc_event_decoder.FCEventDecoder(*args, **kwargs)#

Bases: DataDecoder

Decode FlashCam digitizer event data.

decode_packet(fcio: fcio, evt_rbkd: pygama.lgdo.table.Table | dict[int, pygama.lgdo.table.Table], packet_id: int) bool#

Access FCIOEvent members for each event in the DAQ file.

Parameters:
  • fcio (fcio) – The interface to the fcio data. Enters this function after a call to fcio.get_record() so that data for packet_id ready to be read out.

  • evt_rbkd (pygama.lgdo.table.Table | dict[int, pygama.lgdo.table.Table]) – A single table for reading out all data, or a dictionary of tables keyed by channel number.

  • packet_id (int) – The index of the packet in the fcio stream. Incremented by FCStreamer.

Returns:

n_bytes – (estimated) number of bytes in the packet that was just decoded.

Return type:

bool

get_decoded_values(channel: Optional[int] = None) dict[str, dict[str, Any]]#

Get decoded values (optionally for a given key, typically a channel).

Notes

Must overload for your decoder if it has key-specific decoded values. Must also implement key = None returns a “default” decoded_values. Otherwise, just returns self.decoded_values, which should be defined in the constructor.

Return type:

dict[str, dict[str, Any]]

get_key_list() range#

Overload with list of keys for this decoder, e.g. return range(n_channels). The default version works for decoders with single / no keys.

Return type:

range

set_file_config(fc_config: Struct) None#

Access FCIOConfig members once when each file is opened.

Parameters:

fc_config (Struct) – extracted via decode_config().

pygama.raw.fc.fc_status_decoder module#

class pygama.raw.fc.fc_status_decoder.FCStatusDecoder(*args, **kwargs)#

Bases: DataDecoder

Decode FlashCam digitizer status data.

decode_packet(fcio: fcio, status_rb: RawBuffer, packet_id: int) bool#
Return type:

bool

pygama.raw.fc.fc_streamer module#

class pygama.raw.fc.fc_streamer.FCStreamer#

Bases: DataStreamer

Decode FlashCam data, using the fcutils package to handle file access, and the FlashCam data decoders to save the results and write to output.

_abc_impl = <_abc._abc_data object>#
close_stream() None#

Close this data stream.

Note

Needs to be overloaded.

get_decoder_list() list[pygama.raw.data_decoder.DataDecoder]#

Returns a list of decoder objects for this data stream.

Notes

Needs to be overloaded. Gets called during open_stream().

Return type:

list[pygama.raw.data_decoder.DataDecoder]

open_stream(fcio_filename: str, rb_lib: Optional[RawBufferLibrary] = None, buffer_size: int = 8192, chunk_mode: str = 'any_full', out_stream: str = '') list[pygama.raw.raw_buffer.RawBuffer]#

Initialize the FlashCam data stream.

Refer to the documentation for raw.data_streamer.DataStreamer.open_stream() for a description of the parameters.

Returns:

header_data – a list of length 1 containing the raw buffer holding the FCConfig table.

Return type:

list[pygama.raw.raw_buffer.RawBuffer]

read_packet() bool#

Reads a single packet’s worth of data in to the RawBufferLibrary.

Needs to be overloaded. Gets called by read_chunk() Needs to update self.any_full if any buffers would possibly over-fill on the next read. Needs to update self.n_bytes_read too.

Returns:

still_has_data – returns True while there is still data to read.

Return type:

bool