Skip to content

Commit 3a78a62

Browse files
authored
Merge 94c2b14 into d556c80
2 parents d556c80 + 94c2b14 commit 3a78a62

File tree

4 files changed

+49
-20
lines changed

4 files changed

+49
-20
lines changed

satpy/resample.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@
7272
>>> new_scn = scn.resample(resampler='native')
7373
7474
By default this resamples to the
75-
:meth:`highest resolution area <satpy.scene.Scene.max_area>` (smallest footprint per
76-
pixel) shared between the loaded datasets. You can easily specify the lower
75+
:meth:`highest resolution area <satpy.scene.Scene.finest_area>` (smallest footprint per
76+
pixel) shared between the loaded datasets. You can easily specify the lowest
7777
resolution area:
7878
7979
.. code-block:: python
8080
81-
>>> new_scn = scn.resample(scn.min_area(), resampler='native')
81+
>>> new_scn = scn.resample(scn.coarsest_area(), resampler='native')
8282
8383
Providing an area that is neither the minimum or maximum resolution area
8484
may work, but behavior is currently undefined.

satpy/scene.py

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import logging
2121
import os
22+
import warnings
2223

2324
from satpy.composites import IncompatibleAreas
2425
from satpy.composites.config_loader import CompositorLoader
@@ -221,7 +222,7 @@ def key_func(ds):
221222
# find the highest/lowest area among the provided
222223
return compare_func(areas, key=key_func)
223224

224-
def max_area(self, datasets=None):
225+
def finest_area(self, datasets=None):
225226
"""Get highest resolution area for the provided datasets.
226227
227228
Args:
@@ -233,7 +234,21 @@ def max_area(self, datasets=None):
233234
"""
234235
return self._compare_areas(datasets=datasets, compare_func=max)
235236

236-
def min_area(self, datasets=None):
237+
def max_area(self, datasets=None):
238+
"""Get highest resolution area for the provided datasets. Deprecated.
239+
240+
Args:
241+
datasets (iterable): Datasets whose areas will be compared. Can
242+
be either `xarray.DataArray` objects or
243+
identifiers to get the DataArrays from the
244+
current Scene. Defaults to all datasets.
245+
246+
"""
247+
warnings.warn("'max_area' is deprecated, use 'finest_area' instead.",
248+
warnings.DeprecationWarning)
249+
return self.finest_area(datasets=datasets)
250+
251+
def coarsest_area(self, datasets=None):
237252
"""Get lowest resolution area for the provided datasets.
238253
239254
Args:
@@ -245,6 +260,20 @@ def min_area(self, datasets=None):
245260
"""
246261
return self._compare_areas(datasets=datasets, compare_func=min)
247262

