Skip to content

Commit dedf407

Browse files
author
bearecinos
committed
updated scripts
1 parent c7435ee commit dedf407

File tree

7 files changed

+133
-268
lines changed

7 files changed

+133
-268
lines changed

cryo_plots/alaska_volume_per_config.py

Lines changed: 37 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -96,40 +96,29 @@ def read_experiment_file_vbsl(filename):
9696
exp_name = []
9797
exp_number = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
9898

99-
#print(full_exp_name[0:13])
100-
10199
for f in full_exp_name[0:13]:
102100
volume, tails, basedir = read_experiment_file(f)
103101
volume_no_calving += [np.around(volume,2)]
104102
exp_name += [basedir]
105-
#print('Experiment name', exp_number)
106-
#print('Volume before calving', volume_no_calving)
107103

108104
volume_no_calving_sle = []
109105
for value in volume_no_calving:
110106
volume_no_calving_sle.append(calculate_sea_level_equivalent(value))
111-
#print('Volume before calving SLE', volume_no_calving_sle)
112107

113108
# Extract volumes for calving experiments
114109
# Reading calving experiments contained in 4_2_With_calving_exp_onlyMT
115-
#print(full_exp_name[8:len(full_exp_name)])
116110
volume_calving = []
117111
exp_name_c = []
118112
exp_number_c = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
119113

120-
121114
for f in full_exp_name[13:len(full_exp_name)]:
122115
volume, tails, basedir= read_experiment_file(f)
123116
volume_calving += [np.around(volume,2)]
124117
exp_name_c += [basedir]
125-
#print('Experiment name', exp_number_c)
126-
#print('Volume after calving', volume_calving)
127-
128118

129119
volume_calving_sle = []
130120
for value in volume_calving:
131121
volume_calving_sle.append(calculate_sea_level_equivalent(value))
132-
#print('Volume after calving SLE', volume_calving_sle)
133122

134123
# Extract volumes from volume_below_sea_level.csv
135124
# for the different configurations
@@ -144,7 +133,6 @@ def read_experiment_file_vbsl(filename):
144133
d +'/volume_below_sea_level.csv'))
145134

146135
full_dir_name = sorted(full_dir_name)
147-
#print(full_dir_name)
148136

149137
# Reading no calving volumes below sea level
150138
vbsl = []
@@ -157,10 +145,6 @@ def read_experiment_file_vbsl(filename):
157145
vbsl_c += [np.around(volume_c,2)]
158146
exp_name_bsl += [tails]
159147

160-
# print('Experiment', exp_number)
161-
# print('Volume bsl no calving', vbsl)
162-
# print('Volume bsl calving', vbsl_c)
163-
164148
# sea level equivalent
165149
vbsl_sle = []
166150
vbsl_c_sle = []
@@ -169,18 +153,18 @@ def read_experiment_file_vbsl(filename):
169153
vbsl_sle.append(calculate_sea_level_equivalent(i))
170154
vbsl_c_sle.append(calculate_sea_level_equivalent(j))
171155

172-
#print('Volume bsl no calving in s.l.e', vbsl_sle)
173-
#print('Volume bsl calving in s.l.e', vbsl_c_sle)
174156

175157
percentage = []
176158
for i, j in zip(volume_no_calving, volume_calving):
177159
percentage.append(calculate_volume_percentage(i,j))
178160

161+
print('FOR THE PAPER')
162+
print('----------------')
179163
print('Percentage', min(percentage), max(percentage))
180-
181164
print('Percent for columbia', calculate_volume_percentage(270.40, 349.39))
182165
print('Gt equivalent columbia', 2.98161468959857/1.091)
183166

167+
# Make a dataframe with each configuration output
184168
d = {'Experiment No': exp_number,
185169
'Volume no calving in s.l.e': volume_no_calving_sle,
186170
'Volume no calving bsl in s.l.e': vbsl_sle,
@@ -195,40 +179,56 @@ def read_experiment_file_vbsl(filename):
195179
'Volume differences in km3':
196180
[np.abs(a - b) for a, b in zip(volume_no_calving,volume_calving)]
197181
}
198-
199182
ds = pd.DataFrame(data=d)
200183

