Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: SME2, GOFF, GSLC metadata #9

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/stactools/nisar_sim/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

import fsspec
import h5py
from numpy import ndarray
from pystac import Asset, Item, MediaType
from pystac.extensions.item_assets import AssetDefinition
from shapely.geometry import mapping
from shapely.geometry import Polygon, mapping
from shapely.wkt import loads
from stactools.nisar_sim import constants as c

Expand Down Expand Up @@ -37,8 +38,16 @@ def get_geometry(
if not h5_polygon:
raise MetadataException("Unable to locate boundingPolygon")
polygon = loads(h5_polygon[()])
geometry = mapping(polygon)
bbox = list(polygon.bounds)
if isinstance(polygon, Polygon):
geometry = mapping(polygon)
bbox = list(polygon.bounds)
elif isinstance(polygon, ndarray):
geometry = mapping(polygon[0])
bbox = list(polygon[0].bounds)
else:
raise MetadataException(
f"Unable to parse boundingPolygon of type {type(polygon)}"
)

return geometry, bbox

Expand All @@ -63,7 +72,7 @@ def filename_convention(source: str) -> Dict[str, Any]:

filename_convention = (
r"NISAR_(?P<instrument>[L|S])(?P<level>[0-3])_(?P<processing_type>(PR|UR))_"
r"(?P<product_identifier>(RRSD|RIFG|ROFF|RSLC|RUNW|GCOV|COFF|GSLC|GUNW|SME2))_"
r"(?P<product_identifier>(RRSD|RIFG|ROFF|RSLC|RUNW|GCOV|GOFF|GSLC|GUNW|SME2))_"
r"\d{3}_\d{3}_(?P<orbit_state>[A|D])_\d{3}\w?_.*"
r"(?P<start_datetime>\d{8}T\d{6})_(?P<end_datetime>\d{8}T\d{6}).*"
)
Expand Down
Loading