isce-framework / s1-reader

Sentinel-1 reader
Apache License 2.0
27 stars 12 forks source link

[Bug]: `BurstNoise` fails during `from_noise_annotation` #122

Closed scottstanie closed 1 year ago

scottstanie commented 1 year ago

I got this error

...
  File "/u/aurora-r0/staniewi/repos/sweets/src/sweets/_geocode_slcs.py", line 47, in run_geocode
    cfg = GeoRunConfig.load_from_yaml(str(run_config_path), "s1_cslc_geo")
  File "/u/aurora-r0/staniewi/repos/COMPASS/src/compass/utils/geo_runconfig.py", line 96, in load_from_yaml
    bursts = runconfig_to_bursts(sns)
  File "/u/aurora-r0/staniewi/repos/COMPASS/src/compass/utils/runconfig.py", line 225, in runconfig_to_bursts
    for burst in load_bursts(safe_file, orbit_path, i_subswath, pol):
  File "/u/aurora-r0/staniewi/repos/s1-reader/src/s1reader/s1_reader.py", line 881, in load_bursts
    bursts = _burst_from_zip(path, id_str, orbit_path,
  File "/u/aurora-r0/staniewi/repos/s1-reader/src/s1reader/s1_reader.py", line 948, in _burst_from_zip
    bursts = burst_from_xml(f_annotation, orbit_path, f_tiff, iw2_f_annotation, z_file.open,
  File "/u/aurora-r0/staniewi/repos/s1-reader/src/s1reader/s1_reader.py", line 758, in burst_from_xml
    burst_noise = BurstNoise.from_noise_annotation(noise_annotation,
  File "/u/aurora-r0/staniewi/repos/s1-reader/src/s1reader/s1_annotation.py", line 840, in from_noise_annotation
    id_top = np.argmin(np.abs(noise_annotation.az_line-line_from))
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

Note that id_top = np.argmin(np.abs(noise_annotation.az_line-line_from)) uses .az_line. This is not defined anywhere: https://github.com/opera-adt/s1-reader/blob/ed16185338c879b59518ca26936751a1baffd621/src/s1reader/s1_annotation.py#L776-L789 it's probably a typo from copying this different class: https://github.com/opera-adt/s1-reader/blob/ed16185338c879b59518ca26936751a1baffd621/src/s1reader/s1_annotation.py#L274-L289

Let's add some unit test that runs to make a BurstNoise class, I think this would currently fail for any where ipf_version >= min_ipf_version_az_noise_vector

scottstanie commented 1 year ago

Sorry I was wrong about the .az_line not being defined.

Currently trying to get a reproducible example, since the bug seems not appear when I try to find which file it errored on 😕

scottstanie commented 1 year ago

Closing because I can't find any way to reproduce, and the logic for checking the IPF version seems to imply this bug shouldn't have happened... Sorry for the github noise (pun intended)

seongsujeong commented 1 year ago

@scottstanie Interesting. Please re-open this issue when you are able to reproduce the error you reported here.

The member az_line is defined in the dataclass NoiseAnnotation, which will be assigned None when the IPF version of the data is older than the threshold min_ipf_version_az_noise_vector

What I can think about the error is that the reader failed to parse az_line for some reason, even when the IPF version says the information should exist in the noise annotation, and the following codes assumes that we have some data in az_line. But I will need to some example data to figure out what exactly happened.