Skip to content

Commit abda1d8

Browse files
authored
Updated imagenator and net2cog tests with labels, added MUR25 test (#273)
* Updated imagenator and net2cog tests with labels, added MUR25 test to imagenator * Updated changelog * Removed unused line from net2cog utility.py
1 parent a5dbf06 commit abda1d8

10 files changed

Lines changed: 117 additions & 17 deletions

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ versioning. Rather than a static releases, this repository contains of a number
55
of regression tests that are each semi-independent. This CHANGELOG file should be used
66
to document pull requests to this repository.
77

8+
## 2026-04-21 ([#273](https://github.com/nasa/harmony-regression-tests/pull/273))
9+
10+
### Added
11+
12+
- Updated Imagenator notebook with a MUR25 test
13+
- Added labels to the Harmony requests in the net2cog and Imagenator notebooks
14+
815
## 2026-04-16 ([#271](https://github.com/nasa/harmony-regression-tests/pull/271))
916

1017
### Added

test/imagenator/imagenator_Regression.ipynb

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
" granule_id=[imagenator_info['granule_id']],\n",
161161
" variables='product/vertical_column_stratosphere',\n",
162162
" format='image/png',\n",
163+
" labels=['imagenator-l2-tempo-no2'],\n",
163164
" )\n",
164165
"\n",
165166
" job_id = harmony_client.submit(request)\n",
@@ -247,6 +248,7 @@
247248
" granule_id=[imagenator_info['granule_id']],\n",
248249
" variables='product/vertical_column_stratosphere',\n",
249250
" format='image/png',\n",
251+
" labels=['imagenator-l3-tempo-no2'],\n",
250252
" )\n",
251253
"\n",
252254
" job_id = harmony_client.submit(request)\n",
@@ -275,6 +277,79 @@
275277
"else:\n",
276278
" print('Skipping test: imagenator L3 not configured for environment')"
277279
]
280+
},
281+
{
282+
"cell_type": "markdown",
283+
"id": "4fc3076a",
284+
"metadata": {},
285+
"source": [
286+
"# Test: imagenator L3 request on MUR25 L4 analysed_sst variable\n",
287+
"\n",
288+
"Test rules for MUR/MUR25 collections in harmony-filtering-service + net2cog + hybig"
289+
]
290+
},
291+
{
292+
"cell_type": "code",
293+
"execution_count": null,
294+
"id": "630e396e",
295+
"metadata": {},
296+
"outputs": [],
297+
"source": [
298+
"imagenator_non_prod_information = {\n",
299+
" 'collection': Collection(id='C1238621140-POCLOUD'),\n",
300+
" 'granule_id': 'G1281443693-POCLOUD',\n",
301+
"}\n",
302+
"associated_output = '20260309090000-JPL-L4_GHRSST-SSTfnd-MUR25-GLOB-v02.0-fv04.2_filtered_analysed_sst_reformatted'\n",
303+
"\n",
304+
"imagenator_env = {\n",
305+
" Environment.LOCAL: imagenator_non_prod_information,\n",
306+
" Environment.SIT: imagenator_non_prod_information,\n",
307+
" Environment.UAT: imagenator_non_prod_information,\n",
308+
"}\n",
309+
"\n",
310+
"if harmony_environment in imagenator_env:\n",
311+
" imagenator_info = imagenator_env[harmony_environment]\n",
312+
"else:\n",
313+
" imagenator_info = None\n",
314+
"\n",
315+
"if imagenator_info is not None:\n",
316+
" request = Request(\n",
317+
" collection=imagenator_info['collection'],\n",
318+
" granule_id=[imagenator_info['granule_id']],\n",
319+
" variables=['analysed_sst'],\n",
320+
" labels=['imagenator-l3-mur25'],\n",
321+
" format='image/png',\n",
322+
" )\n",
323+
"\n",
324+
" job_id = harmony_client.submit(request)\n",
325+
" harmony_client.wait_for_processing(job_id)\n",
326+
"\n",
327+
" with TemporaryDirectory() as temp_dir:\n",
328+
" output_files = [\n",
329+
" Path(future.result())\n",
330+
" for future in harmony_client.download_all(job_id, directory=temp_dir)\n",
331+
" ]\n",
332+
"\n",
333+
" # MUR filename contains '.' character so the suffixes trick from above has to be modified\n",
334+
" assert len(output_files) == 3\n",
335+
" assert (\n",
336+
" output_files[0].suffixes[-1] == '.png'\n",
337+
" ), f'{output_files[0].suffixes[-1]} is not PNG'\n",
338+
" assert output_files[1].suffixes[-1] == '.pgw'\n",
339+
" assert output_files[2].suffixes[-1] == '.xml'\n",
340+
"\n",
341+
" reference_data = Path('reference_data')\n",
342+
" expected_png = reference_data / f'{associated_output}.png'\n",
343+
" expected_pgw = reference_data / f'{associated_output}.pgw'\n",
344+
" expected_aux = reference_data / f'{associated_output}.png.aux.xml'\n",
345+
"\n",
346+
" assert output_files[0].read_bytes() == expected_png.read_bytes()\n",
347+
" assert output_files[1].read_bytes() == expected_pgw.read_bytes()\n",
348+
" assert output_files[2].read_bytes() == expected_aux.read_bytes()\n",
349+
" print_success('imagenator L3 request on MUR25 analysed_sst')\n",
350+
"else:\n",
351+
" print('Skipping test: imagenator L3 not configured for environment')"
352+
]
278353
}
279354
],
280355
"metadata": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
0.25
2+
0.0
3+
0.0
4+
-0.25
5+
-179.875
6+
89.875
255 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<PAMDataset>
2+
<SRS dataAxisToSRSAxisMapping="2,1">GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]</SRS>
3+
<GeoTransform> -1.8000000000000000e+02, 2.5000000000000000e-01, 0.0000000000000000e+00, 9.0000000000000000e+01, 0.0000000000000000e+00, -2.5000000000000000e-01</GeoTransform>
4+
</PAMDataset>

