-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
7793614
commit 3e2e687
Showing
61 changed files
with
9,470 additions
and
0 deletions.
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
ocean/FOV_E3SM/E3SM_Antarctic/Program/Ocean/ACC_transport.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#Program determines the ACC strength | ||
|
||
from pylab import * | ||
import numpy | ||
import datetime | ||
import time | ||
import glob, os | ||
import math | ||
import netCDF4 as netcdf | ||
|
||
#Making pathway to folder with all data | ||
directory = '../../Data/' | ||
|
||
def ReadinData(filename, depth_min_index, depth_max_index): | ||
|
||
fh = netcdf.Dataset(filename, 'r') | ||
|
||
#First get the u-grid | ||
lat = fh.variables['lat'][:] #Longitude | ||
depth = fh.variables['depth'][depth_min_index:depth_max_index] #Depth (m) | ||
layer = fh.variables['layer'][depth_min_index:depth_max_index] #Layer thickness (m) | ||
grid_y = fh.variables['DY'][:] #Meridional grid cell length (m) | ||
u_vel = fh.variables['UVEL'][depth_min_index:depth_max_index] #Zonal velocity (m/s) | ||
|
||
fh.close() | ||
|
||
return lat, depth, layer, grid_y, u_vel | ||
|
||
#----------------------------------------------------------------------------------------- | ||
#--------------------------------MAIN SCRIPT STARTS HERE---------------------------------- | ||
#----------------------------------------------------------------------------------------- | ||
|
||
depth_min = 0 | ||
depth_max = 6000 | ||
|
||
#----------------------------------------------------------------------------------------- | ||
|
||
files = glob.glob(directory+'Data/Drake_Passage/E3SM_data_year_*.nc') | ||
files.sort() | ||
|
||
#----------------------------------------------------------------------------------------- | ||
|
||
#Define empty array's | ||
time = np.zeros(len(files)) | ||
|
||
for year_i in range(len(files)): | ||
date = files[year_i][-7:-3] | ||
year = int(date[0:4]) | ||
time[year_i] = year | ||
|
||
#----------------------------------------------------------------------------------------- | ||
|
||
#Get all the relevant indices to determine the mass transport | ||
fh = netcdf.Dataset(files[0], 'r') | ||
|
||
depth = fh.variables['depth'][:] #Depth (m) | ||
|
||
fh.close() | ||
|
||
#Get the dimensions of depth and latitude | ||
depth_min_index = (fabs(depth_min - depth)).argmin() | ||
depth_max_index = (fabs(depth_max - depth)).argmin() + 1 | ||
|
||
#----------------------------------------------------------------------------------------- | ||
#Determine the section length per depth layer | ||
lat, depth, layer_field, grid_y, u_vel = ReadinData(files[0], depth_min_index, depth_max_index) | ||
|
||
for lat_i in range(len(lat)): | ||
#Get all the layers which have a maximum depth below given range | ||
if np.sum(layer_field[:, lat_i]) > depth_max: | ||
#Adjust the last layer | ||
layer_field[-1, lat_i] -= (np.sum(layer_field[:, lat_i]) - depth_max) | ||
|
||
#----------------------------------------------------------------------------------------- | ||
|
||
#Define empty array's | ||
transport_all = ma.masked_all(len(time)) | ||
|
||
for time_i in range(len(time)): | ||
#Now determine for each month | ||
print(time_i) | ||
|
||
lat, depth, layer_field_old, grid_y, u_vel = ReadinData(files[time_i], depth_min_index, depth_max_index) | ||
|
||
#Determine the meridional transport | ||
transport = u_vel * layer_field * grid_y | ||
|
||
#Determine the transport per depth layer (in Sv) and take sum to determine total transport | ||
transport_all[time_i] = np.sum(transport) / 1000000.0 | ||
|
||
#----------------------------------------------------------------------------------------- | ||
|
||
print('Data is written to file') | ||
fh = netcdf.Dataset(directory+'Ocean/ACC_transport_depth_'+str(depth_min)+'-'+str(depth_max)+'_m.nc', 'w') | ||
|
||
fh.createDimension('time', len(time)) | ||
|
||
fh.createVariable('time', float, ('time'), zlib=True) | ||
fh.createVariable('Transport', float, ('time'), zlib=True) | ||
|
||
fh.variables['Transport'].long_name = 'Volume transport' | ||
|
||
fh.variables['time'].units = 'Year' | ||
fh.variables['Transport'].units = 'Sv' | ||
|
||
#Writing data to correct variable | ||
fh.variables['time'][:] = time | ||
fh.variables['Transport'][:] = transport_all | ||
|
||
fh.close() |
44 changes: 44 additions & 0 deletions
44
ocean/FOV_E3SM/E3SM_Antarctic/Program/Ocean/ACC_transport_plot.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#Plot the ACC strength | ||
|
||
from pylab import * | ||
import numpy | ||
import time | ||
import glob, os | ||
import math | ||
import netCDF4 as netcdf | ||
|
||
#Making pathway to folder with all data | ||
directory = '../../Data/' | ||
|
||
#----------------------------------------------------------------------------------------- | ||
#--------------------------------MAIN SCRIPT STARTS HERE---------------------------------- | ||
#----------------------------------------------------------------------------------------- | ||
|
||
depth_min = 0 | ||
depth_max = 6000 | ||
|
||
|
||
#----------------------------------------------------------------------------------------- | ||
|
||
fh = netcdf.Dataset(directory+'Ocean/ACC_transport_depth_'+str(depth_min)+'-'+str(depth_max)+'_m.nc', 'r') | ||
|
||
time = fh.variables['time'][:] | ||
transport = fh.variables['Transport'][:] | ||
|
||
fh.close() | ||
|
||
|
||
fig, ax = subplots() | ||
|
||
|
||
ax.plot(time, transport, '-k', linewidth = 2.0) | ||
ax.set_xlim(500, 600) | ||
ax.set_ylim(90, 210) | ||
ax.set_xlabel('Model year') | ||
ax.set_ylabel('Volume transport (sv)') | ||
ax.set_xticks([500, 520, 540, 560, 580, 600]) | ||
ax.grid() | ||
|
||
ax.set_title('ACC strength, E3SM Antarctic') | ||
|
||
show() |
113 changes: 113 additions & 0 deletions
113
ocean/FOV_E3SM/E3SM_Antarctic/Program/Ocean/AMOC_transport.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#Program determines the AMOC strength | ||
|
||
from pylab import * | ||
import numpy | ||
import datetime | ||
import time | ||
import glob, os | ||
import math | ||
import netCDF4 as netcdf | ||
|
||
#Making pathway to folder with all data | ||
directory = '../../Data/' | ||
|
||
def ReadinData(filename, depth_min_index, depth_max_index): | ||
|
||
fh = netcdf.Dataset(filename, 'r') | ||
|
||
#First get the u-grid | ||
lon = fh.variables['lon'][:] #Longitude | ||
depth = fh.variables['depth'][depth_min_index:depth_max_index] #Depth (m) | ||
layer = fh.variables['layer'][depth_min_index:depth_max_index] #Layer thickness (m) | ||
grid_x = fh.variables['DX'][:] #Zonal grid cell length (m) | ||
v_vel = fh.variables['VVEL'][depth_min_index:depth_max_index] #Meridional velocity (m/s) | ||
salt = fh.variables['SALT'][depth_min_index:depth_max_index] #Salinity (g / kg) | ||
|
||
fh.close() | ||
|
||
return lon, depth, layer, grid_x, v_vel | ||
|
||
#----------------------------------------------------------------------------------------- | ||
#--------------------------------MAIN SCRIPT STARTS HERE---------------------------------- | ||
#----------------------------------------------------------------------------------------- | ||
|
||
depth_min = 0 | ||
depth_max = 1000 | ||
|
||
lat_FOV = 26 | ||
section_name = 'FOV_section_26N' | ||
#----------------------------------------------------------------------------------------- | ||
|
||
files = glob.glob(directory+'Data/'+section_name+'/E3SM_data_year_*.nc') | ||
files.sort() | ||
|
||
#----------------------------------------------------------------------------------------- | ||
|
||
#Define empty array's | ||
time = np.zeros(len(files)) | ||
|
||
for year_i in range(len(files)): | ||
date = files[year_i][-7:-3] | ||
year = int(date[0:4]) | ||
time[year_i] = year | ||
|
||
#----------------------------------------------------------------------------------------- | ||
|
||
#Get all the relevant indices to determine the mass transport | ||
fh = netcdf.Dataset(files[0], 'r') | ||
|
||
depth = fh.variables['depth'][:] #Depth (m) | ||
|
||
fh.close() | ||
|
||
#Get the dimensions of depth and latitude | ||
depth_min_index = (fabs(depth_min - depth)).argmin() | ||
depth_max_index = (fabs(depth_max - depth)).argmin() + 1 | ||
|
||
#----------------------------------------------------------------------------------------- | ||
#Determine the section length per depth layer | ||
lon, depth, layer_field, grid_x, v_vel = ReadinData(files[0], depth_min_index, depth_max_index) | ||
|
||
for lon_i in range(len(lon)): | ||
#Get all the layers which have a maximum depth below given range | ||
if np.sum(layer_field[:, lon_i]) > depth_max: | ||
#Adjust the last layer | ||
layer_field[-1, lon_i] -= (np.sum(layer_field[:, lon_i]) - depth_max) | ||
|
||
#----------------------------------------------------------------------------------------- | ||
|
||
#Define empty array's | ||
transport_all = ma.masked_all(len(time)) | ||
|
||
for time_i in range(len(time)): | ||
#Now determine for each month | ||
print(time_i) | ||
|
||
lon, depth, layer_field_old, grid_x, v_vel = ReadinData(files[time_i], depth_min_index, depth_max_index) | ||
|
||
#Determine the meridional transport | ||
transport = v_vel * layer_field * grid_x | ||
|
||
#Determine the transport per depth layer (in Sv) and take sum to determine total transport | ||
transport_all[time_i] = np.sum(transport) / 1000000.0 | ||
|
||
#----------------------------------------------------------------------------------------- | ||
|
||
print('Data is written to file') | ||
fh = netcdf.Dataset(directory+'Ocean/AMOC_transport_depth_'+str(depth_min)+'-'+str(depth_max)+'_m.nc', 'w') | ||
|
||
fh.createDimension('time', len(time)) | ||
|
||
fh.createVariable('time', float, ('time'), zlib=True) | ||
fh.createVariable('Transport', float, ('time'), zlib=True) | ||
|
||
fh.variables['Transport'].long_name = 'Volume transport' | ||
|
||
fh.variables['time'].units = 'Year' | ||
fh.variables['Transport'].units = 'Sv' | ||
|
||
#Writing data to correct variable | ||
fh.variables['time'][:] = time | ||
fh.variables['Transport'][:] = transport_all | ||
|
||
fh.close() |
47 changes: 47 additions & 0 deletions
47
ocean/FOV_E3SM/E3SM_Antarctic/Program/Ocean/AMOC_transport_plot.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#Program plots the AMOC strength | ||
|
||
from pylab import * | ||
import numpy | ||
import datetime | ||
import time | ||
import glob, os | ||
import math | ||
import netCDF4 as netcdf | ||
|
||
#Making pathway to folder with all data | ||
directory = '../../Data/' | ||
|
||
#----------------------------------------------------------------------------------------- | ||
#--------------------------------MAIN SCRIPT STARTS HERE---------------------------------- | ||
#----------------------------------------------------------------------------------------- | ||
|
||
depth_min = 0 | ||
depth_max = 1000 | ||
|
||
|
||
#----------------------------------------------------------------------------------------- | ||
|
||
fh = netcdf.Dataset(directory+'Ocean/AMOC_transport_depth_'+str(depth_min)+'-'+str(depth_max)+'_m.nc', 'r') | ||
|
||
time = fh.variables['time'][:] | ||
transport = fh.variables['Transport'][:] | ||
|
||
fh.close() | ||
|
||
|
||
fig, ax = subplots() | ||
|
||
ax.fill_between([-100, 2500], 16, 19, alpha=0.25, edgecolor='orange', facecolor='orange') | ||
|
||
|
||
ax.plot(time, transport, '-k', linewidth = 2.0) | ||
ax.set_xlim(500, 600) | ||
ax.set_ylim(-2, 22) | ||
ax.set_xlabel('Model year') | ||
ax.set_ylabel('Volume transport (sv)') | ||
ax.set_xticks([500, 520, 540, 560, 580, 600]) | ||
ax.grid() | ||
|
||
ax.set_title('AMOC strength, E3SM Antarctic') | ||
|
||
show() |
Oops, something went wrong.