263+
def min_area(self, datasets=None):
264+
"""Get lowest resolution area for the provided datasets. Deprecated.
265+
266+
Args:
267+
datasets (iterable): Datasets whose areas will be compared. Can
268+
be either `xarray.DataArray` objects or
269+
identifiers to get the DataArrays from the
270+
current Scene. Defaults to all datasets.
271+
272+
"""
273+
warnings.warn("'min_area' is deprecated, use 'coarsest_area' instead.",
274+
warnings.DeprecationWarning)
275+
return self.coarsest_area(datasets=datasets)
276+
248277
def available_dataset_ids(self, reader_name=None, composites=False):
249278
"""Get DataIDs of loadable datasets.
250279
@@ -552,11 +581,11 @@ def crop(self, area=None, ll_bbox=None, xy_bbox=None, dataset_ids=None):
552581

553582
# get the lowest resolution area, use it as the base of the slice
554583
# this makes sure that the other areas *should* be a consistent factor
555-
min_area = new_scn.min_area()
584+
coarsest_area = new_scn.coarsest_area()
556585
if isinstance(area, str):
557586
area = get_area_def(area)
558-
new_min_area, min_y_slice, min_x_slice = self._slice_area_from_bbox(
559-
min_area, area, ll_bbox, xy_bbox)
587+
new_coarsest_area, min_y_slice, min_x_slice = self._slice_area_from_bbox(
588+
coarsest_area, area, ll_bbox, xy_bbox)
560589
new_target_areas = {}
561590
for src_area, dataset_ids in new_scn.iter_by_area():
562591
if src_area is None:
@@ -565,9 +594,9 @@ def crop(self, area=None, ll_bbox=None, xy_bbox=None, dataset_ids=None):
565594
continue
566595

567596
y_factor, y_remainder = np.divmod(float(src_area.shape[0]),
568-
min_area.shape[0])
597+
coarsest_area.shape[0])
569598
x_factor, x_remainder = np.divmod(float(src_area.shape[1]),
570-
min_area.shape[1])
599+
coarsest_area.shape[1])
571600
y_factor = int(y_factor)
572601
x_factor = int(x_factor)
573602
if y_remainder == 0 and x_remainder == 0:
@@ -684,8 +713,8 @@ def _resampled_scene(self, new_scn, destination_area, reduce_data=True,
684713
destination_area = get_area_def(destination_area)
685714
if hasattr(destination_area, 'freeze'):
686715
try:
687-
max_area = new_scn.max_area()
688-
destination_area = destination_area.freeze(max_area)
716+
finest_area = new_scn.finest_area()
717+
destination_area = destination_area.freeze(finest_area)
689718
except ValueError:
690719
raise ValueError("No dataset areas available to freeze "
691720
"DynamicAreaDefinition.")
@@ -755,7 +784,7 @@ def resample(self, destination=None, datasets=None, generate=True,
755784
Args:
756785
destination (AreaDefinition, GridDefinition): area definition to
757786
resample to. If not specified then the area returned by
758-
`Scene.max_area()` will be used.
787+
`Scene.finest_area()` will be used.
759788
datasets (list): Limit datasets to resample to these specified
760789
data arrays. By default all currently loaded
761790
datasets are resampled.
@@ -780,7 +809,7 @@ def resample(self, destination=None, datasets=None, generate=True,
780809
if (not datasets) or dsid in datasets]
781810

782811
if destination is None:
783-
destination = self.max_area(to_resample_ids)
812+
destination = self.finest_area(to_resample_ids)
784813
new_scn = self.copy(datasets=to_resample_ids)
785814
# we may have some datasets we asked for but don't exist yet
786815
new_scn._wishlist = self._wishlist.copy()

satpy/tests/test_regressions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def test_1258(fake_open_dataset):
179179

180180
scene = Scene(abi_file_list, reader='abi_l1b')
181181
scene.load(['true_color_nocorr', 'C04'], calibration='radiance')
182-
resampled_scene = scene.resample(scene.min_area(), resampler='native')
182+
resampled_scene = scene.resample(scene.coarsest_area(), resampler='native')
183183
assert len(resampled_scene.keys()) == 2
184184

185185

satpy/tests/test_scene.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ def test_delitem(self):
575575
self.assertEqual(len(scene._datasets.keys()), 0)
576576
self.assertRaises(KeyError, scene.__delitem__, 0.2)
577577

578-
def test_min_max_area(self):
579-
"""Test 'min_area' and 'max_area' methods."""
578+
def test_coarsest_finest_area(self):
579+
"""Test 'coarsest_area' and 'finest_area' methods."""
580580
from satpy import Scene
581581
from xarray import DataArray
582582
from pyresample.geometry import AreaDefinition
@@ -612,9 +612,9 @@ def test_min_max_area(self):
612612
ds1.attrs['area'] = area_def1
613613
ds2.attrs['area'] = area_def2
614614
ds3.attrs['area'] = area_def2
615-
self.assertIs(scene.min_area(), area_def1)
616-
self.assertIs(scene.max_area(), area_def2)
617-
self.assertIs(scene.min_area(['2', '3']), area_def2)
615+
self.assertIs(scene.coarsest_area(), area_def1)
616+
self.assertIs(scene.finest_area(), area_def2)
617+
self.assertIs(scene.coarsest_area(['2', '3']), area_def2)
618618

619619
def test_all_datasets_no_readers(self):
620620
"""Test all datasets with no reader."""

0 commit comments

Comments
 (0)