From 1a25de34584510d806f749395ef8436218a65041 Mon Sep 17 00:00:00 2001 From: Simon Liu Date: Mon, 8 Jul 2024 14:00:30 -0700 Subject: [PATCH] fix ghrsst dataset temporal subsetting --- CHANGELOG.md | 3 ++- podaac/subsetter/subset.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0738130d..3fb284a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### 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 @@ -18,7 +19,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 diff --git a/podaac/subsetter/subset.py b/podaac/subsetter/subset.py index 9b1c8497..619eeb24 100644 --- a/podaac/subsetter/subset.py +++ b/podaac/subsetter/subset.py @@ -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 dataset[time_var_name].long_name == "reference time of sst file": + timedelta_seconds = dataset['sst_dtime'].astype('timedelta64[s]') + time_data = dataset[time_var_name] + timedelta_seconds + + return compare(time_data, timestamp) temporal_conds = [] if min_time: @@ -1236,6 +1241,12 @@ def subset(file_to_subset: str, bbox: np.ndarray, output_file: str, except AttributeError: pass + try: + if nc_dataset[time_variable].long_name == "reference time of sst file": + args['mask_and_scale'] = True + except AttributeError: + pass + if hdf_type == 'GPM': args['decode_times'] = False