We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
ICARTT formatting error when using cleanup
When I read in an ICARTT file and then try and run obj.clean.cleanup() to get it to CF standards, it throws the following error.  We should look at making the object compliant with what's needed for this cleanup.

```
Traceback (most recent call last):
  File "/Users/atheisen/opt/anaconda3/lib/python3.8/site-packages/xarray/core/dataset.py", line 1395, in _construct_dataarray
    variable = self._variables[name]
KeyError: 'flag'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "plot_icartt.py", line 22, in <module>
    ds.clean.cleanup()
  File "/Users/atheisen/Code/ACT/act/qc/clean.py", line 151, in cleanup
    self._obj.clean.link_variables()
  File "/Users/atheisen/Code/ACT/act/qc/clean.py", line 583, in link_variables
    self._obj[variable].attrs['ancillary_variables'] = copy.copy(ancillary_variables)
  File "/Users/atheisen/opt/anaconda3/lib/python3.8/site-packages/xarray/core/dataset.py", line 1499, in __getitem__
    return self._construct_dataarray(key)
  File "/Users/atheisen/opt/anaconda3/lib/python3.8/site-packages/xarray/core/dataset.py", line 1397, in _construct_dataarray
    _, name, variable = _get_virtual_variable(
  File "/Users/atheisen/opt/anaconda3/lib/python3.8/site-packages/xarray/core/dataset.py", line 170, in _get_virtual_variable
    ref_var = variables[ref_name]
KeyError: 'flag'
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `act/io/icartt.py`
Content:
```
1 """
2 Modules for Reading/Writing the International Consortium for Atmospheric
3 Research on Transport and Transformation (ICARTT) file format standards V2.0
4 
5 References:
6     ICARTT V2.0 Standards/Conventions:
7     - https://www.earthdata.nasa.gov/s3fs-public/imported/ESDS-RFC-029v2.pdf
8 
9 """
10 import numpy as np
11 import xarray as xr
12 
13 try:
14     import icartt
15     _ICARTT_AVAILABLE = True
16     _format = icartt.Formats.FFI1001
17 except ImportError:
18     _ICARTT_AVAILABLE = False
19     _format = None
20 
21 
22 def read_icartt(filename, format=_format,
23                 return_None=False, **kwargs):
24     """
25 
26     Returns `xarray.Dataset` with stored data and metadata from a user-defined
27     query of ICARTT from a single datastream. Has some procedures to ensure
28     time is correctly fomatted in returned Dataset.
29 
30     Parameters
31     ----------
32     filename : str
33         Name of file to read.
34     format : str
35         ICARTT Format to Read: FFI1001 or FFI2110.
36     return_None : bool, optional
37         Catch IOError exception when file not found and return None.
38         Default is False.
39     **kwargs : keywords
40         keywords to pass on through to icartt.Dataset.
41 
42     Returns
43     -------
44     act_obj : Object (or None)
45         ACT dataset (or None if no data file(s) found).
46 
47     Examples
48     --------
49     This example will load the example sounding data used for unit testing.
50 
51     .. code-block :: python
52 
53         import act
54         the_ds = act.io.icartt.read_icartt(act.tests.sample_files.AAF_SAMPLE_FILE)
55         print(the_ds.attrs['_datastream'])
56 
57     """
58     if not _ICARTT_AVAILABLE:
59         raise ImportError(
60             "ICARTT is required to use to read ICARTT files but is " +
61             "not installed")
62 
63     ds = None
64 
65     # Create an exception tuple to use with try statements. Doing it this way
66     # so we can add the FileNotFoundError if requested. Can add more error
67     # handling in the future.
68     except_tuple = (ValueError,)
69     if return_None:
70         except_tuple = except_tuple + (FileNotFoundError, OSError)
71 
72     try:
73         # Read data file with ICARTT dataset.
74         ict = icartt.Dataset(filename, format=format, **kwargs)
75 
76     except except_tuple as exception:
77         # If requested return None for File not found error
78         if type(exception).__name__ == 'FileNotFoundError':
79             return None
80 
81         # If requested return None for File not found error
82         if (type(exception).__name__ == 'OSError'
83                 and exception.args[0] == 'no files to open'):
84             return None
85 
86     # Define the Uncertainty for each variable. Note it may not be calculated.
87     # If not calculated, assign 'N/A' to the attribute
88     uncertainty = ict.normalComments[6].split(':')[1].split(',')
89 
90     # Define the Upper and Lower Limit of Detection Flags
91     ulod_flag = ict.normalComments[7].split(':')[1]
92     ulod_value = ict.normalComments[8].split(':')[1].split(',')
93     llod_flag = ict.normalComments[9].split(':')[1]
94     llod_value = ict.normalComments[10].split(':')[1].split(',')
95 
96     # Convert ICARTT Object to Xarray Dataset
97     ds_container = []
98     # Counter for uncertainty/LOD values
99     counter = 0
100 
101     # Loop over ICART variables, convert to Xarray DataArray, Append.
102     for key in ict.variables:
103         # Note time is the only independent variable within ICARTT
104         # Short name for time must be "Start_UTC" for ICARTT files.
105         if key != 'Start_UTC':
106             da = xr.DataArray(ict.data[key],
107                               coords=dict(time=ict.times),
108                               name=key, dims=['time'])
109             # Assume if Uncertainity does not match the number of variables,
110             # values were not set within the file. Needs to be string!
111             if len(uncertainty) != len(ict.variables):
112                 da.attrs['uncertainty'] = 'N/A'
113             else:
114                 da.attrs['uncertainty'] = uncertainty[counter]
115 
116             # Assume if ULOD does not match the number of variables within the
117             # the file, ULOD values were not set.
118             if len(ulod_value) != len(ict.variables):
119                 da.attrs['ULOD_Value'] = 'N/A'
120             else:
121                 da.attrs['ULOD_Value'] = ulod_value[counter]
122 
123             # Assume if LLOD does not match the number of variables within the
124             # the file, LLOD values were not set.
125             if len(llod_value) != len(ict.variables):
126                 da.attrs['LLOD_Value'] = 'N/A'
127             else:
128                 da.attrs['LLOD_Value'] = llod_value[counter]
129             # Define the meta data:
130             da.attrs['units'] = ict.variables[key].units
131             da.attrs['mvc'] = ict.variables[key].miss
132             da.attrs['scale_factor'] = ict.variables[key].scale
133             da.attrs['ULOD_Flag'] = ulod_flag
134             da.attrs['LLOD_Flag'] = llod_flag
135             # Append to ds container
136             ds_container.append(da.to_dataset(name=key))
137             # up the counter
138             counter += 1
139 
140     # Concatenate each of the Xarray DataArrays into a single Xarray DataSet
141     ds = xr.merge(ds_container)
142 
143     # Assign ICARTT Meta data to Xarray DataSet
144     ds.attrs['PI'] = ict.PIName
145     ds.attrs['PI_Affiliation'] = ict.PIAffiliation
146     ds.attrs['Platform'] = ict.dataSourceDescription
147     ds.attrs['Mission'] = ict.missionName
148     ds.attrs['DateOfCollection'] = ict.dateOfCollection
149     ds.attrs['DateOfRevision'] = ict.dateOfRevision
150     ds.attrs['Data_Interval'] = ict.dataIntervalCode
151     ds.attrs['Independent_Var'] = str(ict.independentVariable)
152     ds.attrs['Dependent_Var_Num'] = len(ict.dependentVariables)
153     ds.attrs['PI_Contact'] = ict.normalComments[0].split('\n')[0].split(':')[-1]
154     ds.attrs['Platform'] = ict.normalComments[1].split(':')[-1]
155     ds.attrs['Location'] = ict.normalComments[2].split(':')[-1]
156     ds.attrs['Associated_Data'] = ict.normalComments[3].split(':')[-1]
157     ds.attrs['Instrument_Info'] = ict.normalComments[4].split(':')[-1]
158     ds.attrs['Data_Info'] = ict.normalComments[5][11:]
159     ds.attrs['DM_Contact'] = ict.normalComments[11].split(':')[-1]
160     ds.attrs['Project_Info'] = ict.normalComments[12].split(':')[-1]
161     ds.attrs['Stipulations'] = ict.normalComments[13].split(':')[-1]
162     ds.attrs['Comments'] = ict.normalComments[14].split(':')[-1]
163     ds.attrs['Revision'] = ict.normalComments[15].split(':')[-1]
164     ds.attrs['Revision_Comments'] = ict.normalComments[15 + 1].split(':')[-1]
165 
166     # Assign Additional ARM meta data to Xarray DatatSet
167     ds.attrs['_datastream'] = filename.split('/')[-1].split('_')[0]
168 
169     # Return Xarray Dataset
170     return ds
171
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/act/io/icartt.py b/act/io/icartt.py
--- a/act/io/icartt.py
+++ b/act/io/icartt.py
@@ -103,9 +103,13 @@
         # Note time is the only independent variable within ICARTT
         # Short name for time must be "Start_UTC" for ICARTT files.
         if key != 'Start_UTC':
