In [112]:
%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
from hagelslag.evaluation import DistributedROC, DistributedReliability
from hagelslag.evaluation import ContingencyTable
from scipy.ndimage import convolve
from scipy.spatial import cKDTree
from matplotlib import colors

from glob import glob
import xarray as xr
import os
from os.path import join

In [95]:
eval_path = "/glade/p/work/dgagne/ncar_coarse_neighbor_eval_2016/"
eval_files = sorted(os.listdir(eval_path))
eval_test = pd.read_csv(join(eval_path, eval_files[0]))
models = eval_test.columns[eval_test.columns.str.contains("mean")]
run_dates = pd.DatetimeIndex([e.split("_")[-1][:8] for e in eval_files])
thresholds = [25, 50, 75]
prob_thresholds = np.concatenate(([0, 0.01], np.arange(0.1, 1.1, 0.1), [1.05]))
brier = {}
roc = {}
for thresh in thresholds:
    brier[thresh] = pd.DataFrame(index=run_dates, columns=models, dtype=object)
    roc[thresh] = pd.DataFrame(index=run_dates, columns=models, dtype=object)
    #roc[thresh].loc[:, :] = DistributedROC()
    #brier[thresh].loc[:, :] = DistributedReliability()
for ev, eval_file in enumerate(eval_files):
    print(eval_file)
    eval_data = pd.read_csv(join(eval_path, eval_file))
    us_mask = eval_data["us_mask"] == 1
    for thresh in thresholds:
        obs = eval_data.loc[us_mask, "MESH_Max_60min_00.50_{0:2d}".format(thresh)]
        for model in models:
            brier[thresh].loc[run_dates[ev], model] = DistributedReliability(thresholds=prob_thresholds)
            brier[thresh].loc[run_dates[ev], model].update(eval_data.loc[us_mask, model], 
                                                           obs)
            roc[thresh].loc[run_dates[ev], model] = DistributedROC(thresholds=prob_thresholds)
            roc[thresh].loc[run_dates[ev], model].update(eval_data.loc[us_mask, model], 
                                                         obs)


coarse_neighbor_eval_NCAR_20160502.csv
coarse_neighbor_eval_NCAR_20160503.csv
coarse_neighbor_eval_NCAR_20160504.csv
coarse_neighbor_eval_NCAR_20160505.csv
coarse_neighbor_eval_NCAR_20160506.csv
coarse_neighbor_eval_NCAR_20160507.csv
coarse_neighbor_eval_NCAR_20160508.csv
coarse_neighbor_eval_NCAR_20160509.csv

KeyboardInterruptTraceback (most recent call last)
<ipython-input-95-24dc277fef7a> in <module>()
     25             roc[thresh].loc[run_dates[ev], model] = DistributedROC(thresholds=prob_thresholds)
     26             roc[thresh].loc[run_dates[ev], model].update(eval_data.loc[us_mask, model], 
---> 27                                                          obs)

/glade/u/home/dgagne/.local/lib/python2.7/site-packages/hagelslag-0.2-py2.7.egg/hagelslag/evaluation/ProbabilityMetrics.pyc in update(self, forecasts, observations)
     88                                   (observations >= self.obs_threshold))
     89             tn = np.count_nonzero((forecasts < threshold) &
---> 90                                   (observations < self.obs_threshold))
     91             self.contingency_tables.ix[t] += [tp, fp, fn, tn]
     92 

/glade/p/work/dgagne/miniconda/envs/py2/lib/python2.7/site-packages/pandas/core/ops.pyc in wrapper(self, other, axis)
    861             res = _values_from_object(res)
    862 
--> 863         res = pd.Series(res, index=self.index, name=self.name, dtype='bool')
    864         return res
    865 

/glade/p/work/dgagne/miniconda/envs/py2/lib/python2.7/site-packages/pandas/core/series.pyc in __init__(self, data, index, dtype, name, copy, fastpath)
    239             else:
    240                 data = _sanitize_array(data, index, dtype, copy,
--> 241                                        raise_cast_failure=True)
    242 
    243                 data = SingleBlockManager(data, index, fastpath=True)

/glade/p/work/dgagne/miniconda/envs/py2/lib/python2.7/site-packages/pandas/core/series.pyc in _sanitize_array(data, index, dtype, copy, raise_cast_failure)
   2863                     subarr = data.copy()
   2864             else:
-> 2865                 subarr = _try_cast(data, True)
   2866         elif isinstance(data, Index):
   2867             # don't coerce Index types

/glade/p/work/dgagne/miniconda/envs/py2/lib/python2.7/site-packages/pandas/core/series.pyc in _try_cast(arr, take_fast_path)
   2838 
   2839         try:
-> 2840             subarr = _possibly_cast_to_datetime(arr, dtype)
   2841             if not is_extension_type(subarr):
   2842                 subarr = np.array(subarr, dtype=dtype, copy=copy)

/glade/p/work/dgagne/miniconda/envs/py2/lib/python2.7/site-packages/pandas/types/cast.pyc in _possibly_cast_to_datetime(value, dtype, errors)
    776         is_datetime64 = is_datetime64_dtype(dtype)
    777         is_datetime64tz = is_datetime64tz_dtype(dtype)
--> 778         is_timedelta64 = is_timedelta64_dtype(dtype)
    779 
    780         if is_datetime64 or is_datetime64tz or is_timedelta64:

/glade/p/work/dgagne/miniconda/envs/py2/lib/python2.7/site-packages/pandas/types/common.pyc in is_timedelta64_dtype(arr_or_dtype)
     91 def is_timedelta64_dtype(arr_or_dtype):
     92     tipo = _get_dtype_type(arr_or_dtype)
---> 93     return issubclass(tipo, np.timedelta64)
     94 
     95 

KeyboardInterrupt: 

In [3]:
out_path = "/hail/djgagne/ncar_coarse_neighbor_scores_2016/"
for thresh in [25, 50, 75]:
    brier[thresh].to_csv(join(out_path, "ncar_2016_brier_objs_{0:02d}.csv".format(thresh)), index_label="Date")
    roc[thresh].to_csv(join(out_path, "ncar_2016_roc_objs_{0:02d}.csv".format(thresh)), index_label="Date")


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-3-14ebf298a4ec> in <module>()
      1 out_path = "/hail/djgagne/ncar_coarse_neighbor_scores_2016/"
      2 for thresh in [25, 50, 75]:
----> 3     brier[thresh].to_csv(join(out_path, "ncar_2016_brier_objs_{0:02d}.csv".format(thresh)), index_label="Date")
      4     roc[thresh].to_csv(join(out_path, "ncar_2016_roc_objs_{0:02d}.csv".format(thresh)), index_label="Date")

NameError: name 'brier' is not defined

In [79]:
out_path = "/hail/djgagne/ncar_coarse_neighbor_scores_2016/"
brier = {}
roc = {}
for thresh in [25, 50]:
    print(thresh)
    brier_str = pd.read_csv(join(out_path, "ncar_2016_s_2_brier_objs_{0:02d}.csv".format(thresh)), index_col="Date")

    brier[thresh] = pd.DataFrame(index=pd.DatetimeIndex(brier_str.index), columns=brier_str.columns)
    print("Brier")
    for col in brier_str.columns:
        brier[thresh][col] = [DistributedReliability(input_str=s) for s in brier_str[col]]
    roc_str = pd.read_csv(join(out_path, "ncar_2016_roc_objs_{0:02d}.csv".format(thresh)), index_col="Date")
    roc[thresh] = pd.DataFrame(index=pd.DatetimeIndex(roc_str.index), columns=roc_str.columns)
    print("ROC")
    for col in roc_str.columns:
        roc[thresh][col] = [DistributedROC(input_str=s) for s in roc_str[col]]


25
Brier
ROC
50
Brier
ROC

In [80]:
fore_freq = pd.DataFrame(columns=brier[25].columns, index=brier[25].index, dtype=int)
for date in brier[25].index:
    for model in brier[25].columns:
        fore_freq.loc[date, model] = brier[25].loc[date, model].frequencies["Total_Freq"].sum()

In [21]:
ro = rel_objs[0]

In [26]:
ro.frequencies


Out[26]:
Total_Freq Positive_Freq
0 83624 119
1 40189 145
2 23176 159
3 18270 254
4 16256 308
5 16167 467
6 16540 607
7 18413 914
8 22295 1293
9 31158 2210
10 155841 20270
11 31439 4137
12 0 0

In [81]:
rel_objs = brier[25].sum(axis=0)
bss = rel_objs.apply(DistributedReliability.brier_skill_score)
bs = rel_objs.apply(DistributedReliability.brier_score)

In [18]:


In [28]:
rolling_brier["NCAR_HAIL_MAXK1_mean_25"]["2016-05-16"].brier_skill_score()


Out[28]:
-0.09054204346333437

In [85]:
roc_objs = roc[25].sum(axis=0)
roc_objs_50 = roc[50].sum(axis=0)

In [86]:
auc = roc_objs.apply(DistributedROC.auc)
auc_50 = roc_objs_50.apply(DistributedROC.auc)

In [82]:
thresholds = np.array([x[-1] for x in bss.index.str.split("_").values])
model_names = np.array(["_".join(x[:-2]) for x in bss.index.str.split("_").values])

In [12]:
rel_objs


Out[12]:
NCAR_HAIL_MAX2D_mean_5           Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAX2D_mean_20          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAX2D_mean_25          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAX2D_mean_30          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAX2D_mean_35          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAX2D_mean_40          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAX2D_mean_45          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAX2D_mean_50          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAX2D_mean_75          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAXK1_mean_5           Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAXK1_mean_20          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAXK1_mean_25          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAXK1_mean_30          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAXK1_mean_35          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAXK1_mean_40          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAXK1_mean_45          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAXK1_mean_50          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_HAIL_MAXK1_mean_75          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_UP_HELI_MAX_mean_5          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_UP_HELI_MAX_mean_25         Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_UP_HELI_MAX_mean_50         Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_UP_HELI_MAX_mean_75         Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_UP_HELI_MAX_mean_100        Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_UP_HELI_MAX_mean_125        Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_UP_HELI_MAX_mean_150        Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_UP_HELI_MAX_mean_175        Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_UP_HELI_MAX_mean_200        Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_GRPL_MAX_mean_5             Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_GRPL_MAX_mean_10            Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_GRPL_MAX_mean_15            Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
                                                       ...                        
NCAR_REFD_MAX_mean_60            Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_REFD_MAX_mean_65            Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_REFD_MAX_mean_70            Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest_mean_5        Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest_mean_20       Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest_mean_25       Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest_mean_30       Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest_mean_35       Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest_mean_40       Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest_mean_45       Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest_mean_50       Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest_mean_75       Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Elastic-Net_mean_5          Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Elastic-Net_mean_20         Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Elastic-Net_mean_25         Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Elastic-Net_mean_30         Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Elastic-Net_mean_35         Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Elastic-Net_mean_40         Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Elastic-Net_mean_45         Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Elastic-Net_mean_50         Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Elastic-Net_mean_75         Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest-CV_mean_5     Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest-CV_mean_20    Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest-CV_mean_25    Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest-CV_mean_30    Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest-CV_mean_35    Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest-CV_mean_40    Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest-CV_mean_45    Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest-CV_mean_50    Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
NCAR_Random-Forest-CV_mean_75    Obs_Threshold:1.00;Thresholds:0.00 0.01 0.10 0...
dtype: object

In [352]:
plt.figure(figsize=(11, 6))
colors = ["blue", "red", "green", "orange", "orangered", "purple", "navy", "black", "crimson", "skyblue"]
units = {"NCAR_Elastic-Net": "mm",
         "NCAR_Random-Forest": "mm",
         "NCAR_Random-Forest-CV": "mm",
         "NCAR_GRPL_MAX": "kg m$^{-2}$",
         "NCAR_HAILCAST_DIAM_MEAN": "mm",
         "NCAR_HAIL_MAX2D": "mm",
         "NCAR_HAIL_MAXK1": "mm",
         "NCAR_REFD_MAX": "dBZ",
         "NCAR_UP_HELI_MAX": "m$^2$ s$^{-2}$",
         "NCAR_W_UP_MAX": "m s$^{-1}$"
        }
long_names = {"NCAR_Elastic-Net": "Elastic Net",
         "NCAR_Random-Forest": "Random Forest",
         "NCAR_Random-Forest-CV": "Random Forest CV",
         "NCAR_GRPL_MAX": "Column Total Graupel",
         "NCAR_HAILCAST_DIAM_MEAN": "HAILCAST",
         "NCAR_HAIL_MAX2D": "Thompson Hail Column Max",
         "NCAR_HAIL_MAXK1": "Thompson Hail Surface",
         "NCAR_REFD_MAX": "Radar Reflectivity",
         "NCAR_UP_HELI_MAX": "Updraft Helicity",
         "NCAR_W_UP_MAX": "Updraft Speed"
        }
markers = ["o", "v", "*", "s", "D"] * 2
unique_model_names = np.sort(np.unique(model_names))
for m, model_name in enumerate(unique_model_names):
    print(model_name)
    print(thresholds[model_names == model_name])
    plt.plot(np.array(thresholds[model_names == model_name], dtype=float), 
             bss[model_names == model_name], label=long_names[model_name] + " ({0})".format(units[model_name]), 
             marker=markers[m], color=colors[m], lw=2)
    plt.plot(np.arange(200), np.zeros(200), 'k--')
plt.legend(loc=1, fontsize=9)
plt.xticks(np.concatenate((np.arange(0, 55, 5), np.arange(60, 210, 10))))
plt.grid()
plt.ylim(-0.2, 0.2)
plt.xlabel("Storm Surrogate Threshold", fontsize=12)
plt.ylabel("Brier Skill Score", fontsize=12)
plt.title("NCAR Ensemble 25 mm Hail 24-Hour Forecast Brier Skill Scores May-August 2016")
plt.savefig("ncar_ens_thresh_comp_bss_25.png", dpi=300, bbox_inches="tight")
plt.savefig("ncar_ens_thresh_comp_bss_25.pdf", dpi=300, bbox_inches="tight")


NCAR_Elastic-Net
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_GRPL_MAX
['5' '10' '15' '20' '25' '30' '35' '40' '45' '50']
NCAR_HAILCAST_DIAM_MEAN
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_HAIL_MAX2D
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_HAIL_MAXK1
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_REFD_MAX
['50' '55' '60' '65' '70']
NCAR_Random-Forest
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_Random-Forest-CV
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_UP_HELI_MAX
['5' '25' '50' '75' '100' '125' '150' '175' '200']
NCAR_W_UP_MAX
['2' '5' '10' '20' '30' '40']

In [355]:
plt.figure(figsize=(11, 6))
for m, model_name in enumerate(unique_model_names):
    print(model_name)
    print(thresholds[model_names == model_name])
    plt.plot(np.array(thresholds[model_names == model_name], dtype=float), 
             bss_50[model_names == model_name], label=long_names[model_name] + " ({0})".format(units[model_name]), 
             marker=markers[m], color=colors[m], lw=2)
    plt.plot(np.arange(200), np.zeros(200), 'k--')
plt.legend(loc=4, fontsize=10)
plt.xticks(np.concatenate((np.arange(0, 55, 5), np.arange(60, 210, 10))))
plt.grid()
plt.ylim(-0.3, 0.1)
plt.xlabel("Storm Surrogate Threshold")
plt.ylabel("Brier Skill Score")
plt.title("NCAR Ensemble 50 mm Hail 24-Hour Forecast Brier Skill Scores May-August 2016")
plt.savefig("ncar_ens_thresh_comp_bss_50.png", dpi=300, bbox_inches="tight")
plt.savefig("ncar_ens_thresh_comp_bss_50.pdf", dpi=300, bbox_inches="tight")


NCAR_Elastic-Net
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_GRPL_MAX
['5' '10' '15' '20' '25' '30' '35' '40' '45' '50']
NCAR_HAILCAST_DIAM_MEAN
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_HAIL_MAX2D
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_HAIL_MAXK1
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_REFD_MAX
['50' '55' '60' '65' '70']
NCAR_Random-Forest
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_Random-Forest-CV
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_UP_HELI_MAX
['5' '25' '50' '75' '100' '125' '150' '175' '200']
NCAR_W_UP_MAX
['2' '5' '10' '20' '30' '40']

In [353]:
plt.figure(figsize=(11, 6))
colors = ["blue", "red", "green", "orange", "orangered", "purple", "navy", "black", "crimson", "skyblue"]
units = {"NCAR_Elastic-Net": "mm",
         "NCAR_Random-Forest": "mm",
         "NCAR_Random-Forest-CV": "mm",
         "NCAR_GRPL_MAX": "kg m$^{-2}$",
         "NCAR_HAILCAST_DIAM_MEAN": "mm",
         "NCAR_HAIL_MAX2D": "mm",
         "NCAR_HAIL_MAXK1": "mm",
         "NCAR_REFD_MAX": "dBZ",
         "NCAR_UP_HELI_MAX": "m$^2$ s$^{-2}$",
         "NCAR_W_UP_MAX": "m s$^{-1}$"
        }
long_names = {"NCAR_Elastic-Net": "Elastic Net",
         "NCAR_Random-Forest": "Random Forest",
         "NCAR_Random-Forest-CV": "Random Forest CV",
         "NCAR_GRPL_MAX": "Column Total Graupel",
         "NCAR_HAILCAST_DIAM_MEAN": "HAILCAST",
         "NCAR_HAIL_MAX2D": "Thompson Hail Column Max",
         "NCAR_HAIL_MAXK1": "Thompson Hail Surface",
         "NCAR_REFD_MAX": "Radar Reflectivity",
         "NCAR_UP_HELI_MAX": "Updraft Helicity",
         "NCAR_W_UP_MAX": "Updraft Speed"
        }
unique_model_names = np.sort(np.unique(model_names))
for m, model_name in enumerate(unique_model_names):
    print(model_name)
    print(thresholds[model_names == model_name])
    plt.plot(np.array(thresholds[model_names == model_name], dtype=float), 
             auc[model_names == model_name], label=long_names[model_name] + " ({0})".format(units[model_name]), 
             marker=markers[m], color=colors[m], lw=2)
    plt.plot(np.arange(200), np.zeros(200), 'k--')