201184
ds = ds.sort_values(by=['Experiment No'])
202185
ds.to_csv(os.path.join(plot_path,
203186
'MT_glaciers_volume_per_exp.csv'))
204-
print('----------- For de paper ------------------')
205-
print('Mean and std volume with calving',
206-
np.round(np.mean(volume_calving_sle),2), np.round(np.std(volume_calving_sle),2))
207-
print('Mean and std volume no calving',
208-
np.round(np.mean(volume_no_calving_sle),2), np.round(np.std(volume_no_calving_sle),2))
187+
188+
print('----------- For de paper more information ------------------')
189+
190+
print('Mean and std volume with calving for all config',
191+
np.round(np.mean(volume_calving_sle),2),
192+
np.round(np.std(volume_calving_sle),2))
193+
194+
print('Mean and std volume no calving for all config',
195+
np.round(np.mean(volume_no_calving_sle),2),
196+
np.round(np.std(volume_no_calving_sle),2))
197+
209198
print('Mean and std volume below sea level with calving',
210-
np.round(np.mean(vbsl_c_sle),2), np.round(np.std(vbsl_c_sle),2))
199+
np.round(np.mean(vbsl_c_sle),2),
200+
np.round(np.std(vbsl_c_sle),2))
211201

212202
print('Mean and std volume below sea level without calving',
213-
np.round(np.mean(vbsl_sle),2), np.round(np.std(vbsl_sle),2))
203+
np.round(np.mean(vbsl_sle),2),
204+
np.round(np.std(vbsl_sle),2))
214205

215206
print('TABLE',ds)
216207

217-
print('is vbsl bigger than differnces', vbsl_c > ds['Volume differences in km3'].values)
208+
print('For the paper check if the volume below sea level is bigger than diff among config.')
209+
print(vbsl_c > ds['Volume differences in km3'].values)
218210

219211
diff_config = np.diff(volume_calving)
220-
221212
total = abs(diff_config / volume_calving[0:-1])*100
222213

223214
print('volume after calving differences between configs', total)
224215

216+
217+
# Reading Farinotti 2019 regional volume for MT glaciers.
225218
farinotti_data = pd.read_csv(os.path.join(MAIN_PATH,
226219
'input_data/farinotti_volume.csv'))
220+
#Sum the volumes in farinotti data
221+
vol_fari = farinotti_data['vol_itmix_m3'].sum()*1e-9
222+
vol_bsl_fari = farinotti_data['vol_bsl_itmix_m3'].sum()*1e-9
227223

228-
#print(farinotti_data)
229224

225+
print('FOR THE PAPER')
226+
print('our estimate after calving', np.round(np.mean(volume_calving_sle),2))
227+
print('farinotti', calculate_sea_level_equivalent(vol_fari))
228+
print('percentage of vol change',
229+
calculate_volume_percentage(np.mean(volume_calving),vol_fari))
230230

231-
# Plot settings
231+
# Plot everything!
232232
# Set figure width and height in cm
233233
width_cm = 12
234234
height_cm = 8
@@ -249,26 +249,13 @@ def read_experiment_file_vbsl(filename):
249249
ind = np.arange(N)
250250
graph_width = 0.35
251251
labels = np.append(ds['Experiment No'].values, 14)
252-
print(labels)
253-
254-
vol_fari = farinotti_data['vol_itmix_m3'].sum()*1e-9
255-
vol_bsl_fari = farinotti_data['vol_bsl_itmix_m3'].sum()*1e-9
256-
257-
258252

259253
bars1 = np.append(ds['Volume no calving bsl km3'].values, vol_bsl_fari)
260254
bars2 = np.append(ds['Volume no calving in km3'].values, vol_fari)
261-
#print(bars2)
262255

263256
bars3 = ds['Volume with calving bsl km3'].values
264257
bars4 = ds['Volume with calving in km3'].values
265258

266-
267-
268-
269-
270-
print(bars1)
271-
272259
sns.set_color_codes()
273260
sns.set_color_codes("colorblind")
274261

