Skip to content

Commit 8fd0547

Browse files
authored
DAS-2426 Update varinfo config to handle TEMPO_CLDO4_L3 files (#49)
1 parent 99bb042 commit 8fd0547

5 files changed

Lines changed: 80 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,26 @@ The Harmony Regridding Service follows semantic versioning. All notable changes
44
to this project will be documented in this file. The format is based on [Keep a
55
Changelog](http://keepachangelog.com/en/1.0.0/).
66

7-
## [1.8.0] - 2025-09-26
7+
## [v1.9.0] - 2025-10-08
8+
9+
### Added
10+
11+
- Configuration fix the metadata in `TEMPO_CLDO4_L3` files, allowing them to be regridded.
12+
13+
## [v1.8.0] - 2025-09-26
814

915
### Changed
1016

1117
- Changes how implicit grids are determined. To determine the limits of an implicit grid in geographic space, each cell center and all four corners are transformed from the projected space into longitude, latitude and those values are used to determine the limits of the output grid, preventing an accidental cut off of the grid cell edges. Previously, only cell centers were used.
1218

13-
14-
## [1.7.1] - 2025-09-22
19+
## [v1.7.1] - 2025-09-22
1520

1621
### Changed
1722

1823
- No user facing changes.
1924
- Updates GitHub workflow actions to allow correct release note extraction.
2025

21-
22-
## [1.7.0] - 2025-09-17
26+
## [v1.7.0] - 2025-09-17
2327

2428
### Changed
2529

@@ -168,6 +172,10 @@ include updated documentation and files outlined by the
168172
For more information on internal releases prior to NASA open-source approval,
169173
see legacy-CHANGELOG.md.
170174

175+
[v1.9.0]: https://github.com/nasa/harmony-regridding-service/releases/tag/1.9.0
176+
[v1.8.0]: https://github.com/nasa/harmony-regridding-service/releases/tag/1.8.0
177+
[v1.7.1]: https://github.com/nasa/harmony-regridding-service/releases/tag/1.7.1
178+
[v1.7.0]: https://github.com/nasa/harmony-regridding-service/releases/tag/1.7.0
171179
[v1.6.0]: https://github.com/nasa/harmony-regridding-service/releases/tag/1.6.0
172180
[v1.5.0]: https://github.com/nasa/harmony-regridding-service/releases/tag/1.5.0
173181
[v1.4.0]: https://github.com/nasa/harmony-regridding-service/releases/tag/1.4.0

docker/service_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.8.0
1+
1.9.0

harmony_regridding_service/config/HRS_varinfo_config.json

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Identification": "harmony_regridding_service_varinfo_config",
3-
"Version": 5,
3+
"Version": 6,
44
"CollectionShortNamePath": [
55
"/HDF5_GLOBAL/short_name",
66
"/NC_GLOBAL/short_name",
@@ -15,7 +15,8 @@
1515
],
1616
"Mission": {
1717
"ATL\\d{2}": "ICESat2",
18-
"SPL[34].+": "SMAP"
18+
"SPL[34].+": "SMAP",
19+
"TEMPO_CLDO4_L3" :"TEMPO"
1920
},
2021
"ExcludedScienceVariables": [
2122
{
@@ -133,6 +134,24 @@
133134
}
134135
],
135136
"_Description": "Ensure SMAP L4 variables point to the correct dimension variables in the root group."
137+
},
138+
{
139+
"Applicability": {
140+
"Mission": "TEMPO",
141+
"ShortNamePath": "TEMPO_CLDO4_L3",
142+
"VariablePattern": "^/(product|geolocation|support_data)/.*"
143+
},
144+
"Attributes": [
145+
{
146+
"Name": "dimensions",
147+
"Value": "/time /latitude /longitude"
148+
},
149+
{
150+
"Name": "coordinates",
151+
"Value": "time latitude longitude"
152+
}
153+
],
154+
"_Description": "Ensure TEMPO gridded cloud fraction and pressure (O2-O2 dimer) V03 (PROVISIONAL) variables point to the correct coordinate variables in the root group."
136155
}
137156
]
138157
}

harmony_regridding_service/dimensions.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
from varinfo import VarInfoFromNetCDF4
77

8+
from .exceptions import SourceDataError
9+
810

911
class GridDimensionPair(NamedTuple):
1012
"""Horizontal grid dimensions."""
@@ -71,8 +73,12 @@ def get_resampled_dimension_pairs(
7173
Gives a list of the 2-element horizontal dimensions that are used in
7274
regridding this granule file.
7375
"""
74-
return [
76+
dim_pairs = [
7577
GridDimensionPair(*dims)
7678
for dims in var_info.group_variables_by_horizontal_dimensions()
7779
if len(dims) == 2
7880
]
81+
if not dim_pairs:
82+
raise SourceDataError('No horizontal dimension pairs could be determined.')
83+
84+
return dim_pairs

tests/unit/test_dimensions.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
"""Tests the dimensions module."""
22

3+
from unittest.mock import Mock
4+
5+
import pytest
6+
from varinfo import VarInfoFromNetCDF4
7+
38
from harmony_regridding_service.dimensions import (
9+
GridDimensionPair,
410
get_column_dims,
11+
get_resampled_dimension_pairs,
512
get_row_dims,
613
horizontal_dims_for_variable,
714
is_column_dim,
815
is_row_dim,
916
)
17+
from harmony_regridding_service.exceptions import SourceDataError
1018

1119

1220
def test_horizontal_dims_for_variable_grouped(test_IMERG_ncfile, var_info_fxn):
@@ -103,3 +111,33 @@ def test__get_row_dims_y_dims_multiple_values(test_1D_dimensions_ncfile, var_inf
103111

104112
actual = get_row_dims(dims, var_info)
105113
assert expected_dim == actual
114+
115+
116+
def test_get_resampled_dimension_pairs_no_values():
117+
"""Test that SourceDataError is raised when no horizontal dimension pairs exist."""
118+
mock_var_info = Mock(spec=VarInfoFromNetCDF4)
119+
mock_var_info.group_variables_by_horizontal_dimensions.return_value = [
120+
('time',),
121+
('time', 'lat', 'lon'),
122+
]
123+
124+
with pytest.raises(
125+
SourceDataError, match='No horizontal dimension pairs could be determined.'
126+
):
127+
get_resampled_dimension_pairs(mock_var_info)
128+
129+
130+
def test_get_resampled_dimension_pairs():
131+
"""Test that horizontal pairs are returned."""
132+
mock_var_info = Mock(spec=VarInfoFromNetCDF4)
133+
mock_var_info.group_variables_by_horizontal_dimensions.return_value = [
134+
('time',),
135+
('time', 'lat', 'lon'),
136+
('x', 'y'),
137+
('lat', 'lon'),
138+
]
139+
140+
expected_pairs = [GridDimensionPair('x', 'y'), GridDimensionPair('lat', 'lon')]
141+
142+
actual_pairs = get_resampled_dimension_pairs(mock_var_info)
143+
assert actual_pairs == expected_pairs

0 commit comments

Comments
 (0)