Skip to content

Commit

Permalink
Remove long deprecated numpy resampling cache helper
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Oct 23, 2023
1 parent dc3ee7d commit 59c8b94
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions satpy/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,41 +436,10 @@ def _apply_cached_index(self, val, idx_name, persist=False):
setattr(self.resampler, idx_name, val)
return val

def _check_numpy_cache(self, cache_dir, mask=None,
**kwargs):
"""Check if there's Numpy cache file and convert it to zarr."""
if cache_dir is None:
return
fname_np = self._create_cache_filename(cache_dir,
prefix='resample_lut-',
mask=mask, fmt='.npz',
**kwargs)
fname_zarr = self._create_cache_filename(cache_dir, prefix='nn_lut-',
mask=mask, fmt='.zarr',
**kwargs)
LOG.debug("Check if %s exists", fname_np)
if os.path.exists(fname_np) and not os.path.exists(fname_zarr):
import warnings
warnings.warn(
"Using Numpy files as resampling cache is deprecated.",
stacklevel=3
)
LOG.warning("Converting resampling LUT from .npz to .zarr")
zarr_out = xr.Dataset()
with np.load(fname_np, 'r') as fid:
for idx_name, coord in NN_COORDINATES.items():
zarr_out[idx_name] = (coord, fid[idx_name])

# Write indices to Zarr file
zarr_out.to_zarr(fname_zarr)
LOG.debug("Resampling LUT saved to %s", fname_zarr)

def load_neighbour_info(self, cache_dir, mask=None, **kwargs):
"""Read index arrays from either the in-memory or disk cache."""
mask_name = getattr(mask, 'name', None)
cached = {}
self._check_numpy_cache(cache_dir, mask=mask_name, **kwargs)

for idx_name in NN_COORDINATES:
if mask_name in self._index_caches:
cached[idx_name] = self._apply_cached_index(
Expand Down

0 comments on commit 59c8b94

Please sign in to comment.