Skip to content

Commit 3e2e687

Browse files
committed
Add FOV_E3SM directory and python scripts only.
On June 20 2024 a large number of data files were added to the QuickViz repo by RenevanWesten. I removed those with an interactive rebase, and am now adding the python scripts back in. The total size of the data files were 1.6GB.
1 parent 7793614 commit 3e2e687

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+9470
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#Program determines the ACC strength
2+
3+
from pylab import *
4+
import numpy
5+
import datetime
6+
import time
7+
import glob, os
8+
import math
9+
import netCDF4 as netcdf
10+
11+
#Making pathway to folder with all data
12+
directory = '../../Data/'
13+
14+
def ReadinData(filename, depth_min_index, depth_max_index):
15+
16+
fh = netcdf.Dataset(filename, 'r')
17+
18+
#First get the u-grid
19+
lat = fh.variables['lat'][:] #Longitude
20+
depth = fh.variables['depth'][depth_min_index:depth_max_index] #Depth (m)
21+
layer = fh.variables['layer'][depth_min_index:depth_max_index] #Layer thickness (m)
22+
grid_y = fh.variables['DY'][:] #Meridional grid cell length (m)
23+
u_vel = fh.variables['UVEL'][depth_min_index:depth_max_index] #Zonal velocity (m/s)
24+
25+
fh.close()
26+
27+
return lat, depth, layer, grid_y, u_vel
28+
29+
#-----------------------------------------------------------------------------------------
30+
#--------------------------------MAIN SCRIPT STARTS HERE----------------------------------
31+
#-----------------------------------------------------------------------------------------
32+
33+
depth_min = 0
34+
depth_max = 6000
35+
36+
#-----------------------------------------------------------------------------------------
37+
38+
files = glob.glob(directory+'Data/Drake_Passage/E3SM_data_year_*.nc')
39+
files.sort()
40+
41+
#-----------------------------------------------------------------------------------------
42+
43+
#Define empty array's
44+
time = np.zeros(len(files))
45+
46+
for year_i in range(len(files)):
47+
date = files[year_i][-7:-3]
48+
year = int(date[0:4])
49+
time[year_i] = year
50+
51+
#-----------------------------------------------------------------------------------------
52+
53+
#Get all the relevant indices to determine the mass transport
54+
fh = netcdf.Dataset(files[0], 'r')
55+
56+
depth = fh.variables['depth'][:] #Depth (m)
57+
58+
fh.close()
59+
60+
#Get the dimensions of depth and latitude
61+
depth_min_index = (fabs(depth_min - depth)).argmin()
62+
depth_max_index = (fabs(depth_max - depth)).argmin() + 1
63+
64+
#-----------------------------------------------------------------------------------------
65+
#Determine the section length per depth layer
66+
lat, depth, layer_field, grid_y, u_vel = ReadinData(files[0], depth_min_index, depth_max_index)
67+
68+
for lat_i in range(len(lat)):
69+
#Get all the layers which have a maximum depth below given range
70+
if np.sum(layer_field[:, lat_i]) > depth_max:
71+
#Adjust the last layer
72+
layer_field[-1, lat_i] -= (np.sum(layer_field[:, lat_i]) - depth_max)
73+
74+
#-----------------------------------------------------------------------------------------
75+
76+
#Define empty array's
77+
transport_all = ma.masked_all(len(time))
78+
79+
for time_i in range(len(time)):
80+
#Now determine for each month
81+
print(time_i)
82+
83+
lat, depth, layer_field_old, grid_y, u_vel = ReadinData(files[time_i], depth_min_index, depth_max_index)
84+
85+
#Determine the meridional transport
86+
transport = u_vel * layer_field * grid_y
87+
88+
#Determine the transport per depth layer (in Sv) and take sum to determine total transport
89+
transport_all[time_i] = np.sum(transport) / 1000000.0
90+
91+
#-----------------------------------------------------------------------------------------
92+
93+
print('Data is written to file')
94+
fh = netcdf.Dataset(directory+'Ocean/ACC_transport_depth_'+str(depth_min)+'-'+str(depth_max)+'_m.nc', 'w')
95+
96+
fh.createDimension('time', len(time))
97+
98+
fh.createVariable('time', float, ('time'), zlib=True)
99+
fh.createVariable('Transport', float, ('time'), zlib=True)
100+
101+
fh.variables['Transport'].long_name = 'Volume transport'
102+
103+
fh.variables['time'].units = 'Year'
104+
fh.variables['Transport'].units = 'Sv'
105+
106+
#Writing data to correct variable
107+
fh.variables['time'][:] = time
108+
fh.variables['Transport'][:] = transport_all
109+
110+
fh.close()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#Plot the ACC strength
2+
3+
from pylab import *
4+
import numpy
5+
import time
6+
import glob, os
7+
import math
8+
import netCDF4 as netcdf
9+
10+
#Making pathway to folder with all data
11+
directory = '../../Data/'
12+
13+
#-----------------------------------------------------------------------------------------
14+
#--------------------------------MAIN SCRIPT STARTS HERE----------------------------------
15+
#-----------------------------------------------------------------------------------------
16+
17+
depth_min = 0
18+
depth_max = 6000
19+
20+
21+
#-----------------------------------------------------------------------------------------
22+
23+
fh = netcdf.Dataset(directory+'Ocean/ACC_transport_depth_'+str(depth_min)+'-'+str(depth_max)+'_m.nc', 'r')
24+
25+
time = fh.variables['time'][:]
26+
transport = fh.variables['Transport'][:]
27+
28+
fh.close()
29+
30+
31+
fig, ax = subplots()
32+
33+
34+
ax.plot(time, transport, '-k', linewidth = 2.0)
35+
ax.set_xlim(500, 600)
36+
ax.set_ylim(90, 210)
37+
ax.set_xlabel('Model year')
38+
ax.set_ylabel('Volume transport (sv)')
39+
ax.set_xticks([500, 520, 540, 560, 580, 600])
40+
ax.grid()
41+
42+
ax.set_title('ACC strength, E3SM Antarctic')
43+
44+
show()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#Program determines the AMOC strength
2+
3+
from pylab import *
4+
import numpy
5+
import datetime
6+
import time
7+
import glob, os
8+
import math
9+
import netCDF4 as netcdf
10+
11+
#Making pathway to folder with all data
12+
directory = '../../Data/'
13+
14+
def ReadinData(filename, depth_min_index, depth_max_index):
15+
16+
fh = netcdf.Dataset(filename, 'r')
17+
18+
#First get the u-grid
19+
lon = fh.variables['lon'][:] #Longitude
20+
depth = fh.variables['depth'][depth_min_index:depth_max_index] #Depth (m)
21+
layer = fh.variables['layer'][depth_min_index:depth_max_index] #Layer thickness (m)
22+
grid_x = fh.variables['DX'][:] #Zonal grid cell length (m)
23+
v_vel = fh.variables['VVEL'][depth_min_index:depth_max_index] #Meridional velocity (m/s)
24+
salt = fh.variables['SALT'][depth_min_index:depth_max_index] #Salinity (g / kg)
25+
26+
fh.close()
27+
28+
return lon, depth, layer, grid_x, v_vel
29+
30+
#-----------------------------------------------------------------------------------------
31+
#--------------------------------MAIN SCRIPT STARTS HERE----------------------------------
32+
#-----------------------------------------------------------------------------------------
33+
34+
depth_min = 0
35+
depth_max = 1000
36+
37+
lat_FOV = 26
38+
section_name = 'FOV_section_26N'
39+
#-----------------------------------------------------------------------------------------
40+
41+
files = glob.glob(directory+'Data/'+section_name+'/E3SM_data_year_*.nc')
42+
files.sort()
43+
44+
#-----------------------------------------------------------------------------------------
45+
46+
#Define empty array's
47+
time = np.zeros(len(files))
48+
49+
for year_i in range(len(files)):
50+
date = files[year_i][-7:-3]
51+
year = int(date[0:4])
52+
time[year_i] = year
53+
54+
#-----------------------------------------------------------------------------------------
55+
56+
#Get all the relevant indices to determine the mass transport
57+
fh = netcdf.Dataset(files[0], 'r')
58+
59+
depth = fh.variables['depth'][:] #Depth (m)
60+
61+
fh.close()
62+
63+
#Get the dimensions of depth and latitude
64+
depth_min_index = (fabs(depth_min - depth)).argmin()
65+
depth_max_index = (fabs(depth_max - depth)).argmin() + 1
66+
67+
#-----------------------------------------------------------------------------------------
68+
#Determine the section length per depth layer
69+
lon, depth, layer_field, grid_x, v_vel = ReadinData(files[0], depth_min_index, depth_max_index)
70+
71+
for lon_i in range(len(lon)):
72+
#Get all the layers which have a maximum depth below given range
73+
if np.sum(layer_field[:, lon_i]) > depth_max:
74+
#Adjust the last layer
75+
layer_field[-1, lon_i] -= (np.sum(layer_field[:, lon_i]) - depth_max)
76+
77+
#-----------------------------------------------------------------------------------------
78+
79+
#Define empty array's
80+
transport_all = ma.masked_all(len(time))
81+
82+
for time_i in range(len(time)):
83+
#Now determine for each month
84+
print(time_i)
85+
86+
lon, depth, layer_field_old, grid_x, v_vel = ReadinData(files[time_i], depth_min_index, depth_max_index)
87+
88+
#Determine the meridional transport
89+
transport = v_vel * layer_field * grid_x
90+
91+
#Determine the transport per depth layer (in Sv) and take sum to determine total transport
92+
transport_all[time_i] = np.sum(transport) / 1000000.0
93+
94+
#-----------------------------------------------------------------------------------------
95+
96+
print('Data is written to file')
97+
fh = netcdf.Dataset(directory+'Ocean/AMOC_transport_depth_'+str(depth_min)+'-'+str(depth_max)+'_m.nc', 'w')
98+
99+
fh.createDimension('time', len(time))
100+
101+
fh.createVariable('time', float, ('time'), zlib=True)
102+
fh.createVariable('Transport', float, ('time'), zlib=True)
103+
104+
fh.variables['Transport'].long_name = 'Volume transport'
105+
106+
fh.variables['time'].units = 'Year'
107+
fh.variables['Transport'].units = 'Sv'
108+
109+
#Writing data to correct variable
110+
fh.variables['time'][:] = time
111+
fh.variables['Transport'][:] = transport_all
112+
113+
fh.close()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#Program plots the AMOC strength
2+
3+
from pylab import *
4+
import numpy
5+
import datetime
6+
import time
7+
import glob, os
8+
import math
9+
import netCDF4 as netcdf
10+
11+
#Making pathway to folder with all data
12+
directory = '../../Data/'
13+
14+
#-----------------------------------------------------------------------------------------
15+
#--------------------------------MAIN SCRIPT STARTS HERE----------------------------------
16+
#-----------------------------------------------------------------------------------------
17+
18+
depth_min = 0
19+
depth_max = 1000
20+
21+
22+
#-----------------------------------------------------------------------------------------
23+
24+
fh = netcdf.Dataset(directory+'Ocean/AMOC_transport_depth_'+str(depth_min)+'-'+str(depth_max)+'_m.nc', 'r')
25+
26+
time = fh.variables['time'][:]
27+
transport = fh.variables['Transport'][:]
28+
29+
fh.close()
30+
31+
32+
fig, ax = subplots()
33+
34+
ax.fill_between([-100, 2500], 16, 19, alpha=0.25, edgecolor='orange', facecolor='orange')
35+
36+
37+
ax.plot(time, transport, '-k', linewidth = 2.0)
38+
ax.set_xlim(500, 600)
39+
ax.set_ylim(-2, 22)
40+
ax.set_xlabel('Model year')
41+
ax.set_ylabel('Volume transport (sv)')
42+
ax.set_xticks([500, 520, 540, 560, 580, 600])
43+
ax.grid()
44+
45+
ax.set_title('AMOC strength, E3SM Antarctic')
46+
47+
show()

0 commit comments

Comments
 (0)