plt.legend(loc=1, fontsize=9)
plt.xticks(np.concatenate((np.arange(0, 55, 5), np.arange(60, 210, 10))))
plt.grid()
plt.ylim(0.5, 1)
plt.xlabel("Storm Surrogate Threshold")
plt.ylabel("Area Under ROC Curve")
plt.title("NCAR Ensemble 25 mm Hail 24-Hour Forecast AUC May-August 2016")
plt.savefig("ncar_ens_thresh_comp_auc_25.png", dpi=300, bbox_inches="tight")
plt.savefig("ncar_ens_thresh_comp_auc_25.pdf", dpi=300, bbox_inches="tight")


NCAR_Elastic-Net
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_GRPL_MAX
['5' '10' '15' '20' '25' '30' '35' '40' '45' '50']
NCAR_HAILCAST_DIAM_MEAN
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_HAIL_MAX2D
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_HAIL_MAXK1
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_REFD_MAX
['50' '55' '60' '65' '70']
NCAR_Random-Forest
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_Random-Forest-CV
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_UP_HELI_MAX
['5' '25' '50' '75' '100' '125' '150' '175' '200']
NCAR_W_UP_MAX
['2' '5' '10' '20' '30' '40']

In [354]:
plt.figure(figsize=(11, 6))
colors = ["blue", "red", "green", "orange", "orangered", "purple", "navy", "black", "crimson", "skyblue"]
units = {"NCAR_Elastic-Net": "mm",
         "NCAR_Random-Forest": "mm",
         "NCAR_Random-Forest-CV": "mm",
         "NCAR_GRPL_MAX": "kg m$^{-2}$",
         "NCAR_HAILCAST_DIAM_MEAN": "mm",
         "NCAR_HAIL_MAX2D": "mm",
         "NCAR_HAIL_MAXK1": "mm",
         "NCAR_REFD_MAX": "dBZ",
         "NCAR_UP_HELI_MAX": "m$^2$ s$^{-2}$",
         "NCAR_W_UP_MAX": "m s$^{-1}$"
        }
long_names = {"NCAR_Elastic-Net": "Elastic Net",
         "NCAR_Random-Forest": "Random Forest",
         "NCAR_Random-Forest-CV": "Random Forest CV",
         "NCAR_GRPL_MAX": "Column Total Graupel",
         "NCAR_HAILCAST_DIAM_MEAN": "HAILCAST",
         "NCAR_HAIL_MAX2D": "Thompson Hail Column Max",
         "NCAR_HAIL_MAXK1": "Thompson Hail Surface",
         "NCAR_REFD_MAX": "Radar Reflectivity",
         "NCAR_UP_HELI_MAX": "Updraft Helicity",
         "NCAR_W_UP_MAX": "Updraft Speed"
        }
unique_model_names = np.sort(np.unique(model_names))
for m, model_name in enumerate(unique_model_names):
    print(model_name)
    print(thresholds[model_names == model_name])
    plt.plot(np.array(thresholds[model_names == model_name], dtype=float), 
             auc_50[model_names == model_name], label=long_names[model_name] + " ({0})".format(units[model_name]), 
             marker=markers[m], color=colors[m], lw=2)
    plt.plot(np.arange(200), np.zeros(200), 'k--')
plt.legend(loc=1, fontsize=9)
plt.xticks(np.concatenate((np.arange(0, 55, 5), np.arange(60, 210, 10))))
plt.grid()
plt.ylim(0.5, 1)
plt.xlabel("Storm Surrogate Threshold")
plt.ylabel("Area Under ROC Curve")
plt.title("NCAR Ensemble 50 mm Hail 24-Hour Forecast AUC May-August 2016")
plt.savefig("ncar_ens_thresh_comp_auc_50.png", dpi=300, bbox_inches="tight")
plt.savefig("ncar_ens_thresh_comp_auc_50.pdf", dpi=300, bbox_inches="tight")


NCAR_Elastic-Net
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_GRPL_MAX
['5' '10' '15' '20' '25' '30' '35' '40' '45' '50']
NCAR_HAILCAST_DIAM_MEAN
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_HAIL_MAX2D
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_HAIL_MAXK1
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_REFD_MAX
['50' '55' '60' '65' '70']
NCAR_Random-Forest
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_Random-Forest-CV
['5' '20' '25' '30' '35' '40' '45' '50' '75']
NCAR_UP_HELI_MAX
['5' '25' '50' '75' '100' '125' '150' '175' '200']
NCAR_W_UP_MAX
['2' '5' '10' '20' '30' '40']

In [89]:
fig, ax = plt.subplots(figsize=(8, 8))
for m, model_name in enumerate(unique_model_names):
    max_thresh = thresholds[model_names == model_name][bss[model_names == model_name].values.argmax()]
    rel_objs.loc[model_name + "_mean_" + max_thresh].reliability_curve().plot(x="Bin_Start", 
                                                                              y="Positive_Relative_Freq",
                                                                             color=colors[m],
                                                                             marker='.',
                                                                              ax=ax,
                                                                             xlim=(0, 1),
                                                                             ylim=(0, 1),
                                                                             label=long_names[model_name] + " ({0} {1})".format(max_thresh, units[model_name]))
plt.xlabel("Forecast Probability", fontsize=12)
plt.ylabel("Observed Relative Frequency", fontsize=12)
plt.xticks(np.arange(0, 1.1, 0.1))
plt.yticks(np.arange(0, 1.1, 0.1))
plt.plot(np.arange(0, 1.1, .1), np.arange(0, 1.1, .1), 'k--')
plt.legend(loc=0, fontsize=10)
plt.title("NCAR Ensemble 25 mm Hail Reliability Diagram")
plt.savefig("ncar_ens_rel_diag_25.png", dpi=300, bbox_inches="tight")
plt.savefig("ncar_ens_rel_diag_25.pdf", dpi=300, bbox_inches="tight")



In [90]:
fig, ax = plt.subplots(figsize=(8, 8))
for m, model_name in enumerate(unique_model_names):
    max_thresh = thresholds[model_names == model_name][auc[model_names == model_name].values.argmax()]
    roc_objs.loc[model_name + "_mean_" + max_thresh].roc_curve().plot(x="POFD", 
                                                                      y="POD",
                                                                             color=colors[m],
                                                                             marker='.',
                                                                              ax=ax,
                                                                             xlim=(0, 1),
                                                                             ylim=(0, 1),
                                                                             label=long_names[model_name] + " ({0} {1})".format(max_thresh, units[model_name]))
plt.xlabel("Probability of False Detection", fontsize=12)
plt.ylabel("Probability of Detection", fontsize=12)
plt.xticks(np.arange(0, 1.1, 0.1))
plt.yticks(np.arange(0, 1.1, 0.1))
plt.plot(np.arange(0, 1.1, .1), np.arange(0, 1.1, .1), 'k--')
plt.legend(loc=0, fontsize=10)
plt.title("NCAR Ensemble 25 mm Hail ROC Diagram")
plt.savefig("ncar_ens_roc_diag_25.png", dpi=300, bbox_inches="tight")
plt.savefig("ncar_ens_roc_diag_25.pdf", dpi=300, bbox_inches="tight")



In [123]:
fig, ax = plt.subplots(figsize=(10, 5))
colors = ["blue", "red", "green", "orange", "orangered", "purple", "navy", "black", "crimson", "skyblue"]

for m, model_name in enumerate(unique_model_names):
    max_thresh = thresholds[model_names == model_name][bss[model_names == model_name].values.argmax()]
    rc = roc_objs.loc[model_name + "_mean_" + max_thresh].roc_curve()
    rc["PSS"] = rc["POD"] - rc["POFD"]
    rc["CT"] = roc_objs[model_name + "_mean_" + max_thresh].get_contingency_tables()
    rc["ETS"] = rc["CT"].apply(ContingencyTable.ets)
    rc.plot(x="Thresholds", 
            y="ETS",
            color=colors[m],
            marker='.',
            ax=ax,
            xlim=(0, 1),
            ylim=(0, 0.3),
            label=long_names[model_name] + " ({0} {1})".format(max_thresh, units[model_name]))
plt.legend(loc=0, fontsize=10)


Out[123]:
<matplotlib.legend.Legend at 0x2ba1cada2c90>

In [236]:
fig, ax = plt.subplots(figsize=(10, 5))
colors = ["blue", "red", "green", "orange", "orangered", "purple", "navy", "black", "crimson", "skyblue"]

for m, model_name in enumerate(unique_model_names):
    max_thresh = thresholds[model_names == model_name][auc_50[model_names == model_name].values.argmax()]
    rc = roc_objs_50.loc[model_name + "_mean_" + max_thresh].roc_curve()
    rc["PSS"] = rc["POD"] - rc["POFD"]
    rc["CT"] = roc_objs[model_name + "_mean_" + max_thresh].get_contingency_tables()
    rc["ETS"] = rc["CT"].apply(ContingencyTable.ets)
    rc.plot(x="Thresholds", 
            y="ETS",
            color=colors[m],
            marker='.',
            ax=ax,
            xlim=(0, 1),
            ylim=(0, 0.3),
            label=long_names[model_name] + " ({0} {1})".format(max_thresh, units[model_name]))
plt.legend(loc=0, fontsize=10)


Out[236]:
<matplotlib.legend.Legend at 0x2ba210f5acd0>

In [70]:
roc_objs.iloc[0].performance_curve()


Out[70]:
POD FAR Thresholds
0 1.000000 0.934759 0.00
1 0.996147 0.921066 0.01
2 0.991452 0.912406 0.10
3 0.986303 0.906673 0.20
4 0.978079 0.901963 0.30
5 0.968105 0.897558 0.40
6 0.952984 0.893244 0.50
7 0.933329 0.888773 0.60
8 0.903733 0.884062 0.70
9 0.861866 0.878148 0.80
10 0.790305 0.869676 0.90
11 0.133957 0.868412 1.00
12 0.000000 NaN 1.05

In [91]:
fig, ax = plt.subplots(figsize=(8, 8))
for m, model_name in enumerate(unique_model_names):
    max_thresh = thresholds[model_names == model_name][auc[model_names == model_name].values.argmax()]
    roc_objs.loc[model_name + "_mean_" + max_thresh].performance_curve().plot(x="FAR", 
                                                                              y="POD",
                                                                             color=colors[m],
                                                                             marker='.',
                                                                              ax=ax,
                                                                             xlim=(0, 1),
                                                                             ylim=(0, 1),
                                                                             label=long_names[model_name] + " ({0} {1})".format(max_thresh, units[model_name]))
plt.xlabel("Probability of False Detection", fontsize=12)
plt.ylabel("Probability of Detection", fontsize=12)
plt.xticks(np.arange(0, 1.1, 0.1))
plt.yticks(np.arange(0, 1.1, 0.1))
plt.plot(np.arange(0, 1.1, .1), np.arange(0, 1.1, .1), 'k--')
plt.legend(loc=0, fontsize=10)
plt.title("NCAR Ensemble 25 mm Hail Performance Diagram")
plt.savefig("ncar_ens_perf_diag_25.png", dpi=300, bbox_inches="tight")
plt.savefig("ncar_ens_perf_diag_25.pdf", dpi=300, bbox_inches="tight")



In [92]:
fig, ax = plt.subplots(figsize=(8, 8))
for m, model_name in enumerate(unique_model_names):
    max_thresh = thresholds[model_names == model_name][auc_50[model_names == model_name].values.argmax()]
    roc_objs_50.loc[model_name + "_mean_" + max_thresh].roc_curve().plot(x="POFD", 
                                                                      y="POD",
                                                                             color=colors[m],
                                                                             marker='.',
                                                                              ax=ax,
                                                                             xlim=(0, 1),
                                                                             ylim=(0, 1),
                                                                             label=long_names[model_name] + " ({0} {1})".format(max_thresh, units[model_name]))
plt.xlabel("Probability of False Detection", fontsize=12)
plt.ylabel("Probability of Detection", fontsize=12)
plt.xticks(np.arange(0, 1.1, 0.1))
plt.yticks(np.arange(0, 1.1, 0.1))
plt.plot(np.arange(0, 1.1, .1), np.arange(0, 1.1, .1), 'k--')
plt.legend(loc=0, fontsize=10)
plt.title("NCAR Ensemble 50 mm Hail ROC Diagram")
plt.savefig("ncar_ens_roc_diag_50.png", dpi=300, bbox_inches="tight")
plt.savefig("ncar_ens_roc_diag_50.pdf", dpi=300, bbox_inches="tight")



In [93]:
plt.figure(figsize=(6, 6))
for m, model_name in enumerate(unique_model_names):
    num_thresh = np.count_nonzero(model_names == model_name)
    model_thresh = thresholds[model_names == model_name]
    bs_comps = np.zeros((num_thresh, 3))
    for t in range(num_thresh):
        bs_comps[t] = rel_objs.loc[model_name + "_mean_" + model_thresh[t]].brier_score_components()
    plt.plot(bs_comps[:, 0] / bs_comps[:, 2], bs_comps[:, 1] / bs_comps[:, 2], 
             label=long_names[model_name], marker='', color=colors[m])
    plt.scatter(bs_comps[:, 0] / bs_comps[:, 2], bs_comps[:, 1] / bs_comps[:, 2], model_thresh.astype(float), colors[m],
             )
plt.xlim(0, 0.2)
plt.ylim(0, 0.2)
plt.legend(loc=0, fontsize=8)
plt.xlabel("Reliabliity")
plt.ylabel("Resolution")
plt.title("Brier Score Decomposition 25 mm Hail")
plt.savefig("ncar_ens_bs_decomp.pdf", bbox_inches="tight")



In [32]:
total_freqs = np.zeros(len(rel_objs),dtype=int)
for r, ro in enumerate(rel_objs_50.values):
    total_freqs[r] = ro.frequencies["Total_Freq"].sum()
    if total_freqs[r] < 473368:
        print(rel_objs.index[r], total_freqs[r])

In [64]:
total_freqs


Out[64]:
array([441929, 469914, 471101, 472059, 472439, 472987, 473169, 473283,
       473368, 473071, 473368, 473368, 473368, 473368, 473368, 473368,
       473368, 473368, 473288, 473368, 473368, 473368, 473368, 473368,
       473368, 473368, 473368, 473296, 473362, 473368, 473368, 473368,
       473368, 473368, 473368, 473368, 473368, 473329, 473368, 473368,
       473368, 473368, 473368, 473368, 473368, 473368, 445254, 469766,
       472961, 473361, 473368, 473368, 473295, 473368, 473368, 473368,
       473368, 473368, 473368, 473368, 473368, 473368, 473368, 473368,
       473368, 473368, 473368, 473368, 473368, 473368, 473368, 473368,
       473368, 473368, 473368, 473368, 473368, 473368, 473368, 473368,
       473368, 473368, 473368, 473368])

In [51]:
ro = rel_objs.iloc[6]
rc = rel_objs.iloc[6].reliability_curve()
print ro.brier_score_components()
print ro.frequencies["Total_Freq"].sum()
print np.sum(ro.frequencies["Total_Freq"] * (rc["Bin_Start"] - rc["Positive_Relative_Freq"]) ** 2) / ro.frequencies["Total_Freq"].sum()


(0.11235548880560145, 0.006150279667051211, 0.06088900772688263)
473169
0.112355488806

In [94]:
rel_objs_50 = brier[50].sum(axis=0)
bss_50 = rel_objs_50.apply(DistributedReliability.brier_skill_score)

In [63]:
rel_objs.loc["NCAR_UP_HELI_MAX_mean_100"].reliability_curve()


Out[63]:
Bin_Start Bin_End Bin_Center Positive_Relative_Freq Total_Relative_Freq
0 0.00 0.01 0.005 0.035754 0.866901
1 0.01 0.10 0.055 0.190409 0.079427
2 0.10 0.20 0.150 0.289135 0.024615
3 0.20 0.30 0.250 0.369269 0.011934
4 0.30 0.40 0.350 0.416542 0.007075
5 0.40 0.50 0.450 0.420709 0.004529
6 0.50 0.60 0.550 0.473643 0.002725
7 0.60 0.70 0.650 0.476364 0.001743
8 0.70 0.80 0.750 0.569149 0.000794
9 0.80 0.90 0.850 0.672727 0.000232
10 0.90 1.00 0.950 0.666667 0.000025
11 1.00 1.05 1.025 NaN 0.000000

In [43]:
cmap = colors.ListedColormap(['white', 'red'])
bounds=[0,5,10]
norm = colors.BoundaryNorm(bounds, cmap.N)

In [50]:
cmap = plt.get_cmap("Reds")
vals = cmap(np.linspace(0, 1, 5))
vals


Out[50]:
array([[ 1.        ,  0.96078432,  0.94117647,  1.        ],
       [ 0.98823529,  0.7320723 ,  0.62992697,  1.        ],
       [ 0.98357555,  0.41279508,  0.28835065,  1.        ],
       [ 0.7925721 ,  0.0932872 ,  0.11298731,  1.        ],
       [ 0.40392157,  0.        ,  0.05098039,  1.        ]])

In [97]:
print(unique_model_names)
model_name = "NCAR_UP_HELI_MAX"
for model_name in unique_model_names:
    model_thresh = thresholds[model_names == model_name]
    fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 5))
    cmap = plt.get_cmap("inferno")
    cvals = cmap(np.linspace(0.1, 0.9, len(model_thresh)))
    for m, m_thresh in enumerate(model_thresh):
        rel_objs_50.loc[model_name + "_mean_" + m_thresh].reliability_curve().plot(x="Bin_Start", 
                                                                                y="Positive_Relative_Freq",
                                                                                ax=ax1,
                                                                                label=m_thresh,
                                                                               marker='.',
                                                                               color=cvals[m])
        rel_objs_50.loc[model_name + "_mean_" + m_thresh].reliability_curve().plot(x="Bin_Start", 
                                                                                y="Total_Relative_Freq",
                                                                                ax=ax2,
                                                                                label=m_thresh,
                                                                                marker='.',
                                                                               color=cvals[m])
    fig.suptitle("NCAR Ens. " + long_names[model_name] + " 50 mm Hail Forecast", fontsize=14, fontweight="bold")
    ax1.legend(fontsize=9, loc=0)
    ax2.legend_.remove()
    ax2.set_yscale("log")
    ax1.plot(np.arange(0, 1.1, .1), np.arange(0, 1.1, .1), 'k--')
    ax1.set_xlabel("Forecast Probability", fontsize=12)
    ax1.set_ylabel("Observed Relative Frequency", fontsize=12)
    ax2.set_xlabel("Forecast Probability", fontsize=12)
    ax2.set_ylabel("Forecast Relative Frequency", fontsize=12)
    plt.savefig("ncar_hail_rel_{0}_50.pdf".format(model_name), bbox_inches="tight")
    plt.close()


['NCAR_Elastic-Net' 'NCAR_GRPL_MAX' 'NCAR_HAILCAST_DIAM_MEAN'
 'NCAR_HAIL_MAX2D' 'NCAR_HAIL_MAXK1' 'NCAR_REFD_MAX' 'NCAR_Random-Forest'
 'NCAR_Random-Forest-CV' 'NCAR_UP_HELI_MAX' 'NCAR_W_UP_MAX']

In [98]:
print(unique_model_names)
model_name = "NCAR_UP_HELI_MAX"
for model_name in unique_model_names:
    model_thresh = thresholds[model_names == model_name]
    fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 5))
    cmap = plt.get_cmap("inferno")
    cvals = cmap(np.linspace(0.1, 0.9, len(model_thresh)))
    for m, m_thresh in enumerate(model_thresh):
        rel_objs.loc[model_name + "_mean_" + m_thresh].reliability_curve().plot(x="Bin_Start", 
                                                                                y="Positive_Relative_Freq",
                                                                                ax=ax1,
                                                                                label=m_thresh,
                                                                               marker='.',
                                                                               color=cvals[m])
        rel_objs.loc[model_name + "_mean_" + m_thresh].reliability_curve().plot(x="Bin_Start", 
                                                                                y="Total_Relative_Freq",
                                                                                ax=ax2,
                                                                                label=m_thresh,
                                                                                marker='.',
                                                                               color=cvals[m])
    fig.suptitle("NCAR Ens. " + long_names[model_name] + " 25 mm Hail Forecast", fontsize=14, fontweight="bold")
    ax1.legend(fontsize=9, loc=0)
    ax2.legend_.remove()
    ax2.set_yscale("log")
    ax1.plot(np.arange(0, 1.1, .1), np.arange(0, 1.1, .1), 'k--')
    ax1.set_xlabel("Forecast Probability", fontsize=12)
    ax1.set_ylabel("Observed Relative Frequency", fontsize=12)
    ax2.set_xlabel("Forecast Probability", fontsize=12)
    ax2.set_ylabel("Forecast Relative Frequency", fontsize=12)
    plt.savefig("ncar_hail_rel_{0}_25.pdf".format(model_name), bbox_inches="tight")
    plt.close()


['NCAR_Elastic-Net' 'NCAR_GRPL_MAX' 'NCAR_HAILCAST_DIAM_MEAN'
 'NCAR_HAIL_MAX2D' 'NCAR_HAIL_MAXK1' 'NCAR_REFD_MAX' 'NCAR_Random-Forest'
 'NCAR_Random-Forest-CV' 'NCAR_UP_HELI_MAX' 'NCAR_W_UP_MAX']

In [329]:
print(unique_model_names)
model_name = "NCAR_UP_HELI_MAX"
for model_name in unique_model_names:
    model_thresh = thresholds[model_names == model_name]
    fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 5))
    cmap = plt.get_cmap("viridis")
    cvals = cmap(np.linspace(0.2, 0.8, len(model_thresh)))
    for m, m_thresh in enumerate(model_thresh):
        #print(roc_objs.loc[model_name + "_mean_" + m_thresh].performance_curve())
        roc_objs.loc[model_name + "_mean_" + m_thresh].performance_curve().plot(x="FAR", 
                                                                                y="POD",
                                                                                ax=ax1,
                                                                                label=m_thresh,
                                                                               marker='.',
                                                                               color=cvals[m])
        roc_objs.loc[model_name + "_mean_" + m_thresh].roc_curve().plot(x="POFD", 
                                                                                y="POD",
                                                                                ax=ax2,
                                                                                label=m_thresh,
                                                                                marker='.',
                                                                               color=cvals[m])
    fig.suptitle("NCAR Ens. " + long_names[model_name] + " 25 mm Hail Forecast", fontsize=14, fontweight="bold")
    ax1.set_xlim(0, 1)
    ax1.set_ylim(0, 1)
    ax2.set_xlim(0, 1)
    ax2.set_ylim(0, 1)
    ax1.legend(fontsize=9, loc=0)
    ax2.legend_.remove()
    #ax2.set_yscale("log")
    ax1.plot(np.arange(0, 1.1, .1), np.arange(0, 1.1, .1), 'k--')
    ax2.plot(np.arange(0, 1.1, .1), np.arange(0, 1.1, .1), 'k--')
    ax1.set_xlabel("False Alarm Ratio", fontsize=12)
    ax1.set_ylabel("Probability of Detection", fontsize=12)
    ax2.set_xlabel("Probability of False Detection", fontsize=12)
    ax2.set_ylabel("Probability of Detection", fontsize=12)
    plt.savefig("ncar_hail_perf_{0}_25.pdf".format(model_name), bbox_inches="tight")
    plt.close()


['NCAR_Elastic-Net' 'NCAR_GRPL_MAX' 'NCAR_HAILCAST_DIAM_MEAN'
 'NCAR_HAIL_MAX2D' 'NCAR_HAIL_MAXK1' 'NCAR_REFD_MAX' 'NCAR_Random-Forest'
 'NCAR_Random-Forest-CV' 'NCAR_UP_HELI_MAX' 'NCAR_W_UP_MAX']

In [330]:
print(unique_model_names)
model_name = "NCAR_UP_HELI_MAX"
for model_name in unique_model_names:
    model_thresh = thresholds[model_names == model_name]
    fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 5))
    cmap = plt.get_cmap("viridis")
    cvals = cmap(np.linspace(0.2, 0.8, len(model_thresh)))
    for m, m_thresh in enumerate(model_thresh):
        #print(roc_objs.loc[model_name + "_mean_" + m_thresh].performance_curve())
        roc_objs_50.loc[model_name + "_mean_" + m_thresh].performance_curve().plot(x="FAR", 
                                                                                y="POD",
                                                                                ax=ax1,
                                                                                label=m_thresh,
                                                                               marker='.',
                                                                               color=cvals[m])
        roc_objs_50.loc[model_name + "_mean_" + m_thresh].roc_curve().plot(x="POFD", 
                                                                                y="POD",
                                                                                ax=ax2,
                                                                                label=m_thresh,
                                                                                marker='.',
                                                                               color=cvals[m])
    fig.suptitle("NCAR Ens. " + long_names[model_name] + " 50 mm Hail Forecast", fontsize=14, fontweight="bold")
    ax1.set_xlim(0, 1)
    ax1.set_ylim(0, 1)
    ax2.set_xlim(0, 1)
    ax2.set_ylim(0, 1)
    ax1.legend(fontsize=9, loc=0)
    ax2.legend_.remove()
    #ax2.set_yscale("log")
    ax1.plot(np.arange(0, 1.1, .1), np.arange(0, 1.1, .1), 'k--')
    ax2.plot(np.arange(0, 1.1, .1), np.arange(0, 1.1, .1), 'k--')
    ax1.set_xlabel("False Alarm Ratio", fontsize=12)
    ax1.set_ylabel("Probability of Detection", fontsize=12)
    ax2.set_xlabel("Probability of False Detection", fontsize=12)
    ax2.set_ylabel("Probability of Detection", fontsize=12)
    plt.savefig("ncar_hail_perf_{0}_50.pdf".format(model_name), bbox_inches="tight")
    plt.close()


['NCAR_Elastic-Net' 'NCAR_GRPL_MAX' 'NCAR_HAILCAST_DIAM_MEAN'
 'NCAR_HAIL_MAX2D' 'NCAR_HAIL_MAXK1' 'NCAR_REFD_MAX' 'NCAR_Random-Forest'
 'NCAR_Random-Forest-CV' 'NCAR_UP_HELI_MAX' 'NCAR_W_UP_MAX']

In [100]:
fig, ax = plt.subplots(figsize=(8, 8))
for m, model_name in enumerate(unique_model_names):
    max_thresh = thresholds[model_names == model_name][bss_50[model_names == model_name].values.argmax()]
    rel_objs_50.loc[model_name + "_mean_" + max_thresh].reliability_curve().plot(x="Bin_Center", 
                                                                              y="Positive_Relative_Freq",
                                                                             color=colors[m],
                                                                             marker='.',
                                                                              ax=ax,
                                                                             xlim=(0, 1),
                                                                             ylim=(0, 1),
                                                                             label=long_names[model_name] + " ({0} {1})".format(max_thresh, units[model_name]))
plt.xlabel("Forecast Probability", fontsize=12)
plt.ylabel("Observed Relative Frequency", fontsize=12)
plt.xticks(np.arange(0, 1.1, 0.1))
plt.yticks(np.arange(0, 1.1, 0.1))
plt.plot(np.arange(0, 1.1, .1), np.arange(0, 1.1, .1), 'k--')
plt.legend(loc=0, fontsize=10)
plt.title("NCAR Ensemble 50 mm Hail Reliability Diagram")
plt.savefig("ncar_ens_rel_diag_50.png", dpi=300, bbox_inches="tight")
plt.savefig("ncar_ens_rel_diag_50.pdf", dpi=300, bbox_inches="tight")



In [102]:
daily_bss = pd.DataFrame(index=brier[25].index, columns=brier[25].columns)
def brier_skill_score(obj):
    try:
        return DistributedReliability.brier_skill_score(obj)
    except ZeroDivisionError:
        return np.nan
for col in daily_bss:
    daily_bss.loc[:, col] = brier[25][col].apply(brier_skill_score)

In [124]:
daily_bss


Out[124]:
NCAR_HAIL_MAX2D_mean_5 NCAR_HAIL_MAX2D_mean_20 NCAR_HAIL_MAX2D_mean_25 NCAR_HAIL_MAX2D_mean_30 NCAR_HAIL_MAX2D_mean_35 NCAR_HAIL_MAX2D_mean_40 NCAR_HAIL_MAX2D_mean_45 NCAR_HAIL_MAX2D_mean_50 NCAR_HAIL_MAX2D_mean_75 NCAR_HAIL_MAXK1_mean_5 ... NCAR_Elastic-Net_mean_75 NCAR_Random-Forest-CV_mean_5 NCAR_Random-Forest-CV_mean_20 NCAR_Random-Forest-CV_mean_25 NCAR_Random-Forest-CV_mean_30 NCAR_Random-Forest-CV_mean_35 NCAR_Random-Forest-CV_mean_40 NCAR_Random-Forest-CV_mean_45 NCAR_Random-Forest-CV_mean_50 NCAR_Random-Forest-CV_mean_75
Date
2016-05-02 -7.189639 -3.270793 -2.543755 -1.769930 -1.440473 -0.876362 -0.640854 -0.417216 0.365567 -1.444042 ... -0.048590 0.398628 0.409983 0.411566 0.422053 0.436014 0.451408 0.450255 0.415124 -0.048590
2016-05-03 -7.732068 -3.666396 -2.698834 -1.620488 -1.156262 -0.429632 -0.116988 0.121119 0.436986 -0.682004 ... -0.033886 0.440492 0.441488 0.439707 0.434146 0.442201 0.424018 0.384651 0.319216 -0.033886
2016-05-04 -19.893485 -13.280084 -11.496387 -9.117497 -7.763323 -5.019959 -3.294380 -1.917240 -0.317387 -7.129334 ... -0.014446 -0.207453 -0.199069 -0.185374 -0.174412 -0.164755 -0.116926 -0.051807 0.015536 -0.014446
2016-05-05 -27.987419 -16.942550 -13.289572 -8.666233 -6.640694 -3.512229 -2.320207 -1.159874 0.037385 -10.198157 ... -0.011662 0.045256 0.036528 0.037330 0.038125 0.039514 0.030189 0.025491 0.032698 -0.011662
2016-05-06 -12.793825 -8.239850 -6.949228 -5.002362 -3.876317 -1.822522 -0.922886 -0.395987 -0.028207 -5.559074 ... -0.028837 -0.027029 -0.028361 -0.027044 -0.026711 -0.023812 -0.024214 -0.028354 -0.028640 -0.028837
2016-05-07 -18.712853 -11.122744 -9.118044 -5.941124 -4.261661 -1.903663 -1.069529 -0.457827 0.058731 -5.974398 ... -0.024548 0.231822 0.231447 0.226413 0.215678 0.200885 0.195269 0.178255 0.142426 -0.024548
2016-05-08 -8.463085 -4.644323 -3.539613 -2.112258 -1.546683 -0.640193 -0.264794 0.026653 0.246681 -2.813343 ... -0.056604 0.339331 0.321149 0.310315 0.296050 0.287847 0.280528 0.259584 0.219427 -0.056604
2016-05-09 -10.016884 -5.720819 -4.518306 -3.327914 -2.800581 -1.860338 -1.395414 -1.001812 0.302627 -2.899671 ... -0.052331 0.350838 0.362705 0.357586 0.345005 0.339601 0.333717 0.293295 0.201015 -0.052331
2016-05-10 -5.986764 -2.764805 -2.093056 -1.513559 -1.272013 -0.916577 -0.733997 -0.494149 0.218865 -2.027769 ... -0.064731 0.276642 0.277423 0.284709 0.279225 0.277617 0.256735 0.227404 0.166899 -0.064731
2016-05-11 -3.855741 -1.522695 -1.270205 -1.016125 -0.914058 -0.657281 -0.477033 -0.272825 0.301134 -0.223416 ... -0.080082 0.304577 0.312126 0.310942 0.312150 0.316780 0.311748 0.278770 0.232895 -0.080342
2016-05-12 -8.074609 -4.944974 -4.475966 -4.024715 -3.809112 -3.259447 -2.858487 -2.400813 -0.199309 -0.690685 ... -0.035338 0.044224 0.035508 0.029469 0.033100 0.032684 0.033168 0.029532 0.028035 -0.034935
2016-05-13 -6.036731 -2.028227 -1.643712 -1.255609 -1.068032 -0.675343 -0.473655 -0.318744 0.170554 -0.907936 ... -0.056856 0.281262 0.269622 0.263806 0.260119 0.251771 0.238941 0.213497 0.166437 -0.056856
2016-05-14 -14.754240 -8.116993 -6.573230 -5.028033 -4.136350 -2.231076 -1.528949 -0.911505 0.226975 -5.155097 ... -0.030035 0.070430 0.074431 0.076432 0.085135 0.079386 0.071959 0.073165 0.066954 -0.028935
2016-05-15 -20.506299 -10.912783 -8.336820 -5.951260 -4.937218 -2.843268 -1.792796 -0.928827 -0.195326 -6.919179 ... -0.024786 0.165978 0.186570 0.193465 0.192982 0.196136 0.208106 0.212396 0.161074 -0.024786
2016-05-16 -19.607071 -9.463523 -7.389316 -4.724236 -3.480862 -1.922890 -1.473136 -1.148289 -0.030949 -6.331205 ... -0.027165 0.083814 0.098643 0.112521 0.124116 0.130356 0.128343 0.172930 0.145896 -0.027165
2016-05-17 -15.517571 -9.247036 -7.810450 -6.100446 -5.080837 -3.141746 -2.382840 -1.705214 -0.137027 -3.547553 ... -0.031007 0.307860 0.316979 0.320939 0.319441 0.323482 0.316748 0.312406 0.300129 -0.032198
2016-05-18 -16.979145 -10.076923 -8.624773 -6.381251 -5.052998 -2.725284 -1.801254 -1.143020 -0.085835 -5.370784 ... -0.022890 0.148175 0.150560 0.147255 0.135076 0.135176 0.132798 0.115256 0.087042 -0.022890
2016-05-19 -19.456682 -12.934922 -10.897647 -8.392008 -6.909379 -3.879804 -2.785428 -2.098853 -0.449521 -6.725628 ... -0.025261 -0.047871 0.006029 0.028316 0.045713 0.066397 0.065261 0.065379 0.049731 -0.025261
2016-05-20 -20.018748 -12.142060 -10.193309 -7.221259 -5.928603 -3.962268 -3.069340 -2.268196 -0.600043 -5.595945 ... -0.021945 -0.061170 -0.042243 -0.033631 -0.019549 -0.008138 -0.001360 0.014221 0.029344 -0.021945
2016-05-21 -9.238095 -5.402257 -4.207287 -2.671547 -2.009627 -0.951905 -0.586960 -0.330351 0.119493 -3.346620 ... -0.044290 0.204804 0.202611 0.202333 0.207021 0.203480 0.207127 0.194838 0.170891 -0.043966
2016-05-22 -8.799959 -5.030661 -3.754621 -2.493248 -2.121850 -1.523402 -1.172135 -0.830835 0.317119 -3.214912 ... -0.045122 0.331447 0.378936 0.386212 0.392611 0.395229 0.402445 0.388550 0.336493 -0.045122
2016-05-23 -6.851811 -3.561631 -2.524567 -1.669149 -1.451414 -1.098818 -0.894452 -0.661337 0.190611 -1.790803 ... -0.055509 0.259002 0.279923 0.283683 0.287933 0.296539 0.311535 0.318173 0.276819 -0.055146
2016-05-24 -4.463259 -2.995412 -2.553618 -1.794511 -1.341876 -0.712277 -0.511000 -0.358469 0.138037 -1.410652 ... -0.089543 0.190320 0.187813 0.190900 0.192703 0.189876 0.175593 0.133333 0.076581 -0.092444
2016-05-25 -3.144660 -2.240273 -2.055796 -1.691157 -1.366066 -0.747336 -0.545725 -0.379539 0.099155 -1.049742 ... -0.130293 0.174307 0.158336 0.148717 0.140221 0.129500 0.107533 0.068069 0.021648 -0.131168
2016-05-26 -5.510341 -3.931670 -3.418969 -2.681156 -2.278399 -1.586728 -1.272870 -0.972597 -0.028991 -1.517049 ... -0.095507 0.073284 0.113172 0.131431 0.149996 0.165113 0.177558 0.190730 0.134783 -0.098039
2016-05-27 -14.133136 -10.644808 -9.761205 -8.448673 -7.675575 -5.921625 -5.135469 -4.428553 -0.692214 -3.117774 ... -0.040941 0.046351 0.070991 0.084089 0.090248 0.101554 0.109988 0.121827 0.121371 -0.040941
2016-05-28 -12.233864 -8.249644 -7.361426 -6.180566 -5.605382 -4.367336 -3.641746 -2.825426 -0.046225 -1.966888 ... -0.041732 0.209250 0.205374 0.211047 0.207741 0.208433 0.203454 0.188802 0.143397 -0.040573
2016-05-29 -6.215206 -4.099371 -3.658353 -3.023371 -2.640853 -1.898246 -1.560432 -1.229589 0.064033 -1.058246 ... -0.079691 0.048631 0.068090 0.073192 0.075759 0.078788 0.085407 0.106154 0.094819 -0.079425
2016-05-30 -7.250334 -5.174271 -4.733154 -4.215699 -3.946858 -3.283674 -2.870988 -2.399408 -0.125593 -1.298125 ... -0.067782 -0.082527 -0.035729 -0.014911 -0.001088 0.031466 0.059719 0.107703 0.148132 -0.068228
2016-05-31 -4.249249 -2.603912 -2.313783 -2.058452 -1.918641 -1.602552 -1.418786 -1.192876 0.095688 -0.309259 ... -0.101045 0.122658 0.121516 0.111318 0.099983 0.089185 0.086688 0.061574 0.032235 -0.100993
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2016-07-24 -4.245468 -3.051894 -2.868839 -2.639613 -2.488431 -2.141208 -1.911068 -1.641197 -0.416333 -0.010019 ... -0.069061 0.072438 0.099654 0.108785 0.117389 0.123077 0.141018 0.158385 0.119896 -0.071501
2016-07-25 -4.592099 -3.685633 -3.529607 -3.334961 -3.196591 -2.836301 -2.590972 -2.252745 -0.602304 -0.253691 ... -0.088294 -0.034728 -0.017582 -0.016248 -0.004247 0.001692 0.008816 0.015795 -0.006118 -0.090000
2016-07-26 -4.381270 -3.586136 -3.455070 -3.262894 -3.131029 -2.719811 -2.446026 -2.117020 -0.491228 -0.120483 ... -0.095314 0.131031 0.136206 0.134438 0.134550 0.131738 0.136043 0.134293 0.115264 -0.098265
2016-07-27 -2.312045 -1.788261 -1.705371 -1.586136 -1.531121 -1.373153 -1.271091 -1.132319 -0.155769 0.064812 ... -0.158560 0.128485 0.114659 0.106648 0.102031 0.095334 0.085749 0.070069 0.035773 -0.161421
2016-07-29 -3.772275 -2.740234 -2.565277 -2.289025 -2.114148 -1.710066 -1.468006 -1.171616 -0.152144 0.215383 ... -0.094188 0.187711 0.182735 0.181009 0.166546 0.167593 0.159867 0.139012 0.107446 -0.105135
2016-07-30 -3.352783 -2.647906 -2.475105 -2.234289 -2.074270 -1.688309 -1.437426 -1.201857 -0.223958 -0.079397 ... -0.122152 0.062769 0.062878 0.065074 0.064547 0.061270 0.056339 0.043362 0.022335 -0.120163
2016-07-31 -2.509295 -2.008433 -1.930896 -1.814198 -1.728835 -1.494834 -1.310790 -1.069073 -0.066832 -0.378151 ... -0.149929 -0.002915 -0.002465 0.000198 0.000332 -0.004334 -0.015759 -0.021611 -0.048077 -0.150648
2016-08-01 -4.491040 -3.781949 -3.641983 -3.482027 -3.391124 -3.124391 -2.881378 -2.576359 -0.478674 -0.554079 ... -0.084168 -0.125239 -0.089630 -0.079560 -0.063711 -0.042761 0.002205 0.028486 0.020561 -0.085114
2016-08-02 -4.848577 -3.772925 -3.556009 -3.334141 -3.200055 -2.873626 -2.636534 -2.342207 -0.560678 -0.700258 ... -0.075438 -0.000620 0.014933 0.016468 0.018470 0.022344 0.025043 0.022291 0.000962 -0.078761
2016-08-03 -4.605730 -3.433696 -3.279006 -3.070092 -2.918124 -2.492963 -2.223528 -1.885951 -0.318535 -0.419174 ... -0.050962 0.119950 0.140131 0.140207 0.145573 0.156790 0.167859 0.158565 0.123254 -0.069891
2016-08-04 -124.497172 -102.313327 -98.456851 -92.278012 -88.569921 -79.540023 -72.775789 -64.336217 -22.864564 -13.742675 ... -0.003175 -8.829191 -7.853919 -7.353757 -6.770504 -6.137702 -5.022544 -3.442394 -1.292870 -0.003175
2016-08-08 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2016-08-09 -4.893963 -3.876459 -3.708087 -3.475429 -3.325420 -2.798050 -2.474814 -2.048810 -0.287595 -0.645709 ... -0.082358 0.095289 0.106385 0.114150 0.117954 0.119966 0.124680 0.121029 0.091062 -0.084524
2016-08-10 -4.842153 -3.552791 -3.369731 -3.125724 -2.971896 -2.562514 -2.271085 -1.934038 -0.164407 -0.362770 ... -0.084463 0.141804 0.159645 0.161367 0.168652 0.180690 0.186400 0.172970 0.143113 -0.088465
2016-08-11 -6.271590 -5.135609 -4.924509 -4.504391 -4.211785 -3.568560 -3.216203 -2.773763 -0.689957 -0.414250 ... -0.070394 -0.071368 -0.051630 -0.032719 -0.023769 -0.014672 0.035272 0.086785 0.131773 -0.070315
2016-08-12 -8.631229 -7.108720 -6.867851 -6.488552 -6.238636 -5.578302 -5.057561 -4.411841 -0.962080 -0.479387 ... -0.055852 -0.103330 -0.076394 -0.064396 -0.053161 -0.037643 -0.035251 -0.018907 -0.026633 -0.055847
2016-08-13 -6.470542 -5.112198 -4.901863 -4.610655 -4.450335 -3.938245 -3.569052 -3.069730 -0.632993 -0.098792 ... -0.054226 0.177059 0.159884 0.145150 0.126633 0.115393 0.109596 0.091138 0.033273 -0.054589
2016-08-14 -8.256518 -5.638742 -5.236796 -4.683787 -4.376778 -3.593019 -3.039283 -2.476370 -0.305751 -0.285407 ... -0.023905 0.100754 0.086200 0.087299 0.079254 0.074607 0.068918 0.054852 0.039381 -0.045122
2016-08-15 -6.721215 -4.482427 -3.964959 -3.413100 -3.123020 -2.518759 -2.148468 -1.781057 -0.186381 -0.027663 ... -0.060666 0.069710 0.066835 0.060969 0.055470 0.050605 0.044824 0.035461 0.019401 -0.063838
2016-08-16 -5.931578 -4.511740 -4.239461 -3.822862 -3.527181 -2.933253 -2.604429 -2.272683 -0.539168 -0.250387 ... -0.071446 0.043377 0.034618 0.031929 0.028988 0.024231 0.015623 0.015999 -0.004879 -0.070727
2016-08-17 -9.232286 -7.244791 -6.769877 -6.081373 -5.747039 -4.775856 -4.133071 -3.527463 -0.574914 -0.763387 ... -0.048803 0.020738 0.006302 0.001821 0.001422 -0.006095 -0.016445 -0.021405 -0.031798 -0.050083
2016-08-18 -5.961433 -4.507951 -4.171511 -3.770274 -3.506975 -2.780967 -2.359259 -1.894014 -0.243108 -0.741466 ... -0.091791 -0.010031 -0.008763 -0.008876 -0.006322 -0.002351 -0.011447 -0.018005 -0.032977 -0.094011
2016-08-19 -9.061334 -7.180308 -6.825517 -6.419235 -6.104276 -5.312870 -4.799394 -4.151738 -0.925579 -0.954595 ... -0.056029 -0.125027 -0.070258 -0.048511 -0.025065 -0.009446 0.039741 0.091527 0.167962 -0.058544
2016-08-20 -13.965997 -11.173101 -10.724833 -10.173246 -9.828114 -8.785364 -8.084695 -7.157725 -1.441049 -0.292570 ... -0.025972 0.098783 0.091460 0.090560 0.088746 0.090888 0.085961 0.088929 0.068935 -0.029085
2016-08-21 -23.554797 -19.072822 -18.053944 -16.559362 -15.736809 -13.564966 -11.712564 -9.497414 -0.794614 -2.715231 ... -0.014356 0.034271 0.054087 0.067687 0.073940 0.076446 0.068002 0.072577 0.078206 -0.014927
2016-08-26 -4.614852 -3.374502 -3.093059 -2.666341 -2.413613 -1.853123 -1.548848 -1.231822 -0.186034 -0.674293 ... -0.092885 0.003336 0.013622 0.016614 0.015184 0.018059 0.023521 0.020028 0.004430 -0.092885
2016-08-27 -4.425721 -3.214428 -3.052538 -2.798242 -2.633424 -2.247407 -1.995524 -1.673223 -0.295797 -0.635583 ... -0.079024 -0.103725 -0.084272 -0.080412 -0.077548 -0.071991 -0.063837 -0.055079 -0.050368 -0.079028
2016-08-29 -8.072105 -6.651948 -6.432950 -6.192957 -5.992190 -5.319798 -4.840069 -4.267462 -0.535140 -0.826632 ... -0.045369 0.059531 0.078590 0.077987 0.080877 0.079353 0.082840 0.084686 0.066456 -0.045369
2016-08-30 -19.369704 -14.991518 -14.485336 -13.710695 -13.212569 -11.190942 -9.998488 -8.391081 -2.122293 -1.250229 ... -0.018885 -0.021486 -0.018117 -0.018609 -0.018360 -0.017991 -0.017602 -0.018049 -0.018535 -0.018885
2016-08-31 -23.512379 -18.169085 -16.970360 -15.360707 -14.485989 -12.117069 -10.489182 -8.337169 -0.967259 -1.298137 ... -0.018182 -0.017794 -0.017784 -0.017777 -0.017776 -0.017776 -0.017776 -0.017742 -0.017711 -0.018182

107 rows × 84 columns


In [123]:
import matplotlib.dates as mdates
fig, ax = plt.subplots(figsize=(10, 8))
plt.pcolormesh(daily_bss.index, np.arange(0, daily_bss.shape[1]), 
               np.ma.array(daily_bss.values.T, mask=np.isnan(daily_bss.values.T)), vmin=-0.5, vmax=0.5, cmap="RdBu")
#plt.xticks(np.arange(0, daily_bss.shape[0] + 7, 7), daily_bss.index[::7], rotation=90)
ax.xaxis.set_major_formatter(mdates.DateFormatter("%Y-%m-%d"))
plt.ylim(0, daily_bss.shape[1])
plt.yticks(np.arange(0.5, daily_bss.shape[1], 2), 
           daily_bss.columns[::2].str.replace("NCAR_", "").str.replace("_", " ").str.replace("mean ", "").str.replace("-", " "), fontsize=8)
plt.title("NCAR Ensemble 25 mm Hail BSS Time Series")
fig.autofmt_xdate()
plt.colorbar()
plt.savefig("ncar_bss_hail_ts.png", dpi=300, bbox_inches="tight")



In [101]:
fig, ax = plt.subplots(figsize=(12, 5))
daily_bss.plot(y=["NCAR_Random-Forest-CV_mean_25", "NCAR_UP_HELI_MAX_mean_50", "NCAR_HAIL_MAXK1_mean_25", 
                  "NCAR_GRPL_MAX_mean_30", "NCAR_HAILCAST_DIAM_MEAN_mean_25"],
               ax=ax, marker='.', linestyle="")
plt.ylim(-1, 1)
plt.legend(loc=0, fontsize=10)
plt.grid()
plt.ylabel("Brier Skill Score")
plt.xlabel("Date")
plt.title("Daily Brier Skill Score Time Series NCAR Ens 25 mm Hail")
plt.savefig("ncar_bss_ts_hail_25.pdf", dpi=300, bbox_inches="tight")


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-101-66bf6c47f05e> in <module>()
      1 fig, ax = plt.subplots(figsize=(12, 5))
----> 2 daily_bss.plot(y=["NCAR_Random-Forest-CV_mean_25", "NCAR_UP_HELI_MAX_mean_50", "NCAR_HAIL_MAXK1_mean_25", 
      3                   "NCAR_GRPL_MAX_mean_30", "NCAR_HAILCAST_DIAM_MEAN_mean_25"],
      4                ax=ax, marker='.', linestyle="")
      5 plt.ylim(-1, 1)

NameError: name 'daily_bss' is not defined

In [154]:
eval_path = "/hail/djgagne/ncar_coarse_neighbor_eval_2016/"

eval_day = pd.read_csv(join(eval_path, "coarse_neighbor_eval_NCAR_20160804.csv"))

In [42]:
rows = eval_day.i_small.max()  + 1
cols = eval_day.j_small.max() + 1

In [81]:
dr = DistributedReliability()

In [151]:
bmap = Basemap(projection="lcc", resolution="l", lat_0=39, lon_0=-101, lat_1=32, lat_2=46,
               llcrnrlon=-120.81, llcrnrlat=23.159264, urcrnrlon=-65.02124, urcrnrlat=46.88567)

In [155]:
bmap.drawstates()
bmap.drawcountries()
bmap.drawcoastlines()
lons = eval_day.lon.values.reshape(rows, cols)
lats = eval_day.lat.values.reshape(rows, cols)
x, y = bmap(lons, lats)
plt.contourf(x,y, eval_day["NCAR_Random-Forest-CV_mean_25"].values.reshape(rows, cols), np.arange(0, 1.1, 0.1), cmap="Blues")
plt.contour(x,y, eval_day["MESH_Max_60min_00.50_25"].values.reshape(rows, cols), [0.5], colors="green", linewidths=2)


Out[155]:
<matplotlib.contour.QuadContourSet at 0x2ba1e1c771d0>

In [130]:
eval_day["NCAR_HAIL_MAX2D_mean_25"].values[eval_day["us_mask"].values == 1].max()


Out[130]:
1.0

In [50]:
for col in eval_day.columns:
    print(col)


