class_docstr: Test case for CF reader.
class_docstr_tok: ["Test","case","for","CF","reader","."]
docstr: Save a dataset with an area definition to file with cf_writer and read the data again.
docstr_tok: ["Save","a","dataset","with","an","area","definition","to","file","with","cf_writer","and","read","the","data","again","."]
code: def test_write_and_read_with_area_definition(
      self, cf_scene, nc_filename
  ):
      """Save a dataset with an area definition to file with cf_writer and read the data again."""
      cf_scene.save_datasets(
          writer="cf",
          filename=nc_filename,
          engine="h5netcdf",
          flatten_attrs=True,
          pretty=True,
      )
      scn_ = Scene(reader="satpy_cf_nc", filenames=[nc_filename])
      scn_.load(["image0", "image1", "lat"])
      np.testing.assert_array_equal(
          scn_["image0"].data, cf_scene["image0"].data
      )
      np.testing.assert_array_equal(
          scn_["lat"].data, cf_scene["lat"].data
      )  # lat loaded as dataset
      np.testing.assert_array_equal(
          scn_["image0"].coords["lon"], cf_scene["lon"].data
      )  # lon loded as coord
      assert isinstance(
          scn_["image0"].attrs["wavelength"], WavelengthRange
      )
      expected_area = cf_scene["image0"].attrs["area"]
      actual_area = scn_["image0"].attrs["area"]
      assert (
          pytest.approx(expected_area.area_extent, 0.000001)
          == actual_area.area_extent
      )
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=r"You will likely lose important projection information",
              category=UserWarning,
          )
          assert expected_area.proj_dict == actual_area.proj_dict
      assert expected_area.shape == actual_area.shape
      assert expected_area.area_id == actual_area.area_id
      assert expected_area.description == actual_area.description
  
imports: import warnings
  from datetime import datetime
  import numpy
  import pytest
  import xarray
  from pyresample import AreaDefinition, SwathDefinition
  from satpy import Scene
  from satpy.dataset.dataid import WavelengthRange
  from satpy.readers.satpy_cf_nc import SatpyCFFileHandler
label_desc: Use image node_id 1 for calling the TestCFReader obj's underlying member method code with example usage: obj.test_write_and_read_with_area_definition(cf_scene, nc_filename) without return types