Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexErrors with ORFlashCamListenerStatusDecoder when running build_raw #4

Closed
slwatkins opened this issue Jul 6, 2023 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@slwatkins
Copy link
Member

I've updated pygama et al. to the latest versions and have been testing the build_raw functionality, as I'm writing up some code to validate the packets in FC and ORCA files.

With the latest updates and recent files, the build_raw function fails when attempting to decode the FlashCam Listener Status. Here are two MWEs using files from NERSC (where I've truncated the paths for privacy reasons):

from daq2lh5 import build_raw
build_raw(f'{full_path_to_raw_data_on_nersc}/l200-p04-r006-tst-20230510T101033Z.orca', out_spec="raw-data.lh5")

This errors with:

no implementation of OR1DHistoDecoder, corresponding packets will be skipped
no implementation of ORScriptDecoderForRecord, corresponding packets will be skipped
no implementation of ORScriptDecoderForState, corresponding packets will be skipped
got 2 ORFlashCam Waveform Decoders in memory!

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[6], line 1
----> 1 build_raw(f'{full_path_to_raw_data_on_nersc}/l200-p04-r006-tst-20230510T101033Z.orca', out_spec="raw-data.lh5")

File /opt/anaconda3/envs/py310/lib/python3.10/site-packages/daq2lh5/build_raw.py:231, in build_raw(in_stream, in_stream_type, out_spec, buffer_size, n_max, overwrite, compass_config_file, hdf5_compression, **kwargs)
    229 n_bytes_last = streamer.n_bytes_read
    230 while True:
--> 231     chunk_list = streamer.read_chunk()
    233     if log.getEffectiveLevel() <= logging.INFO and n_max == np.inf:
    234         progress_bar.update(streamer.n_bytes_read - n_bytes_last)

File /opt/anaconda3/envs/py310/lib/python3.10/site-packages/daq2lh5/data_streamer.py:283, in DataStreamer.read_chunk(self, chunk_mode_override, rp_max, clear_full_buffers)
    281 still_has_data = True
    282 while True:
--> 283     still_has_data = self.read_packet()
    284     if not still_has_data:
    285         break

File /opt/anaconda3/envs/py310/lib/python3.10/site-packages/daq2lh5/orca/orca_streamer.py:312, in OrcaStreamer.read_packet(self)
    310 decoder = self.decoder_id_dict[data_id]
    311 rbl = self.rbl_id_dict[data_id]
--> 312 self.any_full |= decoder.decode_packet(packet, self.packet_id, rbl)
    313 return True

File /opt/anaconda3/envs/py310/lib/python3.10/site-packages/daq2lh5/orca/orca_flashcam.py:391, in ORFlashCamListenerStatusDecoder.decode_packet(self, packet, packet_id, rbl)
    389 for i_card in range(n_cards):
    390     i_cd = 15 + i_card * cd_size  # start index of this card's data
--> 391     tbl["card_id"].flattened_data.nda[fd0 + i_card] = packet[i_cd + 0]
    392     tbl["card_status"].flattened_data.nda[fd0 + i_card] = packet[i_cd + 1]
    393     tbl["card_eventnumber"].flattened_data.nda[fd0 + i_card] = packet[i_cd + 2]

IndexError: index 1195 is out of bounds for axis 0 with size 187

Trying a different file from a more recent period:

from daq2lh5 import build_raw
build_raw(
    f'{full_path_to_raw_data_on_nersc}/l200-p06-r000-phy-20230611T222756Z.orca',
    out_spec='./test.lh5',
    overwrite=True,
)

Which errors with:

no implementation of OR1DHistoDecoder, corresponding packets will be skipped
no implementation of ORScriptDecoderForRecord, corresponding packets will be skipped
no implementation of ORScriptDecoderForState, corresponding packets will be skipped
got 4 ORFlashCam Waveform Decoders in memory!

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[6], line 1
----> 1 build_raw(
      2          f'{full_path_to_raw_data_on_nersc}/l200-p06-r000-phy-20230611T222756Z.orca',
      3          out_spec='./test.lh5', overwrite=True)

File ~/.conda/envs/py39/lib/python3.9/site-packages/daq2lh5/build_raw.py:231, in build_raw(in_stream, in_stream_type, out_spec, buffer_size, n_max, overwrite, compass_config_file, hdf5_compression, **kwargs)
    229 n_bytes_last = streamer.n_bytes_read
    230 while True:
--> 231     chunk_list = streamer.read_chunk()
    233     if log.getEffectiveLevel() <= logging.INFO and n_max == np.inf:
    234         progress_bar.update(streamer.n_bytes_read - n_bytes_last)

File ~/.conda/envs/py39/lib/python3.9/site-packages/daq2lh5/data_streamer.py:283, in DataStreamer.read_chunk(self, chunk_mode_override, rp_max, clear_full_buffers)
    281 still_has_data = True
    282 while True:
--> 283     still_has_data = self.read_packet()
    284     if not still_has_data:
    285         break

File ~/.conda/envs/py39/lib/python3.9/site-packages/daq2lh5/orca/orca_streamer.py:312, in OrcaStreamer.read_packet(self)
    310 decoder = self.decoder_id_dict[data_id]
    311 rbl = self.rbl_id_dict[data_id]
--> 312 self.any_full |= decoder.decode_packet(packet, self.packet_id, rbl)
    313 return True

File ~/.conda/envs/py39/lib/python3.9/site-packages/daq2lh5/orca/orca_flashcam.py:421, in ORFlashCamListenerStatusDecoder.decode_packet(self, packet, packet_id, rbl)
    415 tbl["card_n_link_errors"].flattened_data.nda[fd0 + i_card] = packet[
    416     i_cd + 13
    417 ]
    418 for j in range(5):
    419     tbl["card_n_other_errors"].flattened_data.nda[
    420         (fd0 + i_card) * 5 + j
--> 421     ] = packet[i_cd + 14 + j]
    422 for j in range(5):
    423     tbl["card_temps"].flattened_data.nda[
    424         (fd0 + i_card) * 5 + j
    425     ] = int_packet[i_cd + 19 + j]

IndexError: index 2391 is out of bounds for axis 0 with size 2391

It's odd that the index errors are happening at different lines, which could be a difference between tst and phy files.

Note that the test for build_raw uses an old file that does not have any packets for the FlashCam Status Listener, so that test will need to be updated to include more packets.

@gipert
Copy link
Member

gipert commented Sep 12, 2023

I have uploaded to legend-testdata a non-truncated file that triggers this error: legend-exp/legend-testdata@ed54f0c. Has been produced by Brady a while ago and should include all the important packets. We should add unit tests that use it.

@jasondet
Copy link
Collaborator

This is my fault -- my implementation of this decoder has bugs. Let me try to find time to fix it.

@jasondet
Copy link
Collaborator

Fixing the status decoder has to wait for Simon to add some methods to pyfcutils. In the meantime I have updated the status decoder to just skip decoding. I'll turn status decoding back on as part of resolving the other issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants