-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
i.landsat.acca: add test cases #5270
base: main
Are you sure you want to change the base?
Conversation
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.
Please also test the actual values (e.g. through assertRasterFitsUnivar)
self.runModule( | ||
"r.mapcalc", | ||
expression=f"{self.output_cloud} = if({self.output_cloud} > 0, 1, 0)", | ||
overwrite=True, | ||
) |
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.
What is the purpose of this?
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.
This is done to follow the standard Landsat approach where 1 means clouds and 0 means clear areas. It is used to turn the cloud layer into a simple binary map. If a pixel has a value greater than 0 (meaning it’s likely a cloud), it’s set to 1. If it’s 0 (no cloud), it stays 0. It also ensures that later calculations, like those using assertRasterFitsUnivar, match the expected values—such as a maximum of 1 and a sum of 2401. Without this step, the sum could be like 10,000
0, | ||
"Cloud detection should identify at least some cloud pixels", | ||
) | ||
if np.sum(cloud_array) > 0 and np.sum(cloud_array) < np.size(cloud_array): |
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.
Why this if?
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.
The condition if np.sum(cloud_array) > 0 and np.sum(cloud_array) < np.size(cloud_array): is used to confirm that cloud detection is neither completely empty nor marking everything as a cloud. If the sum was 0, it would indicate that no clouds were detected. If the sum equals the total number of pixels, it would mean the entire area is classified as a cloud
cloud_array = array.array(cloud_output) | ||
self.assertGreater( | ||
np.sum(cloud_array), | ||
0, | ||
"Cloud detection should identify at least some cloud pixels", | ||
) |
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.
This is pretty much testing the same thing as in the first test
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.
This one specifically focuses on verifying the correlation between cloud pixels and thermal band values. The goal is to confirm that detected clouds align with expected thermal characteristics, beyond just checking if cloud pixels are detected.
This PR introduces a test suite for the i.landsat.acca GRASS GIS module, covering a range of scenarios, including cloud mask creation, cloud shadow detection, and the effect of different input parameters on cloud identification. The test cases ensure correct functionality across scenarios like thermal correlation, binary output validation, and the impact of the b45ratio threshold.
Key updates in this PR include:
Functionality: Validate cloud mask creation using i.landsat.acca and ensure proper cloud detection.
Edge Cases: Test cloud shadow detection and the impact of the b45ratio parameter on cloud detection.
Cloud Mask Validations: Ensure the cloud mask is binary (with only two unique values) and accurately represents cloud and non-cloud pixels, while validating that cloud pixels have higher thermal values than non-cloud pixels.
Test Case Additions:
Basic Functionality:
Edge Cases:
Cloud Shadow Detection: Test cloud shadow detection by ensure that shadow pixels are
detected, and the output is valid.
b45ratio Parameter Effect: Test the impact of the b45ratio parameter on cloud detection by adjusting it. Ensure that a higher b45ratio threshold results in fewer detected cloud pixels, indicating a more conservative approach to cloud identification.
Cloud and Thermal Correlation Validation: