Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ascending flag variable clean up #154

Merged
merged 18 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from 11 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Deprecated
### Removed
### Fixed
- [issue/153](https://github.com/podaac/l2ss-py/issues/153): Remove the asc_node_tai93 variable when blank in the SNDR collections for xarray.decode_times to decode
### Security


Expand Down
7 changes: 7 additions & 0 deletions podaac/subsetter/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,13 @@ def subset(file_to_subset: str, bbox: np.ndarray, output_file: str,
'mask_and_scale': False,
'decode_times': False
}
# clean up time variable in SNDR before decode_times
# SNDR.AQUA files have ascending node time blank
if any('__asc_node_tai93' in i for i in list(nc_dataset.variables)):
asc_time_var = nc_dataset.variables['__asc_node_tai93']
if not asc_time_var[:] > 0:
del nc_dataset.variables['__asc_node_tai93']

if min_time or max_time:
args['decode_times'] = True

Expand Down
Binary file not shown.
28 changes: 28 additions & 0 deletions tests/test_subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,34 @@ def test_subset_size(test_file, data_dir, subset_output_dir, request):

assert subset_file_size < original_file_size

def test_cf_decode_times_sndr(data_dir, subset_output_dir, request):
"""
Check that SNDR ascending and descending granule types are able
to go through xarray cf_decode_times
"""
SNDR_dir = join(data_dir, 'SNDR')
sndr_files = ['SNDR.J1.CRIMSS.20210224T0100.m06.g011.L2_CLIMCAPS_RET.std.v02_28.G.210331064430.nc',
'SNDR.AQUA.AIRS.20140110T0305.m06.g031.L2_CLIMCAPS_RET.std.v02_39.G.210131015806.nc',
'SNDR.SNPP.CRIMSS.20200118T0024.m06.g005.L2_CLIMCAPS_RET.std.v02_28.G.200314032326_subset.nc']
bbox = np.array(((-180, 180), (-90, 90)))
for sndr_file in sndr_files:
output_file = "{}_{}".format(request.node.name, sndr_file)
shutil.copyfile(
os.path.join(SNDR_dir, sndr_file),
os.path.join(subset_output_dir, sndr_file)
)

box_test = subset.subset(
file_to_subset=join(subset_output_dir, sndr_file),
bbox=bbox,
output_file=join(subset_output_dir, output_file),
min_time='2014-01-10T00:50:20Z',
max_time='2021-02-24T01:09:55Z'
)

if not isinstance(box_test, np.ndarray):
raise ValueError('Subset for SNDR not returned properly')


def test_duplicate_dims_sndr(data_dir, subset_output_dir, request):
"""
Expand Down