Skip to content

Commit

Permalink
Merge pull request #9 from ValkyrieSystems/bugfix-from-xml-apc-handling
Browse files Browse the repository at this point in the history
Bugfix metadata params from xml
  • Loading branch information
johnstob authored Jan 8, 2025
2 parents 59a86cb + 3723407 commit f9027d3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
1 change: 1 addition & 0 deletions sarkit/standards/sicd/projection/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def _get_rcv_poly(xmlhelp):
rcv_apc_polys = [
xmlhelp.load(f"{{*}}Position/{{*}}RcvAPC/{{*}}RcvAPCPoly[@index='{c}']")
for c in rcv_apc_indices
if c is not None
]
if rcv_apc_polys:
return functools.reduce(npp.polyadd, rcv_apc_polys) / len(rcv_apc_polys)
Expand Down
3 changes: 0 additions & 3 deletions sarkit/verification/sicd_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -1753,9 +1753,6 @@ def check_rcvapcindex(self) -> None:
"./{*}RadarCollection/{*}RcvChannels/{*}ChanParameters/{*}RcvAPCIndex"
)
]
with self.need("RcvAPC and RcvAPCIndex must be included together"):
assert len(rcvapc_indices) > 0
assert len(rcvapcindex) > 0

for index in rcvapcindex:
with self.need(
Expand Down
8 changes: 8 additions & 0 deletions tests/standards/sicd/test_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ def test_metadata_params():
assert not unset_attrs


def test_metadata_params_without_optional_apcs():
etree = lxml.etree.parse(DATAPATH / "example-sicd-1.3.0.xml")
assert ss_proj.MetadataParams.from_xml(etree).Rcv_Poly is not None
for el in etree.findall(".//{*}RcvAPCIndex") + etree.findall(".//{*}RcvApcPoly"):
el.getparent().remove(el)
assert ss_proj.MetadataParams.from_xml(etree).Rcv_Poly is None


def test_metadata_params_is_monostatic(example_proj_metadata):
example_proj_metadata.Collect_Type = "MONOSTATIC"
assert example_proj_metadata.is_monostatic()
Expand Down
26 changes: 26 additions & 0 deletions tests/verification/test_sicd_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,3 +676,29 @@ def test_check_image_formation_timeline(sicd_con):
)
sicd_con.check("check_image_formation_timeline")
assert sicd_con.failures()


def test_check_rcvapcindex(sicd_con):
# Invalid APCIndex
sicd_con.xmlhelp.set(
"./{*}RadarCollection/{*}RcvChannels/{*}ChanParameters/{*}RcvAPCIndex",
100,
)
sicd_con.check("check_rcvapcindex")
assert sicd_con.failures()

# No APCIndex with APCPolys is OK
rcvapcindex = sicd_con.sicdroot.find(
"./{*}RadarCollection/{*}RcvChannels/{*}ChanParameters/{*}RcvAPCIndex"
)
rcvapcindex.getparent().remove(rcvapcindex)
sicd_con.check("check_rcvapcindex")
assert not sicd_con.failures()


def test_check_rcvapcindex_nopolys(sicd_con):
# APCIndex with no APCPolys
rcvapcnode = sicd_con.sicdroot.find("./{*}Position/{*}RcvAPC")
rcvapcnode.getparent().remove(rcvapcnode)
sicd_con.check("check_rcvapcindex")
assert sicd_con.failures()

0 comments on commit f9027d3

Please sign in to comment.