bopen / sarsen

Algorithms and utilities for Synthetic Aperture Radar (SAR) sensors
Apache License 2.0
271 stars 26 forks source link

Incompatibility with xarray 2023.08 #54

Closed avalentino closed 1 year ago

avalentino commented 1 year ago

The current main have several unittest failures with xarray v2023.08:

$ python3 -m pytest
================================================================== test session starts ==================================================================
platform linux -- Python 3.11.4, pytest-7.4.0, pluggy-1.3.0
rootdir: /home/antonio/projects/forks/sarsen
collected 30 items                                                                                                                                      

tests/test_10_chunking.py ...                                                                                                                     [ 10%]
tests/test_10_datamodel.py .                                                                                                                      [ 13%]
tests/test_10_orbit.py ..                                                                                                                         [ 20%]
tests/test_10_scene.py .FF                                                                                                                        [ 30%]
tests/test_20_geocoding.py ...                                                                                                                    [ 40%]
tests/test_20_sentinel1.py ...                                                                                                                    [ 50%]
tests/test_30_radiometry.py F                                                                                                                     [ 53%]
tests/test_50_apps.py ..FFFF..FFFF                                                                                                                [ 93%]
tests/test_60_main.py .                                                                                                                           [ 96%]
tests/test_90_sarsen.py .                                                                                                                         [100%]

======================================================================= FAILURES ========================================================================
_________________________________________________________________ test_transform_dem_3d _________________________________________________________________

dem_raster = <xarray.DataArray 'dem' (y: 360, x: 360)>
[129600 values with dtype=float32]
Coordinates:
  * x            (x) float64....05
    spatial_ref  int64 ...
Attributes:
    AREA_OR_POINT:  Area
    units:          m
    long_name:      elevation

    def test_transform_dem_3d(dem_raster: xr.DataArray) -> None:
        dem_3d = scene.convert_to_dem_3d(dem_raster)

        # from height over the geoid to height over the ellipsoid
        res = scene.transform_dem_3d(dem_3d, dem_3d.rio.crs, "EPSG:4979")

        assert res.dims == ("axis", "y", "x")
        # this assert fails if proj-data is not properly installed on the system
>       assert abs(res.sel(x=12.5, y=42, method="nearest")[2] - 65.613) < 0.001
E       AssertionError: assert <xarray.DataArray 'dem_3d' ()>\narray(48.613)\nCoordinates:\n    x            float64 12.5\n    spatial_ref  int64 0\n    y            float64 42.0\n    axis         int64 2 < 0.001
E        +  where <xarray.DataArray 'dem_3d' ()>\narray(48.613)\nCoordinates:\n    x            float64 12.5\n    spatial_ref  int64 0\n    y            float64 42.0\n    axis         int64 2 = abs((<xarray.DataArray 'dem_3d' ()>\narray(17.)\nCoordinates:\n    x            float64 12.5\n    spatial_ref  int64 0\n    y            float64 42.0\n    axis         int64 2 - 65.613))

tests/test_10_scene.py:23: AssertionError
____________________________________________________________ test_compute_dem_oriented_area _____________________________________________________________

dem_raster = <xarray.DataArray 'dem' (y: 360, x: 360)>
[129600 values with dtype=float32]
Coordinates:
  * x            (x) float64....05
    spatial_ref  int64 ...
Attributes:
    AREA_OR_POINT:  Area
    units:          m
    long_name:      elevation

    def test_compute_dem_oriented_area(dem_raster: xr.DataArray) -> None:
        dem_3d = scene.convert_to_dem_3d(dem_raster)

>       res = scene.compute_dem_oriented_area(dem_3d)

tests/test_10_scene.py:39: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sarsen/scene.py:110: in compute_dem_oriented_area
    cross_2 = xr.cross(dx2, dy2, dim="axis") / 2
venv/lib/python3.11/site-packages/xarray/core/computation.py:1609: in cross
    c = apply_ufunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:1197: in apply_ufunc
    return apply_dataarray_vfunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:288: in apply_dataarray_vfunc
    args = deep_align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:847: in deep_align
    aligned = align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:783: in align
    aligner.align()
venv/lib/python3.11/site-packages/xarray/core/alignment.py:568: in align
    self.align_indexes()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <xarray.core.alignment.Aligner object at 0x7f0bb1d69650>

    def align_indexes(self) -> None:
        """Compute all aligned indexes and their corresponding coordinate variables."""

        aligned_indexes = {}
        aligned_index_vars = {}
        reindex = {}
        new_indexes = {}
        new_index_vars = {}

        for key, matching_indexes in self.all_indexes.items():
            matching_index_vars = self.all_index_vars[key]
            dims = {d for coord in matching_index_vars[0].values() for d in coord.dims}
            index_cls = key[1]

            if self.join == "override":
                joined_index = matching_indexes[0]
                joined_index_vars = matching_index_vars[0]
                need_reindex = False
            elif key in self.indexes:
                joined_index = self.indexes[key]
                joined_index_vars = self.index_vars[key]
                cmp_indexes = list(
                    zip(
                        [joined_index] + matching_indexes,
                        [joined_index_vars] + matching_index_vars,
                    )
                )
                need_reindex = self._need_reindex(dims, cmp_indexes)
            else:
                if len(matching_indexes) > 1:
                    need_reindex = self._need_reindex(
                        dims,
                        list(zip(matching_indexes, matching_index_vars)),
                    )
                else:
                    need_reindex = False
                if need_reindex:
                    if self.join == "exact":
>                       raise ValueError(
                            "cannot align objects with join='exact' where "
                            "index/labels/sizes are not equal along "
                            "these coordinates (dimensions): "
                            + ", ".join(f"{name!r} {dims!r}" for name, dims in key[0])
                        )
E                       ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)

venv/lib/python3.11/site-packages/xarray/core/alignment.py:415: ValueError
________________________________________________________________ test_compute_gamma_area ________________________________________________________________