@@ -277,53 +264,48 @@ def read_experiment_file_vbsl(filename):
277264

278265
p1_extra = ax1.barh(ind[8:13], bars1[8:13]*-1,
279266
color="indianred", edgecolor="white", height=graph_width,
280-
alpha=0.7)
267+
alpha=0.5)
281268

282269
p2 = ax1.barh(ind[0:8], bars2[0:8], color=sns.xkcd_rgb["ocean blue"],
283270
height=graph_width, edgecolor="white")
284271

285272
p2_extra = ax1.barh(ind[8:13], bars2[8:13], color=sns.xkcd_rgb["ocean blue"],
286273
height=graph_width, edgecolor="white",
287-
alpha=0.7)
274+
alpha=0.5)
288275

289276
p3 = ax1.barh(ind[0:8] - graph_width, bars3[0:8]*-1,
290277
color="indianred",edgecolor="white", height=graph_width)
291278

292279
p3_extra = ax1.barh(ind[8:13] - graph_width, bars3[8:13]*-1,
293-
color="indianred", edgecolor="white", alpha=0.7,
280+
color="indianred", edgecolor="white", alpha=0.5,
294281
height=graph_width)
295282

296283
p4 = ax1.barh(ind[0:8] - graph_width, bars4[0:8], color=sns.xkcd_rgb["teal green"],
297284
edgecolor="white",
298285
height=graph_width)
299286

300287
p4_extra = ax1.barh(ind[8:13] - graph_width, bars4[8:13], color=sns.xkcd_rgb["teal green"],
301-
edgecolor="white", alpha=0.7,
288+
edgecolor="white", alpha=0.5,
302289
height=graph_width)
303290

304291
fari_low = ax1.barh(ind[-1]-graph_width, bars1[13:14]*-1, color="indianred",
305-
edgecolor="white", alpha=0.7,
292+
edgecolor="white",
306293
height=graph_width)
307294

308295
fari = ax1.barh(ind[-1]-graph_width, bars2[13:14], color=sns.xkcd_rgb["grey"],
309296
edgecolor="white", height=graph_width)
310297

311-
312298
ax1.set_xticks([-1000, 0, 1000, 2000, 3000, 4000, 5000])
313299
ax1.set_xticklabels(abs(ax1.get_xticks()), fontsize=20)
314300

315-
#ax1.plot(bars5, 13)
316-
317301
ax2.set_xlim(ax1.get_xlim())
318-
#ax2.tick_params('Volume [mm SLE]', fontsize=20)
319302
ax2.set_xticks(ax1.get_xticks())
320303
array = ax1.get_xticks()
321-
#print(array)
322304

305+
# Get the other axis on sea level equivalent
323306
sle = []
324307
for value in array:
325308
sle.append(np.round(abs(calculate_sea_level_equivalent(value)),2))
326-
#print(sle)
327309

328310
ax2.set_xticklabels(sle,fontsize=20)
329311
ax2.set_xlabel('Volume [mm SLE]', fontsize=18)

cryo_plots/calculate_volume_below_sea_level.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,6 @@
7676
thick_c = cc['thick']
7777
vol_c = cc['volume']
7878

79-
## TODO: delete this part because now I dont have the flowline shortage
80-
## problem
81-
# if len(surface) != len(thick):
82-
# plt.figure()
83-
# plt.plot(surface, color='r')
84-
# plt.plot(thick, color='grey')
85-
# plt.title(
86-
# 'Glacier ' + gdir.rgi_id + ' flowline No.' + np.str(f) +
87-
# ' out of ' + np.str(len(fls)))
88-
# plt.savefig(os.path.join(cfg.PATHS['working_dir'],
89-
# gdir.rgi_id + '_' + np.str(
90-
# f) + '.png'))
91-
# # Warning('({}) something went wrong with the '
92-
# # 'inversion'.format(gdir.rgi_id))
93-
# pass
94-
# else:
9579
bed = surface - thick
9680
bed_c = surface - thick_c
9781

0 commit comments

Comments
 (0)