Skip to content

Fails resampling MODIS level-1 using an omerc projection definition #3391

Description

@adybbroe

Describe the bug
When trying to resample a locally received MODIS level-1 data to an area using an omerc projection, I get a failure:
KeyError: 'Indexing with a boolean dask array is not allowed. This will result in a dask array of unknown shape. Such arrays are unsupported by Xarray.Please compute the indexer first using .compute()'

To Reproduce

    myfiles = Path(DATADIR).glob("*134600*hdf")
    filenames = [str(f) for f in myfiles]
    scn = Scene(reader="modis_l1b", filenames=filenames)

    composite_name = 'ocean_color'
    scn.load([composite_name], resolution=500)
    areaid = 'omerc_bb'
    lcn = scn.resample(areaid, radius_of_influence=10000)

    lcn.save_dataset(composite_name,
                     filename=f'./modis_{scn.start_time:%Y%m%d_%H%M}_{areaid}_{composite_name}.png')

The area definition is like this:

omerc_bb:
  description: Oblique Mercator Bounding Box for Polar Overpasses
  projection:
    ellps: WGS84
    proj: omerc
  optimize_projection: True

Expected behavior

The above code should normally create a png image with data remapped on the given area/projection definition.

Actual results
Text output of actual results or error messages including full tracebacks if applicable.

    lcn = scn.resample(areaid, radius_of_influence=10000)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/usr/src/forks/satpy/satpy/scene.py", line 1001, in resample
    self._resampled_scene(new_scn, destination, resampler=resampler,
  File "/home/xxx/usr/src/forks/satpy/satpy/scene.py", line 875, in _resampled_scene
    destination_area = self._get_finalized_destination_area(destination_area, new_scn)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/usr/src/forks/satpy/satpy/scene.py", line 915, in _get_finalized_destination_area
    destination_area = destination_area.freeze(finest_area)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/mambaforge/envs/python3.12/lib/python3.12/site-packages/pyresample/geometry.py", line 1275, in freeze
    return lonslats.compute_optimal_bb_area(proj_dict, resolution=resolution or self.resolution)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/mambaforge/envs/python3.12/lib/python3.12/site-packages/pyresample/geometry.py", line 1032, in compute_optimal_bb_area
    proj_dict = self.compute_bb_proj_params(proj_dict)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/mambaforge/envs/python3.12/lib/python3.12/site-packages/pyresample/geometry.py", line 964, in compute_bb_proj_params
    return self._compute_omerc_parameters(ellipsoid)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/mambaforge/envs/python3.12/lib/python3.12/site-packages/pyresample/geometry.py", line 915, in _compute_omerc_parameters
    thelons = thelons.where(thelons.notnull(), drop=True)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/mambaforge/envs/python3.12/lib/python3.12/site-packages/xarray/core/common.py", line 1254, in where
    self = self.isel(**indexers)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/mambaforge/envs/python3.12/lib/python3.12/site-packages/xarray/core/dataarray.py", line 1521, in isel
    ds = self._to_temp_dataset()._isel_fancy(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/mambaforge/envs/python3.12/lib/python3.12/site-packages/xarray/core/dataset.py", line 2814, in _isel_fancy
    new_var = var.isel(indexers=var_indexers)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/mambaforge/envs/python3.12/lib/python3.12/site-packages/xarray/core/variable.py", line 1051, in isel
    return self[key]
           ~~~~^^^^^
  File "/home/xxx/mambaforge/envs/python3.12/lib/python3.12/site-packages/xarray/core/variable.py", line 794, in __getitem__
    dims, indexer, new_order = self._broadcast_indexes(key)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/mambaforge/envs/python3.12/lib/python3.12/site-packages/xarray/core/variable.py", line 633, in _broadcast_indexes
    self._validate_indexers(key)
  File "/home/xxx/mambaforge/envs/python3.12/lib/python3.12/site-packages/xarray/core/variable.py", line 686, in _validate_indexers
    raise KeyError(
KeyError: 'Indexing with a boolean dask array is not allowed. This will result in a dask array of unknown shape. Such arrays are unsupported by Xarray.Please compute the indexer first using .compute()'

Screenshots
If applicable, add screenshots to help explain your problem.

Environment Info:

  • OS: RHEL10
  • Satpy Version: latest main
  • PyResample Version: 1.43.2
  • Readers and writers dependencies (when relevant): [run from satpy.utils import check_satpy; check_satpy()]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status
    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions