Skip to content

Commit

Permalink
Add orbit type
Browse files Browse the repository at this point in the history
  • Loading branch information
scottstanie committed Dec 20, 2024
1 parent 4fa76e4 commit 9629834
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/disp_s1/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,12 @@ def _get_start_end_cslcs(files):
reference_point=reference_point,
)

orbit_type = _get_orbit_type(reference_cslc_files[0])
_create_identification_group(
output_name=output_name,
pge_runconfig=pge_runconfig,
radar_wavelength=radar_wavelength,
orbit_type=orbit_type,
reference_start_time=reference_start_time,
reference_end_time=reference_end_time,
secondary_start_time=secondary_start_time,
Expand Down Expand Up @@ -525,6 +527,7 @@ def _create_identification_group(
output_name: Filename,
pge_runconfig: RunConfig,
radar_wavelength: float,
orbit_type: str,
reference_start_time: datetime.datetime,
reference_end_time: datetime.datetime,
secondary_start_time: datetime.datetime,
Expand Down Expand Up @@ -712,7 +715,7 @@ def _create_identification_group(
# CEOS: Section 1.5
_create_dataset(
group=identification_group,
name="ceos_source_data_satellite_names",
name="source_data_satellite_names",
dimensions=(),
data=",".join(input_sensors),
fillvalue=None,
Expand All @@ -722,7 +725,7 @@ def _create_identification_group(
starting_date_str = input_dts[0].isoformat()
_create_dataset(
group=identification_group,
name="ceos_source_data_earliest_acquisition",
name="source_data_earliest_acquisition",
dimensions=(),
data=starting_date_str,
fillvalue=None,
Expand All @@ -732,7 +735,7 @@ def _create_identification_group(
last_date_str = input_dts[-1].isoformat()
_create_dataset(
group=identification_group,
name="ceos_source_data_latest_acquisition",
name="source_data_latest_acquisition",
dimensions=(),
data=last_date_str,
fillvalue=None,
Expand All @@ -748,6 +751,17 @@ def _create_identification_group(
description="Number of input data granule used during processing.",
attrs={"units": "unitless"},
)
_create_dataset(
group=identification_group,
name="source_data_orbit_type",
dimensions=(),
data=orbit_type,
fillvalue=None,
description=(
"Type of orbit (precise, restituted) used during input data processing"
),
attrs={"units": "unitless"},
)

# CEOS: Section 1.6.4 source acquisition parameters
_create_dataset(
Expand Down Expand Up @@ -996,6 +1010,16 @@ def _get_orbit_direction(cslc_filename: Filename) -> Literal["ascending", "desce
return out


def _get_orbit_type(
cslc_filename: Filename,
) -> Literal["precise orbit file", "restituted orbit file"]:
with h5py.File(cslc_filename) as hf:
out = hf["/quality_assurance/orbit_information/orbit_type"][()]
if isinstance(out, bytes):
out = out.decode("utf-8")
return out


def _create_dataset(
*,
group: h5netcdf.Group,
Expand Down

0 comments on commit 9629834

Please sign in to comment.