<jupyter_start><jupyter_text>Load ski resort data<jupyter_code>import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from ema_workbench import load_results, ema_logging
#root = r'C:\Saeid\Prj100\SA_2\snowModelUZH\case1_sattel-hochstuckli\setup1\Results_3'
#root = r'C:\Saeid\Prj100\SA_2\snowModelUZH\case2_Atzmaening\setup1\Results_3'
#root = r'C:\Saeid\Prj100\SA_2\snowModelUZH\case3_hoch-ybrig\setup1\Results_3'
#root = r'C:\Saeid\Prj100\SA_2\snowModelUZH\case4_villars-diablerets_elevations_b1339\setup1\Results_3'
#root = r'C:\Saeid\Prj100\SA_2\snowModelUZH\case4_villars-diablerets_elevations_b1822\setup1\Results_3'
#root = r'C:\Saeid\Prj100\SA_2\snowModelUZH\case4_villars-diablerets_elevations_b2000\setup1\Results_3'
#root = r'C:\Saeid\Prj100\SA_2\snowModelUZH\case4_villars-diablerets_elevations_b2500\setup1\Results_3'
#root = r'C:\Saeid\Prj100\SA_2\snowModelUZH\case5_champex\setup1\Results_3'
#root = r'C:\Saeid\Prj100\SA_2\snowModelUZH\case6_davos_elevations_b1564\setup1\Results_3'
#root = r'C:\Saeid\Prj100\SA_2\snowModelUZH\case6_davos_elevations_b2141\setup1\Results_3'
root = r'C:\Saeid\Prj100\SA_2\snowModelUZH\case6_davos_elevations_b2584\setup1\Results_3'


fh = os.path.join(root, '9000_runs.tar.gz')
experiments, outcomes = load_results(fh)
experiments.head()
outcomes.keys()
type(outcomes)
S_GoodDay = outcomes['S_GoodDay']
#Each row is an experiment containing a timeseries with good snow days in that year
df = pd.DataFrame(S_GoodDay)
df.head()
#Rolling windows, length 10
#Taking the mean of the window
wd = df.rolling(window=10,center=True,axis=1).mean()
wd.head()
wd.shape
np.array(wd.iloc[1,5])<jupyter_output><empty_output><jupyter_text>So, I smoothed the signal of each experiment a little bit.I am now interested in the question: which factors explain the number of good snowdays in a couple of reference years?The reference years are: 10 (beginning of the timeseries), 110 (end of the timeseries) and 60 (half of the timeseries).<jupyter_code>outcomes2 = outcomes.copy()
outcomes2['GD_10'] = np.array(wd.iloc[:,10])
outcomes2['GD_60'] = np.array(wd.iloc[:,60])
outcomes2['GD_110'] = np.array(wd.iloc[:,110])
len(outcomes2['GD_10'])
outcomes2.keys()
experiments2 = experiments
experiments2 = experiments2.pop('policy')
sns.set(font_scale=1.5)<jupyter_output><empty_output><jupyter_text>Feature scoring<jupyter_code>from ema_workbench.analysis import feature_scoring
import seaborn as sns


fig, ax = plt.subplots(figsize=(10,6))

x = experiments
plot = ['GD_10','GD_60','GD_110']
y = {x: outcomes2[x] for x in plot}

fs = feature_scoring.get_feature_scores_all(x, y)
sns.heatmap(fs, cmap='viridis', fmt=".2f", annot=True,
            vmin=0, linewidths=0.28, 
            linecolor="grey",
            cbar_kws={'label': 'features ranks'})


plt.setp(ax.get_xticklabels(), rotation=15, size = 20, ha="right",
         rotation_mode="anchor")

ylabels = ['x_Ablation_1', 'x_Ablation_2', 'x_Accumulation', 'x_Art_Snow', 'x_Climate_Random', 'x_Snow_threshold', 'x_GCMs_RCMs', 'x_Good_Snow', 'x_RCPs']
ax.set_yticklabels(ylabels)
plt.setp(ax.get_yticklabels(), rotation=50, size = 14, ha="right", rotation_mode="anchor")


fig.savefig(os.path.join(root, 'Time_outputs1.tiff'), format='tiff', dpi=300)
fig.savefig(os.path.join(root, 'Time_outputs2.tiff'), format='tiff', dpi=150)

plt.show()<jupyter_output><empty_output><jupyter_text>So that is a pretty cool result! You see that over time, the xRCP (i.e. the climate scenario) starts to strongly dominate the uncertainty of the results!  Dimension stacking<jupyter_code>from ema_workbench.analysis import dimensional_stacking

x = experiments
y = outcomes2['GD_10'] < 100
dimensional_stacking.create_pivot_plot(x,y, 2, nbins=3)
plt.show()<jupyter_output>c:\users\saeed\appdata\local\programs\python\python37\lib\site-packages\matplotlib\colors.py:587: RuntimeWarning: invalid value encountered in greater
  xa[xa > self.N - 1] = self._i_over
c:\users\saeed\appdata\local\programs\python\python37\lib\site-packages\matplotlib\colors.py:588: RuntimeWarning: invalid value encountered in less
  xa[xa < 0] = self._i_under<jupyter_text>How to interpret this?<jupyter_code>from ema_workbench.analysis import dimensional_stacking

x = experiments
y = outcomes2['GD_60'] < 70
dimensional_stacking.create_pivot_plot(x,y, 2, nbins=3)
plt.show()<jupyter_output>c:\users\saeed\appdata\local\programs\python\python37\lib\site-packages\matplotlib\colors.py:587: RuntimeWarning: invalid value encountered in greater
  xa[xa > self.N - 1] = self._i_over
c:\users\saeed\appdata\local\programs\python\python37\lib\site-packages\matplotlib\colors.py:588: RuntimeWarning: invalid value encountered in less
  xa[xa < 0] = self._i_under
{'fraction_non_alphanumeric': 0.13148422612746136, 'fraction_numerical': 0.047215752699555365, 'mean_word_length': 6.5342902711323765, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '270317', 'license': 'MIT', 'n_tokens_mistral': 1992, 'n_tokens_neox': 1845, 'n_words': 313, 'path': 'time_dimension.ipynb', 'repo_name': 'saeedashraf/snow-ski-resort-finance', 'size': '4723'}