Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
def swath_def_2d_numpy_antimeridian():
    """Create a SwathDefinition with numpy arrays (200, 1500) over the antimeridian.

    Longitude values go from positive values to negative values as they cross -180/180.

    """
    lons, lats = _antimeridian_lonlats()
    return SwathDefinition(lons, lats)
Exemplo n.º 3
0
def swath_def_1d_xarray_dask():
    """Create a 1D SwathDefinition of DataArrays(dask) (3,)."""
    chunks = 5
    tlons_1d = xr.DataArray(
        da.from_array(np.array([11.280789, 12.649354, 12.080402]), chunks=chunks),
        dims=('my_dim1',))
    tlats_1d = xr.DataArray(
        da.from_array(np.array([56.011037, 55.629675, 55.641535]), chunks=chunks),
        dims=('my_dim1',))
    return SwathDefinition(lons=tlons_1d, lats=tlats_1d)
Exemplo n.º 4
0
def swath_def_2d_xarray_dask_antimeridian():
    """Create a SwathDefinition with DataArrays(dask) arrays (200, 1500) over the antimeridian.

    Longitude values go from positive values to negative values as they cross -180/180.

    """
    lons, lats = _antimeridian_lonlats()
    lons = xr.DataArray(lons, dims=("y", "x"))
    lats = xr.DataArray(lats, dims=("y", "x"))
    return SwathDefinition(lons, lats)
Exemplo n.º 5
0
 def test_mismatch_geo_data_dims_swath(self, swath_def_2d_xarray_dask,
                                       area_def_stere_target,
                                       data_2d_float32_xarray_dask):
     new_swath_def = SwathDefinition(
         swath_def_2d_xarray_dask.lons.rename({
             'y': 'my_dim_y',
             'x': 'my_dim_x'
         }),
         swath_def_2d_xarray_dask.lats.rename({
             'y': 'my_dim_y',
             'x': 'my_dim_x'
         }))
     resampler = KDTreeNearestXarrayResampler(new_swath_def,
                                              area_def_stere_target)
     with pytest.raises(ValueError, match='.*dimensions do not match.*'):
         resampler.resample(data_2d_float32_xarray_dask)
Exemplo n.º 6
0
def swath_def_2d_xarray_dask():
    """Create a SwathDefinition with DataArrays(dask) (200, 1500)."""
    lons, lats = _euro_lonlats_dask()
    lons = xr.DataArray(lons, dims=("y", "x"))
    lats = xr.DataArray(lats, dims=("y", "x"))
    return SwathDefinition(lons, lats)
Exemplo n.º 7
0
def swath_def_2d_dask():
    """Create a SwathDefinition with dask arrays (200, 1500)."""
    lons, lats = _euro_lonlats_dask()
    return SwathDefinition(lons, lats)
Exemplo n.º 8
0
def swath_def_2d_numpy():
    """Create a SwathDefinition with numpy arrays (200, 1500)."""
    lons, lats = _euro_lonlats()
    return SwathDefinition(lons, lats)