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

Skipped atmospheric_correction integration tests #21

Open
soxofaan opened this issue Jul 19, 2024 · 2 comments
Open

Skipped atmospheric_correction integration tests #21

soxofaan opened this issue Jul 19, 2024 · 2 comments

Comments

@soxofaan
Copy link
Member

while working on #20 I noticed these two test are marked as skipped since dec 2021:

  • test_atmospheric_correction_inputsarecorrect
  • test_atmospheric_correction_defaultbehavior

@pytest.mark.skip(reason="Temporary skip to get tests through")
def test_atmospheric_correction_inputsarecorrect(auth_connection, api_version, tmp_path):
# source product is S2B_MSIL1C_20190411T105029_N0207_R051_T31UFS_20190411T130806
date = "2019-04-11"
bbox=(655000,5677000,660000,5685000)
l1c = (
auth_connection.load_collection("SENTINEL2_L1C_SENTINELHUB")
.filter_temporal(date,date)\
.filter_bbox(crs="EPSG:32631", **dict(zip(["west", "south", "east", "north"], bbox)))
)
l2a=l1c.process(
process_id="atmospheric_correction",
arguments={
"data": THIS,
# "missionId": "SENTINEL2", this is the default
"appendDebugBands" : 1
}
)
output = tmp_path / "icorvalidation_inputcheck.json"
l2a.download(output,format="json")
result=datacube_from_file(output,fmt="json").get_array()
# note that debug bands are multiplied by 100 to store meaningful values as integers
szaref=xarray.open_rasterio(get_path("icor/ref_inputcheck_SZA.tif"))
vzaref=xarray.open_rasterio(get_path("icor/ref_inputcheck_VZA.tif"))
raaref=xarray.open_rasterio(get_path("icor/ref_inputcheck_RAA.tif"))
demref=xarray.open_rasterio(get_path("icor/ref_inputcheck_DEM.tif"))
aotref=xarray.open_rasterio(get_path("icor/ref_inputcheck_AOT.tif"))
cwvref=xarray.open_rasterio(get_path("icor/ref_inputcheck_CWV.tif"))
compare_xarrays(result.loc[date][-6],szaref[0].transpose("x","y"))
compare_xarrays(result.loc[date][-5],vzaref[0].transpose("x","y"))
compare_xarrays(result.loc[date][-4],raaref[0].transpose("x","y"))
compare_xarrays(result.loc[date][-3],demref[0].transpose("x","y"))
compare_xarrays(result.loc[date][-2],aotref[0].transpose("x","y"))
compare_xarrays(result.loc[date][-1],cwvref[0].transpose("x","y"))
@pytest.mark.skip(reason="Temporary skip to get tests through")
def test_atmospheric_correction_defaultbehavior(auth_connection, api_version, tmp_path):
# source product is S2B_MSIL1C_20190411T105029_N0207_R051_T31UFS_20190411T130806
date = "2019-04-11"
bbox=(655000,5677000,660000,5685000)
l1c = (
auth_connection.load_collection("SENTINEL2_L1C_SENTINELHUB")
.filter_temporal(date,date)\
.filter_bbox(crs="EPSG:32631", **dict(zip(["west", "south", "east", "north"], bbox)))
)
l2a=l1c.process(
process_id="atmospheric_correction",
arguments={
"data": THIS,
# "missionId": "SENTINEL2", this is the default
}
)
output = tmp_path / "icorvalidation_default.json"
l2a.download(output,format="json")
result=datacube_from_file(output,fmt="json").get_array()
b2ref=xarray.open_rasterio(get_path("icor/ref_default_B02.tif"))
b3ref=xarray.open_rasterio(get_path("icor/ref_default_B03.tif"))
b4ref=xarray.open_rasterio(get_path("icor/ref_default_B04.tif"))
b8ref=xarray.open_rasterio(get_path("icor/ref_default_B08.tif"))
compare_xarrays(result.loc[date,"B02"],b2ref[0].transpose("x","y"))
compare_xarrays(result.loc[date,"B03"],b3ref[0].transpose("x","y"))
compare_xarrays(result.loc[date,"B04"],b4ref[0].transpose("x","y"))
compare_xarrays(result.loc[date,"B08"],b8ref[0].transpose("x","y"))