i
i_small
j
j_small
lat
lon
us_mask
x
y
Run_Date
Start_Date
End_Date
MESH_Max_60min_00.50_25
MESH_Max_60min_00.50_50
MESH_Max_60min_00.50_75
NCAR_HAIL_MAX2D_mem1_5
NCAR_HAIL_MAX2D_mem1_20
NCAR_HAIL_MAX2D_mem1_25
NCAR_HAIL_MAX2D_mem1_30
NCAR_HAIL_MAX2D_mem1_35
NCAR_HAIL_MAX2D_mem1_40
NCAR_HAIL_MAX2D_mem1_45
NCAR_HAIL_MAX2D_mem1_50
NCAR_HAIL_MAX2D_mem1_75
NCAR_HAIL_MAX2D_mem2_5
NCAR_HAIL_MAX2D_mem2_20
NCAR_HAIL_MAX2D_mem2_25
NCAR_HAIL_MAX2D_mem2_30
NCAR_HAIL_MAX2D_mem2_35
NCAR_HAIL_MAX2D_mem2_40
NCAR_HAIL_MAX2D_mem2_45
NCAR_HAIL_MAX2D_mem2_50
NCAR_HAIL_MAX2D_mem2_75
NCAR_HAIL_MAX2D_mem3_5
NCAR_HAIL_MAX2D_mem3_20
NCAR_HAIL_MAX2D_mem3_25
NCAR_HAIL_MAX2D_mem3_30
NCAR_HAIL_MAX2D_mem3_35
NCAR_HAIL_MAX2D_mem3_40
NCAR_HAIL_MAX2D_mem3_45
NCAR_HAIL_MAX2D_mem3_50
NCAR_HAIL_MAX2D_mem3_75
NCAR_HAIL_MAX2D_mem4_5
NCAR_HAIL_MAX2D_mem4_20
NCAR_HAIL_MAX2D_mem4_25
NCAR_HAIL_MAX2D_mem4_30
NCAR_HAIL_MAX2D_mem4_35
NCAR_HAIL_MAX2D_mem4_40
NCAR_HAIL_MAX2D_mem4_45
NCAR_HAIL_MAX2D_mem4_50
NCAR_HAIL_MAX2D_mem4_75
NCAR_HAIL_MAX2D_mem5_5
NCAR_HAIL_MAX2D_mem5_20
NCAR_HAIL_MAX2D_mem5_25
NCAR_HAIL_MAX2D_mem5_30
NCAR_HAIL_MAX2D_mem5_35
NCAR_HAIL_MAX2D_mem5_40
NCAR_HAIL_MAX2D_mem5_45
NCAR_HAIL_MAX2D_mem5_50
NCAR_HAIL_MAX2D_mem5_75
NCAR_HAIL_MAX2D_mem6_5
NCAR_HAIL_MAX2D_mem6_20
NCAR_HAIL_MAX2D_mem6_25
NCAR_HAIL_MAX2D_mem6_30
NCAR_HAIL_MAX2D_mem6_35
NCAR_HAIL_MAX2D_mem6_40
NCAR_HAIL_MAX2D_mem6_45
NCAR_HAIL_MAX2D_mem6_50
NCAR_HAIL_MAX2D_mem6_75
NCAR_HAIL_MAX2D_mem7_5
NCAR_HAIL_MAX2D_mem7_20
NCAR_HAIL_MAX2D_mem7_25
NCAR_HAIL_MAX2D_mem7_30
NCAR_HAIL_MAX2D_mem7_35
NCAR_HAIL_MAX2D_mem7_40
NCAR_HAIL_MAX2D_mem7_45
NCAR_HAIL_MAX2D_mem7_50
NCAR_HAIL_MAX2D_mem7_75
NCAR_HAIL_MAX2D_mem8_5
NCAR_HAIL_MAX2D_mem8_20
NCAR_HAIL_MAX2D_mem8_25
NCAR_HAIL_MAX2D_mem8_30
NCAR_HAIL_MAX2D_mem8_35
NCAR_HAIL_MAX2D_mem8_40
NCAR_HAIL_MAX2D_mem8_45
NCAR_HAIL_MAX2D_mem8_50
NCAR_HAIL_MAX2D_mem8_75
NCAR_HAIL_MAX2D_mem9_5
NCAR_HAIL_MAX2D_mem9_20
NCAR_HAIL_MAX2D_mem9_25
NCAR_HAIL_MAX2D_mem9_30
NCAR_HAIL_MAX2D_mem9_35
NCAR_HAIL_MAX2D_mem9_40
NCAR_HAIL_MAX2D_mem9_45
NCAR_HAIL_MAX2D_mem9_50
NCAR_HAIL_MAX2D_mem9_75
NCAR_HAIL_MAX2D_mem10_5
NCAR_HAIL_MAX2D_mem10_20
NCAR_HAIL_MAX2D_mem10_25
NCAR_HAIL_MAX2D_mem10_30
NCAR_HAIL_MAX2D_mem10_35
NCAR_HAIL_MAX2D_mem10_40
NCAR_HAIL_MAX2D_mem10_45
NCAR_HAIL_MAX2D_mem10_50
NCAR_HAIL_MAX2D_mem10_75
NCAR_HAIL_MAX2D_mean_5
NCAR_HAIL_MAX2D_mean_20
NCAR_HAIL_MAX2D_mean_25
NCAR_HAIL_MAX2D_mean_30
NCAR_HAIL_MAX2D_mean_35
NCAR_HAIL_MAX2D_mean_40
NCAR_HAIL_MAX2D_mean_45
NCAR_HAIL_MAX2D_mean_50
NCAR_HAIL_MAX2D_mean_75
NCAR_HAIL_MAXK1_mem1_5
NCAR_HAIL_MAXK1_mem1_20
NCAR_HAIL_MAXK1_mem1_25
NCAR_HAIL_MAXK1_mem1_30
NCAR_HAIL_MAXK1_mem1_35
NCAR_HAIL_MAXK1_mem1_40
NCAR_HAIL_MAXK1_mem1_45
NCAR_HAIL_MAXK1_mem1_50
NCAR_HAIL_MAXK1_mem1_75
NCAR_HAIL_MAXK1_mem2_5
NCAR_HAIL_MAXK1_mem2_20
NCAR_HAIL_MAXK1_mem2_25
NCAR_HAIL_MAXK1_mem2_30
NCAR_HAIL_MAXK1_mem2_35
NCAR_HAIL_MAXK1_mem2_40
NCAR_HAIL_MAXK1_mem2_45
NCAR_HAIL_MAXK1_mem2_50
NCAR_HAIL_MAXK1_mem2_75
NCAR_HAIL_MAXK1_mem3_5
NCAR_HAIL_MAXK1_mem3_20
NCAR_HAIL_MAXK1_mem3_25
NCAR_HAIL_MAXK1_mem3_30
NCAR_HAIL_MAXK1_mem3_35
NCAR_HAIL_MAXK1_mem3_40
NCAR_HAIL_MAXK1_mem3_45
NCAR_HAIL_MAXK1_mem3_50
NCAR_HAIL_MAXK1_mem3_75
NCAR_HAIL_MAXK1_mem4_5
NCAR_HAIL_MAXK1_mem4_20
NCAR_HAIL_MAXK1_mem4_25
NCAR_HAIL_MAXK1_mem4_30
NCAR_HAIL_MAXK1_mem4_35
NCAR_HAIL_MAXK1_mem4_40
NCAR_HAIL_MAXK1_mem4_45
NCAR_HAIL_MAXK1_mem4_50
NCAR_HAIL_MAXK1_mem4_75
NCAR_HAIL_MAXK1_mem5_5
NCAR_HAIL_MAXK1_mem5_20
NCAR_HAIL_MAXK1_mem5_25
NCAR_HAIL_MAXK1_mem5_30
NCAR_HAIL_MAXK1_mem5_35
NCAR_HAIL_MAXK1_mem5_40
NCAR_HAIL_MAXK1_mem5_45
NCAR_HAIL_MAXK1_mem5_50
NCAR_HAIL_MAXK1_mem5_75
NCAR_HAIL_MAXK1_mem6_5
NCAR_HAIL_MAXK1_mem6_20
NCAR_HAIL_MAXK1_mem6_25
NCAR_HAIL_MAXK1_mem6_30
NCAR_HAIL_MAXK1_mem6_35
NCAR_HAIL_MAXK1_mem6_40
NCAR_HAIL_MAXK1_mem6_45
NCAR_HAIL_MAXK1_mem6_50
NCAR_HAIL_MAXK1_mem6_75
NCAR_HAIL_MAXK1_mem7_5
NCAR_HAIL_MAXK1_mem7_20
NCAR_HAIL_MAXK1_mem7_25
NCAR_HAIL_MAXK1_mem7_30
NCAR_HAIL_MAXK1_mem7_35
NCAR_HAIL_MAXK1_mem7_40
NCAR_HAIL_MAXK1_mem7_45
NCAR_HAIL_MAXK1_mem7_50
NCAR_HAIL_MAXK1_mem7_75
NCAR_HAIL_MAXK1_mem8_5
NCAR_HAIL_MAXK1_mem8_20
NCAR_HAIL_MAXK1_mem8_25
NCAR_HAIL_MAXK1_mem8_30
NCAR_HAIL_MAXK1_mem8_35
NCAR_HAIL_MAXK1_mem8_40
NCAR_HAIL_MAXK1_mem8_45
NCAR_HAIL_MAXK1_mem8_50
NCAR_HAIL_MAXK1_mem8_75
NCAR_HAIL_MAXK1_mem9_5
NCAR_HAIL_MAXK1_mem9_20
NCAR_HAIL_MAXK1_mem9_25
NCAR_HAIL_MAXK1_mem9_30
NCAR_HAIL_MAXK1_mem9_35
NCAR_HAIL_MAXK1_mem9_40
NCAR_HAIL_MAXK1_mem9_45
NCAR_HAIL_MAXK1_mem9_50
NCAR_HAIL_MAXK1_mem9_75
NCAR_HAIL_MAXK1_mem10_5
NCAR_HAIL_MAXK1_mem10_20
NCAR_HAIL_MAXK1_mem10_25
NCAR_HAIL_MAXK1_mem10_30
NCAR_HAIL_MAXK1_mem10_35
NCAR_HAIL_MAXK1_mem10_40
NCAR_HAIL_MAXK1_mem10_45
NCAR_HAIL_MAXK1_mem10_50
NCAR_HAIL_MAXK1_mem10_75
NCAR_HAIL_MAXK1_mean_5
NCAR_HAIL_MAXK1_mean_20
NCAR_HAIL_MAXK1_mean_25
NCAR_HAIL_MAXK1_mean_30
NCAR_HAIL_MAXK1_mean_35
NCAR_HAIL_MAXK1_mean_40
NCAR_HAIL_MAXK1_mean_45
NCAR_HAIL_MAXK1_mean_50
NCAR_HAIL_MAXK1_mean_75
NCAR_UP_HELI_MAX_mem1_5
NCAR_UP_HELI_MAX_mem1_25
NCAR_UP_HELI_MAX_mem1_50
NCAR_UP_HELI_MAX_mem1_75
NCAR_UP_HELI_MAX_mem1_100
NCAR_UP_HELI_MAX_mem1_125
NCAR_UP_HELI_MAX_mem1_150
NCAR_UP_HELI_MAX_mem1_175
NCAR_UP_HELI_MAX_mem1_200
NCAR_UP_HELI_MAX_mem2_5
NCAR_UP_HELI_MAX_mem2_25
NCAR_UP_HELI_MAX_mem2_50
NCAR_UP_HELI_MAX_mem2_75
NCAR_UP_HELI_MAX_mem2_100
NCAR_UP_HELI_MAX_mem2_125
NCAR_UP_HELI_MAX_mem2_150
NCAR_UP_HELI_MAX_mem2_175
NCAR_UP_HELI_MAX_mem2_200
NCAR_UP_HELI_MAX_mem3_5
NCAR_UP_HELI_MAX_mem3_25
NCAR_UP_HELI_MAX_mem3_50
NCAR_UP_HELI_MAX_mem3_75
NCAR_UP_HELI_MAX_mem3_100
NCAR_UP_HELI_MAX_mem3_125
NCAR_UP_HELI_MAX_mem3_150
NCAR_UP_HELI_MAX_mem3_175
NCAR_UP_HELI_MAX_mem3_200
NCAR_UP_HELI_MAX_mem4_5
NCAR_UP_HELI_MAX_mem4_25
NCAR_UP_HELI_MAX_mem4_50
NCAR_UP_HELI_MAX_mem4_75
NCAR_UP_HELI_MAX_mem4_100
NCAR_UP_HELI_MAX_mem4_125
NCAR_UP_HELI_MAX_mem4_150
NCAR_UP_HELI_MAX_mem4_175
NCAR_UP_HELI_MAX_mem4_200
NCAR_UP_HELI_MAX_mem5_5
NCAR_UP_HELI_MAX_mem5_25
NCAR_UP_HELI_MAX_mem5_50
NCAR_UP_HELI_MAX_mem5_75
NCAR_UP_HELI_MAX_mem5_100
NCAR_UP_HELI_MAX_mem5_125
NCAR_UP_HELI_MAX_mem5_150
NCAR_UP_HELI_MAX_mem5_175
NCAR_UP_HELI_MAX_mem5_200
NCAR_UP_HELI_MAX_mem6_5
NCAR_UP_HELI_MAX_mem6_25
NCAR_UP_HELI_MAX_mem6_50
NCAR_UP_HELI_MAX_mem6_75
NCAR_UP_HELI_MAX_mem6_100
NCAR_UP_HELI_MAX_mem6_125
NCAR_UP_HELI_MAX_mem6_150
NCAR_UP_HELI_MAX_mem6_175
NCAR_UP_HELI_MAX_mem6_200
NCAR_UP_HELI_MAX_mem7_5
NCAR_UP_HELI_MAX_mem7_25
NCAR_UP_HELI_MAX_mem7_50
NCAR_UP_HELI_MAX_mem7_75
NCAR_UP_HELI_MAX_mem7_100
NCAR_UP_HELI_MAX_mem7_125
NCAR_UP_HELI_MAX_mem7_150
NCAR_UP_HELI_MAX_mem7_175
NCAR_UP_HELI_MAX_mem7_200
NCAR_UP_HELI_MAX_mem8_5
NCAR_UP_HELI_MAX_mem8_25
NCAR_UP_HELI_MAX_mem8_50
NCAR_UP_HELI_MAX_mem8_75
NCAR_UP_HELI_MAX_mem8_100
NCAR_UP_HELI_MAX_mem8_125
NCAR_UP_HELI_MAX_mem8_150
NCAR_UP_HELI_MAX_mem8_175
NCAR_UP_HELI_MAX_mem8_200
NCAR_UP_HELI_MAX_mem9_5
NCAR_UP_HELI_MAX_mem9_25
NCAR_UP_HELI_MAX_mem9_50
NCAR_UP_HELI_MAX_mem9_75
NCAR_UP_HELI_MAX_mem9_100
NCAR_UP_HELI_MAX_mem9_125
NCAR_UP_HELI_MAX_mem9_150
NCAR_UP_HELI_MAX_mem9_175
NCAR_UP_HELI_MAX_mem9_200
NCAR_UP_HELI_MAX_mem10_5
NCAR_UP_HELI_MAX_mem10_25
NCAR_UP_HELI_MAX_mem10_50
NCAR_UP_HELI_MAX_mem10_75
NCAR_UP_HELI_MAX_mem10_100
NCAR_UP_HELI_MAX_mem10_125
NCAR_UP_HELI_MAX_mem10_150
NCAR_UP_HELI_MAX_mem10_175
NCAR_UP_HELI_MAX_mem10_200
NCAR_UP_HELI_MAX_mean_5
NCAR_UP_HELI_MAX_mean_25
NCAR_UP_HELI_MAX_mean_50
NCAR_UP_HELI_MAX_mean_75
NCAR_UP_HELI_MAX_mean_100
NCAR_UP_HELI_MAX_mean_125
NCAR_UP_HELI_MAX_mean_150
NCAR_UP_HELI_MAX_mean_175
NCAR_UP_HELI_MAX_mean_200
NCAR_GRPL_MAX_mem1_5
NCAR_GRPL_MAX_mem1_10
NCAR_GRPL_MAX_mem1_15
NCAR_GRPL_MAX_mem1_20
NCAR_GRPL_MAX_mem1_25
NCAR_GRPL_MAX_mem1_30
NCAR_GRPL_MAX_mem1_35
NCAR_GRPL_MAX_mem1_40
NCAR_GRPL_MAX_mem1_45
NCAR_GRPL_MAX_mem1_50
NCAR_GRPL_MAX_mem2_5
NCAR_GRPL_MAX_mem2_10
NCAR_GRPL_MAX_mem2_15
NCAR_GRPL_MAX_mem2_20
NCAR_GRPL_MAX_mem2_25
NCAR_GRPL_MAX_mem2_30
NCAR_GRPL_MAX_mem2_35
NCAR_GRPL_MAX_mem2_40
NCAR_GRPL_MAX_mem2_45
NCAR_GRPL_MAX_mem2_50
NCAR_GRPL_MAX_mem3_5
NCAR_GRPL_MAX_mem3_10
NCAR_GRPL_MAX_mem3_15
NCAR_GRPL_MAX_mem3_20
NCAR_GRPL_MAX_mem3_25
NCAR_GRPL_MAX_mem3_30
NCAR_GRPL_MAX_mem3_35
NCAR_GRPL_MAX_mem3_40
NCAR_GRPL_MAX_mem3_45
NCAR_GRPL_MAX_mem3_50
NCAR_GRPL_MAX_mem4_5
NCAR_GRPL_MAX_mem4_10
NCAR_GRPL_MAX_mem4_15
NCAR_GRPL_MAX_mem4_20
NCAR_GRPL_MAX_mem4_25
NCAR_GRPL_MAX_mem4_30
NCAR_GRPL_MAX_mem4_35
NCAR_GRPL_MAX_mem4_40
NCAR_GRPL_MAX_mem4_45
NCAR_GRPL_MAX_mem4_50
NCAR_GRPL_MAX_mem5_5
NCAR_GRPL_MAX_mem5_10
NCAR_GRPL_MAX_mem5_15
NCAR_GRPL_MAX_mem5_20
NCAR_GRPL_MAX_mem5_25
NCAR_GRPL_MAX_mem5_30
NCAR_GRPL_MAX_mem5_35
NCAR_GRPL_MAX_mem5_40
NCAR_GRPL_MAX_mem5_45
NCAR_GRPL_MAX_mem5_50
NCAR_GRPL_MAX_mem6_5
NCAR_GRPL_MAX_mem6_10
NCAR_GRPL_MAX_mem6_15
NCAR_GRPL_MAX_mem6_20
NCAR_GRPL_MAX_mem6_25
NCAR_GRPL_MAX_mem6_30
NCAR_GRPL_MAX_mem6_35
NCAR_GRPL_MAX_mem6_40
NCAR_GRPL_MAX_mem6_45
NCAR_GRPL_MAX_mem6_50
NCAR_GRPL_MAX_mem7_5
NCAR_GRPL_MAX_mem7_10
NCAR_GRPL_MAX_mem7_15
NCAR_GRPL_MAX_mem7_20
NCAR_GRPL_MAX_mem7_25
NCAR_GRPL_MAX_mem7_30
NCAR_GRPL_MAX_mem7_35
NCAR_GRPL_MAX_mem7_40
NCAR_GRPL_MAX_mem7_45
NCAR_GRPL_MAX_mem7_50
NCAR_GRPL_MAX_mem8_5
NCAR_GRPL_MAX_mem8_10
NCAR_GRPL_MAX_mem8_15
NCAR_GRPL_MAX_mem8_20
NCAR_GRPL_MAX_mem8_25
NCAR_GRPL_MAX_mem8_30
NCAR_GRPL_MAX_mem8_35
NCAR_GRPL_MAX_mem8_40
NCAR_GRPL_MAX_mem8_45
NCAR_GRPL_MAX_mem8_50
NCAR_GRPL_MAX_mem9_5
NCAR_GRPL_MAX_mem9_10
NCAR_GRPL_MAX_mem9_15
NCAR_GRPL_MAX_mem9_20
NCAR_GRPL_MAX_mem9_25
NCAR_GRPL_MAX_mem9_30
NCAR_GRPL_MAX_mem9_35
NCAR_GRPL_MAX_mem9_40
NCAR_GRPL_MAX_mem9_45
NCAR_GRPL_MAX_mem9_50
NCAR_GRPL_MAX_mem10_5
NCAR_GRPL_MAX_mem10_10
NCAR_GRPL_MAX_mem10_15
NCAR_GRPL_MAX_mem10_20
NCAR_GRPL_MAX_mem10_25
NCAR_GRPL_MAX_mem10_30
NCAR_GRPL_MAX_mem10_35
NCAR_GRPL_MAX_mem10_40
NCAR_GRPL_MAX_mem10_45
NCAR_GRPL_MAX_mem10_50
NCAR_GRPL_MAX_mean_5
NCAR_GRPL_MAX_mean_10
NCAR_GRPL_MAX_mean_15
NCAR_GRPL_MAX_mean_20
NCAR_GRPL_MAX_mean_25
NCAR_GRPL_MAX_mean_30
NCAR_GRPL_MAX_mean_35
NCAR_GRPL_MAX_mean_40
NCAR_GRPL_MAX_mean_45
NCAR_GRPL_MAX_mean_50
NCAR_Random-Forest_mem1_5
NCAR_Random-Forest_mem2_5
NCAR_Random-Forest_mem3_5
NCAR_Random-Forest_mem4_5
NCAR_Random-Forest_mem5_5
NCAR_Random-Forest_mem6_5
NCAR_Random-Forest_mem7_5
NCAR_Random-Forest_mem8_5
NCAR_Random-Forest_mem9_5
NCAR_Random-Forest_mem10_5
NCAR_Random-Forest_mean_5
NCAR_Random-Forest_mem1_20
NCAR_Random-Forest_mem2_20
NCAR_Random-Forest_mem3_20
NCAR_Random-Forest_mem4_20
NCAR_Random-Forest_mem5_20
NCAR_Random-Forest_mem6_20
NCAR_Random-Forest_mem7_20
NCAR_Random-Forest_mem8_20
NCAR_Random-Forest_mem9_20
NCAR_Random-Forest_mem10_20
NCAR_Random-Forest_mean_20
NCAR_Random-Forest_mem1_25
NCAR_Random-Forest_mem2_25
NCAR_Random-Forest_mem3_25
NCAR_Random-Forest_mem4_25
NCAR_Random-Forest_mem5_25
NCAR_Random-Forest_mem6_25
NCAR_Random-Forest_mem7_25
NCAR_Random-Forest_mem8_25
NCAR_Random-Forest_mem9_25
NCAR_Random-Forest_mem10_25
NCAR_Random-Forest_mean_25
NCAR_Random-Forest_mem1_30
NCAR_Random-Forest_mem2_30
NCAR_Random-Forest_mem3_30
NCAR_Random-Forest_mem4_30
NCAR_Random-Forest_mem5_30
NCAR_Random-Forest_mem6_30
NCAR_Random-Forest_mem7_30
NCAR_Random-Forest_mem8_30
NCAR_Random-Forest_mem9_30
NCAR_Random-Forest_mem10_30
NCAR_Random-Forest_mean_30
NCAR_Random-Forest_mem1_35
NCAR_Random-Forest_mem2_35
NCAR_Random-Forest_mem3_35
NCAR_Random-Forest_mem4_35
NCAR_Random-Forest_mem5_35
NCAR_Random-Forest_mem6_35
NCAR_Random-Forest_mem7_35
NCAR_Random-Forest_mem8_35
NCAR_Random-Forest_mem9_35
NCAR_Random-Forest_mem10_35
NCAR_Random-Forest_mean_35
NCAR_Random-Forest_mem1_40
NCAR_Random-Forest_mem2_40
NCAR_Random-Forest_mem3_40
NCAR_Random-Forest_mem4_40
NCAR_Random-Forest_mem5_40
NCAR_Random-Forest_mem6_40
NCAR_Random-Forest_mem7_40
NCAR_Random-Forest_mem8_40
NCAR_Random-Forest_mem9_40
NCAR_Random-Forest_mem10_40
NCAR_Random-Forest_mean_40
NCAR_Random-Forest_mem1_45
NCAR_Random-Forest_mem2_45
NCAR_Random-Forest_mem3_45
NCAR_Random-Forest_mem4_45
NCAR_Random-Forest_mem5_45
NCAR_Random-Forest_mem6_45
NCAR_Random-Forest_mem7_45
NCAR_Random-Forest_mem8_45
NCAR_Random-Forest_mem9_45
NCAR_Random-Forest_mem10_45
NCAR_Random-Forest_mean_45
NCAR_Random-Forest_mem1_50
NCAR_Random-Forest_mem2_50
NCAR_Random-Forest_mem3_50
NCAR_Random-Forest_mem4_50
NCAR_Random-Forest_mem5_50
NCAR_Random-Forest_mem6_50
NCAR_Random-Forest_mem7_50
NCAR_Random-Forest_mem8_50
NCAR_Random-Forest_mem9_50
NCAR_Random-Forest_mem10_50
NCAR_Random-Forest_mean_50
NCAR_Random-Forest_mem1_75
NCAR_Random-Forest_mem2_75
NCAR_Random-Forest_mem3_75
NCAR_Random-Forest_mem4_75
NCAR_Random-Forest_mem5_75
NCAR_Random-Forest_mem6_75
NCAR_Random-Forest_mem7_75
NCAR_Random-Forest_mem8_75
NCAR_Random-Forest_mem9_75
NCAR_Random-Forest_mem10_75
NCAR_Random-Forest_mean_75
NCAR_Elastic-Net_mem1_5
NCAR_Elastic-Net_mem2_5
NCAR_Elastic-Net_mem3_5
NCAR_Elastic-Net_mem4_5
NCAR_Elastic-Net_mem5_5
NCAR_Elastic-Net_mem6_5
NCAR_Elastic-Net_mem7_5
NCAR_Elastic-Net_mem8_5
NCAR_Elastic-Net_mem9_5
NCAR_Elastic-Net_mem10_5
NCAR_Elastic-Net_mean_5
NCAR_Elastic-Net_mem1_20
NCAR_Elastic-Net_mem2_20
NCAR_Elastic-Net_mem3_20
NCAR_Elastic-Net_mem4_20
NCAR_Elastic-Net_mem5_20
NCAR_Elastic-Net_mem6_20
NCAR_Elastic-Net_mem7_20
NCAR_Elastic-Net_mem8_20
NCAR_Elastic-Net_mem9_20
NCAR_Elastic-Net_mem10_20
NCAR_Elastic-Net_mean_20
NCAR_Elastic-Net_mem1_25
NCAR_Elastic-Net_mem2_25
NCAR_Elastic-Net_mem3_25
NCAR_Elastic-Net_mem4_25
NCAR_Elastic-Net_mem5_25
NCAR_Elastic-Net_mem6_25
NCAR_Elastic-Net_mem7_25
NCAR_Elastic-Net_mem8_25
NCAR_Elastic-Net_mem9_25
NCAR_Elastic-Net_mem10_25
NCAR_Elastic-Net_mean_25
NCAR_Elastic-Net_mem1_30
NCAR_Elastic-Net_mem2_30
NCAR_Elastic-Net_mem3_30
NCAR_Elastic-Net_mem4_30
NCAR_Elastic-Net_mem5_30
NCAR_Elastic-Net_mem6_30
NCAR_Elastic-Net_mem7_30
NCAR_Elastic-Net_mem8_30
NCAR_Elastic-Net_mem9_30
NCAR_Elastic-Net_mem10_30
NCAR_Elastic-Net_mean_30
NCAR_Elastic-Net_mem1_35
NCAR_Elastic-Net_mem2_35
NCAR_Elastic-Net_mem3_35
NCAR_Elastic-Net_mem4_35
NCAR_Elastic-Net_mem5_35
NCAR_Elastic-Net_mem6_35
NCAR_Elastic-Net_mem7_35
NCAR_Elastic-Net_mem8_35
NCAR_Elastic-Net_mem9_35
NCAR_Elastic-Net_mem10_35
NCAR_Elastic-Net_mean_35
NCAR_Elastic-Net_mem1_40
NCAR_Elastic-Net_mem2_40
NCAR_Elastic-Net_mem3_40
NCAR_Elastic-Net_mem4_40
NCAR_Elastic-Net_mem5_40
NCAR_Elastic-Net_mem6_40
NCAR_Elastic-Net_mem7_40
NCAR_Elastic-Net_mem8_40
NCAR_Elastic-Net_mem9_40
NCAR_Elastic-Net_mem10_40
NCAR_Elastic-Net_mean_40
NCAR_Elastic-Net_mem1_45
NCAR_Elastic-Net_mem2_45
NCAR_Elastic-Net_mem3_45
NCAR_Elastic-Net_mem4_45
NCAR_Elastic-Net_mem5_45
NCAR_Elastic-Net_mem6_45
NCAR_Elastic-Net_mem7_45
NCAR_Elastic-Net_mem8_45
NCAR_Elastic-Net_mem9_45
NCAR_Elastic-Net_mem10_45
NCAR_Elastic-Net_mean_45
NCAR_Elastic-Net_mem1_50
NCAR_Elastic-Net_mem2_50
NCAR_Elastic-Net_mem3_50
NCAR_Elastic-Net_mem4_50
NCAR_Elastic-Net_mem5_50
NCAR_Elastic-Net_mem6_50
NCAR_Elastic-Net_mem7_50
NCAR_Elastic-Net_mem8_50
NCAR_Elastic-Net_mem9_50
NCAR_Elastic-Net_mem10_50
NCAR_Elastic-Net_mean_50
NCAR_Elastic-Net_mem1_75
NCAR_Elastic-Net_mem2_75
NCAR_Elastic-Net_mem3_75
NCAR_Elastic-Net_mem4_75
NCAR_Elastic-Net_mem5_75
NCAR_Elastic-Net_mem6_75
NCAR_Elastic-Net_mem7_75
NCAR_Elastic-Net_mem8_75
NCAR_Elastic-Net_mem9_75
NCAR_Elastic-Net_mem10_75
NCAR_Elastic-Net_mean_75
NCAR_Random-Forest-CV_mem1_5
NCAR_Random-Forest-CV_mem2_5
NCAR_Random-Forest-CV_mem3_5
NCAR_Random-Forest-CV_mem4_5
NCAR_Random-Forest-CV_mem5_5
NCAR_Random-Forest-CV_mem6_5
NCAR_Random-Forest-CV_mem7_5
NCAR_Random-Forest-CV_mem8_5
NCAR_Random-Forest-CV_mem9_5
NCAR_Random-Forest-CV_mem10_5
NCAR_Random-Forest-CV_mean_5
NCAR_Random-Forest-CV_mem1_20
NCAR_Random-Forest-CV_mem2_20
NCAR_Random-Forest-CV_mem3_20
NCAR_Random-Forest-CV_mem4_20
NCAR_Random-Forest-CV_mem5_20
NCAR_Random-Forest-CV_mem6_20
NCAR_Random-Forest-CV_mem7_20
NCAR_Random-Forest-CV_mem8_20
NCAR_Random-Forest-CV_mem9_20
NCAR_Random-Forest-CV_mem10_20
NCAR_Random-Forest-CV_mean_20
NCAR_Random-Forest-CV_mem1_25
NCAR_Random-Forest-CV_mem2_25
NCAR_Random-Forest-CV_mem3_25
NCAR_Random-Forest-CV_mem4_25
NCAR_Random-Forest-CV_mem5_25
NCAR_Random-Forest-CV_mem6_25
NCAR_Random-Forest-CV_mem7_25
NCAR_Random-Forest-CV_mem8_25
NCAR_Random-Forest-CV_mem9_25
NCAR_Random-Forest-CV_mem10_25
NCAR_Random-Forest-CV_mean_25
NCAR_Random-Forest-CV_mem1_30
NCAR_Random-Forest-CV_mem2_30
NCAR_Random-Forest-CV_mem3_30
NCAR_Random-Forest-CV_mem4_30
NCAR_Random-Forest-CV_mem5_30
NCAR_Random-Forest-CV_mem6_30
NCAR_Random-Forest-CV_mem7_30
NCAR_Random-Forest-CV_mem8_30
NCAR_Random-Forest-CV_mem9_30
NCAR_Random-Forest-CV_mem10_30
NCAR_Random-Forest-CV_mean_30
NCAR_Random-Forest-CV_mem1_35
NCAR_Random-Forest-CV_mem2_35
NCAR_Random-Forest-CV_mem3_35
NCAR_Random-Forest-CV_mem4_35
NCAR_Random-Forest-CV_mem5_35
NCAR_Random-Forest-CV_mem6_35
NCAR_Random-Forest-CV_mem7_35
NCAR_Random-Forest-CV_mem8_35
NCAR_Random-Forest-CV_mem9_35
NCAR_Random-Forest-CV_mem10_35
NCAR_Random-Forest-CV_mean_35
NCAR_Random-Forest-CV_mem1_40
NCAR_Random-Forest-CV_mem2_40
NCAR_Random-Forest-CV_mem3_40
NCAR_Random-Forest-CV_mem4_40
NCAR_Random-Forest-CV_mem5_40
NCAR_Random-Forest-CV_mem6_40
NCAR_Random-Forest-CV_mem7_40
NCAR_Random-Forest-CV_mem8_40
NCAR_Random-Forest-CV_mem9_40
NCAR_Random-Forest-CV_mem10_40
NCAR_Random-Forest-CV_mean_40
NCAR_Random-Forest-CV_mem1_45
NCAR_Random-Forest-CV_mem2_45
NCAR_Random-Forest-CV_mem3_45
NCAR_Random-Forest-CV_mem4_45
NCAR_Random-Forest-CV_mem5_45
NCAR_Random-Forest-CV_mem6_45
NCAR_Random-Forest-CV_mem7_45
NCAR_Random-Forest-CV_mem8_45
NCAR_Random-Forest-CV_mem9_45
NCAR_Random-Forest-CV_mem10_45
NCAR_Random-Forest-CV_mean_45
NCAR_Random-Forest-CV_mem1_50
NCAR_Random-Forest-CV_mem2_50
NCAR_Random-Forest-CV_mem3_50
NCAR_Random-Forest-CV_mem4_50
NCAR_Random-Forest-CV_mem5_50
NCAR_Random-Forest-CV_mem6_50
NCAR_Random-Forest-CV_mem7_50
NCAR_Random-Forest-CV_mem8_50
NCAR_Random-Forest-CV_mem9_50
NCAR_Random-Forest-CV_mem10_50
NCAR_Random-Forest-CV_mean_50
NCAR_Random-Forest-CV_mem1_75
NCAR_Random-Forest-CV_mem2_75
NCAR_Random-Forest-CV_mem3_75
NCAR_Random-Forest-CV_mem4_75
NCAR_Random-Forest-CV_mem5_75
NCAR_Random-Forest-CV_mem6_75
NCAR_Random-Forest-CV_mem7_75
NCAR_Random-Forest-CV_mem8_75
NCAR_Random-Forest-CV_mem9_75
NCAR_Random-Forest-CV_mem10_75
NCAR_Random-Forest-CV_mean_75

In [46]:
eval_day.columns[eval_day.columns.str.contains("mean")]


Out[46]:
Index([u'NCAR_HAIL_MAX2D_mean_5', u'NCAR_HAIL_MAX2D_mean_20',
       u'NCAR_HAIL_MAX2D_mean_25', u'NCAR_HAIL_MAX2D_mean_30',
       u'NCAR_HAIL_MAX2D_mean_35', u'NCAR_HAIL_MAX2D_mean_40',
       u'NCAR_HAIL_MAX2D_mean_45', u'NCAR_HAIL_MAX2D_mean_50',
       u'NCAR_HAIL_MAX2D_mean_75', u'NCAR_HAIL_MAXK1_mean_5',
       u'NCAR_HAIL_MAXK1_mean_20', u'NCAR_HAIL_MAXK1_mean_25',
       u'NCAR_HAIL_MAXK1_mean_30', u'NCAR_HAIL_MAXK1_mean_35',
       u'NCAR_HAIL_MAXK1_mean_40', u'NCAR_HAIL_MAXK1_mean_45',
       u'NCAR_HAIL_MAXK1_mean_50', u'NCAR_HAIL_MAXK1_mean_75',
       u'NCAR_UP_HELI_MAX_mean_5', u'NCAR_UP_HELI_MAX_mean_25',
       u'NCAR_UP_HELI_MAX_mean_50', u'NCAR_UP_HELI_MAX_mean_75',
       u'NCAR_UP_HELI_MAX_mean_100', u'NCAR_UP_HELI_MAX_mean_125',
       u'NCAR_UP_HELI_MAX_mean_150', u'NCAR_UP_HELI_MAX_mean_175',
       u'NCAR_UP_HELI_MAX_mean_200', u'NCAR_GRPL_MAX_mean_5',
       u'NCAR_GRPL_MAX_mean_10', u'NCAR_GRPL_MAX_mean_15',
       u'NCAR_GRPL_MAX_mean_20', u'NCAR_GRPL_MAX_mean_25',
       u'NCAR_GRPL_MAX_mean_30', u'NCAR_GRPL_MAX_mean_35',
       u'NCAR_GRPL_MAX_mean_40', u'NCAR_GRPL_MAX_mean_45',
       u'NCAR_GRPL_MAX_mean_50', u'NCAR_Random-Forest_mean_5',
       u'NCAR_Random-Forest_mean_20', u'NCAR_Random-Forest_mean_25',
       u'NCAR_Random-Forest_mean_30', u'NCAR_Random-Forest_mean_35',
       u'NCAR_Random-Forest_mean_40', u'NCAR_Random-Forest_mean_45',
       u'NCAR_Random-Forest_mean_50', u'NCAR_Random-Forest_mean_75',
       u'NCAR_Elastic-Net_mean_5', u'NCAR_Elastic-Net_mean_20',
       u'NCAR_Elastic-Net_mean_25', u'NCAR_Elastic-Net_mean_30',
       u'NCAR_Elastic-Net_mean_35', u'NCAR_Elastic-Net_mean_40',
       u'NCAR_Elastic-Net_mean_45', u'NCAR_Elastic-Net_mean_50',
       u'NCAR_Elastic-Net_mean_75', u'NCAR_Random-Forest-CV_mean_5',
       u'NCAR_Random-Forest-CV_mean_20', u'NCAR_Random-Forest-CV_mean_25',
       u'NCAR_Random-Forest-CV_mean_30', u'NCAR_Random-Forest-CV_mean_35',
       u'NCAR_Random-Forest-CV_mean_40', u'NCAR_Random-Forest-CV_mean_45',
       u'NCAR_Random-Forest-CV_mean_50', u'NCAR_Random-Forest-CV_mean_75'],
      dtype='object')

In [109]:
eval_day.columns


Out[109]:
Index([u'i', u'i_small', u'j', u'j_small', u'lat', u'lon', u'us_mask', u'x',
       u'y', u'Run_Date',
       ...
       u'NCAR_Random-Forest-CV_mem2_75', u'NCAR_Random-Forest-CV_mem3_75',
       u'NCAR_Random-Forest-CV_mem4_75', u'NCAR_Random-Forest-CV_mem5_75',
       u'NCAR_Random-Forest-CV_mem6_75', u'NCAR_Random-Forest-CV_mem7_75',
       u'NCAR_Random-Forest-CV_mem8_75', u'NCAR_Random-Forest-CV_mem9_75',
       u'NCAR_Random-Forest-CV_mem10_75', u'NCAR_Random-Forest-CV_mean_75'],
      dtype='object', length=939)

In [239]:
spatial_names = ["Random Forest CV 25 mm", "HAILCAST 25 mm", "Thompson Hail 25 mm", 
                 "Column Total Graupel 30 kg m$^{-2}$", "Updraft Helicity 50 m$^2$ s$^{-2}$",
                 "Updraft Speed 30 m s$^{-1}$"]
spatial_names_50 = ["Random Forest CV 50 mm", "HAILCAST 50 mm", "Thompson Hail 50 mm", 
                 "Column Total Graupel 40 kg m$^{-2}$", "Updraft Helicity 150 m$^2$ s$^{-2}$",
                 "Updraft Speed 40 m s$^{-1}$"]

In [126]:
spatial_models = ["NCAR_Random-Forest-CV_mean_25", "NCAR_HAILCAST_DIAM_MEAN_mean_25", "NCAR_HAIL_MAXK1_mean_25", 
                  "NCAR_GRPL_MAX_mean_30", "NCAR_UP_HELI_MAX_mean_50", "NCAR_W_UP_MAX_mean_30"]
verif_var = "MESH_Max_60min_00.50_25"
eval_path = "/hail/djgagne/ncar_coarse_neighbor_eval_2016/"
eval_files = sorted(os.listdir(eval_path))
eval_test = pd.read_csv(join(eval_path, eval_files[0]))
rows = eval_test.i_small.max()  + 1
cols = eval_test.j_small.max() + 1
lon = eval_test.lon.reshape((rows, cols))
lat = eval_test.lat.reshape((rows, cols))
#models = eval_test.columns[eval_test.columns.str.contains("mean")]
run_dates = pd.DatetimeIndex([e.split("_")[-1][:8] for e in eval_files])
spatial_data = {}
for model in spatial_models:
    spatial_data[model] = np.zeros((len(run_dates), rows, cols))
