-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path08ClimateChangeVisualization.py
66 lines (53 loc) · 2.09 KB
/
08ClimateChangeVisualization.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# %%
from utils import read_climate, climate_shift, read_data, kriging_predict
import math
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import gaussian_kde
def intensity_plot(precip, temp):
xy = np.vstack([precip, temp])
z = gaussian_kde(xy)(xy)
corr = round(np.corrcoef(precip, temp)[0, 1], 2)
with plt.style.context(['science', 'no-latex']):
plt.scatter(precip,
temp, c=z, s=1)
plt.title('Days density')
plt.xlabel('Mean precipitation')
plt.ylabel('Mean temperature')
plt.xlim(0, 5)
plt.text(3.6, -12, f'R={corr}')
# plt.ylim(-10, 20)
plt.tight_layout()
plt.savefig('../results/MonthlyPrediction/HistoricalClimate.tiff',
bbox_inches='tight', dpi=300)
plt.show()
# %%
if __name__ == '__main__':
climate_model = 'CanESM'
ssp = 'ssp585'
city = 'Cleveland'
material = 'Cast Iron'
# future_climate = read_climate(model=climate_model, ssp=ssp, city=city)
# for year in np.arange(2020, 2100, 10):
# if year == 2020 or year == 2090:
# considered_climate = future_climate[(future_climate.index.year >= year) & (
# future_climate.index.year < year+10)]
# intensity_plot(
# considered_climate['Pr'].values, considered_climate['Temp'].values)
# %%
_, min_temp, precip, _ = read_data()
shift_time = 29
min_temp = climate_shift(
min_temp, shift_day=shift_time + 1, variable='Temp', variation='Mean')
# add precipitation data
shift_time = 29
precip = climate_shift(
precip, shift_day=shift_time + 1, variable='Pr', variation='Mean')
for year in [1990]:
considered_precip = precip[(precip.index.year >= year) &
(precip.index.year < year + 30)]
considered_min_temp = min_temp[(min_temp.index.year >= year)
& (min_temp.index.year < year + 30)]
intensity_plot(
considered_precip.used_value.values, considered_min_temp.used_value.values)
# %%