Skip to content

Commit

Permalink
merge in release 2.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sliu008 committed Jul 29, 2024
2 parents a566251 + 3956b9c commit e2c050a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security


## [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.
- Add a function to test ghrsst dataset ability to access variables when mask_and_scale is true.
### Changed
### Deprecated
### Removed
Expand Down
40 changes: 34 additions & 6 deletions podaac/subsetter/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,38 @@ def decode_cf_datetime(num_dates, units, calendar=None, use_cftime=None):
xarray.coding.times.decode_cf_datetime = decode_cf_datetime


def test_access_sst_dtime_values(datafile):
"""
Test accessing values of 'sst_dtime' variable in a NetCDF file.
Parameters
----------
datafile (str): Path to the NetCDF file.
Returns
-------
access_successful (bool): True if 'sst_dtime' values are accessible, False otherwise.
"""

nc_dataset, _, _ = open_as_nc_dataset(datafile)
args = {
'decode_coords': False,
'mask_and_scale': True,
'decode_times': True
}
try:
with xr.open_dataset(
xr.backends.NetCDF4DataStore(nc_dataset),
**args
) as dataset:
# pylint: disable=pointless-statement
for var_name in dataset.variables:
dataset[var_name].values
except (TypeError, ValueError, KeyError):
return False
return True


def subset(file_to_subset: str, bbox: np.ndarray, output_file: str,
variables: Union[List[str], str, None] = (),
# pylint: disable=too-many-branches, disable=too-many-statements
Expand Down Expand Up @@ -1239,14 +1271,10 @@ def subset(file_to_subset: str, bbox: np.ndarray, output_file: str,
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
if getattr(time_var, 'long_name', None) == "reference time of sst file":
args['mask_and_scale'] = test_access_sst_dtime_values(file_to_subset)
break

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

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

[tool.poetry]
name = "l2ss-py"
version = "2.12.0a0"
version = "2.11.0rc7"
description = "L2 Subsetter Service"
authors = ["podaac-tva <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit e2c050a

Please sign in to comment.