Make a table with best model by calibration basin, including years of calibration


In [ ]:
from __future__ import print_function
%pylab notebook
# import datetime as dt
import glob
import matplotlib.pyplot as plt
import matplotlib.dates as md
#from nose.tools import set_trace
from charistools.hypsometry import Hypsometry
from charistools.meltModels import CalibrationCost
from charistools.modelEnv import ModelEnv
import pandas as pd
import re
import os

In [ ]:
dir = "/Users/brodzik/projects/CHARIS/calibrations_correct_cost"
list = glob.glob("%s/*2str*stats.best20.dat" % dir)
list

In [ ]:
drainageIDs = ["SY_Naryn_at_NarynTown",
               "AM_Vakhsh_at_Komsomolabad",
               "IN_Hunza_at_DainyorBridge",
               "GA_Karnali_at_Benighat",
               "GA_SaptaKosi_at_Chatara"]
majorIDs = ['SY', 'AM', 'IN', 'GA', 'BR']
cal_years = ["2003, 2005, 2007",
             "2004, 2005, 2007",
             "2001, 2002, 2003",
             "2001, 2003, 2004",
             "2003, 2004, 2005"]

In [ ]:
df = pd.DataFrame([])
for drainageID in drainageIDs:
    f = "%s/%s.2str_DDFnbr=10mm_N100_M050.stats.best20.dat" % (dir, drainageID)
    basin_df = pd.read_pickle(f)
    basin_df['basin'] = drainageID
    basin_df['name'] = basin_df['basin'].str.findall(r".{2}_(.+)_at")
    basin_df['name'] = [i[0] for i in basin_df['name']]
    df = df.append(basin_df.iloc[0])

df.drop(['basin', 'abs_voldiff_pcent', 'model', 'monthly_rmse_pcent', 'z'], axis=1, inplace=True)
df['major_basin'] = majorIDs
df['cal_years'] = cal_years
cols = ['name', 'major_basin', 
        'min_snow_ddf', 'max_snow_ddf', 'min_ice_ddf', 'max_ice_ddf', 
        'cal_years', 'annual_voldiff_pcent', 'monthly_rmse_km3']
df = df[cols]
df.columns = ["Basin", 
              "Major Basin", 
              "Min Snow DDF mm oC-1 day-1",
              "Max Snow DDF mm oC-1 day-1",
              "Min Ice DDF mm oC-1 day-1",
              "Max Ice DDF mm oC-1 day-1",
              "Calibration Years",
              "Annual Volumetric Difference (%)",
              "Monthly RMSE (km3)"]
df

In [ ]:
outFile = "%s/calibration_DDFs_best.csv" % dir
df.to_csv(outFile)
outFile

In [ ]: