Skip to content

Commit

Permalink
updated tests to fulfill converage
Browse files Browse the repository at this point in the history
  • Loading branch information
nlensse1 committed May 1, 2024
1 parent 87334e8 commit 4cc29cb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion podaac/subsetter/gpm_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def compute_new_time_data(time_group, nc_dataset):
hour=nc_dataset[time_group+'__Hour'][:][i],
minute=nc_dataset[time_group+'__Minute'][:][i],
second=nc_dataset[time_group+'__Second'][:][i],
microsecond=nc_dataset[time_group+'__Second'][:][i]*1000),
microsecond=nc_dataset[time_group+'__MilliSecond'][:][i]*1000),
time_unit_out) for i in range(len(nc_dataset[time_group+'__Year'][:]))]

return new_time_list, time_unit_out
Expand Down
3 changes: 3 additions & 0 deletions podaac/subsetter/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,9 @@ def subset(file_to_subset: str, bbox: np.ndarray, output_file: str,
except AttributeError:
pass

if hdf_type == 'GPM':
args['decode_times'] = False

with xr.open_dataset(
xr.backends.NetCDF4DataStore(nc_dataset),
**args
Expand Down
Binary file added tests/data/GPM/GPM_test_file_2.HDF5
Binary file not shown.
Binary file removed tests/data/GPM/GPM_test_file_3.HDF5
Binary file not shown.
8 changes: 5 additions & 3 deletions tests/test_subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2315,7 +2315,7 @@ def test_gpm_compute_new_var_data(data_dir, subset_output_dir, request):
since 1980-01-06"""

gpm_dir = join(data_dir, 'GPM')
gpm_file = 'GPM_test_file_3.HDF5'
gpm_file = 'GPM_test_file_2.HDF5'
bbox = np.array(((-180, 180), (-90, 90)))
shutil.copyfile(
os.path.join(gpm_dir, gpm_file),
Expand All @@ -2324,7 +2324,9 @@ def test_gpm_compute_new_var_data(data_dir, subset_output_dir, request):

nc_dataset, has_groups, file_extension = subset.open_as_nc_dataset(join(subset_output_dir, gpm_file))

del nc_dataset.variables["__FS__ScanTime__timeMidScan"]
del nc_dataset.variables["__HS__ScanTime__timeMidScan"]

time_data, time_unit = gc.compute_new_time_data("__FS__ScanTime", nc_dataset)
nc_dataset = gc.change_var_dims(nc_dataset, variables=None)

assert int(time_data[0]) == 1325120552
assert int(nc_dataset["__FS__ScanTime__timeMidScan"][:][0]) == 1306403820

0 comments on commit 4cc29cb

Please sign in to comment.