+def switch_units_to_american(data_map, mapping):
+ """
+ replace units with the American mixture of metric and imperial
+
+ Precip values = imperial
+ Wind values = metric
+ """
+
+ # precip values
+ data_map[mapping['tempMaxHourUnit']] = 'F'
+ data_map[mapping['tempMinHourUnit']] = 'F'
+ data_map[mapping['tempPresUnit']] = 'F'
+ data_map[mapping['dewPointUnit']] = 'F'
+
+ data_map[mapping['precipitationGaugeUnit']] = 'in'
+ data_map[mapping['hsUnit']] = 'in'
+ data_map[mapping['hn24AutoUnit']] = 'in'
+ data_map[mapping['hstAutoUnit']] = 'in'
+
+ data_map[mapping['baroUnit']] = 'inHg'
+
+ # wind values
+ data_map[mapping['windSpeedUnit']] = 'm/s'
+ data_map[mapping['windGustSpeedNumUnit']] = 'm/s'
+
+ return data_map
+
+def convert_nrcs_units_to_metric(element_cd, value):
+ """convert NRCS values from English to metric"""
+ if element_cd == 'TOBS':
+ value = f_to_c(value)
+ elif element_cd == 'SNWD':
+ value = in_to_cm(value)
+ elif element_cd == 'PREC':
+ value = in_to_mm(value)
+ return value
+
+def convert_units_to_american(element_cd, value):
+ """
+ convert value to 'American' units
+
+ The original unit is always metric.
+
+ Precip values = imperial
+ Wind values = metric
+ """
+
+ # temp values
+ if element_cd in ['TMAX', 'TMIN', 'TOBS', 'air_temp', 'air_temp_high_24_hour', 'air_temp_low_24_hour']:
+ value = c_to_f(value)
+
+ # snow values
+ if element_cd in ['SNWD', 'snow_depth']:
+ value = cm_to_in(mm_to_cm(value))
+
+ # likewise for baro values
+ if element_cd in ['PRES', 'pressure']:
+ value = pascal_to_inhg(value)
+
+ # no need to convert wind values, as they will arrive in metric
+ # units in "American" units mode
+ # [
+ # 'WSPD',
+ # 'wind_speed', 'wind_gust'
+ # ]
+ # in_to_mm(value)
+
+ return value
+