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

unit tests #38

Merged
merged 18 commits into from
Jun 2, 2022
Merged

unit tests #38

merged 18 commits into from
Jun 2, 2022

Conversation

LiangJYu
Copy link
Contributor

This PR adds unit tests to the 3 modules in s1-reader. The tests are currently very sparse and serve as a frame to build on.

Usage:

  1. checkout unit_test branch from my fork
  2. cd to tests directory
  3. in terminal call: pytest

To do:

  • test and validate more attributes

requirements.yaml Outdated Show resolved Hide resolved
@yunjunz
Copy link
Member

yunjunz commented May 16, 2022

Thank you @LiangJYu, following your note above, the test runs nicely.

How did you prepare the SAFE zip file? I notice there are measurement folder and tiff files but with 0 in size. Maybe write this in a README.md file within the tests folder?

@LiangJYu
Copy link
Contributor Author

Thank you @LiangJYu, following your note above, the test runs nicely.

How did you prepare the SAFE zip file? I notice there are measurement folder and tiff files but with 0 in size. Maybe write this in a README.md file within the tests folder?

The 0 size files were touchd with a correct name and path. I will add a README to tests folder.

add README
environment.yaml Outdated Show resolved Hide resolved
@LiangJYu
Copy link
Contributor Author

Thus far, the checks for simple attributes have been implemented. I'm unsure how to test the following more complex attributes.

orbit: Ensure all state vectors within sensing start and stop? Check if position actually above surface of the earth? Check if velocity fast enough?

poly1D: These vary with burst so the verbose method would be to store and check order, std, mean, and coeffs of each. I can't think of a cleaner way.

lut2D: Can this be skiped since this is derived from poly1d?

@hfattahi
Copy link
Contributor

@LiangJYu One test that I can think of for orbit is the following where we compute the coordinates for the middle of the burst and it should fall within the burst border.

burst = bursts[0]

from shapely.geometry import Point

# middle of the burst in radar coordinates
r0 = burst.starting_range + 0.5*burst.width*burst.range_pixel_spacing
t0 = (isce3.core.DateTime(burst.sensing_mid)-burst.orbit.reference_epoch)

dem = isce3.geometry.DEMInterpolator(0)
dop = 0.0
rdr_grid=burst.as_isce3_radargrid()
llh = isce3.geometry.rdr2geo(t0.total_seconds(), r0, burst.orbit, rdr_grid.lookside, dop, rdr_grid.wavelength, dem)
pnt = Point(np.degrees(llh[0]), np.degrees(llh[1]))
assert(burst.border[0].contains(pnt))

Even with the inaccurate orbit within the annotation file, we should be able to pass this test.

@hfattahi
Copy link
Contributor

@LiangJYu for the lut2d you can check if we are able to eval successfully compared to poly1d. For example :

np.isclose(burst.doppler.lut2d.eval(t0.total_seconds(),r0), burst.doppler.poly1d.eval(r0))

t0 and r0 can be the same middle of swath in my previous comment.

@LiangJYu LiangJYu changed the title WIP unit tests unit tests May 27, 2022
@LiangJYu
Copy link
Contributor Author

LiangJYu commented Jun 1, 2022

@hfattahi @yunjunz @vbrancat With the new tests added, I think this PR is ready for another look. Thanks!

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.

LGTM! Thanks @LiangJYu for addressing my comments.

Copy link
Member

@yunjunz yunjunz left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you @LiangJYu.

@LiangJYu LiangJYu merged commit 219ef5d into isce-framework:main Jun 2, 2022
@LiangJYu LiangJYu deleted the unit_test branch June 2, 2022 18:37
@seongsujeong
Copy link
Contributor

Hi @LiangJYu @yunjunz I am about to merge the annotation reader in PR #48. The new implementation loads IPF version from manifest.safe file in SAFE .zip file, which is currently not included in the test data. It would be great if the test data is updated with manifest.safe file included, so that the new PR can pass CircieCI.

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.

4 participants