-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LDDS-490 - Add Subset-band-name regression tests suite.
--------- Co-authored-by: Roosevelt Purification <[email protected]> Co-authored-by: Christine Brown-Stevenson <[email protected]> Co-authored-by: Matt Savoie <[email protected]> Co-authored-by: Matt Savoie <[email protected]>
- Loading branch information
1 parent
27fdc3a
commit 6719f5a
Showing
11 changed files
with
348 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
test/nsidc-icesat2/reference_files/*.h5 filter=lfs diff=lfs merge=lfs -text | ||
test/subset-band-name/reference_data/*.hdf filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,265 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "cfc3aea0-3e7c-42b0-a013-f8b9897fc707", | ||
"metadata": {}, | ||
"source": [ | ||
"# LAADS DAAC Subset-Band-Name Regression Tests\n", | ||
"\n", | ||
"This notebook contains contains a suite of regression tests against LAADS DAAC Subset-Band-Name Harmony Service against reference data generated on premises. \n", | ||
"\n", | ||
"Subset-Band-name ideally operates on Levels 1B, 2, 3 and 4 data; HDF4 only.\n", | ||
"\n", | ||
"## Prerequisites\n", | ||
"\n", | ||
"The dependencies for this notebook are listed in the environment.yaml. To test or install locally, create the papermill environment used in the automated regression testing suite:\n", | ||
"\n", | ||
"`conda env create -f ./environment.yaml && conda activate papermill-subsetbandname`\n", | ||
"\n", | ||
"A `.netrc` file must also be located in the test directory of this repository." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "509a1aa5-2a5f-4223-9bfe-f6c222ffffb2", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"## Import shared utility routines:\n", | ||
"import sys\n", | ||
"\n", | ||
"sys.path.append('../shared_utils')\n", | ||
"from utilities import (\n", | ||
" print_error,\n", | ||
" print_success,\n", | ||
" submit_and_download,\n", | ||
")\n", | ||
"\n", | ||
"from harmony import Client, Collection, Environment, Request\n", | ||
"\n", | ||
"from subset_band_name_utitlities import (\n", | ||
" remove_results_files,\n", | ||
" compare_data,\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "e0caf2f1-1a52-4db3-8a6c-bc5c2911fb5e", | ||
"metadata": {}, | ||
"source": [ | ||
"## Set Default Parameters\n", | ||
"\n", | ||
"`papermill` requires default values for parameters used on the workflow. In this case, `harmony_host_url`\n", | ||
"\n", | ||
"The following are the valid values\n", | ||
"- Production: https://harmony.earthdata.nasa.gov\n", | ||
"- UAT: https://harmony.uat.earthdata.nasa.gov\n", | ||
"- SIT: https://harmony.sit.earthdata.nasa.gov\n", | ||
"- Local: http://localhost:3000" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "68b5e491-086c-48c0-b9bd-42ae068aa8f4", | ||
"metadata": { | ||
"editable": true, | ||
"slideshow": { | ||
"slide_type": "" | ||
}, | ||
"tags": [ | ||
"parameters" | ||
] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"harmony_host_url = 'https://harmony.uat.earthdata.nasa.gov'\n", | ||
"# harmony_host_url = 'https://harmony.sit.earthdata.nasa.gov'\n", | ||
"# harmony_host_url = 'http://localhost:3000'\n", | ||
"# harmony_host_url = 'https://harmony.earthdata.nasa.gov'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "37cfa0f5-aa39-453b-b69e-1398472154b7", | ||
"metadata": {}, | ||
"source": [ | ||
"## Identify Harmony Environment" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "9e8b905a-b08c-4288-80b2-42af52ed0241", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"host_environment = {\n", | ||
" 'http://localhost:3000': Environment.LOCAL,\n", | ||
" 'https://harmony.sit.earthdata.nasa.gov': Environment.SIT,\n", | ||
" 'https://harmony.uat.earthdata.nasa.gov': Environment.UAT,\n", | ||
" 'https://harmony.earthdata.nasa.gov': Environment.PROD,\n", | ||
"}\n", | ||
"\n", | ||
"\n", | ||
"harmony_environment = host_environment.get(harmony_host_url)\n", | ||
"\n", | ||
"if harmony_environment is not None:\n", | ||
" harmony_client = Client(env=harmony_environment)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "4ce4a5f7-7f82-455c-b693-52715eed525d", | ||
"metadata": {}, | ||
"source": [ | ||
"## Setting up Collection Environment Variables\n", | ||
"\n", | ||
"The cell below sets up the Collection, Granule and other necessary variables for each tested dataset. The datasets provided are in the `UAT` environment. There is currently one dataset for Level 1B.\n", | ||
"\n", | ||
"- Level 1B: MOD021KM\n", | ||
"- Variable: EV_250_Aggr500_RefSB" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "da8fbd43-8232-496b-a57a-6156447a965c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"mod02hkm_non_production_info = {\n", | ||
" 'collection': Collection(id='C1260442414-LAADSCDUAT'),\n", | ||
" 'granule_id': 'G1261680941-LAADSCDUAT',\n", | ||
" 'variable': ['EV_250_Aggr500_RefSB'],\n", | ||
"}\n", | ||
"\n", | ||
"mod02hkm_production_info = {\n", | ||
" 'collection': Collection(id='C1378577630-LAADS'),\n", | ||
" 'granule_id': 'G2796405746-LAADS',\n", | ||
" 'variable': ['EV_250_Aggr500_RefSB'],\n", | ||
"}\n", | ||
"\n", | ||
"file_indicators = {'MOD02HKM': 'MOD02HKM.EV_250_Aggr500_RefSB_output.hdf'}\n", | ||
"\n", | ||
"reference_data = {\n", | ||
" 'MOD02HKM': 'reference_data/MOD02HKM.A2023309.2305.061.pscs_001729112207.hdf'\n", | ||
"}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "722b554f-d69d-45bf-acfe-2ad255f875c0", | ||
"metadata": {}, | ||
"source": [ | ||
"These selected collections and granules are only available in UAT environment." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "9864c2f7-2263-467f-8b33-4810e609cd41", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"mod02hkm_subsetbandname_env = {\n", | ||
" Environment.LOCAL: mod02hkm_non_production_info,\n", | ||
" Environment.UAT: mod02hkm_non_production_info,\n", | ||
" Environment.SIT: mod02hkm_non_production_info,\n", | ||
" # Environment.PROD: mod02hkm_production_info,\n", | ||
"}\n", | ||
"\n", | ||
"mod02hkm_subsetbandname_info = mod02hkm_subsetbandname_env.get(harmony_environment)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "4640dde7-36cc-4c98-881d-9cbe6ec63d14", | ||
"metadata": {}, | ||
"source": [ | ||
"## Variable Subsetting Test\n", | ||
"In the cell below, variable subsetting is tested by subsetting EV_250_Aggr500_RefSB variable from the MOD02HKM granule. The results are then compared against the reference data file." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "ad598301-433b-41ae-850e-3caa8968a873", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"mod02hkm_test = True\n", | ||
"\n", | ||
"if mod02hkm_subsetbandname_info is not None:\n", | ||
"\n", | ||
" mod02hkm_request = Request(\n", | ||
" collection=mod02hkm_subsetbandname_info['collection'],\n", | ||
" granule_id=mod02hkm_subsetbandname_info['granule_id'],\n", | ||
" variables=mod02hkm_subsetbandname_info['variable'],\n", | ||
" )\n", | ||
"\n", | ||
" submit_and_download(harmony_client, mod02hkm_request, file_indicators['MOD02HKM'])\n", | ||
"\n", | ||
" if not compare_data(\n", | ||
" reference_data['MOD02HKM'], file_indicators['MOD02HKM'], 'EV_250_Aggr500_RefSB'\n", | ||
" ):\n", | ||
" print_error('MOD02HKM data mismatch.')\n", | ||
" mod02hkm_test = False\n", | ||
"\n", | ||
" remove_results_files()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "8abafe2f-2183-43aa-909c-fc845eb8b04a", | ||
"metadata": {}, | ||
"source": [ | ||
"## Complete Test Suite With Pass/Fail/Skip" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "c2904175-3266-4fe7-9ce1-eb7eaf8423d0", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"subsetbandname_tests = mod02hkm_test\n", | ||
"\n", | ||
"if mod02hkm_subsetbandname_info is not None:\n", | ||
" if subsetbandname_tests:\n", | ||
" print_success('Subset-Band-Name test suite PASSED.')\n", | ||
" else:\n", | ||
" raise Exception('Subset-Band-Name test suite FAILED')\n", | ||
"else:\n", | ||
" print(\n", | ||
" f'Subset-Band-Name is not configured for this environment: \"{harmony_environment}\" - skipping tests.'\n", | ||
" )" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: papermill-subset-band-name | ||
channels: | ||
- conda-forge | ||
- nodefaults | ||
dependencies: | ||
- python=3.11.10 | ||
- notebook=7.2.2 | ||
- numpy=1.26.4 | ||
- papermill=2.6.0 | ||
- hdf4=4.2.15 | ||
- pyhdf=0.11.3 | ||
- pip: | ||
- harmony-py==0.4.15 | ||
- xarray==2024.9.0 |
3 changes: 3 additions & 0 deletions
3
test/subset-band-name/reference_data/MOD02HKM.A2023309.2305.061.pscs_001729112207.hdf
Git LFS file not shown
Oops, something went wrong.