Skip to content

Handle edge cases in ASA_WVI_1P files #10

@rmarquarlops

Description

@rmarquarlops
  • Some files in the archive are empty. The reader crashes in this case.

Cropped traceback:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[2], line 2
      1 path = 'ASA_WVI_1PNPDK20110629_184554_000008093104_00070_48791_5869.N1'
----> 2 reader = ASA_WVI_1P_Reader(path)
      3 # dtt = reader.get_datatree(0)
......
 
    190 self.file.seek(2148) # 2148 = 1247 (mph) + 901 (sph)
--> 192 dsd_size, num_dsd = int(self.mph['DSD_SIZE'][:-7]), int(self.mph['NUM_DSD'])        
    193 raw_dsd = self.file.read(dsd_size*num_dsd)
    195 dsd_list = []

ValueError: invalid literal for int() with base 10: ''
  • Certain files are either corrupted or partially incomplete.

Traceback:

Traceback (most recent call last):
  File "/usr/local/bin/L1B_xspectra_ASA_WVI_1P_IFR", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/xsarslc/scripts/L1B_xspectra_ASA_WVI_1P_IFR.py", line 48, in main
    decorated_launch_processing(args)
  File "/usr/local/lib/python3.11/site-packages/xsarslc/processing_stats.py", line 25, in wrapper
    func(*args, **kwargs)
  File "/usr/local/lib/python3.11/site-packages/xsarslc/scripts/L1B_xspectra_ASA_WVI_1P_IFR.py", line 200, in launch_processing
    ) = process_imagettes(reader, imagette_numbers, parameters)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/xsarslc/scripts/L1B_xspectra_ASA_WVI_1P_IFR.py", line 371, in process_imagettes
    dt = reader.get_datatree(i)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/n1_asar/asa_wvi_1p_reader.py", line 41, in get_datatree
    imagette_ds = self.read_imagette_mds(idx)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/n1_asar/asa_wvi_1p_reader.py", line 127, in read_imagette_mds
    d, qi, rln, sar_data = self.read_line(line, fmt)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/n1_asar/asa_wvi_1p_reader.py", line 91, in read_line
    data = struct.unpack(fmt, line)
           ^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: unpack requires a buffer of 2541 bytes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions