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

Fix of nodata, fill value, mask and data type propagation in EOdal #78

Merged
merged 33 commits into from
Oct 18, 2023

Conversation

lukasValentin
Copy link
Collaborator

This PR addresses #77 that shed some light on masking issues in EOdal. In particular, the mask of the Sentinel-2 Scene Classification layer was not propagated correctly. While debugging this issue, I found some general problems with the propagation of data types, fill and nodata values caused by inconsistencies in the code and poor type checking.

The major fixes include:

  • a fill value is now explicitly set to each np.ma.masked_array. If not (previous behavior) numpy would interfere a fill value that would often not be the no-data type of the raster. In the forthcoming release of EOdal, the fill-value will now equal the nodata value.
  • the inference of the highest data type in a RasterCollection has been improved and extended to all INT, FLOAT, and COMPLEX data types currently supported by numpy. In the previous version, all data types were cast to numpy.float32 or even numpy.float64 leading to an unnecessary high consumption of memory.
  • the scale and offset parameters are now correctly written to the file metadata when exporting a Band or RasterCollection object. In previous versions of EOdal, the information about this two attributes was not written to output. Also, the way scale and offset are applied, is now consistent with QGIS meaning that raster files created by EOdal will be shown with correct scale and offset in QGIS (QGIS applies them on the fly when displaying the raster data)

In addition, a new feature was implemented allowing to create cloud-optimized GeoTiffs (COG) from RasterCollection objects. A new keyword-argument as_cog has been added to RasterCollection.to_rasterio. as_cog is False by default. If True, a COG will be generated.

The previous dtype checking function did not work well and missed a lot
of edge cases. Now, it should work with all `int`, `uint`, `float` and
`complex` data types
@lukasValentin lukasValentin added this to the v0.2.3 milestone Oct 16, 2023
@lukasValentin lukasValentin self-assigned this Oct 16, 2023
a TypeError will be raised if the data type of the band data is
incompatible with the data type of the no-data value (e.g., nan is used
for an integer array).
@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Merging #78 (63f9092) into master (239fa0d) will increase coverage by 0.12%.
The diff coverage is 66.26%.

@@            Coverage Diff             @@
##           master      #78      +/-   ##
==========================================
+ Coverage   56.81%   56.94%   +0.12%     
==========================================
  Files          67       68       +1     
  Lines        5220     5265      +45     
  Branches     1047     1059      +12     
==========================================
+ Hits         2966     2998      +32     
- Misses       1957     1960       +3     
- Partials      297      307      +10     
Flag Coverage Δ
unittests 56.94% <66.26%> (+0.12%) ⬆️

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

Files Coverage Δ
eodal/__meta__.py 100.00% <100.00%> (ø)
eodal/core/algorithms.py 67.07% <100.00%> (+1.68%) ⬆️
eodal/core/band.py 75.62% <100.00%> (+0.89%) ⬆️
eodal/core/sensors/sentinel2.py 61.72% <85.71%> (-0.26%) ⬇️
eodal/mapper/mapper.py 75.24% <50.00%> (-0.25%) ⬇️
eodal/core/utils/__init__.py 77.77% <77.77%> (ø)
eodal/utils/geometry.py 79.31% <0.00%> (-2.84%) ⬇️
eodal/core/raster.py 73.16% <38.88%> (-2.20%) ⬇️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@lukasValentin lukasValentin merged commit f0bb31f into EOA-team:master Oct 18, 2023
5 checks passed
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.

1 participant