Skip to content

Commit

Permalink
merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sliu008 committed Jul 9, 2024
2 parents c2b9c89 + 932e928 commit e343bf6
Show file tree
Hide file tree
Showing 3 changed files with 333 additions and 314 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [2.11.0]
### Added
- [issue/267](https://github.com/podaac/l2ss-py/pull/261): Add xtrack and atrack dimension options for get_nd_indexers when bounding box subsetting is performed on SNDR.
- Fix temporal subsetting ghrsst dataset by adding time delta to time variable.
### Changed
### Deprecated
### Removed
Expand All @@ -27,7 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- [issue/260](https://github.com/podaac/l2ss-py/pull/261): Add gpm cleanup function to add a timeMidScan variable if the timeMidScan variable isn't present. Function takes the years, months, days etc ScanTime variables and creates a single time variable using datetime.datetime library.
### Changed
- Update code to determin lat lon time variables
- Update code to determine lat lon time variables
- Update xarray version
- [pull/248](https://github.com/podaac/l2ss-py/pull/248): add Harmony extra_args.cut parameter to subset_params in service adapter
### Deprecated
Expand Down
25 changes: 16 additions & 9 deletions podaac/subsetter/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,12 @@ def build_cond(str_timestamp, compare):
epoch_datetime = dataset[epoch_time_var_name].values[0]
timestamp = np.datetime64(timestamp) - epoch_datetime

return compare(dataset[time_var_name], timestamp)
time_data = dataset[time_var_name]
if getattr(time_data, 'long_name', None) == "reference time of sst file":
timedelta_seconds = dataset['sst_dtime'].astype('timedelta64[s]')
time_data = time_data + timedelta_seconds

return compare(time_data, timestamp)

temporal_conds = []
if min_time:
Expand Down Expand Up @@ -1227,14 +1232,16 @@ def subset(file_to_subset: str, bbox: np.ndarray, output_file: str,

if min_time or max_time:
args['decode_times'] = True
# check fill value and dtype; we know that this will cause an integer Overflow with xarray
for time_variable in [v for v in nc_dataset.variables.keys() if 'time' in v]:
try:
if nc_dataset[time_variable].getncattr('_FillValue') == nc.default_fillvals.get('f8') and \
(nc_dataset[time_variable].dtype == 'float64') or (nc_dataset[time_variable].dtype == 'float32'):
args['mask_and_scale'] = True
except AttributeError:
pass
float_dtypes = ['float64', 'float32']
fill_value_f8 = nc.default_fillvals.get('f8')

for time_variable in (v for v in nc_dataset.variables.keys() if 'time' in v):
time_var = nc_dataset[time_variable]

if (getattr(time_var, '_FillValue', None) == fill_value_f8 and time_var.dtype in float_dtypes) or \
(getattr(time_var, 'long_name', None) == "reference time of sst file"):
args['mask_and_scale'] = True
break

if hdf_type == 'GPM':
args['decode_times'] = False
Expand Down
Loading

0 comments on commit e343bf6

Please sign in to comment.