class_docstr: Test case for CF Area.
class_docstr_tok: ["Test","case","for","CF","Area","."]
docstr: Test the conversion from areas to lon/lat.
docstr_tok: ["Test","the","conversion","from","areas","to","lon\/lat","."]
code: def test_add_lonlat_coords(self, dims):
      """Test the conversion from areas to lon/lat."""
      from satpy.cf.area import _add_lonlat_coords
  
      width, height = (2, 2) if len(dims) == 2 else (10, 10)
      area = AreaDefinition(
          "seviri",
          "Native SEVIRI grid",
          "geos",
          "+a=6378169.0 +h=35785831.0 +b=6356583.8 +lon_0=0 +proj=geos",
          width,
          height,
          [
              -5570248.686685662,
              -5567248.28340708,
              5567248.28340708,
              5570248.686685662,
          ],
      )
      lons_ref, lats_ref = area.get_lonlats()
      if len(dims) == 2:
          data_arr = xr.DataArray(
              data=[[1, 2], [3, 4]], dims=dims, attrs={"area": area}
          )
      else:
          data_arr = xr.DataArray(
              data=da.from_array(
                  np.arange(3 * 10 * 10).reshape(3, 10, 10),
                  chunks=(1, 5, 5),
              ),
              dims=("bands", "y", "x"),
              attrs={"area": area},
          )
  
      res = _add_lonlat_coords(data_arr)
  
      # original should be unmodified
      assert "longitude" not in data_arr.coords
      assert set(res.coords) == {"longitude", "latitude"}
      lat = res["latitude"]
      lon = res["longitude"]
      np.testing.assert_array_equal(lat.data, lats_ref)
      np.testing.assert_array_equal(lon.data, lons_ref)
      assert {
          "name": "latitude",
          "standard_name": "latitude",
          "units": "degrees_north",
      }.items() <= lat.attrs.items()
      assert {
          "name": "longitude",
          "standard_name": "longitude",
          "units": "degrees_east",
      }.items() <= lon.attrs.items()
  
file_path: satpy/satpy/tests/cf_tests/test_area.py
imports: import dask.array
  import numpy
  import pytest
  import xarray
  from pyresample import AreaDefinition, SwathDefinition
  from satpy.cf.area import _add_grid_mapping, area2cf
label_desc: Use image node_id 8 for calling the TestCFArea obj's underlying member method code with example usage: obj.test_add_lonlat_coords(dims) without return types