class_docstr: Test creation of CF DataArray.
docstr: Test the conversion of a DataArray to a CF-compatible DataArray.
docstr_tok: ["Test","the","conversion","of","a","DataArray","to","a","CF-compatible","DataArray","."]
code: def test_make_cf_dataarray(self):
      """Test the conversion of a DataArray to a CF-compatible DataArray."""
      from satpy.cf.data_array import make_cf_data_array
      from satpy.tests.cf_tests._test_data import get_test_attrs
      from satpy.tests.utils import assert_dict_array_equality
  
      # Create set of test attributes
      attrs, attrs_expected, attrs_expected_flat = get_test_attrs()
      attrs["area"] = "some_area"
      attrs["prerequisites"] = [make_dsq(name="hej")]
      attrs["_satpy_id_name"] = "myname"
  
      # Adjust expected attributes
      expected_prereq = "DataQuery(name='hej')"
      update = {
          "prerequisites": [expected_prereq],
          "long_name": attrs["name"],
      }
  
      attrs_expected.update(update)
      attrs_expected_flat.update(update)
  
      attrs_expected.pop("name")
      attrs_expected_flat.pop("name")
  
      # Create test data array
      arr = xr.DataArray(
          np.array([[1, 2], [3, 4]]),
          attrs=attrs,
          dims=("y", "x"),
          coords={"y": [0, 1], "x": [1, 2], "acq_time": ("y", [3, 4])},
      )
  
      # Test conversion to something cf-compliant
      res = make_cf_data_array(arr)
      np.testing.assert_array_equal(res["x"], arr["x"])
      np.testing.assert_array_equal(res["y"], arr["y"])
      np.testing.assert_array_equal(res["acq_time"], arr["acq_time"])
      assert res["x"].attrs == {
          "units": "m",
          "standard_name": "projection_x_coordinate",
      }
      assert res["y"].attrs == {
          "units": "m",
          "standard_name": "projection_y_coordinate",
      }
      assert_dict_array_equality(res.attrs, attrs_expected)
  
      # Test attribute kwargs
      res_flat = make_cf_data_array(
          arr, flatten_attrs=True, exclude_attrs=["int"]
      )
      attrs_expected_flat.pop("int")
      assert_dict_array_equality(res_flat.attrs, attrs_expected_flat)
  
file_path: satpy/satpy/tests/cf_tests/test_dataaarray.py
imports: import numpy
  import xarray
  from satpy.tests.utils import make_dsq
label_desc: Use image node_id 1 for calling the TestCfDataArray obj's underlying member method code with example usage: obj.test_make_cf_dataarray() without return types