Skip to content
Snippets Groups Projects
Unverified Commit 2daf7d42 authored by David Hoese's avatar David Hoese
Browse files

Huge rewrite of the netcdf level_b1 writer

Properly calculate wind gust
Properly assign QC flags
Tons of style changes and better performant array operations
parent ce2a58b5
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,8 @@ The original data format was a key value, space separated data format
PAROSCI, WSPD05305, TEMP107_3, CS10162, RAIN380M, TEMP107_2, TEMP41372,
WDIR05305`.
XXX: Fill value in version 0 seems to be -99999.
Version 1
---------
Effective 2010-06-01T00:27:51Z to 2012-12-03T17:34:17Z.
......@@ -25,12 +27,16 @@ pressure, paro_cal_sig, box_rh, box_air_temp, air_temp_2, air_temp_3,
air_temp_4, wind_speed, wind_dir, rh_shield_freq, rh, air_temp_6_3m, dewpoint,
rtd_shield_freq, air_temp, solar_flux, precip, accum_precip, altimeter.
XXX: Fill value in version 1 seems to be -99999.
Version 2
---------
Effective 2012-12-03T17:34:17Z to present.
Same as Version 1 with the addition of altimeter2 at the end. I'm not sure why
we have 2 altimeter values but as far as I know altimeter2 is not used.
XXX: Fill value in version 2 seems to be -99999.
"""
import re
......@@ -78,6 +84,7 @@ def _make_frame(data):
class ParserV0(object):
"""Parses Version 0 data lines.
"""
fill_value = -99999.
# maps v0 names to names in schema db
names = {'ACCURAIN': 'accum_precip',
......@@ -124,6 +131,7 @@ class ParserV0(object):
class ParserV1V2(object):
"""Parses Version 1 & 2 data lines.
"""
fill_value = -99999.
names = ['station_id', 'year', 'doy', 'hhmm', 'sec', 'box_pressure',
'paro_air_temp_period', 'paro_pressure_period', 'paro_air_temp',
......
......@@ -2,10 +2,20 @@ import math
import numpy as np
try:
from pandas import Series
except ImportError:
# expected to use for isinstance
Series = np.ndarray
NaN = float('nan')
is_nan = lambda a: a != a
def knots_to_mps(knots):
return knots * 0.51444
def dewpoint(tempC, relhum):
"""
Algorithm from Tom Whittaker tempC is the temperature in degrees Celsius,
......@@ -130,7 +140,7 @@ def wind_vector_degrees(vector_east, vector_north):
"""
rads = np.arctan2(vector_east, vector_north)
winddir = np.rad2deg(rads)
if isinstance(winddir, np.ndarray):
if isinstance(winddir, (np.ndarray, Series)):
winddir[np.less(winddir, 0)] += 360
elif winddir < 0:
winddir += 360
......
This diff is collapsed.
......@@ -2,7 +2,7 @@ from numpy import float32
from collections import namedtuple
Var = namedtuple('Var', ['type', 'standard_name', 'name', 'description', 'units', 'valid_min', 'valid_max'])
Var = namedtuple('Var', ['type', 'standard_name', 'name', 'description', 'units', 'valid_min', 'valid_max', 'valid_delta'])
database = dict(
......@@ -13,7 +13,8 @@ database = dict(
'Auxillary Temperature',
'degC',
'',
''
'',
'',
),
box_pressure=Var(
float32,
......@@ -22,7 +23,9 @@ database = dict(
'Pressure inside the data logger enclosure',
'hPa',
'850',
'1100'),
'1100',
'',
),
paro_air_temp_period=Var(
float32,
'',
......@@ -30,7 +33,8 @@ database = dict(
'',
'1',
'',
''
'',
'',
),
paro_pressure_period=Var(
float32,
......@@ -39,7 +43,9 @@ database = dict(
'',
'1',
'',
''),
'',
'',
),
paro_air_temp=Var(
float32,
'air_temperature',
......@@ -47,7 +53,8 @@ database = dict(
'',
'degC',
'-50',
'50'
'50',
'',
),
pressure=Var(
float32,
......@@ -56,7 +63,8 @@ database = dict(
'Air pressure as measured from the PAROSCI pressure sensor',
'hPa',
'850',
'1100'
'1100',
'',
),
paro_cal_sig=Var(
float32,
......@@ -65,7 +73,8 @@ database = dict(
'',
'',
'',
''
'',
'',
),
box_rh=Var(
float32,
......@@ -74,7 +83,8 @@ database = dict(
'Relative humidity inside the data logger enclosure',
'%',
'0',
'100'
'100',
'',
),
box_air_temp=Var(
float32,
......@@ -83,7 +93,8 @@ database = dict(
'Air temperature inside the data logger enclosure',
'degC',
'-50',
'50'
'50',
'',
),
air_temp_2=Var(
float32,
......@@ -91,9 +102,10 @@ database = dict(
'air_temp_2',
'Auxillary air temperature',
'degC',
'-50',
'50',
),
'-50',
'50',
'',
),
air_temp_3=Var(
float32,
'air_temperature',
......@@ -101,7 +113,8 @@ database = dict(
'Auxillary air temperature',
'degC',
'-50',
'50'
'50',
'',
),
air_temp_4=Var(
float32,
......@@ -110,7 +123,8 @@ database = dict(
'Auxillary air temperature',
'degC',
'-50',
'50'
'50',
'',
),
air_temp_5=Var(
float32,
......@@ -119,7 +133,8 @@ database = dict(
'Auxillary air temperature',
'degC',
'-50',
'50'
'50',
'',
),
wind_speed=Var(
float32,
......@@ -128,7 +143,8 @@ database = dict(
'Wind speed',
'm*s^-1',
'0',
'50'
'50',
'',
),
wind_dir=Var(
float32,
......@@ -137,7 +153,8 @@ database = dict(
'Wind direction',
'degrees',
'0',
'360'
'360',
'',
),
rh_shield_freq=Var(
float32,
......@@ -146,7 +163,8 @@ database = dict(
'',
'hz',
'',
''
'',
'',
),
rh=Var(
float32,
......@@ -155,7 +173,8 @@ database = dict(
'Relative humidity',
'%',
'0',
'100'
'100',
'',
),
air_temp_6_3m=Var(
float32,
......@@ -164,7 +183,8 @@ database = dict(
'Air temperature 6.3m from tower base',
'degC',
'-50',
'50'
'50',
'',
),
dewpoint=Var(
float32,
......@@ -173,7 +193,9 @@ database = dict(
'Calculated dewpoint temperature',
'degC',
'-50',
'50'),
'50',
'',
),
rtd_shield_freq=Var(
float32,
'',
......@@ -181,7 +203,8 @@ database = dict(
'',
'',
'',
''
'',
'',
),
air_temp=Var(
float32,
......@@ -190,7 +213,8 @@ database = dict(
'Air temperature',
'degC',
'-50',
'50'
'50',
'',
),
solar_flux=Var(
float32,
......@@ -199,7 +223,9 @@ database = dict(
'Solar flux',
'w*m^-2',
'0',
'3000'),
'3000',
'',
),
precip=Var(
float32,
'',
......@@ -207,7 +233,8 @@ database = dict(
'Precipitation',
'mm',
'0',
'254'
'254',
'',
),
accum_precip=Var(
float32,
......@@ -216,7 +243,8 @@ database = dict(
'Precipitation accumulated since 0Z',
'mm',
'0',
'254'
'254',
'',
),
altimeter=Var(
float32,
......@@ -225,7 +253,8 @@ database = dict(
'',
'inHg',
'',
''
'',
'',
),
gust=Var(
float32,
......@@ -234,10 +263,11 @@ database = dict(
'Wind gust over the previous 2 minutes',
'm/s',
'0',
'50'
'50',
'',
)
)
met_vars = {'air_temp', 'rh', 'solar_flux', 'pressure', 'precip', 'accum_precip',
'wind_speed', 'wind_dir'}
'wind_speed', 'wind_dir', 'gust'}
engr_vars = set(database.keys()) - met_vars
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment