-
Notifications
You must be signed in to change notification settings - Fork 11
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: mosaic nan #323
base: main
Are you sure you want to change the base?
fix: mosaic nan #323
Conversation
@@ -76,91 +76,91 @@ def _check_config_globals( | |||
bounds_by (str) |
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.
Only formatting changse
@@ -191,6 +191,11 @@ def mask_nodata(self) -> xr.DataArray: | |||
``xarray.DataArray`` | |||
""" | |||
nodata_value = self._obj.gw.nodataval | |||
|
|||
if np.isnan(nodata_value): |
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.
skip replacing nodata with nan if already nodata is already nan
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 could be dropped but might speed up things
added test.py by accident
srtm30m_bounding_boxes = str(p / "srtm30m_bounding_boxes.gpkg") | ||
wrs2 = str(p / "wrs2.tar.gz") | ||
|
||
l8_224077_20200518_B2_nan = str(p / "l8_224077_20200518_B2_nan.tif") |
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.
added version with nan for missing data values
), | ||
) | ||
) | ||
|
||
def test_mosaic_max_nan(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.
added tests specific to union and nan
@jgrss I have resolved the problems with mosaicing - but I am getting a new error with h5netcdf tests, I tried pining h5netcdf versions 1.1 and 1.2 but that didn't resolve it. Just wondering if you have any thoughts here. On reading and writing its thowing: ======================================================================
FAIL: test_to_netcdf (tests.test_write.TestWrite.test_to_netcdf)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/work/geowombat/geowombat/tests/test_write.py", line 29, in test_to_netcdf
.gw.to_netcdf(filename=out_path, overwrite=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/geowombat/core/geoxarray.py", line 731, in to_netcdf
to_netcdf(self._obj, filename, *args, **kwargs)
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/geowombat/core/io.py", line 663, in to_netcdf
ds.to_netcdf(
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/xarray/core/dataset.py", line 2327, in to_netcdf
return to_netcdf( # type: ignore # mypy cannot resolve the overloads:(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/xarray/backends/api.py", line 1337, in to_netcdf
dump_to_store(
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/xarray/backends/api.py", line 1384, in dump_to_store
store.store(variables, attrs, check_encoding, writer, unlimited_dims=unlimited_dims)
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/xarray/backends/common.py", line 366, in store
self.set_dimensions(variables, unlimited_dims=unlimited_dims)
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/xarray/backends/common.py", line 443, in set_dimensions
self.set_dimension(dim, length, is_unlimited)
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/xarray/backends/h5netcdf_.py", line 260, in set_dimension
self.ds.dimensions[name] = length
~~~~~~~~~~~~~~~~~~^^^^^^
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/h5netcdf/dimensions.py", line 29, in __setitem__
self._objects[name] = Dimension(self._group, name, size, create_h5ds=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/h5netcdf/dimensions.py", line 91, in __init__
self._create_scale()
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/h5netcdf/dimensions.py", line 211, in _create_scale
if not self._root._h5py.h5ds.is_scale(self._h5ds.id):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5ds.pyx", line 35, in h5py.h5ds.is_scale
File "h5py/defs.pyx", line 4505, in h5py.defs.H5DSis_scale
RuntimeError: Unspecified error in H5DSis_scale (return value <0) |
@@ -513,6 +513,18 @@ def __init__( | |||
w = src.block_window(1, 0, 0) | |||
kwargs["chunks"] = (band_chunks, w.height, w.width) | |||
|
|||
# kw = { |
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.
I would like to send a note to the user if they have config updates when using mosaic or stacking multiple images - since updates to res, etc don't get used since open_warp isn't called -
However when _check_config_globals
is run its breaking all the tests and I am not sure why.
@jgrss This is ready to merge. |
@jgrss I am happy to report I finally figured out how to update the ml scikit-learn to the newest version! Can you take a look through? |
I'll take a look (after a long delay). |
What is this PR changing?
This resolves issues with nan's in arrays during mosaics.
Closes #322
Checklist
Tag options:
Example: