-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmelt_time_series.py
executable file
·99 lines (79 loc) · 2.74 KB
/
melt_time_series.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env python
'''
Script to plot melt time series from different runs
'''
from __future__ import absolute_import, division, print_function, unicode_literals
import sys
import os
import netCDF4
import datetime
import numpy as np
import matplotlib.pyplot as plt
import scipy.signal
from matplotlib import cm
from collections import OrderedDict
import xarray as xr
import glob
runs = OrderedDict()
runs['ISMF'] = {'ts_dir':
#'/global/cscratch1/sd/dcomeau/e3sm_scratch/cori-knl/mpas-analysis-output/20190225.GMPAS-DIB-IAF-ISMF.T62_oEC60to30v3wLI.cori-knl/yrs120-150/timeseries/iceShelfFluxes',
'/global/homes/h/hoffman2/cryo_data/ISMF',
'start':1,
'end':150
}
runs['ISMF-noEAIS'] = {'ts_dir':
#'/global/cscratch1/sd/dcomeau/e3sm_scratch/cori-knl/mpas-analysis-output/20190423.GMPAS-DIB-IAF-ISMF.T62_oEC60to30v3wLI.edison.restrictedMelt/yrs120-150/timeseries/iceShelfFluxes',
'/global/homes/h/hoffman2/cryo_data/ISMF-noEAIS',
'start':50,
'end':150
}
runs['ISMF-noDIB'] = {'ts_dir':
#'/global/cscratch1/sd/dcomeau/e3sm_scratch/cori-knl/mpas-analysis-output/20190423.GMPAS-DIB-IAF-ISMF.T62_oEC60to30v3wLI.edison.restrictedMelt/yrs120-150/timeseries/iceShelfFluxes',
'/global/homes/h/hoffman2/cryo_data/ISMF-noDIB',
'start':1,
'end':100
}
runs['ISMF-MGM'] = {'ts_dir':
#'/global/cscratch1/sd/xylar/analysis/20190819.GMPAS-DIB-IAF-ISMF.T62_oEC60to30v3wLI.cori-knl.testNewGM/',
'/global/homes/h/hoffman2/cryo_data/ISMF-MGM',
'start':21,
'end':100
}
fig1 = plt.figure(1, facecolor='w')
nrow=1
ncol=1
axMelt = fig1.add_subplot(nrow, ncol, 1)
region=5 #FIS
Rregion=6 #RIS
#7=FRIS
#colors=[ cm.tab10(x) for x in np.linspace(0.0, 1.0, 4) ]
r=0
for run in runs:
thisDict = runs[run]
print(thisDict['ts_dir'])
filelist = glob.glob(os.path.join(thisDict['ts_dir'], 'iceShelfFluxes*.nc'))
Fmelt = np.zeros((thisDict['end']-thisDict['start']+1))
Rmelt = np.zeros((thisDict['end']-thisDict['start']+1))
year = np.zeros((thisDict['end']-thisDict['start']+1))
i=0
for infile in sorted(filelist):
#print(infile, i)
#do some fancy stuff
f=netCDF4.Dataset(infile, 'r')
Fmelt[i] = f.variables['totalMeltFlux'][:, region].mean()
year[i] = f.variables['Time'][0] / 365.0 + 1.0 # adding 1.0 offset because sims started then
Rmelt[i] = f.variables['totalMeltFlux'][:, Rregion].mean()
i += 1
axMelt.plot(year, Fmelt, label=run, color=cm.tab10(r))
axMelt.plot(year, Rmelt, '--', color=cm.tab10(r))
r+=1
#plt.plot(ds.Time, ds.totalMeltFlux[:,0])
plt.xlabel('Year')
plt.ylabel('Filchner Ice Shelf melt flux (Gt yr$^{-1}$)')
plt.legend()
yl=axMelt.get_ylim()
plt.plot([1, 1], [-100, 2000], 'k--')
plt.plot([63, 63], [-100, 2000], 'k--')
plt.plot([63+62, 63+62], [-100, 2000], 'k--')
axMelt.set_ylim(yl)
plt.show()