spatial_verif = np.zeros((len(run_dates), rows, cols))
for e, eval_file in enumerate(eval_files):
    print(eval_file)
    eval_data = pd.read_csv(join(eval_path, eval_file))
    spatial_verif[e] = eval_data[verif_var].values.reshape(rows, cols)
    for model in spatial_models:
        spatial_data[model][e] = eval_data[model].values.reshape(rows, cols)


coarse_neighbor_eval_NCAR_20160502.csv
coarse_neighbor_eval_NCAR_20160503.csv
coarse_neighbor_eval_NCAR_20160504.csv
coarse_neighbor_eval_NCAR_20160505.csv
coarse_neighbor_eval_NCAR_20160506.csv
coarse_neighbor_eval_NCAR_20160507.csv
coarse_neighbor_eval_NCAR_20160508.csv
coarse_neighbor_eval_NCAR_20160509.csv
coarse_neighbor_eval_NCAR_20160510.csv
coarse_neighbor_eval_NCAR_20160511.csv
coarse_neighbor_eval_NCAR_20160512.csv
coarse_neighbor_eval_NCAR_20160513.csv
coarse_neighbor_eval_NCAR_20160514.csv
coarse_neighbor_eval_NCAR_20160515.csv
coarse_neighbor_eval_NCAR_20160516.csv
coarse_neighbor_eval_NCAR_20160517.csv
coarse_neighbor_eval_NCAR_20160518.csv
coarse_neighbor_eval_NCAR_20160519.csv
coarse_neighbor_eval_NCAR_20160520.csv
coarse_neighbor_eval_NCAR_20160521.csv
coarse_neighbor_eval_NCAR_20160522.csv
coarse_neighbor_eval_NCAR_20160523.csv
coarse_neighbor_eval_NCAR_20160524.csv
coarse_neighbor_eval_NCAR_20160525.csv
coarse_neighbor_eval_NCAR_20160526.csv
coarse_neighbor_eval_NCAR_20160527.csv
coarse_neighbor_eval_NCAR_20160528.csv
coarse_neighbor_eval_NCAR_20160529.csv
coarse_neighbor_eval_NCAR_20160530.csv
coarse_neighbor_eval_NCAR_20160531.csv
coarse_neighbor_eval_NCAR_20160601.csv
coarse_neighbor_eval_NCAR_20160602.csv
coarse_neighbor_eval_NCAR_20160603.csv
coarse_neighbor_eval_NCAR_20160604.csv
coarse_neighbor_eval_NCAR_20160605.csv
coarse_neighbor_eval_NCAR_20160606.csv
coarse_neighbor_eval_NCAR_20160607.csv
coarse_neighbor_eval_NCAR_20160608.csv
coarse_neighbor_eval_NCAR_20160609.csv
coarse_neighbor_eval_NCAR_20160610.csv
coarse_neighbor_eval_NCAR_20160611.csv
coarse_neighbor_eval_NCAR_20160612.csv
coarse_neighbor_eval_NCAR_20160613.csv
coarse_neighbor_eval_NCAR_20160614.csv
coarse_neighbor_eval_NCAR_20160615.csv
coarse_neighbor_eval_NCAR_20160616.csv
coarse_neighbor_eval_NCAR_20160617.csv
coarse_neighbor_eval_NCAR_20160618.csv
coarse_neighbor_eval_NCAR_20160619.csv
coarse_neighbor_eval_NCAR_20160620.csv
coarse_neighbor_eval_NCAR_20160621.csv
coarse_neighbor_eval_NCAR_20160622.csv
coarse_neighbor_eval_NCAR_20160623.csv
coarse_neighbor_eval_NCAR_20160630.csv
coarse_neighbor_eval_NCAR_20160701.csv
coarse_neighbor_eval_NCAR_20160702.csv
coarse_neighbor_eval_NCAR_20160703.csv
coarse_neighbor_eval_NCAR_20160704.csv
coarse_neighbor_eval_NCAR_20160705.csv
coarse_neighbor_eval_NCAR_20160706.csv
coarse_neighbor_eval_NCAR_20160707.csv
coarse_neighbor_eval_NCAR_20160708.csv
coarse_neighbor_eval_NCAR_20160709.csv
coarse_neighbor_eval_NCAR_20160710.csv
coarse_neighbor_eval_NCAR_20160711.csv
coarse_neighbor_eval_NCAR_20160712.csv
coarse_neighbor_eval_NCAR_20160713.csv
coarse_neighbor_eval_NCAR_20160714.csv
coarse_neighbor_eval_NCAR_20160715.csv
coarse_neighbor_eval_NCAR_20160716.csv
coarse_neighbor_eval_NCAR_20160717.csv
coarse_neighbor_eval_NCAR_20160718.csv
coarse_neighbor_eval_NCAR_20160719.csv
coarse_neighbor_eval_NCAR_20160720.csv
coarse_neighbor_eval_NCAR_20160721.csv
coarse_neighbor_eval_NCAR_20160722.csv
coarse_neighbor_eval_NCAR_20160723.csv
coarse_neighbor_eval_NCAR_20160724.csv
coarse_neighbor_eval_NCAR_20160725.csv
coarse_neighbor_eval_NCAR_20160726.csv
coarse_neighbor_eval_NCAR_20160727.csv
coarse_neighbor_eval_NCAR_20160729.csv
coarse_neighbor_eval_NCAR_20160730.csv
coarse_neighbor_eval_NCAR_20160731.csv
coarse_neighbor_eval_NCAR_20160801.csv
coarse_neighbor_eval_NCAR_20160802.csv
coarse_neighbor_eval_NCAR_20160803.csv
coarse_neighbor_eval_NCAR_20160804.csv
coarse_neighbor_eval_NCAR_20160808.csv
coarse_neighbor_eval_NCAR_20160809.csv
coarse_neighbor_eval_NCAR_20160810.csv
coarse_neighbor_eval_NCAR_20160811.csv
coarse_neighbor_eval_NCAR_20160812.csv
coarse_neighbor_eval_NCAR_20160813.csv
coarse_neighbor_eval_NCAR_20160814.csv
coarse_neighbor_eval_NCAR_20160815.csv
coarse_neighbor_eval_NCAR_20160816.csv
coarse_neighbor_eval_NCAR_20160817.csv
coarse_neighbor_eval_NCAR_20160818.csv
coarse_neighbor_eval_NCAR_20160819.csv
coarse_neighbor_eval_NCAR_20160820.csv
coarse_neighbor_eval_NCAR_20160821.csv
coarse_neighbor_eval_NCAR_20160826.csv
coarse_neighbor_eval_NCAR_20160827.csv
coarse_neighbor_eval_NCAR_20160829.csv
coarse_neighbor_eval_NCAR_20160830.csv
coarse_neighbor_eval_NCAR_20160831.csv

In [255]:
spatial_models_50 = ["NCAR_Random-Forest-CV_mean_50", "NCAR_HAILCAST_DIAM_MEAN_mean_50", "NCAR_HAIL_MAXK1_mean_50", 
                  "NCAR_GRPL_MAX_mean_40", "NCAR_UP_HELI_MAX_mean_150", "NCAR_W_UP_MAX_mean_40"]
verif_var_50 = "MESH_Max_60min_00.50_50"
eval_path = "/hail/djgagne/ncar_coarse_neighbor_eval_2016/"
eval_files = sorted(os.listdir(eval_path))
eval_test = pd.read_csv(join(eval_path, eval_files[0]))
rows = eval_test.i_small.max()  + 1
cols = eval_test.j_small.max() + 1
lon = eval_test.lon.reshape((rows, cols))
lat = eval_test.lat.reshape((rows, cols))
#models = eval_test.columns[eval_test.columns.str.contains("mean")]
run_dates = pd.DatetimeIndex([e.split("_")[-1][:8] for e in eval_files])
spatial_data_50 = {}
for model in spatial_models_50:
    spatial_data_50[model] = np.zeros((len(run_dates), rows, cols))
spatial_verif_50 = np.zeros((len(run_dates), rows, cols))
for e, eval_file in enumerate(eval_files):
    print(eval_file)
    eval_data = pd.read_csv(join(eval_path, eval_file))
    spatial_verif_50[e] = eval_data[verif_var_50].values.reshape(rows, cols)
    for model in spatial_models_50:
        spatial_data_50[model][e] = eval_data[model].values.reshape(rows, cols)


coarse_neighbor_eval_NCAR_20160502.csv
coarse_neighbor_eval_NCAR_20160503.csv
coarse_neighbor_eval_NCAR_20160504.csv
coarse_neighbor_eval_NCAR_20160505.csv
coarse_neighbor_eval_NCAR_20160506.csv
coarse_neighbor_eval_NCAR_20160507.csv
coarse_neighbor_eval_NCAR_20160508.csv
coarse_neighbor_eval_NCAR_20160509.csv
coarse_neighbor_eval_NCAR_20160510.csv
coarse_neighbor_eval_NCAR_20160511.csv
coarse_neighbor_eval_NCAR_20160512.csv
coarse_neighbor_eval_NCAR_20160513.csv
coarse_neighbor_eval_NCAR_20160514.csv
coarse_neighbor_eval_NCAR_20160515.csv
coarse_neighbor_eval_NCAR_20160516.csv
coarse_neighbor_eval_NCAR_20160517.csv
coarse_neighbor_eval_NCAR_20160518.csv
coarse_neighbor_eval_NCAR_20160519.csv
coarse_neighbor_eval_NCAR_20160520.csv
coarse_neighbor_eval_NCAR_20160521.csv
coarse_neighbor_eval_NCAR_20160522.csv
coarse_neighbor_eval_NCAR_20160523.csv
coarse_neighbor_eval_NCAR_20160524.csv
coarse_neighbor_eval_NCAR_20160525.csv
coarse_neighbor_eval_NCAR_20160526.csv
coarse_neighbor_eval_NCAR_20160527.csv
coarse_neighbor_eval_NCAR_20160528.csv
coarse_neighbor_eval_NCAR_20160529.csv
coarse_neighbor_eval_NCAR_20160530.csv
coarse_neighbor_eval_NCAR_20160531.csv
coarse_neighbor_eval_NCAR_20160601.csv
coarse_neighbor_eval_NCAR_20160602.csv
coarse_neighbor_eval_NCAR_20160603.csv
coarse_neighbor_eval_NCAR_20160604.csv
coarse_neighbor_eval_NCAR_20160605.csv
coarse_neighbor_eval_NCAR_20160606.csv
coarse_neighbor_eval_NCAR_20160607.csv
coarse_neighbor_eval_NCAR_20160608.csv
coarse_neighbor_eval_NCAR_20160609.csv
coarse_neighbor_eval_NCAR_20160610.csv
coarse_neighbor_eval_NCAR_20160611.csv
coarse_neighbor_eval_NCAR_20160612.csv
coarse_neighbor_eval_NCAR_20160613.csv
coarse_neighbor_eval_NCAR_20160614.csv
coarse_neighbor_eval_NCAR_20160615.csv
coarse_neighbor_eval_NCAR_20160616.csv
coarse_neighbor_eval_NCAR_20160617.csv
coarse_neighbor_eval_NCAR_20160618.csv
coarse_neighbor_eval_NCAR_20160619.csv
coarse_neighbor_eval_NCAR_20160620.csv
coarse_neighbor_eval_NCAR_20160621.csv
coarse_neighbor_eval_NCAR_20160622.csv
coarse_neighbor_eval_NCAR_20160623.csv
coarse_neighbor_eval_NCAR_20160630.csv
coarse_neighbor_eval_NCAR_20160701.csv
coarse_neighbor_eval_NCAR_20160702.csv
coarse_neighbor_eval_NCAR_20160703.csv
coarse_neighbor_eval_NCAR_20160704.csv
coarse_neighbor_eval_NCAR_20160705.csv
coarse_neighbor_eval_NCAR_20160706.csv
coarse_neighbor_eval_NCAR_20160707.csv
coarse_neighbor_eval_NCAR_20160708.csv
coarse_neighbor_eval_NCAR_20160709.csv
coarse_neighbor_eval_NCAR_20160710.csv
coarse_neighbor_eval_NCAR_20160711.csv
coarse_neighbor_eval_NCAR_20160712.csv
coarse_neighbor_eval_NCAR_20160713.csv
coarse_neighbor_eval_NCAR_20160714.csv
coarse_neighbor_eval_NCAR_20160715.csv
coarse_neighbor_eval_NCAR_20160716.csv
coarse_neighbor_eval_NCAR_20160717.csv
coarse_neighbor_eval_NCAR_20160718.csv
coarse_neighbor_eval_NCAR_20160719.csv
coarse_neighbor_eval_NCAR_20160720.csv
coarse_neighbor_eval_NCAR_20160721.csv
coarse_neighbor_eval_NCAR_20160722.csv
coarse_neighbor_eval_NCAR_20160723.csv
coarse_neighbor_eval_NCAR_20160724.csv
coarse_neighbor_eval_NCAR_20160725.csv
coarse_neighbor_eval_NCAR_20160726.csv
coarse_neighbor_eval_NCAR_20160727.csv
coarse_neighbor_eval_NCAR_20160729.csv
coarse_neighbor_eval_NCAR_20160730.csv
coarse_neighbor_eval_NCAR_20160731.csv
coarse_neighbor_eval_NCAR_20160801.csv
coarse_neighbor_eval_NCAR_20160802.csv
coarse_neighbor_eval_NCAR_20160803.csv
coarse_neighbor_eval_NCAR_20160804.csv
coarse_neighbor_eval_NCAR_20160808.csv
coarse_neighbor_eval_NCAR_20160809.csv
coarse_neighbor_eval_NCAR_20160810.csv
coarse_neighbor_eval_NCAR_20160811.csv
coarse_neighbor_eval_NCAR_20160812.csv
coarse_neighbor_eval_NCAR_20160813.csv
coarse_neighbor_eval_NCAR_20160814.csv
coarse_neighbor_eval_NCAR_20160815.csv
coarse_neighbor_eval_NCAR_20160816.csv
coarse_neighbor_eval_NCAR_20160817.csv
coarse_neighbor_eval_NCAR_20160818.csv
coarse_neighbor_eval_NCAR_20160819.csv
coarse_neighbor_eval_NCAR_20160820.csv
coarse_neighbor_eval_NCAR_20160821.csv
coarse_neighbor_eval_NCAR_20160826.csv
coarse_neighbor_eval_NCAR_20160827.csv
coarse_neighbor_eval_NCAR_20160829.csv
coarse_neighbor_eval_NCAR_20160830.csv
coarse_neighbor_eval_NCAR_20160831.csv

In [156]:
fig, axes = plt.subplots(2, 3, figsize=(12, 6))
plt.subplots_adjust(hspace=0.05, wspace=0.05)
print(axes.ravel())
x, y = bmap(lon, lat)
us_mask = eval_test.us_mask.values.reshape(rows, cols)
verif_sum = convolve(spatial_verif.sum(axis=0) * us_mask, np.ones((5,5)))
for m, model in enumerate(spatial_models):
    bmap.drawstates(ax=axes.ravel()[m])
    bmap.drawcoastlines(ax=axes.ravel()[m])
    bmap.drawcountries(ax=axes.ravel()[m])
    spatial_sum = convolve(np.where(spatial_data[model]  * us_mask > 0.2, 1, 0).sum(axis=0), np.ones((5,5)))
    print(model, spatial_sum.max())
    axes.ravel()[m].contourf(x, y, spatial_sum * us_mask,np.linspace(20, spatial_sum.max(), 10), cmap="viridis", extend="max")
    axes.ravel()[m].set_title(model.replace("NCAR", "").replace("_", " "), fontsize=10)
    axes.ravel()[m].contour(x, y, verif_sum, 
                            np.linspace(20, verif_sum.max(), 5), cmap="Reds")
#bmap.drawstates(ax=axes.ravel()[-1])
#bmap.drawcoastlines(ax=axes.ravel()[-1])
#bmap.drawcountries(ax=axes.ravel()[-1])
#
#axes.ravel()[-1].set_title("MESH 25 mm")
plt.savefig("ncar_hail_spatial_counts.png", dpi=300, bbox_inches="tight")


[<matplotlib.axes._subplots.AxesSubplot object at 0x2ba1d1fb0d90>
 <matplotlib.axes._subplots.AxesSubplot object at 0x2ba1e1ca26d0>
 <matplotlib.axes._subplots.AxesSubplot object at 0x2ba1e37d8610>
 <matplotlib.axes._subplots.AxesSubplot object at 0x2ba1e21d1fd0>
 <matplotlib.axes._subplots.AxesSubplot object at 0x2ba1e1899c50>
 <matplotlib.axes._subplots.AxesSubplot object at 0x2ba1ea5234d0>]
('NCAR_Random-Forest-CV_mean_25', 898)
('NCAR_HAILCAST_DIAM_MEAN_mean_25', 906)
('NCAR_HAIL_MAXK1_mean_25', 1248)
('NCAR_GRPL_MAX_mean_30', 650)
('NCAR_UP_HELI_MAX_mean_50', 807)
('NCAR_W_UP_MAX_mean_30', 481)

In [103]:
fig, axes = plt.subplots(2, 3, figsize=(12, 6))
plt.subplots_adjust(hspace=0.05, wspace=0.05)
print(axes.ravel())
x, y = bmap(lon, lat)
us_mask = eval_test.us_mask.values.reshape(rows, cols)
verif_sum = convolve(spatial_verif[run_dates.month < 7].sum(axis=0) * us_mask, np.ones((5,5)))
for m, model in enumerate(spatial_models):
    bmap.drawstates(ax=axes.ravel()[m])
    bmap.drawcoastlines(ax=axes.ravel()[m])
    bmap.drawcountries(ax=axes.ravel()[m])
    spatial_sum = convolve(np.where(spatial_data[model][run_dates.month < 7]  * us_mask > 0.2, 1, 0).sum(axis=0), np.ones((5,5)))
    print(model, spatial_sum.max())
    axes.ravel()[m].contourf(x, y, spatial_sum,np.linspace(20, spatial_sum.max(), 10), cmap="viridis", extend="max")
    axes.ravel()[m].set_title(model.replace("NCAR", "").replace("_", " "), fontsize=10)
    axes.ravel()[m].contour(x, y, verif_sum, 
                            np.linspace(20, verif_sum.max(), 5), cmap="Reds")
