@@ -394,35 +394,60 @@ def test_get_projected_x_y_extents_whole_earth(self):
394
394
'grid_mapping_name' : 'lambert_azimuthal_equal_area' ,
395
395
}
396
396
)
397
- expected_output1 = {
397
+ expected_output = {
398
398
'x_min' : - 12702459.818865139 ,
399
399
'x_max' : 12702459.818865139 ,
400
400
'y_min' : - 12702440.623773243 ,
401
401
'y_max' : 12702440.710450241 ,
402
402
}
403
403
with self .subTest ('Whole Earth LAEA - Bounding box input' ):
404
- x_y_extents1 = get_projected_x_y_extents (
405
- x_values , y_values , crs , bounding_box = whole_earth_bbox
406
- )
407
- self .assertDictEqual (x_y_extents1 , expected_output1 )
408
404
self .assertDictEqual (
409
- x_y_extents1 ,
410
405
get_projected_x_y_extents (
411
406
x_values , y_values , crs , bounding_box = whole_earth_bbox
412
407
),
413
- expected_output1 ,
408
+ expected_output ,
414
409
)
415
410
416
411
with self .subTest ('Whole Earth LAEA - Shape file input' ):
417
- x_y_extents2 = get_projected_x_y_extents (
418
- x_values , y_values , crs , shape_file = polygon_path
419
- )
420
412
self .assertDictEqual (
421
- x_y_extents2 ,
422
413
get_projected_x_y_extents (
423
414
x_values , y_values , crs , shape_file = polygon_path
424
415
),
425
- expected_output1 ,
416
+ expected_output ,
417
+ )
418
+
419
+ def test_get_projected_x_y_extents_invalid_bbox (self ):
420
+ """Ensure that the an empty extent is returned when the bbox is totally
421
+ outside the granule extent.
422
+
423
+ """
424
+ bbox_outside_granule = BBox (- 180.0 , - 85.0 , 180.0 , - 75.0 )
425
+ # polygon_path = 'tests/geojson_examples/polygon_whole_earth.geo.json'
426
+
427
+ x_values = np .linspace (- 8982000 , 8982000 , 500 )
428
+ y_values = np .linspace (8982000 , - 8982000 , 500 )
429
+
430
+ crs = CRS .from_cf (
431
+ {
432
+ 'false_easting' : 0.0 ,
433
+ 'false_northing' : 0.0 ,
434
+ 'longitude_of_central_meridian' : 0.0 ,
435
+ 'latitude_of_projection_origin' : 90.0 ,
436
+ 'grid_mapping_name' : 'lambert_azimuthal_equal_area' ,
437
+ }
438
+ )
439
+ expected_output = {
440
+ 'x_min' : - 12702459.818865139 ,
441
+ 'x_max' : 12702459.818865139 ,
442
+ 'y_min' : - 12702440.623773243 ,
443
+ 'y_max' : 12702440.710450241 ,
444
+ }
445
+ with self .subTest ('Spatial area outside granule LAEA - Bounding box input' ):
446
+ self .assertDictEqual (
447
+ get_projected_x_y_extents (
448
+ x_values , y_values , crs , bounding_box = bbox_outside_granule
449
+ ),
450
+ expected_output ,
426
451
)
427
452
428
453
def test_get_projected_x_y_variables (self ):
0 commit comments