def test_inconsistent_input_shapes(self, src_geom, match, call_precompute, area_def_stere_target, data_2d_float32_xarray_dask): """Test that geometry and data of the same size but different size still error.""" # transpose the source geometries if isinstance(src_geom, AreaDefinition): src_geom = AreaDefinition( src_geom.area_id, src_geom.description, src_geom.proj_id, src_geom.crs, src_geom.height, src_geom.width, src_geom.area_extent, ) else: src_geom = SwathDefinition( src_geom.lons.T.rename({ 'y': 'x', 'x': 'y' }), src_geom.lats.T.rename({ 'y': 'x', 'x': 'y' }), ) resampler = KDTreeNearestXarrayResampler(src_geom, area_def_stere_target) with pytest.raises(ValueError, match=match): if call_precompute: resampler.precompute( mask=data_2d_float32_xarray_dask.notnull()) else: resampler.resample(data_2d_float32_xarray_dask)
def area_def_lcc_conus_1km(): """Create an AreaDefinition with an LCC projection over CONUS (1500, 2000).""" proj_str = "+proj=lcc +lon_0=-95 +lat_1=35.0 +lat_2=35.0 +datum=WGS84 +no_defs" crs = CRS.from_string(proj_str) area_def = AreaDefinition("area_def_lcc_conus", "", "", crs, SRC_AREA_SHAPE[1], SRC_AREA_SHAPE[0], (-750000, -750000, 750000, 750000)) return area_def
def area_def_lonlat_pm180_target(): """Create an AreaDefinition with a geographic lon/lat projection with prime meridian at 180 (800, 850).""" return AreaDefinition('lonlat_pm180', '', '', { 'proj': 'longlat', 'pm': '180.0', 'datum': 'WGS84', 'no_defs': None, }, DST_AREA_SHAPE[1], DST_AREA_SHAPE[0], [-20.0, 20.0, 20.0, 35.0])
def area_def_stere_target(): """Create an AreaDefinition with a polar-stereographic projection (800, 850).""" return AreaDefinition( 'areaD', 'Europe (3km, HRV, VTC)', 'areaD', { 'a': '6378144.0', 'b': '6356759.0', 'lat_0': '50.00', 'lat_ts': '50.00', 'lon_0': '8.00', 'proj': 'stere' }, DST_AREA_SHAPE[1], DST_AREA_SHAPE[0], [-1370912.72, -909968.64000000001, 1029087.28, 1490031.3600000001])
def area_def_stere_source(): """Create an AreaDefinition with a polar-stereographic projection (10, 50). This area is the same shape as input swath definitions. """ return AreaDefinition( 'areaD', 'Europe (3km, HRV, VTC)', 'areaD', { 'a': '6378144.0', 'b': '6356759.0', 'lat_0': '52.00', 'lat_ts': '52.00', 'lon_0': '5.00', 'proj': 'stere' }, SRC_AREA_SHAPE[1], SRC_AREA_SHAPE[0], [-1370912.72, -909968.64000000001, 1029087.28, 1490031.3600000001])