We should re-enable them, or remove them.
Keeping them like this in the test suite makes maintenance more annoying (e.g. they keep outdated usage patterns and buggy helpers alive)

@soxofaan
Copy link
Member Author

Re-enabling them on a local setup (python 3.11) fails due to usage of removed xarray.open_rasterio functionality:

FAILED tests/test_integration.py::test_atmospheric_correction_inputsarecorrect[1.1.0] - AttributeError: module 'xarray' has no attribute 'open_rasterio'
FAILED tests/test_integration.py::test_atmospheric_correction_defaultbehavior[1.1.0] - AttributeError: module 'xarray' has no attribute 'open_rasterio'

This would still work on jenkins, but that is basically a side-effect because we're stuck there on python 3.8 (which reaches EOL in a couple of months), which does not support newer xarray versions

Running them locally in an old python 3.9 venv fails like this for me:

________ test_atmospheric_correction_inputsarecorrect[1.1.0] ____________
...
        compare_xarrays(result.loc[date][-5],vzaref[0].transpose("x","y"))
>       compare_xarrays(result.loc[date][-4],raaref[0].transpose("x","y"))

tests/test_integration.py:1803:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_integration.py:1760: in compare_xarrays
    np.testing.assert_allclose(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = (<function assert_allclose.<locals>.compare at 0x78708aa35dc0>, array([[13300., 13300., 13300., ..., 13400., 13400., 1... [13400., 13400., 13400., ..., 13300., 13300., 13300.],
       [13400., 13400., 13400., ..., 13300., 13300., 13300.]]))
kwds = {'equal_nan': True, 'err_msg': '', 'header': 'Not equal to tolerance rtol=0, atol=1e-06', 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError:
E           Not equal to tolerance rtol=0, atol=1e-06
E
E           Mismatched elements: 300000 / 400000 (75%)
E           Max absolute difference: 100.
E           Max relative difference: 0.0075188
E            x: array([[13300., 13300., 13300., ..., 13400., 13400., 13400.],
E                  [13300., 13300., 13300., ..., 13400., 13400., 13400.],
E                  [13300., 13300., 13300., ..., 13400., 13400., 13400.],...
E            y: array([[13400., 13400., 13400., ..., 13300., 13300., 13300.],
E                  [13400., 13400., 13400., ..., 13300., 13300., 13300.],
E                  [13400., 13400., 13400., ..., 13300., 13300., 13300.],...

../../../.asdf/installs/python/3.9.15/lib/python3.9/contextlib.py:79: AssertionError



_______ test_atmospheric_correction_defaultbehavior[1.1.0] _________
...
>       compare_xarrays(result.loc[date,"B02"],b2ref[0].transpose("x","y"))

tests/test_integration.py:1835:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_integration.py:1760: in compare_xarrays
    np.testing.assert_allclose(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = (<function assert_allclose.<locals>.compare at 0x78708a7b4700>, array([[484., 373., 340., ..., 374., 395., 381.],
    ...54., 659., 754.],
       [278., 271., 269., ..., 602., 544., 765.],
       [269., 262., 284., ..., 700., 728., 674.]]))
kwds = {'equal_nan': True, 'err_msg': '', 'header': 'Not equal to tolerance rtol=0, atol=1e-06', 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError:
E           Not equal to tolerance rtol=0, atol=1e-06
E
E           x and y nan location mismatch:
E            x: array([[484., 373., 340., ..., 374., 395., 381.],
E                  [339., 367., 371., ..., 401., 394., 374.],
E                  [478., 465., 414., ..., 425., 399., 395.],...
E            y: array([[381., 395., 374., ..., 340., 373., 484.],
E                  [374., 394., 401., ..., 371., 367., 339.],
E                  [395., 399., 425., ..., 414., 465., 478.],...

../../../.asdf/installs/python/3.9.15/lib/python3.9/contextlib.py:79: AssertionError

@soxofaan
Copy link
Member Author

I already tried to modernize/fix the tests, assuming it would just take half an hour (based on #20 experience), but it turns out quite a bit more debug work. Giving up for now and parking it in this ticket

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

No branches or pull requests

1 participant