def parse_data(): sd = parse_get_data("../Test/Data/hemsedal_hollekolten_jan2016.xml") ff_s = Series(sd["25112"]["FF"]["val"], index=sd["25112"]["index"]) # replace fill values to NaN ff_s.replace(-99999.0, np.nan, inplace=True) ff24_s = ff_s.resample("D") sd = parse_get_data("../Test/Data/hemsedal_hoelto_jan2016.xml") ts = Series(sd["25100"]["RR_24"]["val"], index=sd["25100"]["index"]) # select only measurements at 06 every day ts = ts[ts.index.hour == 6] # ts.replace(-99999.0, np.nan, inplace=True) # ts.replace(-1.0, 0.0, inplace=True) print(ff24_s) plt.bar(ts.index, ts.values) plt.hold(True) plt.plot(ff_s.index, ff_s.values) plt.plot(ff24_s.index, ff24_s.values) # plt.bar(sd['25100']['index'], sd['25100']['RR_24']['val']) plt.show()
def parse_data(): sd = parse_get_data('../Test/Data/hemsedal_hollekolten_jan2016.xml') ff_s = Series(sd['25112']['FF']['val'], index=sd['25112']['index']) # replace fill values to NaN ff_s.replace(-99999.0, np.nan, inplace=True) ff24_s = ff_s.resample('D') sd = parse_get_data('../Test/Data/hemsedal_hoelto_jan2016.xml') ts = Series(sd['25100']['RR_24']['val'], index=sd['25100']['index']) # select only measurements at 06 every day ts = ts[ts.index.hour == 6] # ts.replace(-99999.0, np.nan, inplace=True) # ts.replace(-1.0, 0.0, inplace=True) print(ff24_s) plt.bar(ts.index, ts.values) plt.hold(True) plt.plot(ff_s.index, ff_s.values) plt.plot(ff24_s.index, ff24_s.values) # plt.bar(sd['25100']['index'], sd['25100']['RR_24']['val']) plt.show()
if dt.hour == 6 and dt.minute == 0: return True else: return False def removeNull(rr): if rr == -99999.0: return False else: return True if __name__ == '__main__': sd = parse_get_data('../Test/Data/eklima_data.xml') station_id = '15890' # TODO: some stations measure TA with a 10 min interval, which causes the time-axis to be wrong. dates = sd[station_id]['index'] temperature = sd[station_id]['TA']['val'] precip = sd[station_id]['RR_1']['val'] precip_24 = list(filter(removeNull, sd[station_id]['RR_24']['val'])) dates_24 = list(filter(isMetDay, dates)) ta_rr_plotly(station_id, dates, dates_24, temperature, precip, precip_24) ''' dates = [datetime.datetime.today() - datetime.timedelta(days=i) for i in range(4)] temperature = np.array([4, 1, -3, -17])
'RR_1', 'RR_6', 'RRINTENS', 'DAGRRRR00', 'DAGRRSS00', 'X1UU', 'X1UM', 'UU', 'FX_6', 'FX_12', 'X1FX_1', 'X1FF', 'DD', 'FF', 'SAM', 'SA', 'RTS_1', 'SS_1', 'SS_24', 'X1QO', 'QNET', 'QSI', 'QSO', 'QRA', 'QOB', 'QLI', 'QLO', 'QD', 'QR', 'QT'] print(st_elems) st_sensors = [sensor for sensor in relevant_sensors if sensor in st_elems.keys()] ''' STEP 2 ''' rsp = wsKlimaRequest('getMetData', {'timeserietypeID': tt_id, 'format': "", 'from': t_from, 'to': t_to, 'stations': stations, 'elements': st_sensors, 'hours': range(0, 24), 'months': "", 'username': ""}).get() sd = parse_get_data(rsp.content) # pylab.plot(sd[str(stnr)]['index'], sd[str(stnr)]['TA']['val']) # pylab.show() ''' STEP 3 ''' sites = {st_props[str(stnr)]['name']: [st_props[str(stnr)]['latDec'], st_props[str(stnr)]['lonDec']]} forcing_from_thredds(sites)
def isMetDay(dt): if dt.hour == 6 and dt.minute == 0: return True else: return False def removeNull(rr): if rr == -99999.0: return False else: return True if __name__ == '__main__': sd = parse_get_data('../Test/Data/eklima_data.xml') station_id = '15890' # TODO: some stations measure TA with a 10 min interval, which causes the time-axis to be wrong. dates = sd[station_id]['index'] temperature = sd[station_id]['TA']['val'] precip = sd[station_id]['RR_1']['val'] precip_24 = list(filter(removeNull, sd[station_id]['RR_24']['val'])) dates_24 = list(filter(isMetDay, dates)) ta_rr_plotly(station_id, dates, dates_24, temperature, precip, precip_24) ''' dates = [datetime.datetime.today() - datetime.timedelta(days=i) for i in range(4)]