Repository: ARM-DOE/ACT

Issue:
ARM Data API Returns Text when File not Available 
I tried to download gucceilpblhtM1.a0 but it's not available through the webservice due to it being an a0-level file.  Instead the API returned text that was included in the file.  We should put in a check to ensure that these cases are caught and files are not produced.

```
This data file is not available on /data/archive.  To download this file, please an order via Data Discovery. https://adc.arm.gov/discovery
```


Discussion:
@AdamTheisen So files produced, so you want this instead to catch the warning, warn the user and just return from the function without writing anything?
@zssherman yes, if the data are not available, we wouldn't want to write the files and would instead return the message as an error.  Right now, it just gives the false sense that it's downloading files
Gotcha sounds good
@AdamTheisen So for the datetime i chose for that dataset it returned 2 netcdf files. Are these the files you mentioned? I did not get that message though or is the message in these files?
Nvm yep found it!

Resolving patch:
diff --git a/act/discovery/get_armfiles.py b/act/discovery/get_armfiles.py
--- a/act/discovery/get_armfiles.py
+++ b/act/discovery/get_armfiles.py
@@ -143,7 +143,6 @@ def download_data(username, token, datastream, startdate, enddate, time=None, ou
             if time is not None:
                 if time not in fname:
                     continue
-            print(f'[DOWNLOADING] {fname}')
             # construct link to web service saveData function
             save_data_url = (
                 'https://adc.arm.gov/armlive/livedata/' + 'saveData?user={0}&file={1}'
@@ -154,7 +153,13 @@ def download_data(username, token, datastream, startdate, enddate, time=None, ou
                 os.makedirs(output_dir)
             # create file and write bytes to file
             with open(output_file, 'wb') as open_bytes_file:
-                open_bytes_file.write(urlopen(save_data_url).read())
+                data = urlopen(save_data_url).read()
+                if 'This data file is not available' in str(data):
+                    print(fname + ' is not available for download')
+                    continue
+                else:
+                    print(f'[DOWNLOADING] {fname}')
+                    open_bytes_file.write(data)
             file_names.append(output_file)
     else:
         print(
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 @@ def read_icartt(filename, format=_format,
         # 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 @@ def read_icartt(filename, format=_format,
             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
 


Test patch: