-
Notifications
You must be signed in to change notification settings - Fork 292
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2904 +/- ##
==========================================
- Coverage 96.06% 95.86% -0.20%
==========================================
Files 370 372 +2
Lines 54320 54524 +204
==========================================
+ Hits 52185 52272 +87
- Misses 2135 2252 +117
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Pull Request Test Coverage Report for Build 10908934386Warning: 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
💛 - Coveralls |
There was a problem hiding this 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.
|
||
def __init__(self, filename, filename_info, filetype_info, mda, **kwargs): | ||
"""Initialize the reader.""" | ||
super(OLITIRSCHReader, self).__init__(filename, filename_info, filetype_info) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super(OLITIRSCHReader, self).__init__(filename, filename_info, filetype_info) | |
super().__init__(filename, filename_info, filetype_info) |
You don't need this since python 3 :)
data.attrs["standard_name"] = "toa_outgoing_radiance_per_unit_wavelength" | ||
data.attrs["units"] = "W m-2 um-1 sr-1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are provided in the yaml and made available through the info parameter (in get_dataset), would be best to use these to avoid hardcoding, right?
Same goes for the two next paragraphs...
return datetime(self._obs_date.year, self._obs_date.month, self._obs_date.day, | ||
self.center_time.hour, self.center_time.minute, self.center_time.second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add timezone info?
class TestOLITIRSL1(unittest.TestCase): | ||
"""Test generic image reader.""" | ||
|
||
def setUp(self): | ||
"""Create temporary images and metadata to test on.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using pytest mostly and dropping Testcase, so I think you can do this (not tested):
class TestOLITIRSL1(unittest.TestCase): | |
"""Test generic image reader.""" | |
def setUp(self): | |
"""Create temporary images and metadata to test on.""" | |
class TestOLITIRSL1: | |
"""Test generic image reader.""" | |
def setup_method(self): | |
"""Create temporary images and metadata to test on.""" |
"start_time": self.date}) | ||
|
||
# Temp dir for the saved images | ||
self.base_dir = tempfile.mkdtemp() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pytest's tmp_path
is the way to go (gets cleaned up automatically also).
Also we usually have fixtures for test/synthetic files.
There was a problem hiding this comment.
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_path
though.
assert scn.start_time == datetime(2024, 5, 2, 18, 0, 24) | ||
assert scn.end_time == datetime(2024, 5, 2, 18, 0, 24) | ||
|
||
def test_loading(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you split up this test and others to really have one test case per function?
For temporary files, I used pytest fixtures in the modis reader. Here, you could have something similar to:
Then, to use it in a test:
(where 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. |
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 |
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.