Skip to content

issue with Nexrad file #292

@aladinor

Description

@aladinor

Hi everyone,

I am trying to open a 2004 nexrad file and I got an error

import xradar as xd
import fsspec
filepath = "s3://noaa-nexrad-level2/2004/02/19/KVNX/KVNX20040219_043517.gz"
storage_options = {"anon": True}
stream = fsspec.open(filepath, 
                     mode="rb", 
                     compression= "gzip", 
                     **storage_options).open()
dtree = xd.io.open_nexradlevel2_datatree(stream.read())
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[36], line 6
      1 storage_options = {"anon": True}
      2 stream = fsspec.open(filepath, 
      3                      mode="rb", 
      4                      compression= "gzip", 
      5                      **storage_options).open()
----> 6 dtree = xd.io.open_nexradlevel2_datatree(stream.read())

File [~/mambaforge/envs/raw2zarr-dev/lib/python3.12/site-packages/xradar/io/backends/nexrad_level2.py:1724](http://localhost:8888/lab/tree/notebooks/~/mambaforge/envs/raw2zarr-dev/lib/python3.12/site-packages/xradar/io/backends/nexrad_level2.py#line=1723), in open_nexradlevel2_datatree(filename_or_obj, mask_and_scale, decode_times, concat_characters, decode_coords, drop_variables, use_cftime, decode_timedelta, sweep, first_dim, reindex_angle, fix_second_angle, site_coords, optional, lock, **kwargs)
   1721 else:
   1722     with NEXRADLevel2File(filename_or_obj, loaddata=False) as nex:
   1723         # Expected number of elevation cuts from the VCP definition
-> 1724         exp_sweeps = nex.msg_5["number_elevation_cuts"]
   1725         # Actual number of sweeps recorded in the file
   1726         act_sweeps = len(nex.msg_31_data_header)

File [~/mambaforge/envs/raw2zarr-dev/lib/python3.12/site-packages/xradar/io/backends/nexrad_level2.py:493](http://localhost:8888/lab/tree/notebooks/~/mambaforge/envs/raw2zarr-dev/lib/python3.12/site-packages/xradar/io/backends/nexrad_level2.py#line=492), in NEXRADLevel2File.msg_5(self)
    491 """Retrieve MSG5 data."""
    492 if self._msg_5_data is None:
--> 493     self._msg_5_data = self.get_msg_5_data()
    494 return self._msg_5_data

File [~/mambaforge/envs/raw2zarr-dev/lib/python3.12/site-packages/xradar/io/backends/nexrad_level2.py:562](http://localhost:8888/lab/tree/notebooks/~/mambaforge/envs/raw2zarr-dev/lib/python3.12/site-packages/xradar/io/backends/nexrad_level2.py#line=561), in NEXRADLevel2File.get_msg_5_data(self)
    560 """Get MSG5 data."""
    561 # get the record number from the meta header
--> 562 recnum = self.meta_header["msg_5"][0]["record_number"]
    563 self.init_record(recnum)
    564 # skip header

IndexError: list index out of range

is this a corrupted file or an issue with the backend??

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