Skip to content
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/compass/utils/h5_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,33 @@ def add_dataset_and_attrs(group, meta_item):
val_ds.attrs[key] = _as_np_string_if_needed(val)


def _determine_fill_value(dtype):
'''
Helper function to determine COMPASS specific fill values based on h5py
Dataset type (dtype)
'''
# Possible float types and float fill
float_types = [np.double, np.single, np.float32, np.float64, 'float32',
'float64']
float_fill = np.nan

# Possible complex types and complex fill
complex_types = [np.complex128, 'complex64', np.complex64, 'complex32']
complex_fill = np.nan * (0 + 1j)

# Possible int types and int fill
int_types = [np.byte, np.int8]
int_fill = 127

# Iterate through all types and their fill values, then return the fill
# value when a match is found
for types, fill_val in zip([float_types, complex_types, int_types],
[float_fill, complex_fill, int_fill]):
if any([dtype == t for t in types]):
print(dtype)
return fill_val


def init_geocoded_dataset(grid_group, dataset_name, geo_grid, dtype,
description, data=None, output_cfg=None):
'''
Expand Down Expand Up @@ -160,6 +187,7 @@ def init_geocoded_dataset(grid_group, dataset_name, geo_grid, dtype,
# Associate grid mapping with data - projection created later
cslc_ds.attrs['grid_mapping'] = np.string_("projection")

# Build list of metadata to be inserted to accompany dataset
grid_meta_items = [
Meta('x_spacing', geo_grid.spacing_x,
'Spacing of the geographical grid along X-direction',
Expand Down