19
19
20
20
import logging
21
21
import os
22
+ import warnings
22
23
23
24
from satpy .composites import IncompatibleAreas
24
25
from satpy .composites .config_loader import CompositorLoader
@@ -221,7 +222,7 @@ def key_func(ds):
221
222
# find the highest/lowest area among the provided
222
223
return compare_func (areas , key = key_func )
223
224
224
- def max_area (self , datasets = None ):
225
+ def finest_area (self , datasets = None ):
225
226
"""Get highest resolution area for the provided datasets.
226
227
227
228
Args:
@@ -233,7 +234,21 @@ def max_area(self, datasets=None):
233
234
"""
234
235
return self ._compare_areas (datasets = datasets , compare_func = max )
235
236
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 ):
237
252
"""Get lowest resolution area for the provided datasets.
238
253
239
254
Args:
@@ -245,6 +260,20 @@ def min_area(self, datasets=None):
245
260
"""
246
261
return self ._compare_areas (datasets = datasets , compare_func = min )
247
262
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
+
248
277
def available_dataset_ids (self , reader_name = None , composites = False ):
249
278
"""Get DataIDs of loadable datasets.
250
279
@@ -552,11 +581,11 @@ def crop(self, area=None, ll_bbox=None, xy_bbox=None, dataset_ids=None):
552
581
553
582
# get the lowest resolution area, use it as the base of the slice
554
583
# 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 ()
556
585
if isinstance (area , str ):
557
586
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 )
560
589
new_target_areas = {}
561
590
for src_area , dataset_ids in new_scn .iter_by_area ():
562
591
if src_area is None :
@@ -565,9 +594,9 @@ def crop(self, area=None, ll_bbox=None, xy_bbox=None, dataset_ids=None):
565
594
continue
566
595
567
596
y_factor , y_remainder = np .divmod (float (src_area .shape [0 ]),
568
- min_area .shape [0 ])
597
+ coarsest_area .shape [0 ])
569
598
x_factor , x_remainder = np .divmod (float (src_area .shape [1 ]),
570
- min_area .shape [1 ])
599
+ coarsest_area .shape [1 ])
571
600
y_factor = int (y_factor )
572
601
x_factor = int (x_factor )
573
602
if y_remainder == 0 and x_remainder == 0 :
@@ -684,8 +713,8 @@ def _resampled_scene(self, new_scn, destination_area, reduce_data=True,
684
713
destination_area = get_area_def (destination_area )
685
714
if hasattr (destination_area , 'freeze' ):
686
715
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 )
689
718
except ValueError :
690
719
raise ValueError ("No dataset areas available to freeze "
691
720
"DynamicAreaDefinition." )
@@ -755,7 +784,7 @@ def resample(self, destination=None, datasets=None, generate=True,
755
784
Args:
756
785
destination (AreaDefinition, GridDefinition): area definition to
757
786
resample to. If not specified then the area returned by
758
- `Scene.max_area ()` will be used.
787
+ `Scene.finest_area ()` will be used.
759
788
datasets (list): Limit datasets to resample to these specified
760
789
data arrays. By default all currently loaded
761
790
datasets are resampled.
@@ -780,7 +809,7 @@ def resample(self, destination=None, datasets=None, generate=True,
780
809
if (not datasets ) or dsid in datasets ]
781
810
782
811
if destination is None :
783
- destination = self .max_area (to_resample_ids )
812
+ destination = self .finest_area (to_resample_ids )
784
813
new_scn = self .copy (datasets = to_resample_ids )
785
814
# we may have some datasets we asked for but don't exist yet
786
815
new_scn ._wishlist = self ._wishlist .copy ()
0 commit comments