class_docstr: Test various utility functions for working with coordinates.
class_docstr_tok: ["Test","various","utility","functions","for","working","with","coordinates","."]
docstr: Test coordinates being added with an AreaDefinition.
code: def test_area_def_coordinates(self):
      """Test coordinates being added with an AreaDefinition."""
      from pyresample.geometry import AreaDefinition
  
      from satpy.resample import add_crs_xy_coords
  
      area_def = AreaDefinition(
          "test",
          "test",
          "test",
          {"proj": "lcc", "lat_1": 25, "lat_0": 25},
          100,
          200,
          [-100, -100, 100, 100],
      )
      data_arr = xr.DataArray(
          da.zeros((200, 100), chunks=50),
          attrs={"area": area_def},
          dims=("y", "x"),
      )
      new_data_arr = add_crs_xy_coords(data_arr, area_def)
      assert "y" in new_data_arr.coords
      assert "x" in new_data_arr.coords
  
      assert "units" in new_data_arr.coords["y"].attrs
      assert new_data_arr.coords["y"].attrs["units"] == "meter"
      assert "units" in new_data_arr.coords["x"].attrs
      assert new_data_arr.coords["x"].attrs["units"] == "meter"
      assert "crs" in new_data_arr.coords
      assert isinstance(new_data_arr.coords["crs"].item(), CRS)
      assert area_def.crs == new_data_arr.coords["crs"].item()
  
      # already has coords
      data_arr = xr.DataArray(
          da.zeros((200, 100), chunks=50),
          attrs={"area": area_def},
          dims=("y", "x"),
          coords={"y": np.arange(2, 202), "x": np.arange(100)},
      )
      new_data_arr = add_crs_xy_coords(data_arr, area_def)
      assert "y" in new_data_arr.coords
      assert "units" not in new_data_arr.coords["y"].attrs
      assert "x" in new_data_arr.coords
      assert "units" not in new_data_arr.coords["x"].attrs
      np.testing.assert_equal(
          new_data_arr.coords["y"], np.arange(2, 202)
      )
  
      assert "crs" in new_data_arr.coords
      assert isinstance(new_data_arr.coords["crs"].item(), CRS)
      assert area_def.crs == new_data_arr.coords["crs"].item()
  
      # lat/lon area
      area_def = AreaDefinition(
          "test",
          "test",
          "test",
          {"proj": "latlong"},
          100,
          200,
          [-100, -100, 100, 100],
      )
      data_arr = xr.DataArray(
          da.zeros((200, 100), chunks=50),
          attrs={"area": area_def},
          dims=("y", "x"),
      )
      new_data_arr = add_crs_xy_coords(data_arr, area_def)
      assert "y" in new_data_arr.coords
      assert "x" in new_data_arr.coords
  
      assert "units" in new_data_arr.coords["y"].attrs
      assert new_data_arr.coords["y"].attrs["units"] == "degrees_north"
      assert "units" in new_data_arr.coords["x"].attrs
      assert new_data_arr.coords["x"].attrs["units"] == "degrees_east"
      assert "crs" in new_data_arr.coords
      assert isinstance(new_data_arr.coords["crs"].item(), CRS)
      assert area_def.crs == new_data_arr.coords["crs"].item()
  
imports: import os
  import shutil
  import tempfile
  import unittest
  from unittest import mock
  import dask.array
  import numpy
  import pytest
  import xarray
  from pyproj import CRS
  from satpy.resample import NativeResampler
label_desc: Use image node_id 1 for calling the TestCoordinateHelpers obj's underlying member method code with example usage: obj.test_area_def_coordinates() without return types