In [1]:
import seaborn as sns
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
import scipy as sp
from hydromet.io import read_predictors, read_predictands
from hydromet.system import get_model_config, get_model_dir
%matplotlib inline
from phildb.database import PhilDB
db = PhilDB('hm_tsdb')


/Users/amacdon/anaconda/lib/python3.4/site-packages/matplotlib/__init__.py:872: UserWarning: axes.color_cycle is deprecated and replaced with axes.prop_cycle; please use the latter.
  warnings.warn(self.msg_depr % (key, alt_key))

In [2]:
config = get_model_config('project', 'LinearRegression')

In [3]:
config['calibration']['end_date']


Out[3]:
datetime.date(2008, 12, 1)

In [4]:
predictors = read_predictors(db, config, '410730', 'calibration')

In [5]:
predictands = read_predictands(db, config, '410730', 'calibration')

In [6]:
from hydromet.models.linear_regression import LinearRegressionModel

In [7]:
lrm = LinearRegressionModel()

In [8]:
lrm.calibrate(predictors, predictands)

In [9]:
fc_date = '2010-06-01'

In [10]:
for fc_date in pd.date_range('2010-01-01', '2011-12-01', freq='MS'):
    p = read_predictors(db, config, '410730', idx = slice(fc_date, fc_date))
    print(lrm.forecast(p)[0][0] - read_predictands(db, config, '410730', idx = slice(fc_date, fc_date))['Q'].values[0])


326.488413169
4453.65130242
332.15095665
667.287543936
2927.33848578
317.536393439
-18.9383044465
-1368.20736822
-6809.15706284
-2664.07233448
-2611.6064361
-7219.96694703
-3292.97404555
783.693766107
-1922.67172258
-1396.93497482
286.47629382
264.665804855
5.52403147837
-503.222118183
-185.396177992
-394.545085975
4192.81126957
-3919.17968903

In [ ]: