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

Add reader for Landsat L1 data #2904

Merged
merged 15 commits into from
Oct 17, 2024
Merged

Add reader for Landsat L1 data #2904

merged 15 commits into from
Oct 17, 2024

Conversation

simonrp84
Copy link
Member

@simonrp84 simonrp84 commented Sep 13, 2024

This PR adds a reader for Landsat collection 2 level 1 data. It has been tested on Landsat 8 and 9 data and doesn't yet support older satellites in the landsat series.

Right now this is a draft as I haven't added tests, but the reader itself should be fully-functional.

  • Tests added
  • Fully documented

Copy link

codecov bot commented Sep 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.11%. Comparing base (15a0800) to head (dce15c3).
Report is 148 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2904      +/-   ##
==========================================
+ Coverage   96.05%   96.11%   +0.05%     
==========================================
  Files         370      377       +7     
  Lines       54334    54931     +597     
==========================================
+ Hits        52191    52796     +605     
+ Misses       2143     2135       -8     
Flag Coverage Δ
behaviourtests 3.95% <0.00%> (-0.04%) ⬇️
unittests 96.20% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coveralls
Copy link

coveralls commented Sep 13, 2024

Pull Request Test Coverage Report for Build 11374003337

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 355 of 355 (100.0%) changed or added relevant lines in 2 files are covered.
  • 88 unchanged lines in 10 files lost coverage.
  • Overall coverage increased (+0.04%) to 96.209%

Files with Coverage Reduction New Missed Lines %
satpy/composites/config_loader.py 2 94.12%
satpy/tests/reader_tests/test_hrit_base.py 3 97.67%
satpy/readers/seadas_l2.py 3 96.97%
satpy/readers/msi_safe.py 4 98.41%
satpy/tests/reader_tests/modis_tests/_modis_fixtures.py 5 98.38%
satpy/composites/init.py 6 95.05%
satpy/readers/aapp_l1b.py 8 89.89%
satpy/readers/hdfeos_base.py 14 92.78%
satpy/utils.py 19 92.15%
satpy/readers/hrit_base.py 24 85.16%
Totals Coverage Status
Change from base Build 10814739875: 0.04%
Covered Lines: 53034
Relevant Lines: 55124

💛 - Coveralls

@simonrp84 simonrp84 marked this pull request as ready for review September 18, 2024 11:06
Copy link
Member

@mraspaud mraspaud left a comment

Choose a reason for hiding this comment

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

Nice job, I appreciate the comprehensive tests! A few suggestions inline.

satpy/readers/oli_tirs_l1_tif.py Outdated Show resolved Hide resolved
satpy/readers/oli_tirs_l1_tif.py Outdated Show resolved Hide resolved
satpy/readers/oli_tirs_l1_tif.py Outdated Show resolved Hide resolved
satpy/tests/reader_tests/test_oli_tirs_l1_tif.py Outdated Show resolved Hide resolved
"start_time": self.date})

# Temp dir for the saved images
self.base_dir = tempfile.mkdtemp()
Copy link
Member

Choose a reason for hiding this comment

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

pytest's tmp_pathis the way to go (gets cleaned up automatically also).

Also we usually have fixtures for test/synthetic files.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately I don't know how fixtures work, so will be unable to add that. I'll change tmp_paththough.

satpy/tests/reader_tests/test_oli_tirs_l1_tif.py Outdated Show resolved Hide resolved
@pdebuyl
Copy link
Contributor

pdebuyl commented Sep 25, 2024

For temporary files, I used pytest fixtures in the modis reader.

Here, you could have something similar to:

@pytest.fixture(scope="session")
def oli_tirs_l1_tif_samplefiles(tmpdir_factory) -> list[str]:
    """Create a set of OLI TIRS landsat L1 files."""
    path_1 =  str(tmpdir_factory.mktemp("oli_tirs_l1_tif").join("LC08_L1GT_026200_20240502_20240513_02_T2_MTL.xml"))
    with open(path_1, "w") as f:
      f.write(metadata_text)
    path_2 =  str(tmpdir_factory.mktemp("oli_tirs_l1_tif").join("LC08_L1GT_026200_20240502_20240513_02_T2_B4.TIF"))
    return [path_1, path_2, ...]

Then, to use it in a test:

def some_test(self, oli_tirs_l1_tif_samplefiles):
    scn = satpy.Scene(reader="oli_tirs_l1_tif", oli_tirs_l1_tif_samplefiles)

(where some_test is a member of the TestOLITIRSL1 class) will create the files on the fly.

I hope this helps to facilitate using the fixtures if you want to go that way. It is a bit annoying at first but then I found it convenient as you can write several tests that use the sample data files with really low effort.

@pdebuyl
Copy link
Contributor

pdebuyl commented Sep 25, 2024

Regarding the failing tests, the sza on disk contains nans sometimes :-/

I don't know enough about the geotiff writer to comment but this seems to be the root cause

@simonrp84
Copy link
Member Author

Regarding the failing tests, the sza on disk contains nans sometimes :-/

I don't know enough about the geotiff writer to comment but this seems to be the root cause

I think it's because the array I was generating ran from 0->10000. Have changed it locally to 1->10000 and haven't seen the error pop up again! Forgot that 0 was the fill value...

@mraspaud mraspaud added enhancement code enhancements, features, improvements component:readers labels Oct 16, 2024
Copy link
Member

@mraspaud mraspaud left a comment

Choose a reason for hiding this comment

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

LGTM

@mraspaud mraspaud merged commit 56981ff into pytroll:main Oct 17, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:readers enhancement code enhancements, features, improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants