opendatacube / eo-datasets

Easily write, validate and convert EO datasets and metadata.
Apache License 2.0
49 stars 26 forks source link

Use existing nodata attributes if they exist on `xarray.DataArrays` #330

Closed robbibt closed 5 months ago

robbibt commented 5 months ago

Currently the write_measurements_odc_xarray() method requires you to set a single data value to all xr.DataArrays in the input xr.Dataset. However, individual variables in a dataset often have their own nodata values, as specified in their ODC .nodata attribute.

This PR updates write_measurements_odc_xarray() to use the nodata value in the .nodata attribute if it exists (and if no custom nodata value is manually provided via the nodata param).

Have tested this locally and it works well.

codecov[bot] commented 5 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (385071f) 84.39% compared to head (1e08f3d) 84.37%.

Files Patch % Lines
eodatasets3/assemble.py 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #330 +/- ## =========================================== - Coverage 84.39% 84.37% -0.02% =========================================== Files 26 26 Lines 4504 4505 +1 =========================================== Hits 3801 3801 - Misses 703 704 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jeremyh commented 5 months ago

Thanks Robbi