test/imagenator/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.3
1+
0.0.4

test/net2cog/environment.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ channels:
33
- conda-forge
44
- nodefaults
55
dependencies:
6-
- python=3.10
7-
- notebook=6.5.4
8-
- papermill=2.3.4
9-
- rasterio=1.3.7
10-
- rio-cogeo=5.3.4
11-
- numpy=1.24.3
12-
- pip=23.1.2
13-
- matplotlib=3.9.1
6+
- python=3.13
7+
- notebook=7.4.3
8+
- papermill=2.6.0
9+
- rasterio=1.5.0
10+
- rio-cogeo=7.0.2
11+
- numpy=2.4.3
12+
- pip=25.2
13+
- matplotlib=3.10.8
1414
- pip:
15-
- harmony-py==0.4.8
15+
- harmony-py==1.2.0

test/net2cog/net2cog_Regression.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@
274274
" granule_id=[test_config['granule_id']],\n",
275275
" max_results=1,\n",
276276
" format='image/tiff',\n",
277+
" labels=[f'net2cog-{collection}'],\n",
277278
" )\n",
278279
"\n",
279280
" if 'variables_to_subset' in test_config:\n",

test/net2cog/utility.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from os.path import basename
44
from pathlib import Path
55
from tempfile import TemporaryDirectory
6+
from typing import Any
67

78
from harmony import Client
89
from numpy.testing import assert_array_almost_equal
@@ -11,18 +12,20 @@
1112
import matplotlib.pyplot as plt
1213

1314

14-
def print_error(error_string: str) -> str:
15+
def print_error(error_string: str) -> None:
1516
"""Print an error, with formatting for red text."""
1617
print(f'\033[91m{error_string}\033[0m')
18+
return
1719

1820

19-
def print_success(success_string: str) -> str:
21+
def print_success(success_string: str) -> None:
2022
"""Print a success message, with formatting for green text."""
2123
print(f'\033[92mSuccess: {success_string}\033[0m')
24+
return
2225

2326

2427
def validate_smap_outputs(
25-
harmony_client: Client, harmony_job_id: str, expected_results: list
28+
harmony_client: Client, harmony_job_id: str, expected_results: dict[str, Any]
2629
):
2730
"""Helper function to retrieve outputs from Harmony request and compare to reference
2831
metadata and files.
@@ -96,7 +99,7 @@ def assert_dataset_produced_correct_results(
9699

97100

98101
def validate_bounding_box_and_plot_cog_file(
99-
cog_file: str, expected_results: list
102+
cog_file: str, expected_results: dict[str, Any]
100103
) -> None:
101104
"""Helper function to open, validate the bounding box, and plot the COG file.
102105
@@ -111,7 +114,12 @@ def validate_bounding_box_and_plot_cog_file(
111114
assert src.bounds in expected_results['expected_bounding_box']
112115
print_success(f"Correct Bounding Box: {src.bounds}")
113116

114-
extent = [src.bounds.left, src.bounds.right, src.bounds.bottom, src.bounds.top]
117+
extent = (
118+
float(src.bounds.left),
119+
float(src.bounds.right),
120+
float(src.bounds.bottom),
121+
float(src.bounds.top),
122+
)
115123

116124
# If src.bounds.bottom > src.bounds.top, the graph will be inverted.
117125
# When origin='lower' is used, the vertical axis points upward,
@@ -122,6 +130,5 @@ def validate_bounding_box_and_plot_cog_file(
122130
plt.imshow(raster_data, extent=extent)
123131

124132
plt.title(f'{basename(cog_file)}')
125-
plt.xticks([]), plt.yticks([])
126133
plt.show()
127134
print(f'{basename(cog_file)}: {src.bounds}\n')

test/net2cog/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.2
1+
0.4.0

0 commit comments

Comments
 (0)