class_docstr: Test generic image reader.
class_docstr_tok: ["Test","generic","image","reader","."]
docstr: Create temporary images to test on.
docstr_tok: ["Create","temporary","images","to","test","on","."]
code: def setUp(self):
      """Create temporary images to test on."""
      import tempfile
      from datetime import datetime
  
      from pyresample.geometry import AreaDefinition
  
      from satpy.scene import Scene
  
      self.date = datetime(2018, 1, 1)
  
      # Create area definition
      pcs_id = "ETRS89 / LAEA Europe"
      proj4_dict = "EPSG:3035"
      self.x_size = 100
      self.y_size = 100
      area_extent = (
          2426378.0132,
          1528101.2618,
          6293974.6215,
          5446513.5222,
      )
      self.area_def = AreaDefinition(
          "geotiff_area",
          pcs_id,
          pcs_id,
          proj4_dict,
          self.x_size,
          self.y_size,
          area_extent,
      )
  
      # Create datasets for L, LA, RGB and RGBA mode images
      r__ = da.random.randint(
          0, 256, size=(self.y_size, self.x_size), chunks=(50, 50)
      ).astype(np.uint8)
      g__ = da.random.randint(
          0, 256, size=(self.y_size, self.x_size), chunks=(50, 50)
      ).astype(np.uint8)
      b__ = da.random.randint(
          0, 256, size=(self.y_size, self.x_size), chunks=(50, 50)
      ).astype(np.uint8)
      a__ = 255 * np.ones((self.y_size, self.x_size), dtype=np.uint8)
      a__[:10, :10] = 0
      a__ = da.from_array(a__, chunks=(50, 50))
  
      r_nan__ = np.random.uniform(
          0.0, 1.0, size=(self.y_size, self.x_size)
      )
      r_nan__[:10, :10] = np.nan
      r_nan__ = da.from_array(r_nan__, chunks=(50, 50))
  
      ds_l = xr.DataArray(
          da.stack([r__]),
          dims=("bands", "y", "x"),
          attrs={"name": "test_l", "start_time": self.date},
      )
      ds_l["bands"] = ["L"]
      ds_la = xr.DataArray(
          da.stack([r__, a__]),
          dims=("bands", "y", "x"),
          attrs={"name": "test_la", "start_time": self.date},
      )
      ds_la["bands"] = ["L", "A"]
      ds_rgb = xr.DataArray(
          da.stack([r__, g__, b__]),
          dims=("bands", "y", "x"),
          attrs={"name": "test_rgb", "start_time": self.date},
      )
      ds_rgb["bands"] = ["R", "G", "B"]
      ds_rgba = xr.DataArray(
          da.stack([r__, g__, b__, a__]),
          dims=("bands", "y", "x"),
          attrs={"name": "test_rgba", "start_time": self.date},
      )
      ds_rgba["bands"] = ["R", "G", "B", "A"]
  
      ds_l_nan = xr.DataArray(
          da.stack([r_nan__]),
          dims=("bands", "y", "x"),
          attrs={"name": "test_l_nan", "start_time": self.date},
      )
      ds_l_nan["bands"] = ["L"]
  
      # Temp dir for the saved images
      self.base_dir = tempfile.mkdtemp()
  
      # Put the datasets to Scene for easy saving
      scn = Scene()
      scn["l"] = ds_l
      scn["l"].attrs["area"] = self.area_def
      scn["la"] = ds_la
      scn["la"].attrs["area"] = self.area_def
      scn["rgb"] = ds_rgb
      scn["rgb"].attrs["area"] = self.area_def
      scn["rgba"] = ds_rgba
      scn["rgba"].attrs["area"] = self.area_def
      scn["l_nan"] = ds_l_nan
      scn["l_nan"].attrs["area"] = self.area_def
  
      # Save the images.  Two images in PNG and two in GeoTIFF
      scn.save_dataset(
          "l",
          os.path.join(self.base_dir, "test_l.png"),
          writer="simple_image",
      )
      scn.save_dataset(
          "la",
          os.path.join(self.base_dir, "20180101_0000_test_la.png"),
          writer="simple_image",
      )
      scn.save_dataset(
          "rgb",
          os.path.join(self.base_dir, "20180101_0000_test_rgb.tif"),
          writer="geotiff",
      )
      scn.save_dataset(
          "rgba",
          os.path.join(self.base_dir, "test_rgba.tif"),
          writer="geotiff",
      )
      scn.save_dataset(
          "l_nan",
          os.path.join(self.base_dir, "test_l_nan_fillvalue.tif"),
          writer="geotiff",
          fill_value=0,
      )
      scn.save_dataset(
          "l_nan",
          os.path.join(self.base_dir, "test_l_nan_nofillvalue.tif"),
          writer="geotiff",
      )
  
      self.scn = scn
  
file_path: satpy/satpy/tests/reader_tests/test_generic_image.py
imports: import os
  import unittest
  import dask.array
  import numpy
  import pytest
  import xarray
  from satpy.tests.utils import make_dataid
label_desc: Use image node_id 1 for calling the TestGenericImage obj's underlying member method code with example usage: obj.setUp() without return types