Skip to content

Commit

Permalink
added unit test for STAC item along with fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
vishal committed Jul 17, 2024
1 parent 9941521 commit f8ace4b
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 147 deletions.
2 changes: 1 addition & 1 deletion hls_vi/generate_stac_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def main():
parser.add_argument(
"--cmr_xml",
type=str,
default="code/data/HLS-VI.L30.T06WVS.2024120T211159.v2.0.cmr.xml",
default="tests/fixtures/HLS-VI.L30.T06WVS.2024120T211159.v2.0.cmr.xml",
)
parser.add_argument("--out_json", type=str, default="test_output.json")
parser.add_argument(
Expand Down
111 changes: 111 additions & 0 deletions tests/fixtures/test_output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"type": "Feature",
"stac_version": "1.0.0",
"id": "HLS-VI.L30.T06WVS.2024120T211159.v2.0",
"properties": {
"start_datetime": "2024-05-08T16:25:12.736230Z",
"end_datetime": "2024-05-08T16:25:12.736230Z",
"platform": "landsat-8",
"instruments": ["oli"],
"eo:cloud_cover": 6.0,
"proj:transform": [
30.0, 0.0, 399960.0, 0.0, -30.0, 7200000.0, 0.0, 0.0, 1.0
],
"proj:shape": [3660, 3660],
"proj:epsg": 32606,
"view:sun_azimuth": 168.41547441,
"view:azimuth": 179.72857034,
"sci:doi": "10.5067/HLS/HLSL30.002",
"datetime": "2024-05-08T16:25:12.736230Z"
},
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[-149.114568, 64.909135],
[-146.793616, 64.923996],
[-146.800894, 63.938713],
[-149.040061, 63.924491],
[-149.114568, 64.909135]
]
]
]
},
"links": [
{
"rel": "self",
"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-public/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0_stac.json",
"type": "application/json"
},
{ "rel": "cite-as", "href": "https://doi.org/10.5067/HLS/HLSL30.002" }
],
"assets": {
"NDVI": {
"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.NDVI.tif",
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
"eo:bands": [{ "name": "NDVI", "common_name": "NDVI" }],
"roles": ["data"]
},
"EVI": {
"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.EVI.tif",
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
"eo:bands": [{ "name": "EVI", "common_name": "EVI" }],
"roles": ["data"]
},
"MSAVI": {
"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.MSAVI.tif",
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
"eo:bands": [{ "name": "MSAVI", "common_name": "MSAVI" }],
"roles": ["data"]
},
"NBR": {
"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.NBR.tif",
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
"eo:bands": [{ "name": "NBR", "common_name": "NBR" }],
"roles": ["data"]
},
"NBR2": {
"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.NBR2.tif",
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
"eo:bands": [{ "name": "NBR2", "common_name": "NBR2" }],
"roles": ["data"]
},
"NDMI": {
"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.NDMI.tif",
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
"eo:bands": [{ "name": "NDMI", "common_name": "NDMI" }],
"roles": ["data"]
},
"NDWI": {
"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.NDWI.tif",
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
"eo:bands": [{ "name": "NDWI", "common_name": "NDWI" }],
"roles": ["data"]
},
"SAVI": {
"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.SAVI.tif",
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
"eo:bands": [{ "name": "SAVI", "common_name": "SAVI" }],
"roles": ["data"]
},
"TVI": {
"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.TVI.tif",
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
"eo:bands": [{ "name": "TVI", "common_name": "TVI" }],
"roles": ["data"]
},
"thumbnail": {
"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-public/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.jpg",
"type": "image/jpeg",
"roles": ["thumbnail"]
}
},
"bbox": [-149.114568, 63.924491, -146.793616, 64.923996],
"stac_extensions": [
"https://stac-extensions.github.io/eo/v1.1.0/schema.json",
"https://stac-extensions.github.io/projection/v1.1.0/schema.json",
"https://stac-extensions.github.io/view/v1.0.0/schema.json",
"https://stac-extensions.github.io/scientific/v1.0.0/schema.json"
]
}
1 change: 1 addition & 0 deletions tests/fixtures/unit_test_output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type": "Feature", "stac_version": "1.0.0", "id": "HLS-VI.L30.T06WVS.2024120T211159.v2.0", "properties": {"start_datetime": "2024-05-08T16:25:12.736230Z", "end_datetime": "2024-05-08T16:25:12.736230Z", "platform": "landsat-8", "instruments": ["oli"], "eo:cloud_cover": 6.0, "proj:transform": [30.0, 0.0, 399960.0, 0.0, -30.0, 7200000.0, 0.0, 0.0, 1.0], "proj:shape": [3660, 3660], "proj:epsg": 32606, "view:sun_azimuth": 168.41547441, "view:azimuth": 179.72857034, "sci:doi": "10.5067/HLS/HLSL30.002", "datetime": "2024-05-08T16:25:12.736230Z"}, "geometry": {"type": "MultiPolygon", "coordinates": [[[[-149.114568, 64.909135], [-146.793616, 64.923996], [-146.800894, 63.938713], [-149.040061, 63.924491], [-149.114568, 64.909135]]]]}, "links": [{"rel": "self", "href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-public/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0_stac.json", "type": "application/json"}, {"rel": "cite-as", "href": "https://doi.org/10.5067/HLS/HLSL30.002"}], "assets": {"NDVI": {"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.NDVI.tif", "type": "image/tiff; application=geotiff; profile=cloud-optimized", "eo:bands": [{"name": "NDVI", "common_name": "NDVI"}], "roles": ["data"]}, "EVI": {"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.EVI.tif", "type": "image/tiff; application=geotiff; profile=cloud-optimized", "eo:bands": [{"name": "EVI", "common_name": "EVI"}], "roles": ["data"]}, "MSAVI": {"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.MSAVI.tif", "type": "image/tiff; application=geotiff; profile=cloud-optimized", "eo:bands": [{"name": "MSAVI", "common_name": "MSAVI"}], "roles": ["data"]}, "NBR": {"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.NBR.tif", "type": "image/tiff; application=geotiff; profile=cloud-optimized", "eo:bands": [{"name": "NBR", "common_name": "NBR"}], "roles": ["data"]}, "NBR2": {"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.NBR2.tif", "type": "image/tiff; application=geotiff; profile=cloud-optimized", "eo:bands": [{"name": "NBR2", "common_name": "NBR2"}], "roles": ["data"]}, "NDMI": {"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.NDMI.tif", "type": "image/tiff; application=geotiff; profile=cloud-optimized", "eo:bands": [{"name": "NDMI", "common_name": "NDMI"}], "roles": ["data"]}, "NDWI": {"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.NDWI.tif", "type": "image/tiff; application=geotiff; profile=cloud-optimized", "eo:bands": [{"name": "NDWI", "common_name": "NDWI"}], "roles": ["data"]}, "SAVI": {"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.SAVI.tif", "type": "image/tiff; application=geotiff; profile=cloud-optimized", "eo:bands": [{"name": "SAVI", "common_name": "SAVI"}], "roles": ["data"]}, "TVI": {"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.TVI.tif", "type": "image/tiff; application=geotiff; profile=cloud-optimized", "eo:bands": [{"name": "TVI", "common_name": "TVI"}], "roles": ["data"]}, "thumbnail": {"href": "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-public/HLSL30.020/HLS-VI.L30.T06WVS.2024120T211159.v2.0/HLS-VI.L30.T06WVS.2024120T211159.v2.0.jpg", "type": "image/jpeg", "roles": ["thumbnail"]}}, "bbox": [-149.114568, 63.924491, -146.793616, 64.923996], "stac_extensions": ["https://stac-extensions.github.io/eo/v1.1.0/schema.json", "https://stac-extensions.github.io/projection/v1.1.0/schema.json", "https://stac-extensions.github.io/view/v1.0.0/schema.json", "https://stac-extensions.github.io/scientific/v1.0.0/schema.json"]}
146 changes: 0 additions & 146 deletions tests/test_vi.py

This file was deleted.

0 comments on commit f8ace4b

Please sign in to comment.