+            if key == 'qc_flag':
+                key2 = 'quality_flag'
+            else:
+                key2 = key
             da = xr.DataArray(ict.data[key],
                               coords=dict(time=ict.times),
-                              name=key, dims=['time'])
+                              name=key2, dims=['time'])
             # Assume if Uncertainity does not match the number of variables,
             # values were not set within the file. Needs to be string!
             if len(uncertainty) != len(ict.variables):
@@ -133,7 +137,7 @@
             da.attrs['ULOD_Flag'] = ulod_flag
             da.attrs['LLOD_Flag'] = llod_flag
             # Append to ds container
-            ds_container.append(da.to_dataset(name=key))
+            ds_container.append(da.to_dataset(name=key2))
             # up the counter
             counter += 1

{"golden_diff": "diff --git a/act/io/icartt.py b/act/io/icartt.py\n--- a/act/io/icartt.py\n+++ b/act/io/icartt.py\n@@ -103,9 +103,13 @@\n         # Note time is the only independent variable within ICARTT\n         # Short name for time must be \"Start_UTC\" for ICARTT files.\n         if key != 'Start_UTC':\n+            if key == 'qc_flag':\n+                key2 = 'quality_flag'\n+            else:\n+                key2 = key\n             da = xr.DataArray(ict.data[key],\n                               coords=dict(time=ict.times),\n-                              name=key, dims=['time'])\n+                              name=key2, dims=['time'])\n             # Assume if Uncertainity does not match the number of variables,\n             # values were not set within the file. Needs to be string!\n             if len(uncertainty) != len(ict.variables):\n@@ -133,7 +137,7 @@\n             da.attrs['ULOD_Flag'] = ulod_flag\n             da.attrs['LLOD_Flag'] = llod_flag\n             # Append to ds container\n-            ds_container.append(da.to_dataset(name=key))\n+            ds_container.append(da.to_dataset(name=key2))\n             # up the counter\n             counter += 1\n", "issue": "ICARTT formatting error when using cleanup\nWhen I read in an ICARTT file and then try and run obj.clean.cleanup() to get it to CF standards, it throws the following error.  We should look at making the object compliant with what's needed for this cleanup.\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/Users/atheisen/opt/anaconda3/lib/python3.8/site-packages/xarray/core/dataset.py\", line 1395, in _construct_dataarray\r\n    variable = self._variables[name]\r\nKeyError: 'flag'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"plot_icartt.py\", line 22, in <module>\r\n    ds.clean.cleanup()\r\n  File \"/Users/atheisen/Code/ACT/act/qc/clean.py\", line 151, in cleanup\r\n    self._obj.clean.link_variables()\r\n  File \"/Users/atheisen/Code/ACT/act/qc/clean.py\", line 583, in link_variables\r\n    self._obj[variable].attrs['ancillary_variables'] = copy.copy(ancillary_variables)\r\n  File \"/Users/atheisen/opt/anaconda3/lib/python3.8/site-packages/xarray/core/dataset.py\", line 1499, in __getitem__\r\n    return self._construct_dataarray(key)\r\n  File \"/Users/atheisen/opt/anaconda3/lib/python3.8/site-packages/xarray/core/dataset.py\", line 1397, in _construct_dataarray\r\n    _, name, variable = _get_virtual_variable(\r\n  File \"/Users/atheisen/opt/anaconda3/lib/python3.8/site-packages/xarray/core/dataset.py\", line 170, in _get_virtual_variable\r\n    ref_var = variables[ref_name]\r\nKeyError: 'flag'\r\n```\n", "before_files": [{"content": "\"\"\"\nModules for Reading/Writing the International Consortium for Atmospheric\nResearch on Transport and Transformation (ICARTT) file format standards V2.0\n\nReferences:\n    ICARTT V2.0 Standards/Conventions:\n    - https://www.earthdata.nasa.gov/s3fs-public/imported/ESDS-RFC-029v2.pdf\n\n\"\"\"\nimport numpy as np\nimport xarray as xr\n\ntry:\n    import icartt\n    _ICARTT_AVAILABLE = True\n    _format = icartt.Formats.FFI1001\nexcept ImportError:\n    _ICARTT_AVAILABLE = False\n    _format = None\n\n\ndef read_icartt(filename, format=_format,\n                return_None=False, **kwargs):\n    \"\"\"\n\n    Returns `xarray.Dataset` with stored data and metadata from a user-defined\n    query of ICARTT from a single datastream. Has some procedures to ensure\n    time is correctly fomatted in returned Dataset.\n\n    Parameters\n    ----------\n    filename : str\n        Name of file to read.\n    format : str\n        ICARTT Format to Read: FFI1001 or FFI2110.\n    return_None : bool, optional\n        Catch IOError exception when file not found and return None.\n        Default is False.\n    **kwargs : keywords\n        keywords to pass on through to icartt.Dataset.\n\n    Returns\n    -------\n    act_obj : Object (or None)\n        ACT dataset (or None if no data file(s) found).\n\n    Examples\n    --------\n    This example will load the example sounding data used for unit testing.\n\n    .. code-block :: python\n\n        import act\n        the_ds = act.io.icartt.read_icartt(act.tests.sample_files.AAF_SAMPLE_FILE)\n        print(the_ds.attrs['_datastream'])\n\n    \"\"\"\n    if not _ICARTT_AVAILABLE:\n        raise ImportError(\n            \"ICARTT is required to use to read ICARTT files but is \" +\n            \"not installed\")\n\n    ds = None\n\n    # Create an exception tuple to use with try statements. Doing it this way\n    # so we can add the FileNotFoundError if requested. Can add more error\n    # handling in the future.\n    except_tuple = (ValueError,)\n    if return_None:\n        except_tuple = except_tuple + (FileNotFoundError, OSError)\n\n    try:\n        # Read data file with ICARTT dataset.\n        ict = icartt.Dataset(filename, format=format, **kwargs)\n\n    except except_tuple as exception:\n        # If requested return None for File not found error\n        if type(exception).__name__ == 'FileNotFoundError':\n            return None\n\n        # If requested return None for File not found error\n        if (type(exception).__name__ == 'OSError'\n                and exception.args[0] == 'no files to open'):\n            return None\n\n    # Define the Uncertainty for each variable. Note it may not be calculated.\n    # If not calculated, assign 'N/A' to the attribute\n    uncertainty = ict.normalComments[6].split(':')[1].split(',')\n\n    # Define the Upper and Lower Limit of Detection Flags\n    ulod_flag = ict.normalComments[7].split(':')[1]\n    ulod_value = ict.normalComments[8].split(':')[1].split(',')\n    llod_flag = ict.normalComments[9].split(':')[1]\n    llod_value = ict.normalComments[10].split(':')[1].split(',')\n\n    # Convert ICARTT Object to Xarray Dataset\n    ds_container = []\n    # Counter for uncertainty/LOD values\n    counter = 0\n\n    # Loop over ICART variables, convert to Xarray DataArray, Append.\n    for key in ict.variables:\n        # Note time is the only independent variable within ICARTT\n        # Short name for time must be \"Start_UTC\" for ICARTT files.\n        if key != 'Start_UTC':\n            da = xr.DataArray(ict.data[key],\n                              coords=dict(time=ict.times),\n                              name=key, dims=['time'])\n            # Assume if Uncertainity does not match the number of variables,\n            # values were not set within the file. Needs to be string!\n            if len(uncertainty) != len(ict.variables):\n                da.attrs['uncertainty'] = 'N/A'\n            else:\n                da.attrs['uncertainty'] = uncertainty[counter]\n\n            # Assume if ULOD does not match the number of variables within the\n            # the file, ULOD values were not set.\n            if len(ulod_value) != len(ict.variables):\n                da.attrs['ULOD_Value'] = 'N/A'\n            else:\n                da.attrs['ULOD_Value'] = ulod_value[counter]\n\n            # Assume if LLOD does not match the number of variables within the\n            # the file, LLOD values were not set.\n            if len(llod_value) != len(ict.variables):\n                da.attrs['LLOD_Value'] = 'N/A'\n            else:\n                da.attrs['LLOD_Value'] = llod_value[counter]\n            # Define the meta data:\n            da.attrs['units'] = ict.variables[key].units\n            da.attrs['mvc'] = ict.variables[key].miss\n            da.attrs['scale_factor'] = ict.variables[key].scale\n            da.attrs['ULOD_Flag'] = ulod_flag\n            da.attrs['LLOD_Flag'] = llod_flag\n            # Append to ds container\n            ds_container.append(da.to_dataset(name=key))\n            # up the counter\n            counter += 1\n\n    # Concatenate each of the Xarray DataArrays into a single Xarray DataSet\n    ds = xr.merge(ds_container)\n\n    # Assign ICARTT Meta data to Xarray DataSet\n    ds.attrs['PI'] = ict.PIName\n    ds.attrs['PI_Affiliation'] = ict.PIAffiliation\n    ds.attrs['Platform'] = ict.dataSourceDescription\n    ds.attrs['Mission'] = ict.missionName\n    ds.attrs['DateOfCollection'] = ict.dateOfCollection\n    ds.attrs['DateOfRevision'] = ict.dateOfRevision\n    ds.attrs['Data_Interval'] = ict.dataIntervalCode\n    ds.attrs['Independent_Var'] = str(ict.independentVariable)\n    ds.attrs['Dependent_Var_Num'] = len(ict.dependentVariables)\n    ds.attrs['PI_Contact'] = ict.normalComments[0].split('\\n')[0].split(':')[-1]\n    ds.attrs['Platform'] = ict.normalComments[1].split(':')[-1]\n    ds.attrs['Location'] = ict.normalComments[2].split(':')[-1]\n    ds.attrs['Associated_Data'] = ict.normalComments[3].split(':')[-1]\n    ds.attrs['Instrument_Info'] = ict.normalComments[4].split(':')[-1]\n    ds.attrs['Data_Info'] = ict.normalComments[5][11:]\n    ds.attrs['DM_Contact'] = ict.normalComments[11].split(':')[-1]\n    ds.attrs['Project_Info'] = ict.normalComments[12].split(':')[-1]\n    ds.attrs['Stipulations'] = ict.normalComments[13].split(':')[-1]\n    ds.attrs['Comments'] = ict.normalComments[14].split(':')[-1]\n    ds.attrs['Revision'] = ict.normalComments[15].split(':')[-1]\n    ds.attrs['Revision_Comments'] = ict.normalComments[15 + 1].split(':')[-1]\n\n    # Assign Additional ARM meta data to Xarray DatatSet\n    ds.attrs['_datastream'] = filename.split('/')[-1].split('_')[0]\n\n    # Return Xarray Dataset\n    return ds\n", "path": "act/io/icartt.py"}], "after_files": [{"content": "\"\"\"\nModules for Reading/Writing the International Consortium for Atmospheric\nResearch on Transport and Transformation (ICARTT) file format standards V2.0\n\nReferences:\n    ICARTT V2.0 Standards/Conventions:\n    - https://www.earthdata.nasa.gov/s3fs-public/imported/ESDS-RFC-029v2.pdf\n\n\"\"\"\nimport numpy as np\nimport xarray as xr\n\ntry:\n    import icartt\n    _ICARTT_AVAILABLE = True\n    _format = icartt.Formats.FFI1001\nexcept ImportError:\n    _ICARTT_AVAILABLE = False\n    _format = None\n\n\ndef read_icartt(filename, format=_format,\n                return_None=False, **kwargs):\n    \"\"\"\n\n    Returns `xarray.Dataset` with stored data and metadata from a user-defined\n    query of ICARTT from a single datastream. Has some procedures to ensure\n    time is correctly fomatted in returned Dataset.\n\n    Parameters\n    ----------\n    filename : str\n        Name of file to read.\n    format : str\n        ICARTT Format to Read: FFI1001 or FFI2110.\n    return_None : bool, optional\n        Catch IOError exception when file not found and return None.\n        Default is False.\n    **kwargs : keywords\n        keywords to pass on through to icartt.Dataset.\n\n    Returns\n    -------\n    act_obj : Object (or None)\n        ACT dataset (or None if no data file(s) found).\n\n    Examples\n    --------\n    This example will load the example sounding data used for unit testing.\n\n    .. code-block :: python\n\n        import act\n        the_ds = act.io.icartt.read_icartt(act.tests.sample_files.AAF_SAMPLE_FILE)\n        print(the_ds.attrs['_datastream'])\n\n    \"\"\"\n    if not _ICARTT_AVAILABLE:\n        raise ImportError(\n            \"ICARTT is required to use to read ICARTT files but is \" +\n            \"not installed\")\n\n    ds = None\n\n    # Create an exception tuple to use with try statements. Doing it this way\n    # so we can add the FileNotFoundError if requested. Can add more error\n    # handling in the future.\n    except_tuple = (ValueError,)\n    if return_None:\n        except_tuple = except_tuple + (FileNotFoundError, OSError)\n\n    try:\n        # Read data file with ICARTT dataset.\n        ict = icartt.Dataset(filename, format=format, **kwargs)\n\n    except except_tuple as exception:\n        # If requested return None for File not found error\n        if type(exception).__name__ == 'FileNotFoundError':\n            return None\n\n        # If requested return None for File not found error\n        if (type(exception).__name__ == 'OSError'\n                and exception.args[0] == 'no files to open'):\n            return None\n\n    # Define the Uncertainty for each variable. Note it may not be calculated.\n    # If not calculated, assign 'N/A' to the attribute\n    uncertainty = ict.normalComments[6].split(':')[1].split(',')\n\n    # Define the Upper and Lower Limit of Detection Flags\n    ulod_flag = ict.normalComments[7].split(':')[1]\n    ulod_value = ict.normalComments[8].split(':')[1].split(',')\n    llod_flag = ict.normalComments[9].split(':')[1]\n    llod_value = ict.normalComments[10].split(':')[1].split(',')\n\n    # Convert ICARTT Object to Xarray Dataset\n    ds_container = []\n    # Counter for uncertainty/LOD values\n    counter = 0\n\n    # Loop over ICART variables, convert to Xarray DataArray, Append.\n    for key in ict.variables:\n        # Note time is the only independent variable within ICARTT\n        # Short name for time must be \"Start_UTC\" for ICARTT files.\n        if key != 'Start_UTC':\n            if key == 'qc_flag':\n                key2 = 'quality_flag'\n            else:\n                key2 = key\n            da = xr.DataArray(ict.data[key],\n                              coords=dict(time=ict.times),\n                              name=key2, dims=['time'])\n            # Assume if Uncertainity does not match the number of variables,\n            # values were not set within the file. Needs to be string!\n            if len(uncertainty) != len(ict.variables):\n                da.attrs['uncertainty'] = 'N/A'\n            else:\n                da.attrs['uncertainty'] = uncertainty[counter]\n\n            # Assume if ULOD does not match the number of variables within the\n            # the file, ULOD values were not set.\n            if len(ulod_value) != len(ict.variables):\n                da.attrs['ULOD_Value'] = 'N/A'\n            else:\n                da.attrs['ULOD_Value'] = ulod_value[counter]\n\n            # Assume if LLOD does not match the number of variables within the\n            # the file, LLOD values were not set.\n            if len(llod_value) != len(ict.variables):\n                da.attrs['LLOD_Value'] = 'N/A'\n            else:\n                da.attrs['LLOD_Value'] = llod_value[counter]\n            # Define the meta data:\n            da.attrs['units'] = ict.variables[key].units\n            da.attrs['mvc'] = ict.variables[key].miss\n            da.attrs['scale_factor'] = ict.variables[key].scale\n            da.attrs['ULOD_Flag'] = ulod_flag\n            da.attrs['LLOD_Flag'] = llod_flag\n            # Append to ds container\n            ds_container.append(da.to_dataset(name=key2))\n            # up the counter\n            counter += 1\n\n    # Concatenate each of the Xarray DataArrays into a single Xarray DataSet\n    ds = xr.merge(ds_container)\n\n    # Assign ICARTT Meta data to Xarray DataSet\n    ds.attrs['PI'] = ict.PIName\n    ds.attrs['PI_Affiliation'] = ict.PIAffiliation\n    ds.attrs['Platform'] = ict.dataSourceDescription\n    ds.attrs['Mission'] = ict.missionName\n    ds.attrs['DateOfCollection'] = ict.dateOfCollection\n    ds.attrs['DateOfRevision'] = ict.dateOfRevision\n    ds.attrs['Data_Interval'] = ict.dataIntervalCode\n    ds.attrs['Independent_Var'] = str(ict.independentVariable)\n    ds.attrs['Dependent_Var_Num'] = len(ict.dependentVariables)\n    ds.attrs['PI_Contact'] = ict.normalComments[0].split('\\n')[0].split(':')[-1]\n    ds.attrs['Platform'] = ict.normalComments[1].split(':')[-1]\n    ds.attrs['Location'] = ict.normalComments[2].split(':')[-1]\n    ds.attrs['Associated_Data'] = ict.normalComments[3].split(':')[-1]\n    ds.attrs['Instrument_Info'] = ict.normalComments[4].split(':')[-1]\n    ds.attrs['Data_Info'] = ict.normalComments[5][11:]\n    ds.attrs['DM_Contact'] = ict.normalComments[11].split(':')[-1]\n    ds.attrs['Project_Info'] = ict.normalComments[12].split(':')[-1]\n    ds.attrs['Stipulations'] = ict.normalComments[13].split(':')[-1]\n    ds.attrs['Comments'] = ict.normalComments[14].split(':')[-1]\n    ds.attrs['Revision'] = ict.normalComments[15].split(':')[-1]\n    ds.attrs['Revision_Comments'] = ict.normalComments[15 + 1].split(':')[-1]\n\n    # Assign Additional ARM meta data to Xarray DatatSet\n    ds.attrs['_datastream'] = filename.split('/')[-1].split('_')[0]\n\n    # Return Xarray Dataset\n    return ds\n", "path": "act/io/icartt.py"}]}