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

Annotation class attrs #123

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
convert SwathRfiInfo to return an instance, remove the ipf check fr…
…om classmethod

Since the ET cant be parsed if the file doesnt exist, not clear how the check would fail
  • Loading branch information
scottstanie committed Jun 28, 2023
commit b997da3fd976af69aace5da6d3a7e446668c2f21
27 changes: 13 additions & 14 deletions src/s1reader/s1_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,12 +672,6 @@ def from_et(cls,
cls: SwathRfiInfo
dataclass populated by this function
'''

if ipf_version < RFI_INFO_AVAILABLE_FROM:
# RFI related processing is not in place
# return an empty dataclass
return None

# Attempt to locate the RFI information from the input annotations
header_lads = et_product.find('imageAnnotation/processingInformation')
if header_lads is None:
Expand All @@ -690,22 +684,27 @@ def from_et(cls,
'in the RFI annotation')

# Start to load RFI information
cls.rfi_mitigation_performed =\
rfi_mitigation_performed =\
header_lads.find('rfiMitigationPerformed').text
cls.rfi_mitigation_domain =\
rfi_mitigation_domain =\
header_lads.find('rfiMitigationDomain').text

num_burst_rfi_report = len(header_rfi)
cls.rfi_burst_report_list = [None] * num_burst_rfi_report
cls.azimuth_time_list = [None] * num_burst_rfi_report
rfi_burst_report_list = [None] * num_burst_rfi_report
azimuth_time_list = [None] * num_burst_rfi_report

for i_burst, elem_burst in enumerate(header_rfi):
cls.rfi_burst_report_list[i_burst] =\
rfi_burst_report_list[i_burst] =\
element_to_dict(elem_burst)['rfiBurstReport']
cls.azimuth_time_list[i_burst] =\
cls.rfi_burst_report_list[i_burst]['azimuthTime']
azimuth_time_list[i_burst] =\
rfi_burst_report_list[i_burst]['azimuthTime']

return cls
return cls(
rfi_mitigation_performed,
rfi_mitigation_domain,
rfi_burst_report_list,
azimuth_time_list,
)


@classmethod
Expand Down
4 changes: 1 addition & 3 deletions src/s1reader/s1_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,7 @@ def burst_from_xml(annotation_path: str, orbit_path: str, tiff_path: str,
'annotation/rfi/rfi-')
with open_method(rfi_annotation_path, 'r') as f_rads:
tree_rads = ET.parse(f_rads)
burst_rfi_info_swath = SwathRfiInfo.from_et(tree_rads,
tree_lads,
ipf_version)
burst_rfi_info_swath = SwathRfiInfo.from_et(tree_rads, tree_lads)

else:
burst_rfi_info_swath = None
Expand Down