Skip to content

Commit

Permalink
MNT: Add supplement table when codes are not present in 4680. (ARM-DO…
Browse files Browse the repository at this point in the history
  • Loading branch information
zssherman authored Apr 26, 2023
1 parent 94d5c29 commit 69e567d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions act/utils/inst_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

def decode_present_weather(ds, variable=None, decoded_name=None):
"""
This function is to decode codes reported from automatic weather stations suchas the PWD22.
This is based on WMO Table 4680.
This function is to decode codes reported from automatic weather stations such as the PWD22.
This is based on WMO Table 4680 as well as a supplement table for WMO table 4677.
Parameters
----------
Expand Down Expand Up @@ -37,8 +37,8 @@ def decode_present_weather(ds, variable=None, decoded_name=None):
if variable not in ds:
raise ValueError('Variable not in the dataset')

# Define the weather hash
weather = {
# Define the weather hash for WMO table 4680.
weather_4680 = {
0: 'No significant weather observed',
1: 'Clouds generally dissolving or becoming less developed during the past hour',
2: 'State of the sky on the whole unchanged during the past hour',
Expand Down Expand Up @@ -121,6 +121,18 @@ def decode_present_weather(ds, variable=None, decoded_name=None):
-9999: 'Missing',
}

# Define the weather hash for WMO table 4677.
weather_4677 = {
88: 'Shower(s) of snow pellets or small hail, with or without rain or rain and snow mixed, moderate or heavy',
}

# Join weather tables
weather_combined = dict(weather_4680)
weather_combined.update(weather_4677)

# Sort keys to be in order
weather = dict(sorted(weather_combined.items()))

# If a decoded name is not passed, make one
if decoded_name is None:
decoded_name = variable + '_decoded'
Expand Down

0 comments on commit 69e567d

Please sign in to comment.