Skip to content

Commit

Permalink
Remove h5py as required dependency (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiggi committed Mar 30, 2024
1 parent c468afe commit 0b87161
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
19 changes: 15 additions & 4 deletions gpm/io/data_integrity.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"""This module contains functions that check the GPM files integrity."""
import os

import h5py
import xarray as xr

from gpm.io.checks import (
check_product,
Expand All @@ -38,12 +38,23 @@


def get_corrupted_filepaths(filepaths):
"""Return the file paths of corrupted files."""
l_corrupted = []
for filepath in filepaths:
# Load hdf granule file
try:
hdf = h5py.File(filepath, "r") # h5py._hl.files.File
hdf.close()
# Try open the HDF file

# DataTree.close() does not work yet!
# dt = datatree.open_datatree(filepath, engine="netcdf4")
# dt.close()

# h5py it's an heavy dependency !
# hdf = h5py.File(filepath, "r") # h5py._hl.files.File
# hdf.close()

ds = xr.open_dataset(filepath, engine="netcdf4", group="")
ds.close()

except OSError:
l_corrupted.append(filepath)
return l_corrupted
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ keywords = ["GPM", "Precipitation", "API", "DPR", "PMW", "IMERG"]
dependencies = [
"xarray<=2024.2.0", # ongoing xarray datatree migration
"xarray-datatree", # to be deprecated as soon datatree in xarray is working
"h5py", # to discard as soon as possible
"netcdf4",
"dask",
"distributed",
Expand All @@ -62,7 +61,7 @@ dev = ["pre-commit", "loghub",
"pytest", "pytest-cov", "pytest-mock", "pytest-check", "pytest-sugar",
"pytest-watcher", "deepdiff",
"pip-tools", "bumpver", "twine", "wheel", "build", "setuptools>=61.0.0",
"ximage", "pyvista", "polars", "pyarrow", "pyresample",
"ximage", "pyvista", "polars", "pyarrow", "pyresample", "h5py",
"sphinx", "sphinx-gallery", "sphinx-book-theme", "nbsphinx", "sphinx_mdinclude"]

[project.urls]
Expand Down

0 comments on commit 0b87161

Please sign in to comment.