Skip to content

Commit

Permalink
Merge branch 'development' into s3_vars
Browse files Browse the repository at this point in the history
  • Loading branch information
JessicaS11 authored Nov 20, 2023
2 parents 150d763 + 142b7ab commit ddd2540
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 6 deletions.
10 changes: 9 additions & 1 deletion doc/source/user_guide/changelog/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ icepyx ChangeLog
This is the list of changes made to icepyx in between each release.
Full details can be found in the `commit logs <https://github.com/icesat2py/icepyx/commits>`_.

Latest Release (Version 0.8.0)
Latest Release (Version 0.8.1)
------------------------------

.. toctree::
:maxdepth: 2

v0.8.1

Version 0.8.0
-------------

.. toctree::
:maxdepth: 2

Expand Down
18 changes: 18 additions & 0 deletions doc/source/user_guide/changelog/v0.8.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
What's new in 0.8.1 (14 November 2023)
-------------------------------------

These are the changes in icepyx 0.8.1 See :ref:`release` for a full changelog
including other versions of icepyx.



Bug fixes
~~~~~~~~~

- fix the ATL08 delta_time dimension read error (#470)


Contributors
~~~~~~~~~~~~

.. contributors:: v0.8.0..v0.8.1|HEAD
32 changes: 32 additions & 0 deletions icepyx/core/is2ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,35 @@ def latest_version(product):
return max(
[entry["version_id"] for entry in _about_product["feed"]["entry"]]
)

def extract_product(filepath):
"""
Read the product type from the metadata of the file. Return the product as a string.
"""
with h5py.File(filepath, 'r') as f:
try:
product = f.attrs['short_name']
if isinstance(product, bytes):
# For most products the short name is stored in a bytes string
product = product.decode()
elif isinstance(product, np.ndarray):
# ATL14 saves the short_name as an array ['ATL14']
product = product[0]
product = _validate_product(product)
except KeyError:
raise 'Unable to parse the product name from file metadata'
return product

def extract_version(filepath):
"""
Read the version from the metadata of the file. Return the version as a string.
"""
with h5py.File(filepath, 'r') as f:
try:
version = f['METADATA']['DatasetIdentification'].attrs['VersionID']
if isinstance(version, np.ndarray):
# ATL14 stores the version as an array ['00x']
version = version[0]
except KeyError:
raise 'Unable to parse the version from file metadata'
return version
7 changes: 2 additions & 5 deletions icepyx/core/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,11 +695,8 @@ def _combine_nested_vars(is2ds, ds, grp_path, wanted_dict):
except (AttributeError, KeyError):
pass

try:
is2ds = is2ds.assign(ds[grp_spec_vars])
except xr.MergeError:
ds = ds[grp_spec_vars].reset_coords()
is2ds = is2ds.assign(ds)
ds = ds[grp_spec_vars].swap_dims({"delta_time": "photon_idx"})
is2ds = is2ds.assign(ds)

return is2ds

Expand Down

0 comments on commit ddd2540

Please sign in to comment.