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 reader (s1_annotation.py) - initial implementation #48

Merged
merged 43 commits into from
Aug 8, 2022

Conversation

seongsujeong
Copy link
Contributor

This PR implements the reader for Calibration Annotation Data Set (CADS), and Noise Annotation Data Set (NADS), which was related to the issue #27. This work is in context of implementing thermal noise correction. The structure of CADS and NADS are very similar, so their readers shares similar procedure to read. Therefore the readers are implemented together in s1_annotation.py

Few examples of the usage are as below:

import s1_annotation
cads=calibration('/Users/USER_NAME/DATA/COMPASS/S1B_IW_SLC__1SDV_20210112T014942_20210112T015009_025115_02FD69_DDC9.zip',polarization='VV',subswath=2)
nads=noise('/Users/USER_NAME/DATA/COMPASS/SAFE/S1B_IW_SLC__1SDV_20210112T014942_20210112T015009_025115_02FD69_DDC9',polarization='VV',subswath=1) #can assign a SAFE directory

cads.IPF_version #'003.31' for example. Also works for nads
cads.list_gamma

nads.rg_list_NoiseRangeLut #Range noise vector
nads.az_line #Range noise vector
nads.az_noiseAzimuthLut #Azinuth noise vector

Notes:

  • in s1_annotation.noise, the attribues related to range noise vector has prefix rg, and the ones about the azimuth noise vector has az
  • The information on the annotation are parsed on-the-fly.

Copy link
Contributor

@gshiroma gshiroma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding this, @seongsujeong . That's nice that you wrote a class that can be used for both radiometric calibration and thermal noise correction. This is a good start. I have a few comments/suggestions below. I'd also suggest running this code through some PEP8 checker. I'm looking forward to having this class used by the S-1 reader.

src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
Copy link
Contributor

@LiangJYu LiangJYu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies in advance - My comments are effectively asking for a rewrite of this.

Not in the PR but should be is the inclusion and integration of Calibration and Noise with the rest s1reader modules. I think Calibration and Noise should be attributes of the Sentinel1BurstSlc dataclass. The init of these objects should occur when a Sentinel1BurstSlc is initalized.

Let me know if you have any questions.

src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
Copy link
Contributor

@hfattahi hfattahi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seongsujeong thank you for this nice PR. As we briefly discussed offline, I think it will be great to slightly restructure this PR such that the Noise and Calibration are returned as isce3.core.LUT2D objects which are class members of the existing Sentinel1BurstSlc class. Since they are small and trivial to read, I think they should be read by default as we read the data and should not require an extra call. At a higher level workflow a user of the reader should not do any extra work and the returned burst should have LUT2D of noise and calibration. Please let me know if you have any concern or if this my comment is not clear.

Copy link
Contributor

@LiangJYu LiangJYu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for this incomplete review. I'll try to finish reviewing sometime this coming week.

src/s1reader/s1_reader.py Outdated Show resolved Hide resolved
src/s1reader/s1_reader.py Outdated Show resolved Hide resolved
src/s1reader/s1_reader.py Outdated Show resolved Hide resolved
src/s1reader/s1_reader.py Outdated Show resolved Hide resolved
src/s1reader/s1_reader.py Outdated Show resolved Hide resolved
src/s1reader/s1_reader.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
Copy link
Contributor

@LiangJYu LiangJYu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seongsujeong nice work! Few comments before it's ready.

src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_reader.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
Seongsu Jeong and others added 2 commits August 1, 2022 22:35
Updating branch `annotation_reader` in this for to date
Copy link
Contributor

@gshiroma gshiroma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, @seongsujeong . Thank you for working on that. I still have some minor comments before we merge this PR.

src/s1reader/s1_annotation.py Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_annotation.py Outdated Show resolved Hide resolved
src/s1reader/s1_reader.py Outdated Show resolved Hide resolved
src/s1reader/s1_reader.py Outdated Show resolved Hide resolved
@seongsujeong
Copy link
Contributor Author

Thank you all for the inputs for this PR. I've updated the branch to date to test it before merging it into the main repo. Looks like pytest in CircieCI is failing, with the error summary below:

=============================================== short test summary info ===============================================
ERROR tests/test_bursts.py::test_burst - KeyError: "There is no item named 'manifest.safe' in the archive"
ERROR tests/test_orbit.py::test_orbit_datetime - KeyError: "There is no item named 'manifest.safe' in the archive"
ERROR tests/test_reader.py::test_burst_from_zip - KeyError: "There is no item named 'manifest.safe' in the archive"

I've taken a look at the test data .../tests/data/S1A_IW_SLC__1SDV_20200511T135117_20200511T135144_032518_03C421_7768.zip, and found that the file manifest.safe is missing in the .zip file.
This PR includes updates on s1_reader.py that reads IPF version from the manifest.safe file. I wonder if someone can commit a new .zip file for the test data that has the file.

@seongsujeong seongsujeong mentioned this pull request Aug 2, 2022
Copy link
Contributor

@gshiroma gshiroma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also forgot to ask you to please resolve the codacy issues.

@gshiroma
Copy link
Contributor

gshiroma commented Aug 2, 2022

I also forgot to ask you to please resolve the codacy issues.

Nevermind. I just noticed you did that yesterday. Thanks!

@LiangJYu
Copy link
Contributor

LiangJYu commented Aug 2, 2022

