WSL/SLF GitLab Repository

Commit bcdda5ec authored by Rebecca Kurup Buchholz's avatar Rebecca Kurup Buchholz
Browse files

Converted string to floats values for gcnet line cleaner

parent ad410c75
......@@ -11,6 +11,7 @@ from gcnet.util.constants import Columns
# Values matching null_value are replaced with None
def get_gcnet_line_clean(row, date_format, null_value):
row = {
# Computed time fields
Columns.TIMESTAMP_ISO.value: get_utc_datetime(row['timestamp_iso'], date_format),
Columns.TIMESTAMP.value: get_unix_timestamp(row['timestamp_iso'], date_format),
Columns.YEAR.value: get_year(row['timestamp_iso']),
......@@ -20,30 +21,40 @@ def get_gcnet_line_clean(row, date_format, null_value):
Columns.DAY.value: year_day(row['timestamp_iso'], date_format),
Columns.WEEK.value: year_week(row['timestamp_iso'], date_format),
# TODO clarify these values: OWSR, OSWR_min, NSWR_max (for 'fields' line in NEAD file)
Columns.SWIN.value: row['swin'], Columns.SWOUT.value: row['swout'], Columns.NETRAD.value: row['netrad'],
Columns.AIRTEMP1.value: row['airtemp1'], Columns.AIRTEMP2.value: row['airtemp2'],
Columns.AIRTEMP_CS500AIR1.value: row['airtemp_cs500air1'],
Columns.AIRTEMP_CS500AIR2.value: row['airtemp_cs500air2'],
Columns.RH1.value: row['rh1'], Columns.RH2.value: row['rh2'],
Columns.WINDSPEED1.value: row['windspeed1'], Columns.WINDSPEED2.value: row['windspeed2'],
Columns.WINDDIR1.value: row['winddir1'], Columns.WINDDIR2.value: row['winddir2'],
Columns.PRESSURE.value: row['pressure'],
Columns.SH1.value: row['sh1'], Columns.SH2.value: row['sh2'],
Columns.BATTVOLT.value: row['battvolt'],
Columns.SWIN_MAX.value: row['swin_maximum'], Columns.SWOUT_MIN.value: row['swout_minimum'],
Columns.NETRAD_MAX.value: row['netrad_maximum'],
Columns.AIRTEMP1_MAX.value: row['airtemp1_maximum'], Columns.AIRTEMP2_MAX.value: row['airtemp2_maximum'],
Columns.AIRTEMP1_MIN.value: row['airtemp1_minimum'], Columns.AIRTEMP2_MIN.value: row['airtemp2_minimum'],
Columns.WINDSPEED_U1_MAX.value: row['windspeed_u1_maximum'],
Columns.WINDSPEED_U2_MAX.value: row['windspeed_u2_maximum'],
Columns.WINDSPEED_U1_STDEV.value: row['windspeed_u1_stdev'],
Columns.WINDSPEED_U2_STDEV.value: row['windspeed_u2_stdev'],
Columns.REFTEMP.value: row['reftemp']
# Fields directly read from input data, convert input string values to float values
Columns.SWIN.value: float(row['swin']),
Columns.SWOUT.value: float(row['swout']),
Columns.NETRAD.value: float(row['netrad']),
Columns.AIRTEMP1.value: float(row['airtemp1']),
Columns.AIRTEMP2.value: float(row['airtemp2']),
Columns.AIRTEMP_CS500AIR1.value: float(row['airtemp_cs500air1']),
Columns.AIRTEMP_CS500AIR2.value: float(row['airtemp_cs500air2']),
Columns.RH1.value: float(row['rh1']),
Columns.RH2.value: float(row['rh2']),
Columns.WINDSPEED1.value: float(row['windspeed1']),
Columns.WINDSPEED2.value: float(row['windspeed2']),
Columns.WINDDIR1.value: float(row['winddir1']),
Columns.WINDDIR2.value: float(row['winddir2']),
Columns.PRESSURE.value: float(row['pressure']),
Columns.SH1.value: float(row['sh1']),
Columns.SH2.value: float(row['sh2']),
Columns.BATTVOLT.value: float(row['battvolt']),
Columns.SWIN_MAX.value: float(row['swin_maximum']),
Columns.SWIN_STDEV.value: float(row['swin_stdev']),
Columns.NETRAD_STDEV.value: float(row['netrad_stdev']),
Columns.AIRTEMP1_MAX.value: float(row['airtemp1_maximum']),
Columns.AIRTEMP2_MAX.value: float(row['airtemp2_maximum']),
Columns.AIRTEMP1_MIN.value: float(row['airtemp1_minimum']),
Columns.AIRTEMP2_MIN.value: float(row['airtemp2_minimum']),
Columns.WINDSPEED_U1_MAX.value: float(row['windspeed_u1_maximum']),
Columns.WINDSPEED_U2_MAX.value: float(row['windspeed_u2_maximum']),
Columns.WINDSPEED_U1_STDEV.value: float(row['windspeed_u1_stdev']),
Columns.WINDSPEED_U2_STDEV.value: float(row['windspeed_u2_stdev']),
Columns.REFTEMP.value: float(row['reftemp'])
}
# null_value is converted to float and then back to string to compare with row values
null_value_float = str(float(null_value))
# null_value is converted to float to compare with row values
null_value_float = float(null_value)
# Assign values to None that match null_value
for key, value in row.items():
......@@ -85,7 +96,7 @@ def get_julian_day(date_string, date_format):
dt_object = get_utc_datetime(date_string, date_format)
dt_object = dt_object.timetuple()
julian_day = dt_object.tm_yday
return julian_day
return float(julian_day)
# Returns hour from date string
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment