Skip to content

Commit

Permalink
Updated rsgislib.zonalstats hdf5 functions to check whether input h5_…
Browse files Browse the repository at this point in the history
…files are lists
  • Loading branch information
petebunting committed Jun 19, 2024
1 parent fa9ea1b commit 3379230
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions python/rsgislib/zonalstats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,9 @@ def merge_extracted_hdf5_data(
"""
import h5py

if not isinstance(h5_files, list):
raise rsgislib.RSGISPyException("h5_files must be a list.")

if len(h5_files) == 0:
raise rsgislib.RSGISPyException("The list of input files is empty.")

Expand Down Expand Up @@ -1695,6 +1698,9 @@ def merge_extracted_hdf5_vars_data(
"""
import h5py

if not isinstance(h5_files, list):
raise rsgislib.RSGISPyException("h5_files must be a list.")

if len(h5_files) == 0:
raise rsgislib.RSGISPyException("The list of input files is empty.")

Expand Down Expand Up @@ -2126,6 +2132,9 @@ def merge_extracted_hdf5_chip_data(
if datatype is None:
datatype = rsgislib.TYPE_32FLOAT

if not isinstance(h5_files, list):
raise rsgislib.RSGISPyException("h5_files must be a list.")

first = True
n_feats = 0
chip_size = 0
Expand Down Expand Up @@ -2605,6 +2614,9 @@ def merge_extracted_hdf5_chip_ref_data(
if datatype is None:
datatype = rsgislib.TYPE_32FLOAT

if not isinstance(h5_files, list):
raise rsgislib.RSGISPyException("h5_files must be a list.")

first = True
n_feats = 0
chip_size = 0
Expand Down Expand Up @@ -2836,6 +2848,9 @@ def get_var_from_hdf5_data(h5_files: List[str], var_idx: int = 0) -> numpy.array
"""
import h5py

if not isinstance(h5_files, list):
raise rsgislib.RSGISPyException("h5_files must be a list.")

if var_idx < 0:
raise rsgislib.RSGISPyException("The variable index must be greater than 0.")

Expand Down Expand Up @@ -2878,6 +2893,9 @@ def get_hdf5_data(h5_files: List[str]) -> numpy.array:
"""
import h5py

if not isinstance(h5_files, list):
raise rsgislib.RSGISPyException("h5_files must be a list.")

num_vals = 0
n_vars = 0
first = True
Expand Down

0 comments on commit 3379230

Please sign in to comment.