From e74150d9962e557dc1d076a33becac453e28ba5f Mon Sep 17 00:00:00 2001 From: wroberts <wroberts4@wisc.edu> Date: Fri, 26 Jul 2019 14:51:14 -0500 Subject: [PATCH] Fix merge conflicts and replace database with frame --- aosstower/level_00/influxdb.py | 57 +--------------------------------- 1 file changed, 1 insertion(+), 56 deletions(-) diff --git a/aosstower/level_00/influxdb.py b/aosstower/level_00/influxdb.py index 80b50a6..92445ec 100644 --- a/aosstower/level_00/influxdb.py +++ b/aosstower/level_00/influxdb.py @@ -10,7 +10,6 @@ import sys import requests from metobscommon import influxdb from aosstower.level_00.parser import read_frames -from aosstower import schema from metobscommon.util import calc from metobscommon.util.nc import calculate_wind_gust import numpy as np @@ -98,7 +97,6 @@ class Updater(object): frame = pd.DataFrame(self.data) KNOTS_9 = calc.knots_to_mps(9.) KNOTS_5 = calc.knots_to_mps(5.) - database = {k: schema.database_dict[k] for k in schema.met_vars} frame.set_index('timestamp', inplace=True) frame.mask(frame == -99999., inplace=True) frame.fillna(value=np.nan, inplace=True) @@ -107,7 +105,7 @@ class Updater(object): frame['wind_dir']) frame['wind_dir'] = calc.wind_vector_degrees(frame['wind_east'], frame['wind_north']) - if 'air_temp' in frame and 'rh' in frame and ('dewpoint' in database or 'dewpoint_mean' in database): + if 'air_temp' in frame and 'rh' in frame and ('dewpoint' in frame or 'dewpoint_mean' in frame): LOG.info("'dewpoint' is missing from the input file, will calculate " "it from air temp and relative humidity") frame['dewpoint'] = calc.dewpoint(frame['air_temp'], frame['rh']) @@ -254,58 +252,6 @@ def main(): influxdb.insert(lines, host=args.host, port=args.port, dbname=args.dbname) # Record is in a list of size 1, but want just the record. avg = updater.rolling_average(record[0]) -<<<<<<< HEAD - # Once every 5 minutes: 0 through 295 seconds inclusive. - if avg is not None: - # For timestamp, want YYYY-MM-DD+hh:mm:ss of last dataset that was averaged, rounded up to nearest minute. - timestamp = avg.index[-1].round('1T').isoformat('+') - wind_dir = avg['wind_dir'][-1] - wind_dir_2m = avg['wind_dir_2m'][-1] - # Converts from m/s to mph. - wind_speed = avg['wind_speed'][-1] * 2.23694 - wind_speed_2m = avg['wind_speed_2m'][-1] * 2.23694 - cur_gust = avg['cur_gust'][-1] * 2.23694 - gust_10m = avg['gust_10m'][-1] * 2.23694 - rel_hum = avg['rel_hum'][-1] - # Converts degrees Celsius to degrees Fahrenheit - air_temp = avg['air_temp'][-1] * 9. / 5. + 32. - # hpa to barometric pressure inches - pressure = avg['pressure'][-1] * 0.02952998016471232 - # degrees Celcus to degrees Fahrenheit. - dewpoint = avg['dewpoint'][-1] * 9. / 5. + 32. - solar_flux = avg['solar_flux'][-1] - precip = avg['precip'][-1] - accum_precip = avg['accum_precip'][-1] - url = ('http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?' - 'ID={wu_id}&' - 'PASSWORD={wu_pw}&' - 'action=updateraw&' - 'dateutc={timestamp}&' - 'winddir={wind_dir}&' - 'winddir_avg2m={wind_dir_2m}&' - 'windspeedmph={wind_speed}&' - 'windspdmph_avg2m={wind_speed_2m}&' - 'windgustmph={cur_gust}&' - 'windgustmph_10m={gust_10m}&' - 'humidity={rel_hum}&' - 'tempf={air_temp}&' - 'baromin={pressure}&' - 'dewptf={dewpoint}&' - 'solarradiation={solar_flux}&' - 'rainin={precip}&' - 'dailyrainin={accum_precip}&' - 'softwaretype=SSEC-RIG').format(wu_id=args.wu_id, wu_pw=wu_pw, - timestamp=timestamp, wind_dir=wind_dir, wind_dir_2m=wind_dir_2m, - wind_speed=wind_speed, wind_speed_2m=wind_speed_2m, - cur_gust=cur_gust, gust_10m=gust_10m, rel_hum=rel_hum, - air_temp=air_temp, pressure=pressure, dewpoint=dewpoint, - solar_flux=solar_flux, precip=precip, accum_precip=accum_precip) - if wu_pw and args.ldmp: - # TODO: CHECK FOR SUCCESS RESPONSE PING AFTER SENDING. - resp = requests.post(url) - if resp != 'success': - raise ValueError('Data not received.') -======= # Once every 5 minutes: 0 through 295 seconds inclusive in 5 second intervals. if avg is not None: url = construct_url(get_url_data(avg, args.wu_id, wu_pw)) @@ -314,7 +260,6 @@ def main(): if resp.status_code != 200: warnings.warn('Data failed to upload to {0} with status code {1}: {2}'.format( url, resp.status_code, resp.text)) ->>>>>>> master if args.sleep_interval: time.sleep(args.sleep_interval) -- GitLab