dem_ecef = <xarray.DataArray 'dem_3d' (axis: 3, y: 360, x: 360)>
array([[[4639035.90736075, 4639029.48935904, 4639021.61878218, .... 0
  * y            (y) float64 41.95 41.95 41.95 41.95 ... 42.05 42.05 42.05 42.05
  * axis         (axis) int64 0 1 2

    def test_compute_gamma_area(dem_ecef: xr.DataArray) -> None:
        dem_direction = xr.DataArray()
>       res = radiometry.compute_gamma_area(dem_ecef, dem_direction)

tests/test_30_radiometry.py:8: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sarsen/radiometry.py:56: in compute_gamma_area
    dem_oriented_area = scene.compute_dem_oriented_area(dem_ecef)
sarsen/scene.py:110: in compute_dem_oriented_area
    cross_2 = xr.cross(dx2, dy2, dim="axis") / 2
venv/lib/python3.11/site-packages/xarray/core/computation.py:1609: in cross
    c = apply_ufunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:1197: in apply_ufunc
    return apply_dataarray_vfunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:288: in apply_dataarray_vfunc
    args = deep_align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:847: in deep_align
    aligned = align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:783: in align
    aligner.align()
venv/lib/python3.11/site-packages/xarray/core/alignment.py:568: in align
    self.align_indexes()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <xarray.core.alignment.Aligner object at 0x7f0bb0b84750>

    def align_indexes(self) -> None:
        """Compute all aligned indexes and their corresponding coordinate variables."""

        aligned_indexes = {}
        aligned_index_vars = {}
        reindex = {}
        new_indexes = {}
        new_index_vars = {}

        for key, matching_indexes in self.all_indexes.items():
            matching_index_vars = self.all_index_vars[key]
            dims = {d for coord in matching_index_vars[0].values() for d in coord.dims}
            index_cls = key[1]

            if self.join == "override":
                joined_index = matching_indexes[0]
                joined_index_vars = matching_index_vars[0]
                need_reindex = False
            elif key in self.indexes:
                joined_index = self.indexes[key]
                joined_index_vars = self.index_vars[key]
                cmp_indexes = list(
                    zip(
                        [joined_index] + matching_indexes,
                        [joined_index_vars] + matching_index_vars,
                    )
                )
                need_reindex = self._need_reindex(dims, cmp_indexes)
            else:
                if len(matching_indexes) > 1:
                    need_reindex = self._need_reindex(
                        dims,
                        list(zip(matching_indexes, matching_index_vars)),
                    )
                else:
                    need_reindex = False
                if need_reindex:
                    if self.join == "exact":
>                       raise ValueError(
                            "cannot align objects with join='exact' where "
                            "index/labels/sizes are not equal along "
                            "these coordinates (dimensions): "
                            + ", ".join(f"{name!r} {dims!r}" for name, dims in key[0])
                        )
E                       ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)

venv/lib/python3.11/site-packages/xarray/core/alignment.py:415: ValueError
__________________________________________________ test_terrain_correction_fast_rtc[data_path0-IW/VV] ___________________________________________________

tmpdir = local('/tmp/pytest-of-antonio/pytest-3/test_terrain_correction_fast_r0')
data_path = PosixPath('/home/antonio/projects/forks/sarsen/tests/data/S1B_IW_GRDH_1SDV_20211223T051122_20211223T051147_030148_039993_5371.SAFE')
group = 'IW/VV'

    @pytest.mark.parametrize("data_path,group", zip(DATA_PATHS, GROUPS))
    @pytest.mark.skipif(os.getenv("GITHUB_ACTIONS") == "true", reason="too much memory")
    def test_terrain_correction_fast_rtc(
        tmpdir: py.path.local, data_path: pathlib.Path, group: str
    ) -> None:
        out = str(tmpdir.join("RTC.tif"))
        product = sentinel1.Sentinel1SarProduct(
            str(data_path),
            group,
        )

>       res = apps.terrain_correction(
            product,
            str(DEM_RASTER),
            correct_radiometry="gamma_nearest",
            output_urlpath=out,
        )

tests/test_50_apps.py:58: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sarsen/apps.py:166: in terrain_correction
    acquisition = acquisition.persist()
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1029: in persist
    return new._persist_inplace(**kwargs)
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1003: in _persist_inplace
    evaluated_data = dask.persist(*lazy_data.values(), **kwargs)
venv/lib/python3.11/site-packages/dask/base.py:967: in persist
    results = schedule(dsk, keys, **kwargs)
venv/lib/python3.11/site-packages/dask/threaded.py:89: in get
    results = get_async(
venv/lib/python3.11/site-packages/dask/local.py:511: in get_async
    raise_exception(exc, tb)
venv/lib/python3.11/site-packages/dask/local.py:319: in reraise
    raise exc
venv/lib/python3.11/site-packages/dask/local.py:224: in execute_task
    result = _execute_task(task, data)
venv/lib/python3.11/site-packages/dask/core.py:121: in _execute_task
    return func(*(_execute_task(a, cache) for a in args))
venv/lib/python3.11/site-packages/xarray/core/parallel.py:268: in _wrapper
    result = func(*converted_args, **kwargs)
sarsen/apps.py:36: in simulate_acquisition
    gamma_area = radiometry.compute_gamma_area(
sarsen/radiometry.py:56: in compute_gamma_area
    dem_oriented_area = scene.compute_dem_oriented_area(dem_ecef)
sarsen/scene.py:110: in compute_dem_oriented_area
    cross_2 = xr.cross(dx2, dy2, dim="axis") / 2
venv/lib/python3.11/site-packages/xarray/core/computation.py:1609: in cross
    c = apply_ufunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:1197: in apply_ufunc
    return apply_dataarray_vfunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:288: in apply_dataarray_vfunc
    args = deep_align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:847: in deep_align
    aligned = align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:783: in align
    aligner.align()
venv/lib/python3.11/site-packages/xarray/core/alignment.py:568: in align
    self.align_indexes()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <xarray.core.alignment.Aligner object at 0x7f0b8bca5690>

    def align_indexes(self) -> None:
        """Compute all aligned indexes and their corresponding coordinate variables."""

        aligned_indexes = {}
        aligned_index_vars = {}
        reindex = {}
        new_indexes = {}
        new_index_vars = {}

        for key, matching_indexes in self.all_indexes.items():
            matching_index_vars = self.all_index_vars[key]
            dims = {d for coord in matching_index_vars[0].values() for d in coord.dims}
            index_cls = key[1]

            if self.join == "override":
                joined_index = matching_indexes[0]
                joined_index_vars = matching_index_vars[0]
                need_reindex = False
            elif key in self.indexes:
                joined_index = self.indexes[key]
                joined_index_vars = self.index_vars[key]
                cmp_indexes = list(
                    zip(
                        [joined_index] + matching_indexes,
                        [joined_index_vars] + matching_index_vars,
                    )
                )
                need_reindex = self._need_reindex(dims, cmp_indexes)
            else:
                if len(matching_indexes) > 1:
                    need_reindex = self._need_reindex(
                        dims,
                        list(zip(matching_indexes, matching_index_vars)),
                    )
                else:
                    need_reindex = False
                if need_reindex:
                    if self.join == "exact":
>                       raise ValueError(
                            "cannot align objects with join='exact' where "
                            "index/labels/sizes are not equal along "
                            "these coordinates (dimensions): "
                            + ", ".join(f"{name!r} {dims!r}" for name, dims in key[0])
                        )
E                       ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)

venv/lib/python3.11/site-packages/xarray/core/alignment.py:415: ValueError
__________________________________________________ test_terrain_correction_fast_rtc[data_path1-IW1/VV] __________________________________________________

tmpdir = local('/tmp/pytest-of-antonio/pytest-3/test_terrain_correction_fast_r1')
data_path = PosixPath('/home/antonio/projects/forks/sarsen/tests/data/S1A_IW_SLC__1SDV_20220104T170557_20220104T170624_041314_04E951_F1F1.SAFE')
group = 'IW1/VV'

    @pytest.mark.parametrize("data_path,group", zip(DATA_PATHS, GROUPS))
    @pytest.mark.skipif(os.getenv("GITHUB_ACTIONS") == "true", reason="too much memory")
    def test_terrain_correction_fast_rtc(
        tmpdir: py.path.local, data_path: pathlib.Path, group: str
    ) -> None:
        out = str(tmpdir.join("RTC.tif"))
        product = sentinel1.Sentinel1SarProduct(
            str(data_path),
            group,
        )

>       res = apps.terrain_correction(
            product,
            str(DEM_RASTER),
            correct_radiometry="gamma_nearest",
            output_urlpath=out,
        )

tests/test_50_apps.py:58: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sarsen/apps.py:166: in terrain_correction
    acquisition = acquisition.persist()
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1029: in persist
    return new._persist_inplace(**kwargs)
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1003: in _persist_inplace
    evaluated_data = dask.persist(*lazy_data.values(), **kwargs)
venv/lib/python3.11/site-packages/dask/base.py:967: in persist
    results = schedule(dsk, keys, **kwargs)
venv/lib/python3.11/site-packages/dask/threaded.py:89: in get
    results = get_async(
venv/lib/python3.11/site-packages/dask/local.py:511: in get_async
    raise_exception(exc, tb)
venv/lib/python3.11/site-packages/dask/local.py:319: in reraise
    raise exc
venv/lib/python3.11/site-packages/dask/local.py:224: in execute_task
    result = _execute_task(task, data)
venv/lib/python3.11/site-packages/dask/core.py:121: in _execute_task
    return func(*(_execute_task(a, cache) for a in args))
venv/lib/python3.11/site-packages/xarray/core/parallel.py:268: in _wrapper
    result = func(*converted_args, **kwargs)
sarsen/apps.py:36: in simulate_acquisition
    gamma_area = radiometry.compute_gamma_area(
sarsen/radiometry.py:56: in compute_gamma_area
    dem_oriented_area = scene.compute_dem_oriented_area(dem_ecef)
sarsen/scene.py:110: in compute_dem_oriented_area
    cross_2 = xr.cross(dx2, dy2, dim="axis") / 2
venv/lib/python3.11/site-packages/xarray/core/computation.py:1609: in cross
    c = apply_ufunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:1197: in apply_ufunc
    return apply_dataarray_vfunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:288: in apply_dataarray_vfunc
    args = deep_align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:847: in deep_align
    aligned = align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:783: in align
    aligner.align()
venv/lib/python3.11/site-packages/xarray/core/alignment.py:568: in align
    self.align_indexes()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <xarray.core.alignment.Aligner object at 0x7f0bb05f1fd0>

    def align_indexes(self) -> None:
        """Compute all aligned indexes and their corresponding coordinate variables."""

        aligned_indexes = {}
        aligned_index_vars = {}
        reindex = {}
        new_indexes = {}
        new_index_vars = {}

        for key, matching_indexes in self.all_indexes.items():
            matching_index_vars = self.all_index_vars[key]
            dims = {d for coord in matching_index_vars[0].values() for d in coord.dims}
            index_cls = key[1]

            if self.join == "override":
                joined_index = matching_indexes[0]
                joined_index_vars = matching_index_vars[0]
                need_reindex = False
            elif key in self.indexes:
                joined_index = self.indexes[key]
                joined_index_vars = self.index_vars[key]
                cmp_indexes = list(
                    zip(
                        [joined_index] + matching_indexes,
                        [joined_index_vars] + matching_index_vars,
                    )
                )
                need_reindex = self._need_reindex(dims, cmp_indexes)
            else:
                if len(matching_indexes) > 1:
                    need_reindex = self._need_reindex(
                        dims,
                        list(zip(matching_indexes, matching_index_vars)),
                    )
                else:
                    need_reindex = False
                if need_reindex:
                    if self.join == "exact":
>                       raise ValueError(
                            "cannot align objects with join='exact' where "
                            "index/labels/sizes are not equal along "
                            "these coordinates (dimensions): "
                            + ", ".join(f"{name!r} {dims!r}" for name, dims in key[0])
                        )
E                       ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)

venv/lib/python3.11/site-packages/xarray/core/alignment.py:415: ValueError
_____________________________________________________ test_terrain_correction_rtc[data_path0-IW/VV] _____________________________________________________

tmpdir = local('/tmp/pytest-of-antonio/pytest-3/test_terrain_correction_rtc_da0')
data_path = PosixPath('/home/antonio/projects/forks/sarsen/tests/data/S1B_IW_GRDH_1SDV_20211223T051122_20211223T051147_030148_039993_5371.SAFE')
group = 'IW/VV'

    @pytest.mark.parametrize("data_path,group", zip(DATA_PATHS, GROUPS))
    @pytest.mark.skipif(os.getenv("GITHUB_ACTIONS") == "true", reason="too much memory")
    def test_terrain_correction_rtc(
        tmpdir: py.path.local, data_path: pathlib.Path, group: str
    ) -> None:
        out = str(tmpdir.join("RTC.tif"))
        product = sentinel1.Sentinel1SarProduct(
            str(data_path),
            group,
        )

>       res = apps.terrain_correction(
            product,
            str(DEM_RASTER),
            correct_radiometry="gamma_bilinear",
            output_urlpath=out,
        )

tests/test_50_apps.py:80: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sarsen/apps.py:166: in terrain_correction
    acquisition = acquisition.persist()
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1029: in persist
    return new._persist_inplace(**kwargs)
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1003: in _persist_inplace
    evaluated_data = dask.persist(*lazy_data.values(), **kwargs)
venv/lib/python3.11/site-packages/dask/base.py:967: in persist
    results = schedule(dsk, keys, **kwargs)
venv/lib/python3.11/site-packages/dask/threaded.py:89: in get
    results = get_async(
venv/lib/python3.11/site-packages/dask/local.py:511: in get_async
    raise_exception(exc, tb)
venv/lib/python3.11/site-packages/dask/local.py:319: in reraise
    raise exc
venv/lib/python3.11/site-packages/dask/local.py:224: in execute_task
    result = _execute_task(task, data)
venv/lib/python3.11/site-packages/dask/core.py:121: in _execute_task
    return func(*(_execute_task(a, cache) for a in args))
venv/lib/python3.11/site-packages/xarray/core/parallel.py:268: in _wrapper
    result = func(*converted_args, **kwargs)
sarsen/apps.py:36: in simulate_acquisition
    gamma_area = radiometry.compute_gamma_area(
sarsen/radiometry.py:56: in compute_gamma_area
    dem_oriented_area = scene.compute_dem_oriented_area(dem_ecef)
sarsen/scene.py:110: in compute_dem_oriented_area
    cross_2 = xr.cross(dx2, dy2, dim="axis") / 2
venv/lib/python3.11/site-packages/xarray/core/computation.py:1609: in cross
    c = apply_ufunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:1197: in apply_ufunc
    return apply_dataarray_vfunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:288: in apply_dataarray_vfunc
    args = deep_align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:847: in deep_align
    aligned = align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:783: in align
    aligner.align()
venv/lib/python3.11/site-packages/xarray/core/alignment.py:568: in align
    self.align_indexes()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <xarray.core.alignment.Aligner object at 0x7f0bb0b057d0>

    def align_indexes(self) -> None:
        """Compute all aligned indexes and their corresponding coordinate variables."""

        aligned_indexes = {}
        aligned_index_vars = {}
        reindex = {}
        new_indexes = {}
        new_index_vars = {}

        for key, matching_indexes in self.all_indexes.items():
            matching_index_vars = self.all_index_vars[key]
            dims = {d for coord in matching_index_vars[0].values() for d in coord.dims}
            index_cls = key[1]

            if self.join == "override":
                joined_index = matching_indexes[0]
                joined_index_vars = matching_index_vars[0]
                need_reindex = False
            elif key in self.indexes:
                joined_index = self.indexes[key]
                joined_index_vars = self.index_vars[key]
                cmp_indexes = list(
                    zip(
                        [joined_index] + matching_indexes,
                        [joined_index_vars] + matching_index_vars,
                    )
                )
                need_reindex = self._need_reindex(dims, cmp_indexes)
            else:
                if len(matching_indexes) > 1:
                    need_reindex = self._need_reindex(
                        dims,
                        list(zip(matching_indexes, matching_index_vars)),
                    )
                else:
                    need_reindex = False
                if need_reindex:
                    if self.join == "exact":
>                       raise ValueError(
                            "cannot align objects with join='exact' where "
                            "index/labels/sizes are not equal along "
                            "these coordinates (dimensions): "
                            + ", ".join(f"{name!r} {dims!r}" for name, dims in key[0])
                        )
E                       ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)

venv/lib/python3.11/site-packages/xarray/core/alignment.py:415: ValueError
____________________________________________________ test_terrain_correction_rtc[data_path1-IW1/VV] _____________________________________________________

tmpdir = local('/tmp/pytest-of-antonio/pytest-3/test_terrain_correction_rtc_da1')
data_path = PosixPath('/home/antonio/projects/forks/sarsen/tests/data/S1A_IW_SLC__1SDV_20220104T170557_20220104T170624_041314_04E951_F1F1.SAFE')
group = 'IW1/VV'

    @pytest.mark.parametrize("data_path,group", zip(DATA_PATHS, GROUPS))
    @pytest.mark.skipif(os.getenv("GITHUB_ACTIONS") == "true", reason="too much memory")
    def test_terrain_correction_rtc(
        tmpdir: py.path.local, data_path: pathlib.Path, group: str
    ) -> None:
        out = str(tmpdir.join("RTC.tif"))
        product = sentinel1.Sentinel1SarProduct(
            str(data_path),
            group,
        )

>       res = apps.terrain_correction(
            product,
            str(DEM_RASTER),
            correct_radiometry="gamma_bilinear",
            output_urlpath=out,
        )

tests/test_50_apps.py:80: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sarsen/apps.py:166: in terrain_correction
    acquisition = acquisition.persist()
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1029: in persist
    return new._persist_inplace(**kwargs)
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1003: in _persist_inplace
    evaluated_data = dask.persist(*lazy_data.values(), **kwargs)
venv/lib/python3.11/site-packages/dask/base.py:967: in persist
    results = schedule(dsk, keys, **kwargs)
venv/lib/python3.11/site-packages/dask/threaded.py:89: in get
    results = get_async(
venv/lib/python3.11/site-packages/dask/local.py:511: in get_async
    raise_exception(exc, tb)
venv/lib/python3.11/site-packages/dask/local.py:319: in reraise
    raise exc
venv/lib/python3.11/site-packages/dask/local.py:224: in execute_task
    result = _execute_task(task, data)
venv/lib/python3.11/site-packages/dask/core.py:121: in _execute_task
    return func(*(_execute_task(a, cache) for a in args))
venv/lib/python3.11/site-packages/xarray/core/parallel.py:268: in _wrapper
    result = func(*converted_args, **kwargs)
sarsen/apps.py:36: in simulate_acquisition
    gamma_area = radiometry.compute_gamma_area(
sarsen/radiometry.py:56: in compute_gamma_area
    dem_oriented_area = scene.compute_dem_oriented_area(dem_ecef)
sarsen/scene.py:110: in compute_dem_oriented_area
    cross_2 = xr.cross(dx2, dy2, dim="axis") / 2
venv/lib/python3.11/site-packages/xarray/core/computation.py:1609: in cross
    c = apply_ufunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:1197: in apply_ufunc
    return apply_dataarray_vfunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:288: in apply_dataarray_vfunc
    args = deep_align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:847: in deep_align
    aligned = align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:783: in align
    aligner.align()
venv/lib/python3.11/site-packages/xarray/core/alignment.py:568: in align
    self.align_indexes()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <xarray.core.alignment.Aligner object at 0x7f0bb02a3bd0>

    def align_indexes(self) -> None:
        """Compute all aligned indexes and their corresponding coordinate variables."""

        aligned_indexes = {}
        aligned_index_vars = {}
        reindex = {}
        new_indexes = {}
        new_index_vars = {}

        for key, matching_indexes in self.all_indexes.items():
            matching_index_vars = self.all_index_vars[key]
            dims = {d for coord in matching_index_vars[0].values() for d in coord.dims}
            index_cls = key[1]

            if self.join == "override":
                joined_index = matching_indexes[0]
                joined_index_vars = matching_index_vars[0]
                need_reindex = False
            elif key in self.indexes:
                joined_index = self.indexes[key]
                joined_index_vars = self.index_vars[key]
                cmp_indexes = list(
                    zip(
                        [joined_index] + matching_indexes,
                        [joined_index_vars] + matching_index_vars,
                    )
                )
                need_reindex = self._need_reindex(dims, cmp_indexes)
            else:
                if len(matching_indexes) > 1:
                    need_reindex = self._need_reindex(
                        dims,
                        list(zip(matching_indexes, matching_index_vars)),
                    )
                else:
                    need_reindex = False
                if need_reindex:
                    if self.join == "exact":
>                       raise ValueError(
                            "cannot align objects with join='exact' where "
                            "index/labels/sizes are not equal along "
                            "these coordinates (dimensions): "
                            + ", ".join(f"{name!r} {dims!r}" for name, dims in key[0])
                        )
E                       ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)

venv/lib/python3.11/site-packages/xarray/core/alignment.py:415: ValueError
________________________________________________ test_terrain_correction_fast_rtc_dask[data_path0-IW/VV] ________________________________________________

tmpdir = local('/tmp/pytest-of-antonio/pytest-3/test_terrain_correction_fast_r2')
data_path = PosixPath('/home/antonio/projects/forks/sarsen/tests/data/S1B_IW_GRDH_1SDV_20211223T051122_20211223T051147_030148_039993_5371.SAFE')
group = 'IW/VV'

    @pytest.mark.parametrize("data_path,group", zip(DATA_PATHS, GROUPS))
    @pytest.mark.skipif(os.getenv("GITHUB_ACTIONS") == "true", reason="too much memory")
    def test_terrain_correction_fast_rtc_dask(
        tmpdir: py.path.local, data_path: pathlib.Path, group: str
    ) -> None:
        out = str(tmpdir.join("RTC.tif"))
        product = sentinel1.Sentinel1SarProduct(
            str(data_path),
            group,
        )

>       res = apps.terrain_correction(
            product,
            str(DEM_RASTER),
            correct_radiometry="gamma_nearest",
            output_urlpath=out,
            chunks=1024,
        )

tests/test_50_apps.py:124: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sarsen/apps.py:166: in terrain_correction
    acquisition = acquisition.persist()
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1029: in persist
    return new._persist_inplace(**kwargs)
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1003: in _persist_inplace
    evaluated_data = dask.persist(*lazy_data.values(), **kwargs)
venv/lib/python3.11/site-packages/dask/base.py:967: in persist
    results = schedule(dsk, keys, **kwargs)
venv/lib/python3.11/site-packages/dask/threaded.py:89: in get
    results = get_async(
venv/lib/python3.11/site-packages/dask/local.py:511: in get_async
    raise_exception(exc, tb)
venv/lib/python3.11/site-packages/dask/local.py:319: in reraise
    raise exc
venv/lib/python3.11/site-packages/dask/local.py:224: in execute_task
    result = _execute_task(task, data)
venv/lib/python3.11/site-packages/dask/core.py:121: in _execute_task
    return func(*(_execute_task(a, cache) for a in args))
venv/lib/python3.11/site-packages/xarray/core/parallel.py:268: in _wrapper
    result = func(*converted_args, **kwargs)
sarsen/apps.py:36: in simulate_acquisition
    gamma_area = radiometry.compute_gamma_area(
sarsen/radiometry.py:56: in compute_gamma_area
    dem_oriented_area = scene.compute_dem_oriented_area(dem_ecef)
sarsen/scene.py:110: in compute_dem_oriented_area
    cross_2 = xr.cross(dx2, dy2, dim="axis") / 2
venv/lib/python3.11/site-packages/xarray/core/computation.py:1609: in cross
    c = apply_ufunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:1197: in apply_ufunc
    return apply_dataarray_vfunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:288: in apply_dataarray_vfunc
    args = deep_align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:847: in deep_align
    aligned = align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:783: in align
    aligner.align()
venv/lib/python3.11/site-packages/xarray/core/alignment.py:568: in align
    self.align_indexes()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <xarray.core.alignment.Aligner object at 0x7f0b8bc5d7d0>

    def align_indexes(self) -> None:
        """Compute all aligned indexes and their corresponding coordinate variables."""

        aligned_indexes = {}
        aligned_index_vars = {}
        reindex = {}
        new_indexes = {}
        new_index_vars = {}

        for key, matching_indexes in self.all_indexes.items():
            matching_index_vars = self.all_index_vars[key]
            dims = {d for coord in matching_index_vars[0].values() for d in coord.dims}
            index_cls = key[1]

            if self.join == "override":
                joined_index = matching_indexes[0]
                joined_index_vars = matching_index_vars[0]
                need_reindex = False
            elif key in self.indexes:
                joined_index = self.indexes[key]
                joined_index_vars = self.index_vars[key]
                cmp_indexes = list(
                    zip(
                        [joined_index] + matching_indexes,
                        [joined_index_vars] + matching_index_vars,
                    )
                )
                need_reindex = self._need_reindex(dims, cmp_indexes)
            else:
                if len(matching_indexes) > 1:
                    need_reindex = self._need_reindex(
                        dims,
                        list(zip(matching_indexes, matching_index_vars)),
                    )
                else:
                    need_reindex = False
                if need_reindex:
                    if self.join == "exact":
>                       raise ValueError(
                            "cannot align objects with join='exact' where "
                            "index/labels/sizes are not equal along "
                            "these coordinates (dimensions): "
                            + ", ".join(f"{name!r} {dims!r}" for name, dims in key[0])
                        )
E                       ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)

venv/lib/python3.11/site-packages/xarray/core/alignment.py:415: ValueError
_______________________________________________ test_terrain_correction_fast_rtc_dask[data_path1-IW1/VV] ________________________________________________

tmpdir = local('/tmp/pytest-of-antonio/pytest-3/test_terrain_correction_fast_r3')
data_path = PosixPath('/home/antonio/projects/forks/sarsen/tests/data/S1A_IW_SLC__1SDV_20220104T170557_20220104T170624_041314_04E951_F1F1.SAFE')
group = 'IW1/VV'

    @pytest.mark.parametrize("data_path,group", zip(DATA_PATHS, GROUPS))
    @pytest.mark.skipif(os.getenv("GITHUB_ACTIONS") == "true", reason="too much memory")
    def test_terrain_correction_fast_rtc_dask(
        tmpdir: py.path.local, data_path: pathlib.Path, group: str
    ) -> None:
        out = str(tmpdir.join("RTC.tif"))
        product = sentinel1.Sentinel1SarProduct(
            str(data_path),
            group,
        )

>       res = apps.terrain_correction(
            product,
            str(DEM_RASTER),
            correct_radiometry="gamma_nearest",
            output_urlpath=out,
            chunks=1024,
        )

tests/test_50_apps.py:124: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sarsen/apps.py:166: in terrain_correction
    acquisition = acquisition.persist()
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1029: in persist
    return new._persist_inplace(**kwargs)
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1003: in _persist_inplace
    evaluated_data = dask.persist(*lazy_data.values(), **kwargs)
venv/lib/python3.11/site-packages/dask/base.py:967: in persist
    results = schedule(dsk, keys, **kwargs)
venv/lib/python3.11/site-packages/dask/threaded.py:89: in get
    results = get_async(
venv/lib/python3.11/site-packages/dask/local.py:511: in get_async
    raise_exception(exc, tb)
venv/lib/python3.11/site-packages/dask/local.py:319: in reraise
    raise exc
venv/lib/python3.11/site-packages/dask/local.py:224: in execute_task
    result = _execute_task(task, data)
venv/lib/python3.11/site-packages/dask/core.py:121: in _execute_task
    return func(*(_execute_task(a, cache) for a in args))
venv/lib/python3.11/site-packages/xarray/core/parallel.py:268: in _wrapper
    result = func(*converted_args, **kwargs)
sarsen/apps.py:36: in simulate_acquisition
    gamma_area = radiometry.compute_gamma_area(
sarsen/radiometry.py:56: in compute_gamma_area
    dem_oriented_area = scene.compute_dem_oriented_area(dem_ecef)
sarsen/scene.py:110: in compute_dem_oriented_area
    cross_2 = xr.cross(dx2, dy2, dim="axis") / 2
venv/lib/python3.11/site-packages/xarray/core/computation.py:1609: in cross
    c = apply_ufunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:1197: in apply_ufunc
    return apply_dataarray_vfunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:288: in apply_dataarray_vfunc
    args = deep_align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:847: in deep_align
    aligned = align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:783: in align
    aligner.align()
venv/lib/python3.11/site-packages/xarray/core/alignment.py:568: in align
    self.align_indexes()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <xarray.core.alignment.Aligner object at 0x7f0bb0889ad0>

    def align_indexes(self) -> None:
        """Compute all aligned indexes and their corresponding coordinate variables."""

        aligned_indexes = {}
        aligned_index_vars = {}
        reindex = {}
        new_indexes = {}
        new_index_vars = {}

        for key, matching_indexes in self.all_indexes.items():
            matching_index_vars = self.all_index_vars[key]
            dims = {d for coord in matching_index_vars[0].values() for d in coord.dims}
            index_cls = key[1]

            if self.join == "override":
                joined_index = matching_indexes[0]
                joined_index_vars = matching_index_vars[0]
                need_reindex = False
            elif key in self.indexes:
                joined_index = self.indexes[key]
                joined_index_vars = self.index_vars[key]
                cmp_indexes = list(
                    zip(
                        [joined_index] + matching_indexes,
                        [joined_index_vars] + matching_index_vars,
                    )
                )
                need_reindex = self._need_reindex(dims, cmp_indexes)
            else:
                if len(matching_indexes) > 1:
                    need_reindex = self._need_reindex(
                        dims,
                        list(zip(matching_indexes, matching_index_vars)),
                    )
                else:
                    need_reindex = False
                if need_reindex:
                    if self.join == "exact":
>                       raise ValueError(
                            "cannot align objects with join='exact' where "
                            "index/labels/sizes are not equal along "
                            "these coordinates (dimensions): "
                            + ", ".join(f"{name!r} {dims!r}" for name, dims in key[0])
                        )
E                       ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)

venv/lib/python3.11/site-packages/xarray/core/alignment.py:415: ValueError
__________________________________________________ test_terrain_correction_rtc_dask[data_path0-IW/VV] ___________________________________________________

tmpdir = local('/tmp/pytest-of-antonio/pytest-3/test_terrain_correction_rtc_da2')
data_path = PosixPath('/home/antonio/projects/forks/sarsen/tests/data/S1B_IW_GRDH_1SDV_20211223T051122_20211223T051147_030148_039993_5371.SAFE')
group = 'IW/VV'

    @pytest.mark.parametrize("data_path,group", zip(DATA_PATHS, GROUPS))
    @pytest.mark.skipif(os.getenv("GITHUB_ACTIONS") == "true", reason="too much memory")
    def test_terrain_correction_rtc_dask(
        tmpdir: py.path.local, data_path: pathlib.Path, group: str
    ) -> None:
        out = str(tmpdir.join("RTC.tif"))
        product = sentinel1.Sentinel1SarProduct(
            str(data_path),
            group,
        )

>       res = apps.terrain_correction(
            product,
            str(DEM_RASTER),
            correct_radiometry="gamma_bilinear",
            output_urlpath=out,
            chunks=1024,
        )

tests/test_50_apps.py:147: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sarsen/apps.py:166: in terrain_correction
    acquisition = acquisition.persist()
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1029: in persist
    return new._persist_inplace(**kwargs)
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1003: in _persist_inplace
    evaluated_data = dask.persist(*lazy_data.values(), **kwargs)
venv/lib/python3.11/site-packages/dask/base.py:967: in persist
    results = schedule(dsk, keys, **kwargs)
venv/lib/python3.11/site-packages/dask/threaded.py:89: in get
    results = get_async(
venv/lib/python3.11/site-packages/dask/local.py:511: in get_async
    raise_exception(exc, tb)
venv/lib/python3.11/site-packages/dask/local.py:319: in reraise
    raise exc
venv/lib/python3.11/site-packages/dask/local.py:224: in execute_task
    result = _execute_task(task, data)
venv/lib/python3.11/site-packages/dask/core.py:121: in _execute_task
    return func(*(_execute_task(a, cache) for a in args))
venv/lib/python3.11/site-packages/xarray/core/parallel.py:268: in _wrapper
    result = func(*converted_args, **kwargs)
sarsen/apps.py:36: in simulate_acquisition
    gamma_area = radiometry.compute_gamma_area(
sarsen/radiometry.py:56: in compute_gamma_area
    dem_oriented_area = scene.compute_dem_oriented_area(dem_ecef)
sarsen/scene.py:110: in compute_dem_oriented_area
    cross_2 = xr.cross(dx2, dy2, dim="axis") / 2
venv/lib/python3.11/site-packages/xarray/core/computation.py:1609: in cross
    c = apply_ufunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:1197: in apply_ufunc
    return apply_dataarray_vfunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:288: in apply_dataarray_vfunc
    args = deep_align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:847: in deep_align
    aligned = align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:783: in align
    aligner.align()
venv/lib/python3.11/site-packages/xarray/core/alignment.py:568: in align
    self.align_indexes()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <xarray.core.alignment.Aligner object at 0x7f0b8bfae750>

    def align_indexes(self) -> None:
        """Compute all aligned indexes and their corresponding coordinate variables."""

        aligned_indexes = {}
        aligned_index_vars = {}
        reindex = {}
        new_indexes = {}
        new_index_vars = {}

        for key, matching_indexes in self.all_indexes.items():
            matching_index_vars = self.all_index_vars[key]
            dims = {d for coord in matching_index_vars[0].values() for d in coord.dims}
            index_cls = key[1]

            if self.join == "override":
                joined_index = matching_indexes[0]
                joined_index_vars = matching_index_vars[0]
                need_reindex = False
            elif key in self.indexes:
                joined_index = self.indexes[key]
                joined_index_vars = self.index_vars[key]
                cmp_indexes = list(
                    zip(
                        [joined_index] + matching_indexes,
                        [joined_index_vars] + matching_index_vars,
                    )
                )
                need_reindex = self._need_reindex(dims, cmp_indexes)
            else:
                if len(matching_indexes) > 1:
                    need_reindex = self._need_reindex(
                        dims,
                        list(zip(matching_indexes, matching_index_vars)),
                    )
                else:
                    need_reindex = False
                if need_reindex:
                    if self.join == "exact":
>                       raise ValueError(
                            "cannot align objects with join='exact' where "
                            "index/labels/sizes are not equal along "
                            "these coordinates (dimensions): "
                            + ", ".join(f"{name!r} {dims!r}" for name, dims in key[0])
                        )
E                       ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)

venv/lib/python3.11/site-packages/xarray/core/alignment.py:415: ValueError
__________________________________________________ test_terrain_correction_rtc_dask[data_path1-IW1/VV] __________________________________________________

tmpdir = local('/tmp/pytest-of-antonio/pytest-3/test_terrain_correction_rtc_da3')
data_path = PosixPath('/home/antonio/projects/forks/sarsen/tests/data/S1A_IW_SLC__1SDV_20220104T170557_20220104T170624_041314_04E951_F1F1.SAFE')
group = 'IW1/VV'

    @pytest.mark.parametrize("data_path,group", zip(DATA_PATHS, GROUPS))
    @pytest.mark.skipif(os.getenv("GITHUB_ACTIONS") == "true", reason="too much memory")
    def test_terrain_correction_rtc_dask(
        tmpdir: py.path.local, data_path: pathlib.Path, group: str
    ) -> None:
        out = str(tmpdir.join("RTC.tif"))
        product = sentinel1.Sentinel1SarProduct(
            str(data_path),
            group,
        )

>       res = apps.terrain_correction(
            product,
            str(DEM_RASTER),
            correct_radiometry="gamma_bilinear",
            output_urlpath=out,
            chunks=1024,
        )

tests/test_50_apps.py:147: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sarsen/apps.py:166: in terrain_correction
    acquisition = acquisition.persist()
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1029: in persist
    return new._persist_inplace(**kwargs)
venv/lib/python3.11/site-packages/xarray/core/dataset.py:1003: in _persist_inplace
    evaluated_data = dask.persist(*lazy_data.values(), **kwargs)
venv/lib/python3.11/site-packages/dask/base.py:967: in persist
    results = schedule(dsk, keys, **kwargs)
venv/lib/python3.11/site-packages/dask/threaded.py:89: in get
    results = get_async(
venv/lib/python3.11/site-packages/dask/local.py:511: in get_async
    raise_exception(exc, tb)
venv/lib/python3.11/site-packages/dask/local.py:319: in reraise
    raise exc
venv/lib/python3.11/site-packages/dask/local.py:224: in execute_task
    result = _execute_task(task, data)
venv/lib/python3.11/site-packages/dask/core.py:121: in _execute_task
    return func(*(_execute_task(a, cache) for a in args))
venv/lib/python3.11/site-packages/xarray/core/parallel.py:268: in _wrapper
    result = func(*converted_args, **kwargs)
sarsen/apps.py:36: in simulate_acquisition
    gamma_area = radiometry.compute_gamma_area(
sarsen/radiometry.py:56: in compute_gamma_area
    dem_oriented_area = scene.compute_dem_oriented_area(dem_ecef)
sarsen/scene.py:110: in compute_dem_oriented_area
    cross_2 = xr.cross(dx2, dy2, dim="axis") / 2
venv/lib/python3.11/site-packages/xarray/core/computation.py:1609: in cross
    c = apply_ufunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:1197: in apply_ufunc
    return apply_dataarray_vfunc(
venv/lib/python3.11/site-packages/xarray/core/computation.py:288: in apply_dataarray_vfunc
    args = deep_align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:847: in deep_align
    aligned = align(
venv/lib/python3.11/site-packages/xarray/core/alignment.py:783: in align
    aligner.align()
venv/lib/python3.11/site-packages/xarray/core/alignment.py:568: in align
    self.align_indexes()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <xarray.core.alignment.Aligner object at 0x7f0b8bec2d90>

    def align_indexes(self) -> None:
        """Compute all aligned indexes and their corresponding coordinate variables."""

        aligned_indexes = {}
        aligned_index_vars = {}
        reindex = {}
        new_indexes = {}
        new_index_vars = {}

        for key, matching_indexes in self.all_indexes.items():
            matching_index_vars = self.all_index_vars[key]
            dims = {d for coord in matching_index_vars[0].values() for d in coord.dims}
            index_cls = key[1]

            if self.join == "override":
                joined_index = matching_indexes[0]
                joined_index_vars = matching_index_vars[0]
                need_reindex = False
            elif key in self.indexes:
                joined_index = self.indexes[key]
                joined_index_vars = self.index_vars[key]
                cmp_indexes = list(
                    zip(
                        [joined_index] + matching_indexes,
                        [joined_index_vars] + matching_index_vars,
                    )
                )
                need_reindex = self._need_reindex(dims, cmp_indexes)
            else:
                if len(matching_indexes) > 1:
                    need_reindex = self._need_reindex(
                        dims,
                        list(zip(matching_indexes, matching_index_vars)),
                    )
                else:
                    need_reindex = False
                if need_reindex:
                    if self.join == "exact":
>                       raise ValueError(
                            "cannot align objects with join='exact' where "
                            "index/labels/sizes are not equal along "
                            "these coordinates (dimensions): "
                            + ", ".join(f"{name!r} {dims!r}" for name, dims in key[0])
                        )
E                       ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)

venv/lib/python3.11/site-packages/xarray/core/alignment.py:415: ValueError
=================================================================== warnings summary ====================================================================
tests/test_20_geocoding.py::test_secant_method
  /home/antonio/projects/forks/sarsen/sarsen/geocoding.py:44: RuntimeWarning: invalid value encountered in divide
    t_prev, t_curr = t_curr, t_curr - np.where(q != 0, p / q, 0)  # type: ignore

tests/test_20_sentinel1.py: 26 warnings
tests/test_50_apps.py: 52 warnings
  /home/antonio/projects/forks/sarsen/sarsen/sentinel1.py:30: UserWarning: Converting non-nanosecond precision datetime values to nanosecond precision. This behavior can eventually be relaxed in xarray, as it is an artifact from pandas which is now beginning to support non-nanosecond precision values. This warning is caused by passing non-nanosecond np.datetime64 or np.timedelta64 values to the DataArray or Variable constructor; it can be silenced by converting the values to nanosecond precision ahead of time.
    ds = xr.open_dataset(product_urlpath, group=group, chunks=chunks, **kwargs)

tests/test_20_sentinel1.py: 7 warnings
tests/test_50_apps.py: 18 warnings
  /home/antonio/projects/forks/sarsen/venv/lib/python3.11/site-packages/rioxarray/_io.py:1132: NotGeoreferencedWarning: Dataset has no geotransform, gcps, or rpcs. The identity matrix will be returned.
    warnings.warn(str(rio_warning.message), type(rio_warning.message))  # type: ignore

tests/test_20_sentinel1.py: 7 warnings
tests/test_50_apps.py: 14 warnings
  /home/antonio/projects/forks/sarsen/venv/lib/python3.11/site-packages/xarray/core/dataset.py:269: UserWarning: The specified chunks separate the stored chunks along dimension "line" starting at index 2048. This could degrade performance. Instead, consider rechunking after loading.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================ short test summary info ================================================================
FAILED tests/test_10_scene.py::test_transform_dem_3d - AssertionError: assert <xarray.DataArray 'dem_3d' ()>\narray(48.613)\nCoordinates:\n    x            float64 12.5\n    spatial_ref  int64 0\n    y  ...
FAILED tests/test_10_scene.py::test_compute_dem_oriented_area - ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)
FAILED tests/test_30_radiometry.py::test_compute_gamma_area - ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)
FAILED tests/test_50_apps.py::test_terrain_correction_fast_rtc[data_path0-IW/VV] - ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)
FAILED tests/test_50_apps.py::test_terrain_correction_fast_rtc[data_path1-IW1/VV] - ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)
FAILED tests/test_50_apps.py::test_terrain_correction_rtc[data_path0-IW/VV] - ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)
FAILED tests/test_50_apps.py::test_terrain_correction_rtc[data_path1-IW1/VV] - ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)
FAILED tests/test_50_apps.py::test_terrain_correction_fast_rtc_dask[data_path0-IW/VV] - ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)
FAILED tests/test_50_apps.py::test_terrain_correction_fast_rtc_dask[data_path1-IW1/VV] - ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)
FAILED tests/test_50_apps.py::test_terrain_correction_rtc_dask[data_path0-IW/VV] - ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)
FAILED tests/test_50_apps.py::test_terrain_correction_rtc_dask[data_path1-IW1/VV] - ValueError: cannot align objects with join='exact' where index/labels/sizes are not equal along these coordinates (dimensions): 'x' ('x',)
================================================ 11 failed, 19 passed, 125 warnings in 124.60s (0:02:04) ================================================

Any idea about how to fix / workaround this issue?

alexamici commented 1 year ago

@avalentino thanks for reporting!

I confirmed failures with version 2023.8.0 of xarray, but all tests pass with version 2023.9.0.

I would consider this an internal bug of xarray that have been fixed and close this issue.

avalentino commented 1 year ago

Thanks @alexamici , I can confirm that also 2023.8.1 seems to work. It is really something specific for 2023.8.0