-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_mslr.py
More file actions
42 lines (37 loc) · 1.79 KB
/
plot_mslr.py
File metadata and controls
42 lines (37 loc) · 1.79 KB
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
#!/usr/bin/env python
#%%
import numpy as np, pandas as pd
from netCDF4 import Dataset
from datetime import date, datetime, timedelta
import matplotlib.pyplot as plt
from matplotlib import cm
from scipy.signal import savgol_filter
homedir = '/home/mlicer/projects/podnebnik/SSH/'
sshfile = '{}SLR_total.csv'.format(homedir)
ssh = pd.read_csv(sshfile,parse_dates=['date'])
ssh = ssh.set_index(['date'])
ssh =ssh.drop(['ssh_rcp26', 'ssh_rcp45','rcp45_mean','ssh_rcp85','rcp85_mean'],axis=1)
#low pass filter:
ssh['historical_rollmean_15yr'] = savgol_filter(ssh['ssh_historical'],15, 2, mode='nearest')
ssh['tot_rcp85_rollmean_15yr'] = savgol_filter(ssh['tot_rcp85'],15, 2, mode='nearest')
ssh['tot_rcp45_rollmean_15yr'] = savgol_filter(ssh['tot_rcp45'],15, 2, mode='nearest')
figname='{}Total_SSH_RCP85_RCP45.pdf'.format(homedir)
lwidth=3
lwidth2=5
alpha=0.4
plt.close()
plt.figure(figsize=(15,15))
plt.title('MSLR in Northern Adriatic')
plt.plot(ssh.index,ssh['ssh_historical'],'k', linewidth=lwidth, label='MedCordex Reanalysis')# %%
plt.plot(ssh.index,ssh['historical_rollmean_15yr'],'k', linewidth=lwidth2, alpha= alpha, label='15yr Rolling Mean Historical MSLR')# %%
plt.plot(ssh.index,ssh['tot_rcp85'],'orangered', linewidth=lwidth, label='Total MSLR RCP8.5')# %%
plt.plot(ssh.index,ssh['tot_rcp85_rollmean_15yr'],'orangered', linewidth=lwidth2, alpha=alpha, label='15yr Rolling Mean RCP8.5')# %%
plt.plot(ssh.index,ssh['tot_rcp45'],'steelblue', linewidth=lwidth, label='Total MSLR RCP4.5')# %%
plt.plot(ssh.index,ssh['tot_rcp45_rollmean_15yr'],'steelblue', linewidth=lwidth2, alpha=alpha,label='15yr Rolling Mean RCP4.5')# %%
plt.xlabel('Year')
plt.ylabel('MSLR [m]')
plt.grid()
plt.legend()
plt.savefig(figname,dpi=300,bbox_inches='tight')
ssh.to_csv('{}MSLR_North_Adriatic_2100_RCP85_RCP45.csv'.format(homedir))
# %%