class_docstr: Test case for collect_cf_dataset.
class_docstr_tok: ["Test","case","for","collect_cf_dataset","."]
docstr: Test collecting CF datasets from a DataArray objects.
docstr_tok: ["Test","collecting","CF","datasets","from","a","DataArray","objects","."]
code: def test_collect_cf_dataset(self):
      """Test collecting CF datasets from a DataArray objects."""
      from satpy.cf.datasets import _collect_cf_dataset
  
      geos = AreaDefinition(
          area_id="geos",
          description="geos",
          proj_id="geos",
          projection={
              "proj": "geos",
              "h": 35785831.0,
              "a": 6378169.0,
              "b": 6356583.8,
          },
          width=2,
          height=2,
          area_extent=[-1, -1, 1, 1],
      )
  
      # Define test datasets
      data = [[1, 2], [3, 4]]
      y = [1, 2]
      x = [1, 2]
      time = [1, 2]
      tstart = datetime.datetime(2019, 4, 1, 12, 0)
      tend = datetime.datetime(2019, 4, 1, 12, 15)
      list_dataarrays = [
          xr.DataArray(
              data=data,
              dims=("y", "x"),
              coords={"y": y, "x": x, "acq_time": ("y", time)},
              attrs={
                  "name": "var1",
                  "start_time": tstart,
                  "end_time": tend,
                  "area": geos,
              },
          ),
          xr.DataArray(
              data=data,
              dims=("y", "x"),
              coords={"y": y, "x": x, "acq_time": ("y", time)},
              attrs={"name": "var2", "long_name": "variable 2"},
          ),
      ]
  
      # Collect datasets
      ds = _collect_cf_dataset(
          list_dataarrays,
          include_lonlats=True,
      )
  
      # Test results
      assert len(ds.keys()) == 3
      assert set(ds.keys()) == {"var1", "var2", "geos"}
  
      da_var1 = ds["var1"]
      da_var2 = ds["var2"]
      assert da_var1.name == "var1"
      assert da_var1.attrs["grid_mapping"] == "geos"
      assert da_var1.attrs["long_name"] == "var1"
      # variable 2
      assert "grid_mapping" not in da_var2.attrs
      assert da_var2.attrs["long_name"] == "variable 2"
  
file_path: satpy/satpy/tests/cf_tests/test_datasets.py
imports: import datetime
  import numpy
  import pytest
  import xarray
  from pyresample import AreaDefinition, create_area_def
label_desc: Use image node_id 1 for calling the TestCollectCfDataset obj's underlying member method code with example usage: obj.test_collect_cf_dataset() without return types