class_docstr: Test the scene class.
class_docstr_tok: ["Test","the","scene","class","."]
docstr: Test __getitem__ with slices.
docstr_tok: ["Test","__getitem__","with","slices","."]
code: def test_getitem_slices(self):
      """Test __getitem__ with slices."""
      from pyresample.geometry import AreaDefinition, SwathDefinition
      from pyresample.utils import proj4_str_to_dict
  
      scene1 = Scene()
      scene2 = Scene()
      proj_dict = proj4_str_to_dict(
          "+proj=lcc +datum=WGS84 +ellps=WGS84 "
          "+lon_0=-95. +lat_0=25 +lat_1=25 "
          "+units=m +no_defs"
      )
      area_def = AreaDefinition(
          "test",
          "test",
          "test",
          proj_dict,
          200,
          400,
          (-1000.0, -1500.0, 1000.0, 1500.0),
      )
      swath_def = SwathDefinition(
          lons=np.zeros((5, 10)), lats=np.zeros((5, 10))
      )
      scene1["1"] = scene2["1"] = xr.DataArray(np.zeros((5, 10)))
      scene1["2"] = scene2["2"] = xr.DataArray(
          np.zeros((5, 10)), dims=("y", "x")
      )
      scene1["3"] = xr.DataArray(
          np.zeros((5, 10)), dims=("y", "x"), attrs={"area": area_def}
      )
      anc_vars = [
          xr.DataArray(
              np.ones((5, 10)),
              attrs={"name": "anc_var", "area": area_def},
          )
      ]
      attrs = {"ancillary_variables": anc_vars, "area": area_def}
      scene1["3a"] = xr.DataArray(
          np.zeros((5, 10)), dims=("y", "x"), attrs=attrs
      )
      scene2["4"] = xr.DataArray(
          np.zeros((5, 10)), dims=("y", "x"), attrs={"area": swath_def}
      )
      anc_vars = [
          xr.DataArray(
              np.ones((5, 10)),
              attrs={"name": "anc_var", "area": swath_def},
          )
      ]
      attrs = {"ancillary_variables": anc_vars, "area": swath_def}
      scene2["4a"] = xr.DataArray(
          np.zeros((5, 10)), dims=("y", "x"), attrs=attrs
      )
      new_scn1 = scene1[2:5, 2:8]
      new_scn2 = scene2[2:5, 2:8]
      for new_scn in [new_scn1, new_scn2]:
          # datasets without an area don't get sliced
          assert new_scn["1"].shape == (5, 10)
          assert new_scn["2"].shape == (5, 10)
  
      assert new_scn1["3"].shape == (3, 6)
      assert "area" in new_scn1["3"].attrs
      assert new_scn1["3"].attrs["area"].shape == (3, 6)
      assert new_scn1["3a"].shape == (3, 6)
      a_var = new_scn1["3a"].attrs["ancillary_variables"][0]
      assert a_var.shape == (3, 6)
  
      assert new_scn2["4"].shape == (3, 6)
      assert "area" in new_scn2["4"].attrs
      assert new_scn2["4"].attrs["area"].shape == (3, 6)
      assert new_scn2["4a"].shape == (3, 6)
      a_var = new_scn2["4a"].attrs["ancillary_variables"][0]
      assert a_var.shape == (3, 6)
  
imports: import math
  import numpy
  import pytest
  import xarray
  from dask import array
  from satpy import Scene
  from satpy.dataset.dataid import default_id_keys_config
  from satpy.tests.utils import FAKE_FILEHANDLER_END, FAKE_FILEHANDLER_START, make_cid, make_dataid
label_desc: Use image node_id 9 for calling the TestDataAccessMethods obj's underlying member method code with example usage: obj.test_getitem_slices() without return types