Thank you all for the inputs for this PR. I've updated the branch to date to test it before merging it into the main repo. Looks like pytest in CircieCI is failing, with the error summary below:

=============================================== short test summary info ===============================================
ERROR tests/test_bursts.py::test_burst - KeyError: "There is no item named 'manifest.safe' in the archive"
ERROR tests/test_orbit.py::test_orbit_datetime - KeyError: "There is no item named 'manifest.safe' in the archive"
ERROR tests/test_reader.py::test_burst_from_zip - KeyError: "There is no item named 'manifest.safe' in the archive"

I've taken a look at the test data .../tests/data/S1A_IW_SLC__1SDV_20200511T135117_20200511T135144_032518_03C421_7768.zip, and found that the file manifest.safe is missing in the .zip file. This PR includes updates on s1_reader.py that reads IPF version from the manifest.safe file. I wonder if someone can commit a new .zip file for the test data that has the file.

I'm working this and will submit a PR to this branch sometime today.

@LiangJYu
Copy link
Contributor

LiangJYu commented Aug 2, 2022

The scope of the fix grew being adding manifest.safe so I issued a new PR to main instead of to your PR. See #58

@seongsujeong seongsujeong mentioned this pull request Aug 2, 2022
@seongsujeong
Copy link
Contributor Author

The scope of the fix grew being adding manifest.safe so I issued a new PR to main instead of to your PR. See #58

Also left a commend on the PR #58, but confirmed that CircleCI passed. Thank you for the update on the unit test!

Copy link
Contributor

@gshiroma gshiroma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you, @seongsujeong , for addressing all my comments. Just please make sure to address all new Codacy issues before merging it.

@seongsujeong seongsujeong merged commit cfb0443 into isce-framework:main Aug 8, 2022
seongsujeong added a commit that referenced this pull request Aug 9, 2022
* annotation reader (s1_annotation.py) init. commit

* s1_annotation.py - rev1 after the suggestion by @gshiroma

* s1_annotation.py - Pylinted to be more conform to PEP8

* annotation objects are attributes of `Sentinel1BurstSlc`

* s1_annotation.py : Classes for Burst-wide information

* s1_reader.py - annotation information are stored in each Sentinel1BurstSlc instances

* fix on `s1_annotation.parse_polynomial_element()` to read `azimuthFmRatePolynomial` in older format.

* Adding features for applying beta0

* s1_reader.py - differentiating the polynomial parsing scheme based on exception handling

* thermal noise LUT for IPF lower than 2.90

* Update src/s1reader/s1_reader.py - comment from Liang

Co-authored-by: Liang Yu <[email protected]>

* Fix on edits committed on another branch

* removing placeholder

Co-authored-by: Liang Yu <[email protected]>

* get_ipf_version - revision by @LiangJYu

Co-authored-by: Liang Yu <[email protected]>

* Update src/s1reader/s1_reader.py - remove placeholder

Co-authored-by: Liang Yu <[email protected]>

* moving the single-use variables closer to where they are used.

Co-authored-by: Liang Yu <[email protected]>

* Update src/s1reader/s1_reader.py

Co-authored-by: Liang Yu <[email protected]>

* s1_annotation.py - readibility improvement

* Update on docstring for `AnnotationBase`

Co-authored-by: Liang Yu <[email protected]>

* revision on error message

Co-authored-by: Liang Yu <[email protected]>

* Addressing comments by @LiangJYu and @vbrancat in PR #48

* s1_annotation.py - code cleanup

Co-authored-by: Liang Yu <[email protected]>

* s1_annotation.py - readability improvement

Co-authored-by: Liang Yu <[email protected]>

* readibility improvement

* changing the datatype of IPF version to version.Version. Changing the affected functions accordingly.

* space between args in _parse_list

* addressing the comments by @vbrancat

* added manifest.safe to test SAFE/zip

* updated burst ID format

* fixed directory structure in zip to match S1 SAFE spec

* Update src/s1reader/s1_annotation.py

Co-authored-by: Gustavo H. X. Shiroma <[email protected]>

* Update src/s1reader/s1_annotation.py

Co-authored-by: Gustavo H. X. Shiroma <[email protected]>

* Update src/s1reader/s1_annotation.py

Co-authored-by: Gustavo H. X. Shiroma <[email protected]>

* Update src/s1reader/s1_annotation.py

Co-authored-by: Gustavo H. X. Shiroma <[email protected]>

* s1_annotation.py - fixing the logic to add margin to azimuth noise LUT

Co-authored-by: Gustavo H. X. Shiroma <[email protected]>

* s1_reader.py - removing lines that commented out

Co-authored-by: Gustavo H. X. Shiroma <[email protected]>

* s1_reader.py - further removal of lines that commented out

Co-authored-by: Gustavo H. X. Shiroma <[email protected]>

* Addressing comments by @gshiroma and other minor fix

* Addressing codacy issues

* Taking care of codacy issues

* Fixing Codacy issue

* Fix on taking care of some old IPF version when loading AZ FM rate polynomial

* fix on readability

* fix on PEP issue

* Addressing the comment by @gshiroma

* more context and description to the AZ FM rate format change

Co-authored-by: Seongsu Jeong <[email protected]>
Co-authored-by: Liang Yu <[email protected]>
Co-authored-by: Gustavo H. X. Shiroma <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants