-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtotal_O3.py
More file actions
157 lines (122 loc) · 5.27 KB
/
total_O3.py
File metadata and controls
157 lines (122 loc) · 5.27 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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 24 13:35:44 2016
@author: hanbre
"""
from __future__ import print_function
import sys
import numpy as np
import pandas as pd
import xarray as xray
import matplotlib.pyplot as plt
import seaborn as sns
import HB_module.outsourced
sns.set_palette('deep')
fig = plt.figure()
plt.hold(True)
deepblue = (0.2980392156862745, 0.4470588235294118, 0.6901960784313725)
pastelblue = (0.5725490196078431, 0.7764705882352941, 1.0)
darkblue = (0.0, 0.10980392156862745, 0.4980392156862745)
deepgreen = (0.3333333333333333, 0.6588235294117647, 0.40784313725490196)
darkgreen = (0.00392156862745098, 0.4588235294117647, 0.09019607843137255)
pastelgreen = (0.592156862745098, 0.9411764705882353, 0.6666666666666666)
pastelred = (1.0, 0.6235294117647059, 0.6039215686274509)
deepred = (0.7686274509803922, 0.3058823529411765, 0.3215686274509804)
darkred = (0.5490196078431373, 0.03529411764705882, 0.0)
pastelpurple = (0.8156862745098039, 0.7333333333333333, 1.0)
darkpurple = (0.4627450980392157, 0.0, 0.6313725490196078)
deeppurple = (0.5058823529411764, 0.4470588235294118, 0.6980392156862745)
with open('files/full_global.dat','r') as file_in:
c = 0
#sns.set_palette('dark')
for line in file_in:
l = line.strip('\n')
c += 1
ds = xray.open_dataset(l)
O3_vmm = ds.O3.squeeze()
O3_mmm = O3_vmm*(48.0/28.94)
g=9.81
P0 = ds.P0
PS = ds.PS
hyai = ds.hyai
hybi = ds.hybi
if 'new_control' in line:
O3_mmm=xray.concat([O3_mmm,O3_mmm,O3_mmm,O3_mmm,O3_mmm,O3_mmm,O3_mmm,O3_mmm,O3_mmm,O3_mmm],dim='time')
PS = xray.concat([PS,PS,PS,PS,PS,PS,PS,PS,PS,PS],dim='time')
#P0 = xray.concat([P0,P0,P0,P0,P0],dim='time')
Plevi = hyai*P0+hybi*PS
Plevi = Plevi.values
dp = np.zeros((66,120))
for i in xrange(Plevi.shape[1]):
dp[:,i] = Plevi[1:,i]-Plevi[0:66,i]
O3_t = O3_mmm*(dp.transpose()/g)
O3_tot = O3_t.sum(dim='lev')
O3_tot_DU = O3_tot/2.1415e-5
if c == 1:
O3_tot_DU_mean = np.zeros((5,len(O3_tot_DU)))
if 'new_control' in line:
plt.plot(O3_tot_DU,linewidth='3',label='cntrl',color=darkblue)
else:
O3_tot_DU_mean[c-1,:] = O3_tot_DU
plt.plot(O3_tot_DU,linewidth='2',color=pastelblue,label='ens{0}'.format(c))
if c == 1:
index, xtext = HB_module.outsourced.parse_time_axis(ds.time,11)
plt.xticks(index.tolist(),xtext,fontsize='18')
locs, labels = plt.xticks()
plt.setp(labels, rotation=45)
locs, labels = plt.yticks()
plt.setp(labels, fontsize='18')
plt.ylim(100,450)
plt.plot(np.mean(O3_tot_DU_mean,axis=0),linewidth='3',label='ensm',color=deepblue)
plt.xlabel('Time',fontsize='18'); plt.ylabel('Column O3 (DU)',fontsize=18)
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.,fontsize='16')
#plt.title('Arctic column ozone',fontsize=18)
#plt.show()
#fig.savefig('files/tot_ant-arctic_O3.png',dpi=200,bbox_inches='tight')
with open('files/tot_O3_antarctic_list.dat','r') as file_in:
c = 0
#sns.set_palette('dark')
for line in file_in:
l = line.strip('\n')
c += 1
ds = xray.open_dataset(l)
O3_vmm = ds.O3.squeeze()
O3_mmm = O3_vmm*(48.0/28.94)
g=9.81
P0 = ds.P0
PS = ds.PS
hyai = ds.hyai
hybi = ds.hybi
if 'new_control' in line:
O3_mmm=xray.concat([O3_mmm,O3_mmm,O3_mmm,O3_mmm,O3_mmm,O3_mmm,O3_mmm,O3_mmm,O3_mmm,O3_mmm],dim='time')
PS = xray.concat([PS,PS,PS,PS,PS,PS,PS,PS,PS,PS],dim='time')
#P0 = xray.concat([P0,P0,P0,P0,P0],dim='time')
Plevi = hyai*P0+hybi*PS
Plevi = Plevi.values
dp = np.zeros((66,120))
for i in xrange(Plevi.shape[1]):
dp[:,i] = Plevi[1:,i]-Plevi[0:66,i]
O3_t = O3_mmm*(dp.transpose()/g)
O3_tot = O3_t.sum(dim='lev')
O3_tot_DU = O3_tot/2.1415e-5
if c == 1:
O3_tot_DU_mean = np.zeros((5,len(O3_tot_DU)))
if 'new_control' in line:
plt.plot(O3_tot_DU,linewidth='3',label='cntrl',color=darkred)
else:
O3_tot_DU_mean[c-1,:] = O3_tot_DU
plt.plot(O3_tot_DU,linewidth='2',color=pastelred,label='ens{0}'.format(c))
if c == 1:
index, xtext = HB_module.outsourced.parse_time_axis(ds.time,11)
plt.xticks(index.tolist(),xtext,fontsize='18')
locs, labels = plt.xticks()
plt.setp(labels, rotation=45)
locs, labels = plt.yticks()
plt.setp(labels, fontsize='18')
plt.ylim(100,450)
plt.plot(np.mean(O3_tot_DU_mean,axis=0),linewidth='3',label='ensm',color=deepred)
plt.xlabel('Time',fontsize='18'); plt.ylabel('Column O3 (DU)',fontsize=18)
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.,fontsize='16')
plt.title('Global (blue) and Tropics (red) column ozone',fontsize=18)
#plt.show()
#fig.savefig('files/tot_glob-trops_O3.png',dpi=200,bbox_inches='tight')