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

Only set fill value as nan for floating point arrays #113

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions ndpyramid/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
import xarray as xr

from .common import Projection
from .utils import add_metadata_and_zarr_encoding, get_levels, get_version, multiscales_template
from .utils import (
add_metadata_and_zarr_encoding,
get_levels,
get_version,
multiscales_template,
)


def pyramid_coarsen(
Expand Down Expand Up @@ -132,7 +137,10 @@ def pyramid_reproject(
dst_transform = projection_model.transform(dim=dim)

def reproject(da, var):
da.encoding['_FillValue'] = np.nan
# Set float FillValue that rasterio will use to initialize array
if da.encoding.get('_FillValue') is None and np.issubdtype(da.dtype, np.floating):
da.encoding['_FillValue'] = np.nan

da = da.rio.reproject(
projection_model._crs,
resampling=Resampling[resampling_dict[var]],
Expand Down
Loading