#bmap.drawstates(ax=axes.ravel()[-1])
#bmap.drawcoastlines(ax=axes.ravel()[-1])
#bmap.drawcountries(ax=axes.ravel()[-1])
#
#axes.ravel()[-1].set_title("MESH 25 mm")
plt.savefig("ncar_hail_spatial_counts_may_june.png", dpi=300, bbox_inches="tight")


[<matplotlib.axes._subplots.AxesSubplot object at 0x2ab8a17fa910>
 <matplotlib.axes._subplots.AxesSubplot object at 0x2ab8a2cdc890>
 <matplotlib.axes._subplots.AxesSubplot object at 0x2ab8a2e78d10>
 <matplotlib.axes._subplots.AxesSubplot object at 0x2ab8a0bc5110>
 <matplotlib.axes._subplots.AxesSubplot object at 0x2ab8a37a1090>
 <matplotlib.axes._subplots.AxesSubplot object at 0x2ab8ace7dd10>]
('NCAR_Random-Forest-CV_mean_25', 420)
('NCAR_HAILCAST_DIAM_MEAN_mean_25', 445)
('NCAR_HAIL_MAXK1_mean_25', 493)
('NCAR_GRPL_MAX_mean_30', 343)
('NCAR_UP_HELI_MAX_mean_50', 404)
('NCAR_W_UP_MAX_mean_30', 296)

In [108]:
fig, axes = plt.subplots(2, 3, figsize=(12, 6))
plt.subplots_adjust(hspace=0.05, wspace=0.05)
print(axes.ravel())
x, y = bmap(lon, lat)
us_mask = eval_test.us_mask.values.reshape(rows, cols)
verif_sum = convolve(spatial_verif[run_dates.month > 6].sum(axis=0) * us_mask, np.ones((5,5)))
for m, model in enumerate(spatial_models):
    bmap.drawstates(ax=axes.ravel()[m])
    bmap.drawcoastlines(ax=axes.ravel()[m])
    bmap.drawcountries(ax=axes.ravel()[m])
    spatial_sum = convolve(np.where(spatial_data[model][run_dates.month > 6]  * us_mask > 0.2, 1, 0).sum(axis=0), np.ones((5,5)))
    print(model, spatial_sum.max())
    axes.ravel()[m].contourf(x, y, spatial_sum,np.linspace(20, 600, 10), cmap="viridis", extend="max")
    axes.ravel()[m].set_title(model.replace("NCAR", "").replace("_", " "), fontsize=10)
    axes.ravel()[m].contour(x, y, verif_sum, 
                            np.linspace(20, 400, 5), cmap="Reds")
#bmap.drawstates(ax=axes.ravel()[-1])
#bmap.drawcoastlines(ax=axes.ravel()[-1])
#bmap.drawcountries(ax=axes.ravel()[-1])
#
#axes.ravel()[-1].set_title("MESH 25 mm")
plt.savefig("ncar_hail_spatial_counts_july_august.png", dpi=300, bbox_inches="tight")


[<matplotlib.axes._subplots.AxesSubplot object at 0x2ab8a044a410>
 <matplotlib.axes._subplots.AxesSubplot object at 0x2ab8a278b3d0>
 <matplotlib.axes._subplots.AxesSubplot object at 0x2ab8a25ec850>
 <matplotlib.axes._subplots.AxesSubplot object at 0x2ab8a1bd9c10>
 <matplotlib.axes._subplots.AxesSubplot object at 0x2ab8a0cadb90>
 <matplotlib.axes._subplots.AxesSubplot object at 0x2ab8a0d05850>]
('NCAR_Random-Forest-CV_mean_25', 599)
('NCAR_HAILCAST_DIAM_MEAN_mean_25', 567)
('NCAR_HAIL_MAXK1_mean_25', 780)
('NCAR_GRPL_MAX_mean_30', 472)
('NCAR_UP_HELI_MAX_mean_50', 471)
('NCAR_W_UP_MAX_mean_30', 353)

In [112]:
p_thresh = 0.3
weights = np.ones((9, 9))
fig, axes = plt.subplots(2, 3, figsize=(12, 6))
ax_flat = axes.ravel()
plt.subplots_adjust(hspace=0.05, wspace=0.05)
for m, model in enumerate(spatial_models):
    hits = np.where((spatial_data[model][run_dates.month < 7] >= p_thresh) & (spatial_verif[run_dates.month < 7] == 1), 1, 0).sum(axis=0)
    false_alarms = np.where((spatial_data[model][run_dates.month < 7] >= p_thresh) & (spatial_verif[run_dates.month < 7] == 0), 1, 0).sum(axis=0)
    misses = np.where((spatial_data[model][run_dates.month < 7] < p_thresh) & (spatial_verif[run_dates.month < 7] == 1), 1, 0).sum(axis=0)
    tn = np.where((spatial_data[model][run_dates.month < 7] < p_thresh) & (spatial_verif[run_dates.month < 7] == 0), 1, 0).sum(axis=0)
    n_obs = convolve(spatial_verif[run_dates.month < 7].sum(axis=0), weights)
    pod = convolve(hits, weights) / convolve(hits + misses, weights).astype(float)
    far = convolve(false_alarms, weights) / convolve(hits + false_alarms, weights).astype(float)
    pofd = convolve(false_alarms, weights) / convolve(tn + false_alarms, weights).astype(float)
    bmap.drawstates(ax=ax_flat[m])
    bmap.drawcoastlines(ax=ax_flat[m])
    bmap.drawcountries(ax=ax_flat[m])
    ax_flat[m].set_title(model)
    ax_flat[m].pcolormesh(x, y, np.ma.array(pod - pofd, mask=(us_mask == 0) | (n_obs < 100)), vmin=0, vmax=0.5, cmap="viridis")


/glade/p/work/dgagne/miniconda/envs/py2/lib/python2.7/site-packages/ipykernel/__main__.py:12: RuntimeWarning: invalid value encountered in divide
/glade/p/work/dgagne/miniconda/envs/py2/lib/python2.7/site-packages/ipykernel/__main__.py:13: RuntimeWarning: invalid value encountered in divide

In [115]:
bmap.drawstates()
bmap.drawcoastlines()
bmap.drawcountries()
bmap.pcolormesh(x, y, n_obs)


Out[115]:
<matplotlib.collections.QuadMesh at 0x2b497dc63850>

In [278]:
ct_shape = np.concatenate([[len(spatial_models), 4], spatial_data.values()[0].shape[1:]])
spatial_ct = np.zeros(ct_shape)
sp_ct_conv = np.zeros(ct_shape)
spatial_ets = np.zeros(ct_shape[[0, 2, 3]])
c_filt = np.ones((8, 8))
p_thresh = 0.2
for m, model in enumerate(spatial_models):
    spatial_ct[m, 0] = np.where((spatial_data[model] >= p_thresh) & (spatial_verif == 1), 1, 0).sum(axis=0)
    spatial_ct[m, 1] = np.where((spatial_data[model] >= p_thresh) & (spatial_verif == 0), 1, 0).sum(axis=0)
    spatial_ct[m, 2] = np.where((spatial_data[model] < p_thresh) & (spatial_verif == 1), 1, 0).sum(axis=0)
    spatial_ct[m, 3] = np.where((spatial_data[model] < p_thresh) & (spatial_verif == 0), 1, 0).sum(axis=0)
    for t in range(4):
        sp_ct_conv[m, t] = convolve(spatial_ct[m, t] * us_mask, c_filt)
    r = (sp_ct_conv[m, 0] + sp_ct_conv[m, 1]) * (sp_ct_conv[m, 0] + sp_ct_conv[m, 2]) / sp_ct_conv[m].sum(axis=0)
    spatial_ets[m] = (sp_ct_conv[m, 0] - r) / (sp_ct_conv[m, 0:3].sum(axis=0) - r)

In [295]:
ct_shape = np.concatenate([[len(spatial_models_50), 4], spatial_data_50.values()[0].shape[1:]])
spatial_ct_50 = np.zeros(ct_shape)
sp_ct_conv = np.zeros(ct_shape)
spatial_ets_50 = np.zeros(ct_shape[[0, 2, 3]])
c_filt = np.ones((8, 8))
p_thresh = 0.2
for m, model in enumerate(spatial_models_50):
    spatial_ct_50[m, 0] = np.where((spatial_data_50[model] >= p_thresh) & (spatial_verif_50 == 1), 1, 0).sum(axis=0)
    spatial_ct_50[m, 1] = np.where((spatial_data_50[model] >= p_thresh) & (spatial_verif_50 == 0), 1, 0).sum(axis=0)
    spatial_ct_50[m, 2] = np.where((spatial_data_50[model] < p_thresh) & (spatial_verif_50 == 1), 1, 0).sum(axis=0)
    spatial_ct_50[m, 3] = np.where((spatial_data_50[model] < p_thresh) & (spatial_verif_50 == 0), 1, 0).sum(axis=0)
    for t in range(4):
        sp_ct_conv[m, t] = convolve(spatial_ct_50[m, t] * us_mask, c_filt)
    r = (sp_ct_conv[m, 0] + sp_ct_conv[m, 1]) * (sp_ct_conv[m, 0] + sp_ct_conv[m, 2]) / sp_ct_conv[m].sum(axis=0)
    spatial_ets_50[m] = (sp_ct_conv[m, 0] - r) / (sp_ct_conv[m, 0:3].sum(axis=0) - r)

In [316]:
print(spatial_models)
fig, axes = plt.subplots(2, 3, figsize=(12, 5.5))
ax_flat = axes.ravel()
plt.subplots_adjust(0.02, 0.02, 0.9, 0.9, hspace=0.05, wspace=0.05)
for m, model in enumerate(spatial_models):
    bmap.drawstates(ax=ax_flat[m])
    bmap.drawcoastlines(ax=ax_flat[m])
    bmap.drawcountries(ax=ax_flat[m])
    if m == 0:
        ax_flat[m].contourf(x, y, np.ma.array(spatial_ets[m], mask=us_mask==0), 
                            np.linspace(-0.4, 0.4, 17), cmap="RdBu_r")
    else:
        cont = ax_flat[m].contourf(x, y, spatial_ets[0] - np.ma.array(spatial_ets[m] , mask=us_mask==0), 
                                   np.linspace(-0.4, 0.4, 17) , cmap="RdBu_r")
    ax_flat[m].set_title(spatial_names[m])
cbar_ax = fig.add_axes([0.92, 0.05, 0.05, 0.85])
cbar = fig.colorbar(cont, cax=cbar_ax)
cbar.ax.set_ylabel("Random Forest ETS - Model ETS", fontsize=12)
fig.suptitle("NCAR Ensemble 25 mm Hail Equitable Threat Score (P=20 %) Differences from Random Forest", fontsize=14, fontweight="bold")
plt.savefig("ncar_hail_spatial_ets_diff_25.pdf", bbox_inches="tight")


['NCAR_Random-Forest-CV_mean_25', 'NCAR_HAILCAST_DIAM_MEAN_mean_25', 'NCAR_HAIL_MAXK1_mean_25', 'NCAR_GRPL_MAX_mean_30', 'NCAR_UP_HELI_MAX_mean_50', 'NCAR_W_UP_MAX_mean_30']

In [317]:
print(spatial_models)
fig, axes = plt.subplots(2, 3, figsize=(12, 5.5))
ax_flat = axes.ravel()
plt.subplots_adjust(0.02, 0.02, 0.9, 0.9, hspace=0.05, wspace=0.05)
for m, model in enumerate(spatial_models):
    bmap.drawstates(ax=ax_flat[m])
    bmap.drawcoastlines(ax=ax_flat[m])
    bmap.drawcountries(ax=ax_flat[m])
    if m == 0:
        ax_flat[m].contourf(x, y, np.ma.array(spatial_ets_50[m], mask=us_mask==0), 
                            np.linspace(-0.4, 0.4, 17), cmap="RdBu_r", extend="both")
    else:
        cont = ax_flat[m].contourf(x, y,np.ma.array(spatial_ets_50[0] - spatial_ets_50[m] , mask=us_mask==0), 
                                   np.linspace(-0.4, 0.4, 17) , cmap="RdBu_r", extend="both")
    ax_flat[m].set_title(spatial_names_50[m])
cbar_ax = fig.add_axes([0.92, 0.05, 0.05, 0.85])
cbar = fig.colorbar(cont, cax=cbar_ax)
cbar.ax.set_ylabel("Random Forest ETS - Model ETS", fontsize=12)
fig.suptitle("NCAR Ensemble 50 mm Hail Equitable Threat Score (P=20 %) Differences from Random Forest", fontsize=14, fontweight="bold")
plt.savefig("ncar_hail_spatial_ets_diff_50.pdf", bbox_inches="tight")


['NCAR_Random-Forest-CV_mean_25', 'NCAR_HAILCAST_DIAM_MEAN_mean_25', 'NCAR_HAIL_MAXK1_mean_25', 'NCAR_GRPL_MAX_mean_30', 'NCAR_UP_HELI_MAX_mean_50', 'NCAR_W_UP_MAX_mean_30']

In [327]:
print(spatial_models)
fig, axes = plt.subplots(2, 3, figsize=(12, 5.5))
ax_flat = axes.ravel()
plt.subplots_adjust(0.02, 0.02, 0.9, 0.9, hspace=0.05, wspace=0.05)
for m, model in enumerate(spatial_models):
    bmap.drawstates(ax=ax_flat[m])
    bmap.drawcoastlines(ax=ax_flat[m])
    bmap.drawcountries(ax=ax_flat[m])
    if m == 0:
        ax_flat[m].contourf(x, y, np.ma.array(spatial_ets_50[m], mask=us_mask==0), 
                            np.linspace(0, 0.5, 9), cmap="Reds")
    else:
        cont = ax_flat[m].contourf(x, y,np.ma.array(spatial_ets_50[m] , mask=us_mask==0), 
                                   np.linspace(0, 0.5, 11) , cmap="Reds")
    ax_flat[m].set_title(spatial_names_50[m])
cbar_ax = fig.add_axes([0.92, 0.05, 0.05, 0.85])
cbar = fig.colorbar(cont, cax=cbar_ax)
cbar.ax.set_ylabel("Equitable Threat Score", fontsize=12)
fig.suptitle("NCAR Ensemble 50 mm Hail Equitable Threat Score for 20% Hail Probability", fontsize=14, fontweight="bold")
plt.savefig("ncar_hail_spatial_ets_50.pdf", bbox_inches="tight")


['NCAR_Random-Forest-CV_mean_25', 'NCAR_HAILCAST_DIAM_MEAN_mean_25', 'NCAR_HAIL_MAXK1_mean_25', 'NCAR_GRPL_MAX_mean_30', 'NCAR_UP_HELI_MAX_mean_50', 'NCAR_W_UP_MAX_mean_30']

In [326]:
print(spatial_models)
fig, axes = plt.subplots(2, 3, figsize=(12, 5.5))
ax_flat = axes.ravel()
plt.subplots_adjust(0.02, 0.02, 0.9, 0.9, hspace=0.05, wspace=0.05)
for m, model in enumerate(spatial_models):
    bmap.drawstates(ax=ax_flat[m])
    bmap.drawcoastlines(ax=ax_flat[m])
    bmap.drawcountries(ax=ax_flat[m])
    if m == 0:
        ax_flat[m].contourf(x, y, np.ma.array(spatial_ets[m], mask=us_mask==0), 
                            np.linspace(0, 0.5, 9), cmap="Reds")
    else:
        cont = ax_flat[m].contourf(x, y,np.ma.array(spatial_ets[m] , mask=us_mask==0), 
                                   np.linspace(0, 0.5, 11) , cmap="Reds")
    ax_flat[m].set_title(spatial_names[m])
cbar_ax = fig.add_axes([0.92, 0.05, 0.05, 0.85])
cbar = fig.colorbar(cont, cax=cbar_ax)
cbar.ax.set_ylabel("Equitable Threat Score", fontsize=12)
fig.suptitle("NCAR Ensemble 25 mm Hail Equitable Threat Score for 20% Hail Probability", fontsize=14, fontweight="bold")
plt.savefig("ncar_hail_spatial_ets_25.pdf", bbox_inches="tight")


['NCAR_Random-Forest-CV_mean_25', 'NCAR_HAILCAST_DIAM_MEAN_mean_25', 'NCAR_HAIL_MAXK1_mean_25', 'NCAR_GRPL_MAX_mean_30', 'NCAR_UP_HELI_MAX_mean_50', 'NCAR_W_UP_MAX_mean_30']

In [348]:
fig, axes = plt.subplots(1, 2, figsize=(12, 5.5))
ax_flat = axes.ravel()
plt.subplots_adjust(0.02, 0.02, 0.98, 0.98, hspace=0.05, wspace=0.05)
spatial_count_50 = convolve(spatial_verif_50.sum(axis=0) * us_mask, c_filt)
spatial_count_25 = convolve(spatial_verif.sum(axis=0) * us_mask, c_filt)
for ax in ax_flat:
    bmap.drawstates(ax=ax)
    bmap.drawcoastlines(ax=ax)
    bmap.drawcountries(ax=ax)
cont1 = ax_flat[0].contourf(x, y, 
                            np.ma.array(spatial_count_25, mask=(us_mask==0) | (spatial_count_25 < 10)),
                            np.arange(0, 1250, 100),
                            cmap="Reds")
cont2 = ax_flat[1].contourf(x, y, 
                            np.ma.array(spatial_count_50, 
                                        mask=(us_mask==0) | (spatial_count_50  < 10)),
                           np.arange(0, spatial_count_50.max() + 25, 25),
                           cmap="Reds")
cbar1 = plt.colorbar(mappable=cont1, ax=ax_flat[0], shrink=0.5, fraction=0.1)
cbar2 = plt.colorbar(mappable=cont2, ax=ax_flat[1], shrink=0.5, fraction=0.1)
cbar1.ax.set_ylabel("Number of 25 mm Hail Events")
cbar2.ax.set_ylabel("Number of 50 mm Hail Events")
ax_flat[0].set_title("25 mm Hail Observed Frequency")
ax_flat[1].set_title("50 mm Hail Observed Frequency")
fig.suptitle("Observed Hail Spatial Distributions", y=0.85, fontsize=14, fontweight="bold")
plt.savefig("ncar_hail_spatial_obs_freq.pdf", bbox_inches="tight")



In [ ]: