Skip to content

Commit 0bb999e

Browse files
authored
Merge pull request #111 from podaac/release/2.1.0
Release 2.1.0
2 parents 60cb808 + 21f3a1f commit 0bb999e

10 files changed

+105
-71
lines changed

.github/workflows/build-pipeline.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ jobs:
128128
git tag -a "${{ env.software_version }}" -m "Version ${{ env.software_version }}"
129129
git push origin "${{ env.software_version }}"
130130
- name: Publish UMM-S with new version
131-
uses: podaac/[email protected].1
131+
uses: podaac/[email protected].3
132132
if: |
133133
github.ref == 'refs/heads/main' ||
134134
startsWith(github.ref, 'refs/heads/release')
@@ -138,6 +138,7 @@ jobs:
138138
env: ${{ env.venue }}
139139
version: ${{ env.software_version }}
140140
timeout: 60
141+
disable_removal: 'true'
141142
env:
142143
LAUNCHPAD_TOKEN_SIT: ${{secrets.LAUNCHPAD_TOKEN_SIT}}
143144
LAUNCHPAD_TOKEN_UAT: ${{secrets.LAUNCHPAD_TOKEN_UAT}}

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
9+
## [2.1.0]
810
### Added
9-
### Changed
11+
### Changed
12+
- [issue/106](https://github.com/podaac/l2ss-py/issues/106): he5 temporal subsetting for determining start time. Find start time in units attributes or work back from first UTC time.
13+
- [issue/93](https://github.com/podaac/l2ss-py/issues/93): Added input argument to cmr updater to disable association removal
1014
### Deprecated
1115
### Removed
1216
### Fixed
17+
- [issue/105](https://github.com/podaac/l2ss-py/issues/105): Added function to convert np object to python native objects.
1318
### Security
1419

1520
## [2.0.0]

cmr/ops_associations.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@ C2205121520-POCLOUD
5050
C2075141605-POCLOUD
5151
C2251465126-POCLOUD
5252
C2254232941-POCLOUD
53+
C2251464384-POCLOUD
54+
C2247621105-POCLOUD

cmr/uat_associations.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ C1242387592-POCLOUD
3434
C1238658051-POCLOUD
3535
C1238657959-POCLOUD
3636
C1238621087-POCLOUD
37+
C1238621088-POCLOUD
38+
C1240739713-POCLOUD
39+
C1244459498-POCLOUD

podaac/subsetter/subset.py

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,17 @@ def compute_time_variable_name(dataset, lat_var):
528528
raise ValueError('Unable to determine time variable')
529529

530530

531+
def compute_utc_name(dataset):
532+
"""
533+
Get the name of the utc variable if it is there to determine origine time
534+
"""
535+
for var_name in list(dataset.data_vars.keys()):
536+
if 'utc' in var_name.lower() and 'time' in var_name.lower():
537+
return var_name
538+
539+
return None
540+
541+
531542
def get_time_epoch_var(dataset, time_var_name):
532543
"""
533544
Get the name of the epoch time var. This is only needed in the case
@@ -686,7 +697,6 @@ def build_cond(str_timestamp, compare):
686697
timestamp = pd.to_datetime(timestamp)
687698
if np.issubdtype(dataset[time_var_name].dtype, np.dtype(np.timedelta64)):
688699
if is_time_mjd(dataset, time_var_name):
689-
# mjd when timedelta based on
690700
mjd_datetime = datetime_from_mjd(dataset, time_var_name)
691701
if mjd_datetime is None:
692702
raise ValueError('Unable to get datetime from dataset to calculate time delta')
@@ -698,10 +708,6 @@ def build_cond(str_timestamp, compare):
698708
epoch_datetime = dataset[epoch_time_var_name].values[0]
699709
timestamp = np.datetime64(timestamp) - epoch_datetime
700710

701-
if np.issubdtype(dataset[time_var_name].dtype, np.dtype(float)):
702-
start_date = np.datetime64(dataset[time_var_name].attrs['Units'][-10:])
703-
timestamp = (np.datetime64(timestamp) - start_date).astype('timedelta64[s]').astype('float')
704-
705711
return compare(dataset[time_var_name], timestamp)
706712

707713
temporal_conds = []
@@ -1003,13 +1009,12 @@ def _rename_variables(dataset, base_dataset):
10031009
var_group = _get_nested_group(base_dataset, var_name)
10041010
variable = dataset.variables[var_name]
10051011
var_dims = [x.split(GROUP_DELIM)[-1] for x in dataset.variables[var_name].dims]
1006-
10071012
if np.issubdtype(
10081013
dataset.variables[var_name].dtype, np.dtype(np.datetime64)
10091014
) or np.issubdtype(
10101015
dataset.variables[var_name].dtype, np.dtype(np.timedelta64)
10111016
):
1012-
# Use xarray datetime encoder
1017+
10131018
cf_dt_coder = xr.coding.times.CFDatetimeCoder()
10141019
encoded_var = cf_dt_coder.encode(dataset.variables[var_name])
10151020
variable = encoded_var
@@ -1102,6 +1107,7 @@ def get_coordinate_variable_names(dataset, lat_var_names=None, lon_var_names=Non
11021107
time_var_names : list
11031108
List of time coordinate variables.
11041109
"""
1110+
11051111
if not lat_var_names or not lon_var_names:
11061112
lat_var_names, lon_var_names = compute_coordinate_variable_names(dataset)
11071113
if not time_var_names:
@@ -1110,9 +1116,35 @@ def get_coordinate_variable_names(dataset, lat_var_names=None, lon_var_names=Non
11101116
dataset, dataset[lat_var_name]
11111117
) for lat_var_name in lat_var_names
11121118
]
1119+
time_var_names.append(compute_utc_name(dataset))
1120+
time_var_names = list(dict.fromkeys([x for x in time_var_names if x is not None])) # remove Nones and any duplicates
1121+
11131122
return lat_var_names, lon_var_names, time_var_names
11141123

11151124

1125+
def convert_to_datetime(dataset, time_vars):
1126+
"""
1127+
converts the time variable to datetime if xarray doesn't decode times
1128+
"""
1129+
for var in time_vars:
1130+
start_date = datetime.datetime.strptime("1993-01-01T00:00:00.00", "%Y-%m-%dT%H:%M:%S.%f") if any('TAI93' in str(dataset[var].attrs[attribute_name])
1131+
for attribute_name in dataset[var].attrs) else None
1132+
1133+
if np.issubdtype(dataset[var].dtype, np.dtype(float)):
1134+
# adjust the time values from the start date
1135+
if start_date:
1136+
dataset[var].values = [start_date + datetime.timedelta(seconds=i) for i in dataset[var].values]
1137+
# copy the values from the utc time variable to the time variable
1138+
else:
1139+
utc_var_name = compute_utc_name(dataset)
1140+
if utc_var_name:
1141+
dataset[var].values = [datetime.datetime(i[0], i[1], i[2], hour=i[3], minute=i[4], second=i[5]) for i in dataset[utc_var_name].values]
1142+
else:
1143+
pass
1144+
1145+
return dataset
1146+
1147+
11161148
def subset(file_to_subset, bbox, output_file, variables=None,
11171149
# pylint: disable=too-many-branches, disable=too-many-statements
11181150
cut=True, shapefile=None, min_time=None, max_time=None, origin_source=None,
@@ -1169,7 +1201,6 @@ def subset(file_to_subset, bbox, output_file, variables=None,
11691201

11701202
if file_extension == 'he5':
11711203
nc_dataset, has_groups = h5file_transform(file_to_subset)
1172-
11731204
else:
11741205
# Open dataset with netCDF4 first, so we can get group info
11751206
nc_dataset = nc.Dataset(file_to_subset, mode='r')
@@ -1202,11 +1233,11 @@ def subset(file_to_subset, bbox, output_file, variables=None,
12021233
lon_var_names=lon_var_names,
12031234
time_var_names=time_var_names
12041235
)
1205-
1236+
if min_time or max_time:
1237+
dataset = convert_to_datetime(dataset, time_var_names)
12061238
chunks = calculate_chunks(dataset)
12071239
if chunks:
12081240
dataset = dataset.chunk(chunks)
1209-
12101241
if variables:
12111242
# Drop variables that aren't explicitly requested, except lat_var_name and
12121243
# lon_var_name which are needed for subsetting
@@ -1266,7 +1297,6 @@ def subset(file_to_subset, bbox, output_file, variables=None,
12661297
} for var_name in time_var_names
12671298
if 'units' in nc_dataset.variables[var_name].__dict__
12681299
}
1269-
12701300
for var in dataset.data_vars:
12711301
if var not in encoding:
12721302
encoding[var] = compression

podaac/subsetter/subset_harmony.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def podaac_to_harmony_bbox(bbox):
5050
array, int or float
5151
Harmony bbox
5252
"""
53-
return [bbox[0][0], bbox[1][0], bbox[0][1], bbox[1][1]]
53+
54+
return_box = [bbox.item(0), bbox.item(2), bbox.item(1), bbox.item(3)]
55+
return return_box
5456

5557

5658
def harmony_to_podaac_bbox(bbox):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
[tool.poetry]
1414
name = "l2ss-py"
15-
version = "2.0.0"
15+
version = "2.1.0-rc.1"
1616
description = "L2 Subsetter Service"
1717
authors = ["podaac-tva <[email protected]>"]
1818
license = "Apache-2.0"
7.44 MB
Binary file not shown.
File renamed without changes.

0 commit comments

Comments
 (0)