We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Valid Min in act.utils.decode_present_weather
* ACT version: 1.3.4
* Python version:3.9.15
* Operating System: Windows 10

### Description

I am receiving an error for "del data.attrs['valid_min'] when reading in data trying to decode present weather data. 

### What I Did

```
act.utils.decode_present_weather(ds_fd70,'present_wx2',precip_codes)
decode_present_weather
    del data.attrs['valid_min']

KeyError: 'valid_min'

When outputting time I have:
ds_fd70.time

array(['2023-03-09T16:45:00.000000000', '2023-03-09T17:00:00.000000000',
       '2023-03-09T17:15:00.000000000', '2023-03-09T17:30:00.000000000',
       '2023-03-09T17:45:00.000000000', '2023-03-09T18:00:00.000000000',
       '2023-03-09T18:15:00.000000000', '2023-03-09T18:30:00.000000000',
       '2023-03-09T18:45:00.000000000', '2023-03-09T19:00:00.000000000',
       '2023-03-09T19:15:00.000000000', '2023-03-09T19:30:00.000000000',
```


--- 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/utils/inst_utils.py`
Content:
```
1 """
2 Functions containing utilities for instruments.
3 
4 """
5 
6 
7 def decode_present_weather(ds, variable=None, decoded_name=None):
8     """
9     This function is to decode codes reported from automatic weather stations suchas the PWD22.
10     This is based on WMO Table 4680.
11 
12     Parameters
13     ----------
14     ds : xarray.Dataset
15         ACT or Xarray dataset from which to convert codes
16     variable : string
17         Variable to decode
18     decoded_name : string
19         New variable name to store updated labels
20 
21     Returns
22     -------
23     ds : xarray.Dataset
24         Returns dataset with new decoded data
25 
26     References
27     ----------
28     WMO Manual on Code Volume I.1
29     https://www.wmo.int/pages/prog/www/WMOCodes/WMO306_vI1/Publications/2017update/Sel9.pdf
30 
31     """
32 
33     # Check to ensure that a variable name is passed
34     if variable is None:
35         raise ValueError('You must specify a variable')
36 
37     if variable not in ds:
38         raise ValueError('Variable not in the dataset')
39 
40     # Define the weather hash
41     weather = {
42         0: 'No significant weather observed',
43         1: 'Clouds generally dissolving or becoming less developed during the past hour',
44         2: 'State of the sky on the whole unchanged during the past hour',
45         3: 'Clouds generally forming or developing during the past hour',
46         4: 'Haze or smoke, or dust in suspension in the air, visibility >= 1 km',
47         5: 'Haze or smoke, or dust in suspension in the air, visibility < 1 km',
48         10: 'Mist',
49         11: 'Diamond dust',
50         12: 'Distant lightning',
51         18: 'Squalls',
52         20: 'Fog',
53         21: 'Precipitation',
54         22: 'Drizzle (not freezing) or snow grains',
55         23: 'Rain (not freezing)',
56         24: 'Snow',
57         25: 'Freezing drizzle or freezing rain',
58         26: 'Thunderstorm (with or without precipitation)',
59         27: 'Blowing or drifting snow or sand',
60         28: 'Blowing or drifting snow or sand, visibility >= 1 km',
61         29: 'Blowing or drifting snow or sand, visibility < 1 km',
62         30: 'Fog',
63         31: 'Fog or ice fog in patches',
64         32: 'Fog or ice fog, has become thinner during the past hour',
65         33: 'Fog or ice fog, no appreciable change during the past hour',
66         34: 'Fog or ice fog, has begun or become thicker during the past hour',
67         35: 'Fog, depositing rime',
68         40: 'Precipitation',
69         41: 'Precipitation, slight or moderate',
70         42: 'Precipitation, heavy',
71         43: 'Liquid precipitation, slight or moderate',
72         44: 'Liquid precipitation, heavy',
73         45: 'Solid precipitation, slight or moderate',
74         46: 'Solid precipitation, heavy',
75         47: 'Freezing precipitation, slight or moderate',
76         48: 'Freezing precipitation, heavy',
77         50: 'Drizzle',
78         51: 'Drizzle, not freezing, slight',
79         52: 'Drizzle, not freezing, moderate',
80         53: 'Drizzle, not freezing, heavy',
81         54: 'Drizzle, freezing, slight',
82         55: 'Drizzle, freezing, moderate',
83         56: 'Drizzle, freezing, heavy',
84         57: 'Drizzle and rain, slight',
85         58: 'Drizzle and rain, moderate or heavy',
86         60: 'Rain',
87         61: 'Rain, not freezing, slight',
88         62: 'Rain, not freezing, moderate',
89         63: 'Rain, not freezing, heavy',
90         64: 'Rain, freezing, slight',
91         65: 'Rain, freezing, moderate',
92         66: 'Rain, freezing, heavy',
93         67: 'Rain (or drizzle) and snow, slight',
94         68: 'Rain (or drizzle) and snow, moderate or heavy',
95         70: 'Snow',
96         71: 'Snow, light',
97         72: 'Snow, moderate',
98         73: 'Snow, heavy',
99         74: 'Ice pellets, slight',
100         75: 'Ice pellets, moderate',
101         76: 'Ice pellets, heavy',
102         77: 'Snow grains',
103         78: 'Ice crystals',
104         80: 'Shower(s) or Intermittent Precipitation',
105         81: 'Rain shower(s) or intermittent rain, slight',
106         82: 'Rain shower(s) or intermittent rain, moderate',
107         83: 'Rain shower(s) or intermittent rain, heavy',
108         84: 'Rain shower(s) or intermittent rain, violent',
109         85: 'Snow shower(s) or intermittent snow, slight',
110         86: 'Snow shower(s) or intermittent snow, moderate',
111         87: 'Snow shower(s) or intermittent snow, heavy',
112         89: 'Hail',
113         90: 'Thunderstorm',
114         91: 'Thunderstorm, slight or moderate, with no precipitation',
115         92: 'Thunderstorm, slight or moderate, with rain showers and/or snow showers',
116         93: 'Thunderstorm, slight or moderate, with hail',
117         94: 'Thunderstorm, heavy, with no precipitation',
118         95: 'Thunderstorm, heavy, with rain showers and/or snow showers',
119         96: 'Thunderstorm, heavy, with hail',
120         99: 'Tornado',
121         -9999: 'Missing',
122     }
123 
124     # If a decoded name is not passed, make one
125     if decoded_name is None:
126         decoded_name = variable + '_decoded'
127 
128     # Get data and fill nans with -9999
129     data = ds[variable]
130     data = data.fillna(-9999)
131 
132     # Get the weather type for each code
133     wx_type = [weather[d] for d in data.values]
134 
135     # Massage the data array to set back in the dataset
136     data.values = wx_type
137     data.attrs['long_name'] = data.attrs['long_name'] + ' Decoded'
138     del data.attrs['valid_min']
139     del data.attrs['valid_max']
140 
141     ds[decoded_name] = data
142 
143     return ds
144
```
--- 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/utils/inst_utils.py b/act/utils/inst_utils.py
--- a/act/utils/inst_utils.py
+++ b/act/utils/inst_utils.py
@@ -134,9 +134,14 @@
 
     # Massage the data array to set back in the dataset
     data.values = wx_type
-    data.attrs['long_name'] = data.attrs['long_name'] + ' Decoded'
-    del data.attrs['valid_min']
-    del data.attrs['valid_max']
+    if 'long_name' in data.attrs:
+        data.attrs['long_name'] = data.attrs['long_name'] + ' Decoded'
+    else:
+        data.attrs['long_name'] = 'Decoded present weather values'
+    if 'valid_min' in data.attrs:
+        del data.attrs['valid_min']
+    if 'valid_max' in data.attrs:
+        del data.attrs['valid_max']
 
     ds[decoded_name] = data

{"golden_diff": "diff --git a/act/utils/inst_utils.py b/act/utils/inst_utils.py\n--- a/act/utils/inst_utils.py\n+++ b/act/utils/inst_utils.py\n@@ -134,9 +134,14 @@\n \n     # Massage the data array to set back in the dataset\n     data.values = wx_type\n-    data.attrs['long_name'] = data.attrs['long_name'] + ' Decoded'\n-    del data.attrs['valid_min']\n-    del data.attrs['valid_max']\n+    if 'long_name' in data.attrs:\n+        data.attrs['long_name'] = data.attrs['long_name'] + ' Decoded'\n+    else:\n+        data.attrs['long_name'] = 'Decoded present weather values'\n+    if 'valid_min' in data.attrs:\n+        del data.attrs['valid_min']\n+    if 'valid_max' in data.attrs:\n+        del data.attrs['valid_max']\n \n     ds[decoded_name] = data\n", "issue": "Valid Min in act.utils.decode_present_weather\n* ACT version: 1.3.4\r\n* Python version:3.9.15\r\n* Operating System: Windows 10\r\n\r\n### Description\r\n\r\nI am receiving an error for \"del data.attrs['valid_min'] when reading in data trying to decode present weather data. \r\n\r\n### What I Did\r\n\r\n```\r\nact.utils.decode_present_weather(ds_fd70,'present_wx2',precip_codes)\r\ndecode_present_weather\r\n    del data.attrs['valid_min']\r\n\r\nKeyError: 'valid_min'\r\n\r\nWhen outputting time I have:\r\nds_fd70.time\r\n\r\narray(['2023-03-09T16:45:00.000000000', '2023-03-09T17:00:00.000000000',\r\n       '2023-03-09T17:15:00.000000000', '2023-03-09T17:30:00.000000000',\r\n       '2023-03-09T17:45:00.000000000', '2023-03-09T18:00:00.000000000',\r\n       '2023-03-09T18:15:00.000000000', '2023-03-09T18:30:00.000000000',\r\n       '2023-03-09T18:45:00.000000000', '2023-03-09T19:00:00.000000000',\r\n       '2023-03-09T19:15:00.000000000', '2023-03-09T19:30:00.000000000',\r\n```\r\n\n", "before_files": [{"content": "\"\"\"\nFunctions containing utilities for instruments.\n\n\"\"\"\n\n\ndef decode_present_weather(ds, variable=None, decoded_name=None):\n    \"\"\"\n    This function is to decode codes reported from automatic weather stations suchas the PWD22.\n    This is based on WMO Table 4680.\n\n    Parameters\n    ----------\n    ds : xarray.Dataset\n        ACT or Xarray dataset from which to convert codes\n    variable : string\n        Variable to decode\n    decoded_name : string\n        New variable name to store updated labels\n\n    Returns\n    -------\n    ds : xarray.Dataset\n        Returns dataset with new decoded data\n\n    References\n    ----------\n    WMO Manual on Code Volume I.1\n    https://www.wmo.int/pages/prog/www/WMOCodes/WMO306_vI1/Publications/2017update/Sel9.pdf\n\n    \"\"\"\n\n    # Check to ensure that a variable name is passed\n    if variable is None:\n        raise ValueError('You must specify a variable')\n\n    if variable not in ds:\n        raise ValueError('Variable not in the dataset')\n\n    # Define the weather hash\n    weather = {\n        0: 'No significant weather observed',\n        1: 'Clouds generally dissolving or becoming less developed during the past hour',\n        2: 'State of the sky on the whole unchanged during the past hour',\n        3: 'Clouds generally forming or developing during the past hour',\n        4: 'Haze or smoke, or dust in suspension in the air, visibility >= 1 km',\n        5: 'Haze or smoke, or dust in suspension in the air, visibility < 1 km',\n        10: 'Mist',\n        11: 'Diamond dust',\n        12: 'Distant lightning',\n        18: 'Squalls',\n        20: 'Fog',\n        21: 'Precipitation',\n        22: 'Drizzle (not freezing) or snow grains',\n        23: 'Rain (not freezing)',\n        24: 'Snow',\n        25: 'Freezing drizzle or freezing rain',\n        26: 'Thunderstorm (with or without precipitation)',\n        27: 'Blowing or drifting snow or sand',\n        28: 'Blowing or drifting snow or sand, visibility >= 1 km',\n        29: 'Blowing or drifting snow or sand, visibility < 1 km',\n        30: 'Fog',\n        31: 'Fog or ice fog in patches',\n        32: 'Fog or ice fog, has become thinner during the past hour',\n        33: 'Fog or ice fog, no appreciable change during the past hour',\n        34: 'Fog or ice fog, has begun or become thicker during the past hour',\n        35: 'Fog, depositing rime',\n        40: 'Precipitation',\n        41: 'Precipitation, slight or moderate',\n        42: 'Precipitation, heavy',\n        43: 'Liquid precipitation, slight or moderate',\n        44: 'Liquid precipitation, heavy',\n        45: 'Solid precipitation, slight or moderate',\n        46: 'Solid precipitation, heavy',\n        47: 'Freezing precipitation, slight or moderate',\n        48: 'Freezing precipitation, heavy',\n        50: 'Drizzle',\n        51: 'Drizzle, not freezing, slight',\n        52: 'Drizzle, not freezing, moderate',\n        53: 'Drizzle, not freezing, heavy',\n        54: 'Drizzle, freezing, slight',\n        55: 'Drizzle, freezing, moderate',\n        56: 'Drizzle, freezing, heavy',\n        57: 'Drizzle and rain, slight',\n        58: 'Drizzle and rain, moderate or heavy',\n        60: 'Rain',\n        61: 'Rain, not freezing, slight',\n        62: 'Rain, not freezing, moderate',\n        63: 'Rain, not freezing, heavy',\n        64: 'Rain, freezing, slight',\n        65: 'Rain, freezing, moderate',\n        66: 'Rain, freezing, heavy',\n        67: 'Rain (or drizzle) and snow, slight',\n        68: 'Rain (or drizzle) and snow, moderate or heavy',\n        70: 'Snow',\n        71: 'Snow, light',\n        72: 'Snow, moderate',\n        73: 'Snow, heavy',\n        74: 'Ice pellets, slight',\n        75: 'Ice pellets, moderate',\n        76: 'Ice pellets, heavy',\n        77: 'Snow grains',\n        78: 'Ice crystals',\n        80: 'Shower(s) or Intermittent Precipitation',\n        81: 'Rain shower(s) or intermittent rain, slight',\n        82: 'Rain shower(s) or intermittent rain, moderate',\n        83: 'Rain shower(s) or intermittent rain, heavy',\n        84: 'Rain shower(s) or intermittent rain, violent',\n        85: 'Snow shower(s) or intermittent snow, slight',\n        86: 'Snow shower(s) or intermittent snow, moderate',\n        87: 'Snow shower(s) or intermittent snow, heavy',\n        89: 'Hail',\n        90: 'Thunderstorm',\n        91: 'Thunderstorm, slight or moderate, with no precipitation',\n        92: 'Thunderstorm, slight or moderate, with rain showers and/or snow showers',\n        93: 'Thunderstorm, slight or moderate, with hail',\n        94: 'Thunderstorm, heavy, with no precipitation',\n        95: 'Thunderstorm, heavy, with rain showers and/or snow showers',\n        96: 'Thunderstorm, heavy, with hail',\n        99: 'Tornado',\n        -9999: 'Missing',\n    }\n\n    # If a decoded name is not passed, make one\n    if decoded_name is None:\n        decoded_name = variable + '_decoded'\n\n    # Get data and fill nans with -9999\n    data = ds[variable]\n    data = data.fillna(-9999)\n\n    # Get the weather type for each code\n    wx_type = [weather[d] for d in data.values]\n\n    # Massage the data array to set back in the dataset\n    data.values = wx_type\n    data.attrs['long_name'] = data.attrs['long_name'] + ' Decoded'\n    del data.attrs['valid_min']\n    del data.attrs['valid_max']\n\n    ds[decoded_name] = data\n\n    return ds\n", "path": "act/utils/inst_utils.py"}], "after_files": [{"content": "\"\"\"\nFunctions containing utilities for instruments.\n\n\"\"\"\n\n\ndef decode_present_weather(ds, variable=None, decoded_name=None):\n    \"\"\"\n    This function is to decode codes reported from automatic weather stations suchas the PWD22.\n    This is based on WMO Table 4680.\n\n    Parameters\n    ----------\n    ds : xarray.Dataset\n        ACT or Xarray dataset from which to convert codes\n    variable : string\n        Variable to decode\n    decoded_name : string\n        New variable name to store updated labels\n\n    Returns\n    -------\n    ds : xarray.Dataset\n        Returns dataset with new decoded data\n\n    References\n    ----------\n    WMO Manual on Code Volume I.1\n    https://www.wmo.int/pages/prog/www/WMOCodes/WMO306_vI1/Publications/2017update/Sel9.pdf\n\n    \"\"\"\n\n    # Check to ensure that a variable name is passed\n    if variable is None:\n        raise ValueError('You must specify a variable')\n\n    if variable not in ds:\n        raise ValueError('Variable not in the dataset')\n\n    # Define the weather hash\n    weather = {\n        0: 'No significant weather observed',\n        1: 'Clouds generally dissolving or becoming less developed during the past hour',\n        2: 'State of the sky on the whole unchanged during the past hour',\n        3: 'Clouds generally forming or developing during the past hour',\n        4: 'Haze or smoke, or dust in suspension in the air, visibility >= 1 km',\n        5: 'Haze or smoke, or dust in suspension in the air, visibility < 1 km',\n        10: 'Mist',\n        11: 'Diamond dust',\n        12: 'Distant lightning',\n        18: 'Squalls',\n        20: 'Fog',\n        21: 'Precipitation',\n        22: 'Drizzle (not freezing) or snow grains',\n        23: 'Rain (not freezing)',\n        24: 'Snow',\n        25: 'Freezing drizzle or freezing rain',\n        26: 'Thunderstorm (with or without precipitation)',\n        27: 'Blowing or drifting snow or sand',\n        28: 'Blowing or drifting snow or sand, visibility >= 1 km',\n        29: 'Blowing or drifting snow or sand, visibility < 1 km',\n        30: 'Fog',\n        31: 'Fog or ice fog in patches',\n        32: 'Fog or ice fog, has become thinner during the past hour',\n        33: 'Fog or ice fog, no appreciable change during the past hour',\n        34: 'Fog or ice fog, has begun or become thicker during the past hour',\n        35: 'Fog, depositing rime',\n        40: 'Precipitation',\n        41: 'Precipitation, slight or moderate',\n        42: 'Precipitation, heavy',\n        43: 'Liquid precipitation, slight or moderate',\n        44: 'Liquid precipitation, heavy',\n        45: 'Solid precipitation, slight or moderate',\n        46: 'Solid precipitation, heavy',\n        47: 'Freezing precipitation, slight or moderate',\n        48: 'Freezing precipitation, heavy',\n        50: 'Drizzle',\n        51: 'Drizzle, not freezing, slight',\n        52: 'Drizzle, not freezing, moderate',\n        53: 'Drizzle, not freezing, heavy',\n        54: 'Drizzle, freezing, slight',\n        55: 'Drizzle, freezing, moderate',\n        56: 'Drizzle, freezing, heavy',\n        57: 'Drizzle and rain, slight',\n        58: 'Drizzle and rain, moderate or heavy',\n        60: 'Rain',\n        61: 'Rain, not freezing, slight',\n        62: 'Rain, not freezing, moderate',\n        63: 'Rain, not freezing, heavy',\n        64: 'Rain, freezing, slight',\n        65: 'Rain, freezing, moderate',\n        66: 'Rain, freezing, heavy',\n        67: 'Rain (or drizzle) and snow, slight',\n        68: 'Rain (or drizzle) and snow, moderate or heavy',\n        70: 'Snow',\n        71: 'Snow, light',\n        72: 'Snow, moderate',\n        73: 'Snow, heavy',\n        74: 'Ice pellets, slight',\n        75: 'Ice pellets, moderate',\n        76: 'Ice pellets, heavy',\n        77: 'Snow grains',\n        78: 'Ice crystals',\n        80: 'Shower(s) or Intermittent Precipitation',\n        81: 'Rain shower(s) or intermittent rain, slight',\n        82: 'Rain shower(s) or intermittent rain, moderate',\n        83: 'Rain shower(s) or intermittent rain, heavy',\n        84: 'Rain shower(s) or intermittent rain, violent',\n        85: 'Snow shower(s) or intermittent snow, slight',\n        86: 'Snow shower(s) or intermittent snow, moderate',\n        87: 'Snow shower(s) or intermittent snow, heavy',\n        89: 'Hail',\n        90: 'Thunderstorm',\n        91: 'Thunderstorm, slight or moderate, with no precipitation',\n        92: 'Thunderstorm, slight or moderate, with rain showers and/or snow showers',\n        93: 'Thunderstorm, slight or moderate, with hail',\n        94: 'Thunderstorm, heavy, with no precipitation',\n        95: 'Thunderstorm, heavy, with rain showers and/or snow showers',\n        96: 'Thunderstorm, heavy, with hail',\n        99: 'Tornado',\n        -9999: 'Missing',\n    }\n\n    # If a decoded name is not passed, make one\n    if decoded_name is None:\n        decoded_name = variable + '_decoded'\n\n    # Get data and fill nans with -9999\n    data = ds[variable]\n    data = data.fillna(-9999)\n\n    # Get the weather type for each code\n    wx_type = [weather[d] for d in data.values]\n\n    # Massage the data array to set back in the dataset\n    data.values = wx_type\n    if 'long_name' in data.attrs:\n        data.attrs['long_name'] = data.attrs['long_name'] + ' Decoded'\n    else:\n        data.attrs['long_name'] = 'Decoded present weather values'\n    if 'valid_min' in data.attrs:\n        del data.attrs['valid_min']\n    if 'valid_max' in data.attrs:\n        del data.attrs['valid_max']\n\n    ds[decoded_name] = data\n\n    return ds\n", "path": "act/utils/inst_utils.py"}]}