Error while trying to open ATL08 file with icepyx

Hi everyone! New icepyx user here :slight_smile:

I am trying to open a single ATL8 file (manually from the Earthdata portal), and everything goes fine up to a weird crash (a full gist is here):

filepath = './ATL08_20200614005307_12140704_005_01.h5'
reader = ipx.Read(filepath, "ATL08")
reader.vars.append(beam_list=['gt1l','gt1r','gt2l','gt2r','gt3l','gt3r'], var_list=["h_canopy", "latitude", "longitude"])


ds = reader.load()
ds


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Input In [7], in <cell line: 1>()
----> 1 ds = reader.load()
      2 ds

File ~/miniconda3/envs/cpu-pangeo/lib/python3.8/site-packages/icepyx/core/read.py:443, in Read.load(self)
    436 # DevNote: I'd originally hoped to rely on intake-xarray in order to not have to iterate through the files myself,
    437 # by providing a generalized url/source in building the catalog.
    438 # However, this led to errors when I tried to combine two identical datasets because the single dimension was equal.
    439 # In these situations, xarray recommends manually controlling the merge/concat process yourself.
    440 # While unlikely to be a broad issue, I've heard of multiple matching timestamps causing issues for combining multiple IS2 datasets.
    441 for file in self._filelist:
    442     all_dss.append(
--> 443         self._build_single_file_dataset(file, groups_list)
    444     )  # wanted_groups, vgrp.keys()))
    446 if len(all_dss) == 1:
    447     return all_dss[0]

File ~/miniconda3/envs/cpu-pangeo/lib/python3.8/site-packages/icepyx/core/read.py:577, in Read._build_single_file_dataset(self, file, groups_list)
    575     for grp_path in ["orbit_info"] + list(wanted_groups_set):
    576         ds = self._read_single_var(file, grp_path)
--> 577         is2ds = Read._add_var_to_ds(
    578             is2ds, ds, grp_path, wanted_groups_tiered, wanted_dict
    579         )
    581 return is2ds

File ~/miniconda3/envs/cpu-pangeo/lib/python3.8/site-packages/icepyx/core/read.py:342, in Read._add_var_to_ds(is2ds, ds, grp_path, wanted_groups_tiered, wanted_dict)
    339 wanted_vars = list(wanted_dict.keys())
    341 if grp_path in ["orbit_info", "ancillary_data"]:
--> 342     grp_spec_vars = [
    343         wanted_vars[i]
    344         for i, x in enumerate(wanted_groups_tiered[0])
    345         if x == grp_path
    346     ]
    348     for var in grp_spec_vars:
    349         is2ds = is2ds.assign({var: ("gran_idx", ds[var].data)})

File ~/miniconda3/envs/cpu-pangeo/lib/python3.8/site-packages/icepyx/core/read.py:343, in <listcomp>(.0)
    339 wanted_vars = list(wanted_dict.keys())
    341 if grp_path in ["orbit_info", "ancillary_data"]:
    342     grp_spec_vars = [
--> 343         wanted_vars[i]
    344         for i, x in enumerate(wanted_groups_tiered[0])
    345         if x == grp_path
    346     ]
    348     for var in grp_spec_vars:
    349         is2ds = is2ds.assign({var: ("gran_idx", ds[var].data)})

IndexError: list index out of range

Any suggestions on what may be going on?

Hi @rlourenco, just to follow up in case anyone has the same issue. This IndexError was a bug in the read.py code (see details IndexError: list index out of range · Issue #277 · icesat2py/icepyx · GitHub), which has since been fixed in add read-in functionality for deeply nested variables by JessicaS11 · Pull Request #281 · icesat2py/icepyx · GitHub.

So if you update to IcePyx v0.6.2 or newer (instructions at Installation — icepyx documentation), this shouldn’t be a problem anymore.

1 Like