diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index df48d7b..7893893 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,21 +3,21 @@ repos: - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 23.7.0 hooks: - id: black - repo: https://github.com/codespell-project/codespell - rev: v2.2.2 + rev: v2.2.5 hooks: - id: codespell args: [--ignore-words=.codespellignore] types_or: [jupyter, markdown, python, shell] - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 6.1.0 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.0.1 + rev: v1.4.1 hooks: - id: mypy additional_dependencies: @@ -28,6 +28,6 @@ repos: hooks: - id: isort - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.33.0 + rev: v0.35.0 hooks: - id: markdownlint diff --git a/docker/Dockerfile b/docker/Dockerfile index d56076c..3e87974 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -19,7 +19,7 @@ RUN apt-get -y -q update \ RUN python -m venv /opt/venv RUN pip install . h5py --no-binary rasterio \ && ls /opt/venv \ - && rm -r /opt/venv/lib/python3.10/site-packages/stactools/nisar_sim + && rm -r /opt/venv/lib/python3.11/site-packages/stactools/nisar_sim FROM dependencies as builder diff --git a/examples/collection.json b/examples/collection.json index eab9bf3..5c76d50 100644 --- a/examples/collection.json +++ b/examples/collection.json @@ -219,9 +219,9 @@ ] }, "XX_129.h5": { - "title": "XD_129 HDF5 Data File", + "title": "XX_129 HDF5 Data File", "type": "application/x-hdf5", - "description": "No Dither: 129 Frequency HDF5 file in NISAR format", + "description": "No Dither: 129 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -283,9 +283,9 @@ ] }, "XG_129.h5": { - "title": "XD_129 HDF5 Data File", + "title": "XG_129 HDF5 Data File", "type": "application/x-hdf5", - "description": "Dithered With Gaps: 129 Frequency HDF5 file in NISAR format", + "description": "Dithered With Gaps: 129 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -349,7 +349,7 @@ "XD_129.h5": { "title": "XD_129 HDF5 Data File", "type": "application/x-hdf5", - "description": "Dithered Without Gaps: 129 Frequency HDF5 file in NISAR format", + "description": "Dithered Without Gaps: 129 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -835,9 +835,9 @@ ] }, "XX_138.h5": { - "title": "XD_138 HDF5 Data File", + "title": "XX_138 HDF5 Data File", "type": "application/x-hdf5", - "description": "No Dither: 138 Frequency HDF5 file in NISAR format", + "description": "No Dither: 138 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -899,9 +899,9 @@ ] }, "XG_138.h5": { - "title": "XD_138 HDF5 Data File", + "title": "XG_138 HDF5 Data File", "type": "application/x-hdf5", - "description": "Dithered With Gaps: 138 Frequency HDF5 file in NISAR format", + "description": "Dithered With Gaps: 138 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -965,7 +965,7 @@ "XD_138.h5": { "title": "XD_138 HDF5 Data File", "type": "application/x-hdf5", - "description": "Dithered Without Gaps: 138 Frequency HDF5 file in NISAR format", + "description": "Dithered Without Gaps: 138 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -1451,9 +1451,9 @@ ] }, "XX_143.h5": { - "title": "XD_143 HDF5 Data File", + "title": "XX_143 HDF5 Data File", "type": "application/x-hdf5", - "description": "No Dither: 143 Frequency HDF5 file in NISAR format", + "description": "No Dither: 143 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -1515,9 +1515,9 @@ ] }, "XG_143.h5": { - "title": "XD_143 HDF5 Data File", + "title": "XG_143 HDF5 Data File", "type": "application/x-hdf5", - "description": "Dithered With Gaps: 143 Frequency HDF5 file in NISAR format", + "description": "Dithered With Gaps: 143 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -1581,7 +1581,7 @@ "XD_143.h5": { "title": "XD_143 HDF5 Data File", "type": "application/x-hdf5", - "description": "Dithered Without Gaps: 143 Frequency HDF5 file in NISAR format", + "description": "Dithered Without Gaps: 143 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -2067,9 +2067,9 @@ ] }, "CX_129.h5": { - "title": "CD_129 HDF5 Data File", + "title": "CX_129 HDF5 Data File", "type": "application/x-hdf5", - "description": "No Dither: 129 Frequency HDF5 file in NISAR format", + "description": "No Dither: 129 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -2131,9 +2131,9 @@ ] }, "CG_129.h5": { - "title": "CD_129 HDF5 Data File", + "title": "CG_129 HDF5 Data File", "type": "application/x-hdf5", - "description": "Dithered With Gaps: 129 Frequency HDF5 file in NISAR format", + "description": "Dithered With Gaps: 129 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -2197,7 +2197,7 @@ "CD_129.h5": { "title": "CD_129 HDF5 Data File", "type": "application/x-hdf5", - "description": "Dithered Without Gaps: 129 Frequency HDF5 file in NISAR format", + "description": "Dithered Without Gaps: 129 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -2683,9 +2683,9 @@ ] }, "CX_138.h5": { - "title": "CD_138 HDF5 Data File", + "title": "CX_138 HDF5 Data File", "type": "application/x-hdf5", - "description": "No Dither: 138 Frequency HDF5 file in NISAR format", + "description": "No Dither: 138 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -2747,9 +2747,9 @@ ] }, "CG_138.h5": { - "title": "CD_138 HDF5 Data File", + "title": "CG_138 HDF5 Data File", "type": "application/x-hdf5", - "description": "Dithered With Gaps: 138 Frequency HDF5 file in NISAR format", + "description": "Dithered With Gaps: 138 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -2813,7 +2813,7 @@ "CD_138.h5": { "title": "CD_138 HDF5 Data File", "type": "application/x-hdf5", - "description": "Dithered Without Gaps: 138 Frequency HDF5 file in NISAR format", + "description": "Dithered Without Gaps: 138 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -3299,9 +3299,9 @@ ] }, "CX_143.h5": { - "title": "CD_143 HDF5 Data File", + "title": "CX_143 HDF5 Data File", "type": "application/x-hdf5", - "description": "No Dither: 143 Frequency HDF5 file in NISAR format", + "description": "No Dither: 143 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -3363,9 +3363,9 @@ ] }, "CG_143.h5": { - "title": "CD_143 HDF5 Data File", + "title": "CG_143 HDF5 Data File", "type": "application/x-hdf5", - "description": "Dithered With Gaps: 143 Frequency HDF5 file in NISAR format", + "description": "Dithered With Gaps: 143 NMode HDF5 file in NISAR format", "role": [ "data" ] @@ -3429,7 +3429,7 @@ "CD_143.h5": { "title": "CD_143 HDF5 Data File", "type": "application/x-hdf5", - "description": "Dithered Without Gaps: 143 Frequency HDF5 file in NISAR format", + "description": "Dithered Without Gaps: 143 NMode HDF5 file in NISAR format", "role": [ "data" ] diff --git a/examples/winnip_31604_12061_004_120717_L090_CX_07/winnip_31604_12061_004_120717_L090_CX_07.json b/examples/winnip_31604_12061_004_120717_L090_CX_07/winnip_31604_12061_004_120717_L090_CX_07.json index 64f573e..60aae21 100644 --- a/examples/winnip_31604_12061_004_120717_L090_CX_07/winnip_31604_12061_004_120717_L090_CX_07.json +++ b/examples/winnip_31604_12061_004_120717_L090_CX_07/winnip_31604_12061_004_120717_L090_CX_07.json @@ -94,8 +94,8 @@ "CX_129.h5": { "href": "winnip_31604_12061_004_120717_L090_CX_129_07.h5", "type": "application/x-hdf5", - "title": "CD_129 HDF5 Data File", - "description": "No Dither: 129 Frequency HDF5 file in NISAR format", + "title": "CX_129 HDF5 Data File", + "description": "No Dither: 129 NMode HDF5 file in NISAR format", "role": [ "data" ] diff --git a/src/stactools/nisar_sim/nisar_assets.py b/src/stactools/nisar_sim/nisar_assets.py index 5177275..cdbfcc8 100644 --- a/src/stactools/nisar_sim/nisar_assets.py +++ b/src/stactools/nisar_sim/nisar_assets.py @@ -6,167 +6,165 @@ from stactools.nisar_sim import constants as c -def NISAR_SIM_ASSETS_NO_DITHER( - xtalk: str, frequency: str -) -> Dict[str, AssetDefinition]: +def NISAR_SIM_ASSETS_NO_DITHER(xtalk: str, nmode: str) -> Dict[str, AssetDefinition]: return { - f"{xtalk}X_{frequency}.ann": AssetDefinition( + f"{xtalk}X_{nmode}.ann": AssetDefinition( { - "title": f"{xtalk}X_{frequency} Annotation File", + "title": f"{xtalk}X_{nmode} Annotation File", "type": MediaType.TEXT, - "description": f"No Dither: {frequency} Annotation File", + "description": f"No Dither: {nmode} Annotation File", "role": ["metadata"], } ), - f"HH_{xtalk}X_{frequency}.slc": AssetDefinition( + f"HH_{xtalk}X_{nmode}.slc": AssetDefinition( { - "title": f"{xtalk}X_{frequency} HH Polarization Single Look Complex File", + "title": f"{xtalk}X_{nmode} HH Polarization Single Look Complex File", "type": "application/octet-stream", "description": "Single look complex slant range image for HH polarization", "role": ["data"], } ), - f"HV_{xtalk}X_{frequency}.slc": AssetDefinition( + f"HV_{xtalk}X_{nmode}.slc": AssetDefinition( { - "title": f"{xtalk}X_{frequency} HV Polarization Single Look Complex File", + "title": f"{xtalk}X_{nmode} HV Polarization Single Look Complex File", "type": "application/octet-stream", "description": "Single look complex slant range image for HV polarization", "role": ["data"], } ), - f"VH_{xtalk}X_{frequency}.slc": AssetDefinition( + f"VH_{xtalk}X_{nmode}.slc": AssetDefinition( { - "title": f"{xtalk}X_{frequency} VH Polarization Single Look Complex File", + "title": f"{xtalk}X_{nmode} VH Polarization Single Look Complex File", "type": "application/octet-stream", "description": "Single look complex slant range image for VH polarization", "role": ["data"], } ), - f"VV_{xtalk}X_{frequency}.slc": AssetDefinition( + f"VV_{xtalk}X_{nmode}.slc": AssetDefinition( { - "title": f"{xtalk}X_{frequency} VV Polarization Single Look Complex File", + "title": f"{xtalk}X_{nmode} VV Polarization Single Look Complex File", "type": "application/octet-stream", "description": "Single look complex slant range image for VV polarization", "role": ["data"], } ), - f"HHHH_{xtalk}X_{frequency}.mlc": AssetDefinition( + f"HHHH_{xtalk}X_{nmode}.mlc": AssetDefinition( { - "title": f"{xtalk}X_{frequency} HHHH Crossproduct Multi Look File", + "title": f"{xtalk}X_{nmode} HHHH Crossproduct Multi Look File", "type": "application/octet-stream", "description": "Multi look cross product slant range image for crossproduct HHHH", "role": ["data"], } ), - f"HVHV_{xtalk}X_{frequency}.mlc": AssetDefinition( + f"HVHV_{xtalk}X_{nmode}.mlc": AssetDefinition( { - "title": f"{xtalk}X_{frequency} HVHV Crossproduct Multi Look File", + "title": f"{xtalk}X_{nmode} HVHV Crossproduct Multi Look File", "type": "application/octet-stream", "description": "Multi look cross product slant range image for crossproduct HVHV", "role": ["data"], } ), - f"VVVV_{xtalk}X_{frequency}.mlc": AssetDefinition( + f"VVVV_{xtalk}X_{nmode}.mlc": AssetDefinition( { - "title": f"{xtalk}X_{frequency} VVVV Crossproduct Multi Look File", + "title": f"{xtalk}X_{nmode} VVVV Crossproduct Multi Look File", "type": "application/octet-stream", "description": "Multi look cross product slant range image for crossproduct VVVV", "role": ["data"], } ), - f"HHHV_{xtalk}X_{frequency}.mlc": AssetDefinition( + f"HHHV_{xtalk}X_{nmode}.mlc": AssetDefinition( { - "title": f"{xtalk}X_{frequency} HHHV Crossproduct Multi Look File", + "title": f"{xtalk}X_{nmode} HHHV Crossproduct Multi Look File", "type": "application/octet-stream", "description": "Multi look cross product slant range image for crossproduct HHHV", "role": ["data"], } ), - f"HHVV_{xtalk}X_{frequency}.mlc": AssetDefinition( + f"HHVV_{xtalk}X_{nmode}.mlc": AssetDefinition( { - "title": f"{xtalk}X_{frequency} HHVV Crossproduct Multi Look File", + "title": f"{xtalk}X_{nmode} HHVV Crossproduct Multi Look File", "type": "application/octet-stream", "description": "Multi look cross product slant range image for crossproduct HHVV", "role": ["data"], } ), - f"HVVV_{xtalk}X_{frequency}.mlc": AssetDefinition( + f"HVVV_{xtalk}X_{nmode}.mlc": AssetDefinition( { - "title": f"{xtalk}X_{frequency} HVVV Crossproduct Multi Look File", + "title": f"{xtalk}X_{nmode} HVVV Crossproduct Multi Look File", "type": "application/octet-stream", "description": "Multi look cross product slant range image for crossproduct HVVV", "role": ["data"], } ), - f"HHHH_{xtalk}X_{frequency}.grd": AssetDefinition( + f"HHHH_{xtalk}X_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}X_{frequency} Ground Range Projected File for Crossproduct HHHH", + "title": f"{xtalk}X_{nmode} Ground Range Projected File for Crossproduct HHHH", "type": "application/octet-stream", "description": ( - f"No Dither: {frequency} ground range projected (equiangular) and" + f"No Dither: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct HHHH" ), "role": ["data"], } ), - f"HVHV_{xtalk}X_{frequency}.grd": AssetDefinition( + f"HVHV_{xtalk}X_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}X_{frequency} Ground Range Projected File for Crossproduct HVHV", + "title": f"{xtalk}X_{nmode} Ground Range Projected File for Crossproduct HVHV", "type": "application/octet-stream", "description": ( - f"No Dither: {frequency} ground range projected (equiangular) and" + f"No Dither: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct HVHV" ), "role": ["data"], } ), - f"VVVV_{xtalk}X_{frequency}.grd": AssetDefinition( + f"VVVV_{xtalk}X_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}X_{frequency} Ground Range Projected File for Crossproduct VVVV", + "title": f"{xtalk}X_{nmode} Ground Range Projected File for Crossproduct VVVV", "type": "application/octet-stream", "description": ( - f"No Dither: {frequency} ground range projected (equiangular) and" + f"No Dither: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct VVVV" ), "role": ["data"], } ), - f"HHHV_{xtalk}X_{frequency}.grd": AssetDefinition( + f"HHHV_{xtalk}X_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}X_{frequency} Ground Range Projected File for Crossproduct HHHV", + "title": f"{xtalk}X_{nmode} Ground Range Projected File for Crossproduct HHHV", "type": "application/octet-stream", "description": ( - f"No Dither: {frequency} ground range projected (equiangular) and" + f"No Dither: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct HHHV" ), "role": ["data"], } ), - f"HHVV_{xtalk}X_{frequency}.grd": AssetDefinition( + f"HHVV_{xtalk}X_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}X_{frequency} Ground Range Projected File for Crossproduct HHVV", + "title": f"{xtalk}X_{nmode} Ground Range Projected File for Crossproduct HHVV", "type": "application/octet-stream", "description": ( - f"No Dither: {frequency} ground range projected (equiangular) and" + f"No Dither: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct HHVV" ), "role": ["data"], } ), - f"HVVV_{xtalk}X_{frequency}.grd": AssetDefinition( + f"HVVV_{xtalk}X_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}X_{frequency} Ground Range Projected File for Crossproduct HVVV", + "title": f"{xtalk}X_{nmode} Ground Range Projected File for Crossproduct HVVV", "type": "application/octet-stream", "description": ( - f"No Dither: {frequency} ground range projected (equiangular) and" + f"No Dither: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct HVVV" ), "role": ["data"], } ), - f"{xtalk}X_{frequency}.hgt": AssetDefinition( + f"{xtalk}X_{nmode}.hgt": AssetDefinition( { - "title": f"{xtalk}X_{frequency} HGT File", + "title": f"{xtalk}X_{nmode} HGT File", "type": "application/octet-stream", "description": ( "Digital elevation model (DEM) used during processing and ground projection" @@ -174,9 +172,9 @@ def NISAR_SIM_ASSETS_NO_DITHER( "role": ["data"], } ), - f"{xtalk}X_{frequency}.inc": AssetDefinition( + f"{xtalk}X_{nmode}.inc": AssetDefinition( { - "title": f"{xtalk}X_{frequency} Incidence Angle File", + "title": f"{xtalk}X_{nmode} Incidence Angle File", "type": "application/octet-stream", "description": ( "Ground range local incidence angle, the angle between" @@ -185,9 +183,9 @@ def NISAR_SIM_ASSETS_NO_DITHER( "role": ["data"], } ), - f"{xtalk}X_{frequency}.flat.inc": AssetDefinition( + f"{xtalk}X_{nmode}.flat.inc": AssetDefinition( { - "title": f"{xtalk}X_{frequency} Flat Earth Incidence Angle File", + "title": f"{xtalk}X_{nmode} Flat Earth Incidence Angle File", "type": "application/octet-stream", "description": ( "Ground range local incidence angle, the angle between" @@ -196,9 +194,9 @@ def NISAR_SIM_ASSETS_NO_DITHER( "role": ["data"], } ), - f"{xtalk}X_{frequency}.slope": AssetDefinition( + f"{xtalk}X_{nmode}.slope": AssetDefinition( { - "title": f"{xtalk}X_{frequency} Terrain Slope File", + "title": f"{xtalk}X_{nmode} Terrain Slope File", "type": "application/octet-stream", "description": ( "Ground range terrain slope containing the derivatives of the DEM in the East" @@ -207,9 +205,9 @@ def NISAR_SIM_ASSETS_NO_DITHER( "role": ["data"], } ), - f"{xtalk}X_{frequency}.rtc": AssetDefinition( + f"{xtalk}X_{nmode}.rtc": AssetDefinition( { - "title": f"{xtalk}X_{frequency} Radiometric Terrain Correction Factor", + "title": f"{xtalk}X_{nmode} Radiometric Terrain Correction Factor", "type": "application/octet-stream", "description": ( "Radiometric terrain correction factor that can be applied to grd files" @@ -217,9 +215,9 @@ def NISAR_SIM_ASSETS_NO_DITHER( "role": ["data"], } ), - f"{xtalk}X_{frequency}.kmz": AssetDefinition( + f"{xtalk}X_{nmode}.kmz": AssetDefinition( { - "title": f"{xtalk}X_{frequency} Keyhole Markup Language Zipped File", + "title": f"{xtalk}X_{nmode} Keyhole Markup Language Zipped File", "type": "application/vnd.google-earth.kmz", "description": ( "Full resolution image representing the GRD data in Keyhole Markup Language" @@ -227,11 +225,11 @@ def NISAR_SIM_ASSETS_NO_DITHER( "role": ["overlay"], } ), - f"{xtalk}X_{frequency[:-1]}.h5": AssetDefinition( + f"{xtalk}X_{nmode[:-1]}.h5": AssetDefinition( { - "title": f"{xtalk}D_{frequency[:-1]} HDF5 Data File", + "title": f"{xtalk}X_{nmode[:-1]} HDF5 Data File", "type": MediaType.HDF5, - "description": f"No Dither: {frequency[:-1]} Frequency HDF5 file in NISAR format", + "description": f"No Dither: {nmode[:-1]} NMode HDF5 file in NISAR format", "role": ["data"], } ), @@ -239,89 +237,89 @@ def NISAR_SIM_ASSETS_NO_DITHER( def NISAR_SIM_ASSETS_DITHERED_WITH_GAPS( - xtalk: str, frequency: str + xtalk: str, nmode: str ) -> Dict[str, AssetDefinition]: return { - f"{xtalk}G_{frequency}.ann": AssetDefinition( + f"{xtalk}G_{nmode}.ann": AssetDefinition( { - "title": f"{xtalk}G_{frequency} Annotation File", + "title": f"{xtalk}G_{nmode} Annotation File", "type": MediaType.TEXT, - "description": f"Dithered With Gaps: {frequency} Annotation File", + "description": f"Dithered With Gaps: {nmode} Annotation File", "role": ["metadata"], } ), - f"HHHH_{xtalk}G_{frequency}.grd": AssetDefinition( + f"HHHH_{xtalk}G_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}G_{frequency} Ground Range Projected File for Crossproduct HHHH", + "title": f"{xtalk}G_{nmode} Ground Range Projected File for Crossproduct HHHH", "type": "application/octet-stream", "description": ( - f"Dithered With Gaps: {frequency} ground range projected (equiangular) and" + f"Dithered With Gaps: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct HHHH" ), "role": ["data"], } ), - f"HVHV_{xtalk}G_{frequency}.grd": AssetDefinition( + f"HVHV_{xtalk}G_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}G_{frequency} Ground Range Projected File for Crossproduct HVHV", + "title": f"{xtalk}G_{nmode} Ground Range Projected File for Crossproduct HVHV", "type": "application/octet-stream", "description": ( - f"Dithered With Gaps: {frequency} ground range projected (equiangular) and" + f"Dithered With Gaps: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct HVHV" ), "role": ["data"], } ), - f"VVVV_{xtalk}G_{frequency}.grd": AssetDefinition( + f"VVVV_{xtalk}G_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}G_{frequency} Ground Range Projected File for Crossproduct VVVV", + "title": f"{xtalk}G_{nmode} Ground Range Projected File for Crossproduct VVVV", "type": "application/octet-stream", "description": ( - f"Dithered With Gaps: {frequency} ground range projected (equiangular) and" + f"Dithered With Gaps: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct VVVV" ), "role": ["data"], } ), - f"HHHV_{xtalk}G_{frequency}.grd": AssetDefinition( + f"HHHV_{xtalk}G_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}G_{frequency} Ground Range Projected File for Crossproduct HHHV", + "title": f"{xtalk}G_{nmode} Ground Range Projected File for Crossproduct HHHV", "type": "application/octet-stream", "description": ( - f"Dithered With Gaps: {frequency} ground range projected (equiangular) and" + f"Dithered With Gaps: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct HHHV" ), "role": ["data"], } ), - f"HHVV_{xtalk}G_{frequency}.grd": AssetDefinition( + f"HHVV_{xtalk}G_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}G_{frequency} Ground Range Projected File for Crossproduct HHVV", + "title": f"{xtalk}G_{nmode} Ground Range Projected File for Crossproduct HHVV", "type": "application/octet-stream", "description": ( - f"Dithered With Gaps: {frequency} ground range projected (equiangular) and" + f"Dithered With Gaps: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct HHVV" ), "role": ["data"], } ), - f"HVVV_{xtalk}G_{frequency}.grd": AssetDefinition( + f"HVVV_{xtalk}G_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}G_{frequency} Ground Range Projected File for Crossproduct HVVV", + "title": f"{xtalk}G_{nmode} Ground Range Projected File for Crossproduct HVVV", "type": "application/octet-stream", "description": ( - f"Dithered With Gaps: {frequency} ground range projected (equiangular) and" + f"Dithered With Gaps: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct HVVV" ), "role": ["data"], } ), - f"{xtalk}G_{frequency[:-1]}.h5": AssetDefinition( + f"{xtalk}G_{nmode[:-1]}.h5": AssetDefinition( { - "title": f"{xtalk}D_{frequency[:-1]} HDF5 Data File", + "title": f"{xtalk}G_{nmode[:-1]} HDF5 Data File", "type": MediaType.HDF5, "description": ( - f"Dithered With Gaps: {frequency[:-1]} Frequency HDF5 file in NISAR format" + f"Dithered With Gaps: {nmode[:-1]} NMode HDF5 file in NISAR format" ), "role": ["data"], } @@ -330,89 +328,89 @@ def NISAR_SIM_ASSETS_DITHERED_WITH_GAPS( def NISAR_SIM_ASSETS_DITHERED_WITHOUT_GAPS( - xtalk: str, frequency: str + xtalk: str, nmode: str ) -> Dict[str, AssetDefinition]: return { - f"{xtalk}D_{frequency}.ann": AssetDefinition( + f"{xtalk}D_{nmode}.ann": AssetDefinition( { - "title": f"{xtalk}D_{frequency} Annotation File", + "title": f"{xtalk}D_{nmode} Annotation File", "type": MediaType.TEXT, - "description": f"Dithered Without Gaps: {frequency} Annotation File", + "description": f"Dithered Without Gaps: {nmode} Annotation File", "role": ["metadata"], } ), - f"HHHH_{xtalk}D_{frequency}.grd": AssetDefinition( + f"HHHH_{xtalk}D_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}D_{frequency} Ground Range Projected File for Crossproduct HHHH", + "title": f"{xtalk}D_{nmode} Ground Range Projected File for Crossproduct HHHH", "type": "application/octet-stream", "description": ( - f"Dithered Without Gaps: {frequency} ground range projected (equiangular) and" + f"Dithered Without Gaps: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct HHHH" ), "role": ["data"], } ), - f"HVHV_{xtalk}D_{frequency}.grd": AssetDefinition( + f"HVHV_{xtalk}D_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}D_{frequency} Ground Range Projected File for Crossproduct HVHV", + "title": f"{xtalk}D_{nmode} Ground Range Projected File for Crossproduct HVHV", "type": "application/octet-stream", "description": ( - f"Dithered Without Gaps: {frequency} ground range projected (equiangular) and" + f"Dithered Without Gaps: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct HVHV" ), "role": ["data"], } ), - f"VVVV_{xtalk}D_{frequency}.grd": AssetDefinition( + f"VVVV_{xtalk}D_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}D_{frequency} Ground Range Projected File for Crossproduct VVVV", + "title": f"{xtalk}D_{nmode} Ground Range Projected File for Crossproduct VVVV", "type": "application/octet-stream", "description": ( - f"Dithered Without Gaps: {frequency} ground range projected (equiangular) and" + f"Dithered Without Gaps: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct VVVV" ), "role": ["data"], } ), - f"HHHV_{xtalk}D_{frequency}.grd": AssetDefinition( + f"HHHV_{xtalk}D_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}D_{frequency} Ground Range Projected File for Crossproduct HHHV", + "title": f"{xtalk}D_{nmode} Ground Range Projected File for Crossproduct HHHV", "type": "application/octet-stream", "description": ( - f"Dithered Without Gaps: {frequency} ground range projected (equiangular) and" + f"Dithered Without Gaps: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct HHHV" ), "role": ["data"], } ), - f"HHVV_{xtalk}D_{frequency}.grd": AssetDefinition( + f"HHVV_{xtalk}D_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}D_{frequency} Ground Range Projected File for Crossproduct HHVV", + "title": f"{xtalk}D_{nmode} Ground Range Projected File for Crossproduct HHVV", "type": "application/octet-stream", "description": ( - f"Dithered Without Gaps: {frequency} ground range projected (equiangular) and" + f"Dithered Without Gaps: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct HHVV" ), "role": ["data"], } ), - f"HVVV_{xtalk}D_{frequency}.grd": AssetDefinition( + f"HVVV_{xtalk}D_{nmode}.grd": AssetDefinition( { - "title": f"{xtalk}D_{frequency} Ground Range Projected File for Crossproduct HVVV", + "title": f"{xtalk}D_{nmode} Ground Range Projected File for Crossproduct HVVV", "type": "application/octet-stream", "description": ( - f"Dithered Without Gaps: {frequency} ground range projected (equiangular) and" + f"Dithered Without Gaps: {nmode} ground range projected (equiangular) and" " multi-looked data for crossproduct HVVV" ), "role": ["data"], } ), - f"{xtalk}D_{frequency[:-1]}.h5": AssetDefinition( + f"{xtalk}D_{nmode[:-1]}.h5": AssetDefinition( { - "title": f"{xtalk}D_{frequency[:-1]} HDF5 Data File", + "title": f"{xtalk}D_{nmode[:-1]} HDF5 Data File", "type": MediaType.HDF5, "description": ( - f"Dithered Without Gaps: {frequency[:-1]} Frequency HDF5 file in NISAR format" + f"Dithered Without Gaps: {nmode[:-1]} NMode HDF5 file in NISAR format" ), "role": ["data"], } @@ -425,24 +423,24 @@ def get_assets( dither: Optional[str] = None, xtalk: Optional[str] = None, ) -> Dict[str, AssetDefinition]: - nmodes = [f"{mode}{frequency}" for mode in c.NMODE for frequency in ["A", "B"]] + nmodes = [f"{mode}{nmode}" for mode in c.NMODE for nmode in ["A", "B"]] assets = {} if collection: for _talk in c.XTALK: - for _frequency in nmodes: - assets.update(NISAR_SIM_ASSETS_NO_DITHER(_talk, _frequency)) - assets.update(NISAR_SIM_ASSETS_DITHERED_WITH_GAPS(_talk, _frequency)) - assets.update(NISAR_SIM_ASSETS_DITHERED_WITHOUT_GAPS(_talk, _frequency)) + for _nmode in nmodes: + assets.update(NISAR_SIM_ASSETS_NO_DITHER(_talk, _nmode)) + assets.update(NISAR_SIM_ASSETS_DITHERED_WITH_GAPS(_talk, _nmode)) + assets.update(NISAR_SIM_ASSETS_DITHERED_WITHOUT_GAPS(_talk, _nmode)) if dither: if not xtalk: xtalk = "C" - for _frequency in nmodes: + for _nmode in nmodes: if dither == "X": - assets.update(NISAR_SIM_ASSETS_NO_DITHER(xtalk, _frequency)) + assets.update(NISAR_SIM_ASSETS_NO_DITHER(xtalk, _nmode)) if dither == "G": - assets.update(NISAR_SIM_ASSETS_DITHERED_WITH_GAPS(xtalk, _frequency)) + assets.update(NISAR_SIM_ASSETS_DITHERED_WITH_GAPS(xtalk, _nmode)) if dither == "D": - assets.update(NISAR_SIM_ASSETS_DITHERED_WITHOUT_GAPS(xtalk, _frequency)) + assets.update(NISAR_SIM_ASSETS_DITHERED_WITHOUT_GAPS(xtalk, _nmode)) return assets diff --git a/tests/test_commands.py b/tests/test_commands.py index 6e3883e..e58bdce 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -4,12 +4,16 @@ import pystac from click import Command, Group -from stactools.testing.cli_test import CliTestCase +from click.testing import CliRunner +from stactools.cli.cli import cli from stactools.nisar_sim.commands import create_nisarsim_command -class CommandsTest(CliTestCase): +class CommandsTest: + def __init__(self) -> None: + self.runner = CliRunner() + def create_subcommand_functions(self) -> List[Callable[[Group], Command]]: return [create_nisarsim_command] @@ -20,9 +24,11 @@ def test_create_collection(self) -> None: # Example: destination = os.path.join(tmp_dir, "collection.json") - result = self.run_command(f"nisarsim create-collection {destination}") + result = self.runner.invoke( + cli, ["nisarsim", "create-collection" f"{destination}"] + ) - assert result.exit_code == 0, "\n{}".format(result.output) + assert result.exit_code == 0, f"\n{result.output}" jsons = [p for p in os.listdir(tmp_dir) if p.endswith(".json")] assert len(jsons) == 1 @@ -42,10 +48,18 @@ def test_create_item(self) -> None: destination = os.path.join(tmp_dir, "item.json") dither = "X" nmode = "129" - result = self.run_command( - f"nisarsim create-item {inpath} {destination} --dither {dither} --nmode {nmode}" + result = self.runner.invoke( + cli, + [ + "nisarsim", + "create-item", + f"{inpath}", + f"{destination}", + f"--dither {dither}", + f"--nmode {nmode}", + ], ) - assert result.exit_code == 0, "\n{}".format(result.output) + assert result.exit_code == 0, f"\n{result.output}" jsons = [p for p in os.listdir(tmp_dir) if p.endswith(".json")] assert len(jsons) == 1