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 freezing of areas before resampling even as strings #348

Merged
merged 2 commits into from
Jul 1, 2018
Merged
Show file tree
Hide file tree
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
14 changes: 0 additions & 14 deletions satpy/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
import xarray as xr
import dask
import dask.array as da
import six

from pyresample.bilinear import get_bil_info, get_sample_from_bil_info
from pyresample.ewa import fornav, ll2cr
Expand Down Expand Up @@ -181,19 +180,6 @@ def get_area_def(area_name):
return parse_area_file(get_area_file(), area_name)[0]


def get_frozen_area(to_freeze, ref):
"""Freeze the *to_freeze* area according to *ref* if applicable, otherwise
return *to_freeze* as an area definition instance.
"""
if isinstance(to_freeze, (str, six.text_type)):
to_freeze = get_area_def(to_freeze)

try:
return to_freeze.freeze(ref)
except AttributeError:
return to_freeze


class BaseResampler(object):
"""Base abstract resampler class."""

Expand Down
9 changes: 6 additions & 3 deletions satpy/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@
replace_anc)
from satpy.node import DependencyTree
from satpy.readers import DatasetDict, load_readers
from satpy.resample import (resample_dataset, get_frozen_area,
prepare_resampler)
from satpy.resample import (resample_dataset,
prepare_resampler, get_area_def)
from satpy.writers import load_writer
from pyresample.geometry import AreaDefinition
from xarray import DataArray
import six

try:
import configparser
Expand Down Expand Up @@ -866,13 +867,15 @@ def _resampled_scene(self, new_scn, destination_area, **resample_kwargs):
new_datasets = {}
datasets = list(new_scn.datasets.values())
max_area = None
if isinstance(destination_area, (str, six.text_type)):
destination_area = get_area_def(destination_area)
if hasattr(destination_area, 'freeze'):
try:
max_area = new_scn.max_area()
destination_area = destination_area.freeze(max_area)
except ValueError:
raise ValueError("No dataset areas available to freeze "
"DynamicAreaDefinition.")
destination_area = get_frozen_area(destination_area, max_area)

resamplers = {}
for dataset, parent_dataset in dataset_walker(datasets):
Expand Down