Skip to content

Commit 2c189e4

Browse files
authored
Populate GCOV & GSLC Static Layers Data Access (isce-framework#100)
* disable polarimetric symmetrization by default * revert changes to `symmetrize_cross_pol_channels` * Update GCOV and GSLC specification XMLs * Revert changes to the GCOV and GSLC specification XMLs * populate static layers data access template * handle an empty static layers data access * remove unnecessary `default` argument * set default value to "(NOT SPECIFIED)" * Move function `get_static_layers_data_access()` outside of the class `BaseL2WriterSingleInput` * Move function `get_static_layers_data_access()` outside of the class `BaseL2WriterSingleInput` (2) * returns "(NOT SPECIFIED)" if `static_layers_data_access_runconfig` is `None` or empty string * improve function ``get_static_layers_data_access()` * improve error message * move `staticLayersDataAccess` from `ceosAnalysisReadyData` group to `identification` * move the runconfig field `static_layers_data_access` to the `primary_executable` group * move the runconfig field `static_layers_data_access` to the `primary_executable` group (2); improve docstrings * improve docstrings * improve docstrings * improve runconfig comments * move `get_static_layers_data_access()` into nisar.products.utils * fix typo
1 parent 8101d85 commit 2c189e4

File tree

7 files changed

+95
-23
lines changed

7 files changed

+95
-23
lines changed

python/packages/nisar/products/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
populate_dataset_attrs_from_spec,
1212
)
1313
from .projection import build_projection_dataset_attrs_dict
14+
from .utils import get_static_layers_data_access

python/packages/nisar/products/utils.py

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import numpy as np
44
from numpy.typing import ArrayLike
5+
import journal
56

67

78
def to_bytes(s: str | ArrayLike) -> np.ndarray:
@@ -16,4 +17,60 @@ def to_bytes(s: str | ArrayLike) -> np.ndarray:
1617
numpy.ndarray
1718
The input string(s) converted to bytestrings with 'utf-8' encoding.
1819
"""
19-
return np.char.encode(s, encoding="utf-8")
20+
return np.char.encode(s, encoding="utf-8")
21+
22+
23+
def get_static_layers_data_access(
24+
static_layers_data_access_template: str | None,
25+
granule_id: str | None) -> str:
26+
"""
27+
Read the static layers data access template and replace the placeholder
28+
"{granule_id}" with the granule ID, if provided.
29+
30+
Parameters
31+
----------
32+
static_layers_data_access_template: str or None
33+
Template string for static layers data access. If the string contains
34+
the substring "{granule_id}", that substring will be replaced with
35+
the contents of `granule_id`.
36+
If set to `None` or an empty string, the function returns
37+
"(NOT SPECIFIED)"
38+
If the string is valid, i.e., it is not `None` or an empty string,
39+
and it does not contain the substring "{granule_id}", then
40+
`granule_id` is ignored.
41+
granule_id: str or None
42+
The granule ID, which will be used to replace the substring
43+
"{granule_id}" in `static_layers_data_access_template`.
44+
If the template string contains "{granule_id}", but `granule_id` is
45+
`None`, empty string, or "(NOT SPECIFIED)", the function raises an
46+
error.
47+
48+
Returns
49+
-------
50+
static_layers_data_access: str
51+
The static layers data access string with "{granule_id}" placeholder
52+
replaced. Returns "(NOT SPECIFIED)" if
53+
`static_layers_data_access_template` is `None` or an empty
54+
string.
55+
"""
56+
57+
if not static_layers_data_access_template:
58+
return '(NOT SPECIFIED)'
59+
60+
static_layers_data_access = static_layers_data_access_template
61+
62+
if '{granule_id}' in static_layers_data_access_template:
63+
if not granule_id or granule_id == '(NOT SPECIFIED)':
64+
error_msg = ('The placeholder "{granule_id}" is included in'
65+
' the static layers data access template,'
66+
' but the `granule_id` was not provided'
67+
" or is invalid")
68+
error_channel = journal.error('get_static_layers_data_access')
69+
error_channel.log(error_msg)
70+
raise ValueError(error_msg)
71+
72+
static_layers_data_access = \
73+
static_layers_data_access_template.replace('{granule_id}',
74+
granule_id)
75+
76+
return static_layers_data_access

python/packages/nisar/products/writers/BaseL2WriterSingleInput.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from isce3.core.types import truncate_mantissa
1212
from isce3.geometry import get_near_and_far_range_incidence_angles
1313
from nisar.products.readers.orbit import load_orbit
14+
from nisar.products.utils import get_static_layers_data_access
1415

1516

1617
LEXICOGRAPHIC_BASE_POLS = ['HH', 'HV', 'VH', 'VV']
@@ -808,12 +809,17 @@ def populate_identification_l2_specific(self):
808809
'identification/platformName',
809810
default='(NOT SPECIFIED)')
810811

811-
def populate_ceos_analysis_ready_data_parameters_l2_common(self):
812+
static_layers_data_access_runconfig = \
813+
self.cfg['primary_executable']['static_layers_data_access']
812814

813-
self.copy_from_runconfig(
814-
'{PRODUCT}/metadata/ceosAnalysisReadyData/staticLayersDataAccess',
815-
'ceos_analysis_ready_data/static_layers_data_access',
816-
default='(NOT SPECIFIED)')
815+
static_layers_data_access = get_static_layers_data_access(
816+
static_layers_data_access_runconfig, self.granule_id)
817+
818+
self.set_value(
819+
'identification/staticLayersDataAccess',
820+
static_layers_data_access)
821+
822+
def populate_ceos_analysis_ready_data_parameters_l2_common(self):
817823

818824
ceos_ard_document_identifier = \
819825
('https://ceos.org/ard/files/PFS/SAR/v1.0/CEOS-ARD_PFS'

share/nisar/defaults/gcov.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ runconfig:
134134
# the corresponding metadata field will be set to "(NOT SPECIFIED)".
135135
product_doi:
136136

137+
# Data access for the static layers product associated with the
138+
# output product (URL or DOI). If not provided, the corresponding
139+
# metadata field will be set to "(NOT SPECIFIED)".
140+
# If this string contains the substring "{granule_id}", that substring
141+
# will be replaced with the granule ID.
142+
static_layers_data_access:
143+
137144
# Composite release ID (CRID). If not provided, the corresponding
138145
# metadata field will be set to b'A10000'.
139146
composite_release_id:
@@ -547,10 +554,6 @@ runconfig:
547554
# to populate the output product's metadata
548555
ceos_analysis_ready_data:
549556

550-
# NOT YET IMPLEMENTED
551-
# Data access for the static layers product associated with the output product (URL or DOI)
552-
static_layers_data_access:
553-
554557
# Estimated geometric accuracy (bias and standard deviation)
555558
# in meters in the X- and Y-directions over the coordinate
556559
# system defined by the product's EPSG code

share/nisar/defaults/gslc.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ runconfig:
6767
product_type: GSLC
6868
product_version: 0.1.0
6969
product_doi:
70+
71+
# Data access for the static layers product associated with the
72+
# output product (URL or DOI). If not provided, the corresponding
73+
# metadata field will be set to "(NOT SPECIFIED)".
74+
# If this string contains the substring "{granule_id}", that substring
75+
# will be replaced with the granule ID.
76+
static_layers_data_access:
77+
7078
composite_release_id:
7179
processing_type:
7280
processing_center:
@@ -327,10 +335,6 @@ runconfig:
327335
# to populate the output product's metadata
328336
ceos_analysis_ready_data:
329337

330-
# NOT YET IMPLEMENTED
331-
# Data access for the static layers product associated with the output product (URL or DOI)
332-
static_layers_data_access:
333-
334338
# Estimated geometric accuracy (bias and standard deviation)
335339
# in meters in the X- and Y-directions over the coordinate
336340
# system defined by the product's EPSG code

share/nisar/schemas/gcov.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ runconfig:
6262
product_type: enum('GCOV')
6363
product_version: str('^\d+\.\d+\.\d+$', required=False)
6464
product_doi: str(required=False)
65+
66+
# Data access for the static layers product associated with the output
67+
# product (URL or DOI)
68+
static_layers_data_access: str(required=False)
69+
6570
composite_release_id: regex(r'\w\d\d\d\d\d', name='CRID', required=False)
6671
processing_type: enum('PR', 'UR', 'OD', required=False)
6772
product_accuracy: enum('P', 'M', 'N', 'F', required=False)
@@ -537,11 +542,6 @@ geocode_options:
537542

538543
ceos_analysis_ready_data_options:
539544

540-
# NOT YET IMPLEMENTED
541-
# Data access for the static layers product associated with the output
542-
# product (URL or DOI)
543-
static_layers_data_access: str(required=False)
544-
545545
# Estimated geometric accuracy (bias and standard deviation)
546546
# in meters in the X- and Y-directions over the coordinate
547547
# system defined by the product's EPSG code

share/nisar/schemas/gslc.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ runconfig:
6363
product_type: enum('GSLC')
6464
product_version: str('^\d+\.\d+\.\d+$', required=False)
6565
product_doi: str(required=False)
66+
67+
# Data access for the static layers product associated with the output
68+
# product (URL or DOI)
69+
static_layers_data_access: str(required=False)
70+
6671
composite_release_id: regex(r'\w\d\d\d\d\d', name='CRID', required=False)
6772
processing_type: enum('PR', 'UR', 'OD', required=False)
6873
product_accuracy: enum('P', 'M', 'N', 'F', required=False)
@@ -302,10 +307,6 @@ geocode_options:
302307

303308
ceos_analysis_ready_data_options:
304309

305-
# NOT YET IMPLEMENTED
306-
# Data access for the static layers product associated with the output product (URL or DOI)
307-
static_layers_data_access: str(required=False)
308-
309310
# Estimated geometric accuracy (bias and standard deviation)
310311
# in meters in the X- and Y-directions over the coordinate
311312
# system defined by the product's EPSG code

0 commit comments

Comments
 (0)