Skip to content

Commit

Permalink
Bunch of updates, documentation coming later
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaitlin Naughten committed Mar 6, 2017
1 parent f3ad52c commit b5a2c75
Show file tree
Hide file tree
Showing 42 changed files with 2,814 additions and 117 deletions.
19 changes: 15 additions & 4 deletions adv_frazil.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def adv_frazil ():
file_tail = 'iceh_avg.nc'

# Bounds and ticks for colour scales
max_abs = 0.2
tick_abs = 0.05
max_anom = 1.0
tick_anom = 0.5
max_abs = 1
tick_abs = 0.25
max_anom = 2.0
tick_anom = 1.0

# Degrees to radians conversion factor
deg2rad = pi/180.
Expand All @@ -31,6 +31,11 @@ def adv_frazil ():
# Boundary of regular grid to embed circle in
circle_bdry = -70+90

lon_ticks = array([-120, -60, 60, 120, 180])
lat_ticks = array([-44, -42, -42, -44, -41])
lon_labels = [r'120$^{\circ}$W', r'60$^{\circ}$W', r'60$^{\circ}$E', r'120$^{\circ}$E', r'180$^{\circ}$']
lon_rot = [-60, 60, -60, 60, 0]

# Read frazil data from U3_LIM simulation; also grid and mask variables
id = Dataset(paths[0]+file_tail, 'r')
data_tmp = id.variables['frazil'][0,:350,:]
Expand Down Expand Up @@ -62,6 +67,9 @@ def adv_frazil ():
# Coordinates of centre of missing circle
x_c = -(lat_c+90)*cos(lon_c*deg2rad+pi/2)
y_c = (lat_c+90)*sin(lon_c*deg2rad+pi/2)
# Longitude labels
x_ticks = -(lat_ticks+90)*cos(lon_ticks*deg2rad+pi/2)
y_ticks = (lat_ticks+90)*sin(lon_ticks*deg2rad+pi/2)
# Regular grid to embed missing circle in
x_reg, y_reg = meshgrid(linspace(-circle_bdry, circle_bdry, num=100), linspace(-circle_bdry, circle_bdry, num=100))
# Mask everything except the circle out of the regular grid
Expand All @@ -78,6 +86,9 @@ def adv_frazil ():
# Shade the frazil data (pcolor not contourf so we don't misrepresent the
# model grid)
img0 = pcolor(x, y, data0, vmin=0, vmax=max_abs, cmap='jet')
# Add longitude labels
for i in range(size(x_ticks)):
text(x_ticks[i], y_ticks[i], lon_labels[i], ha='center', rotation=lon_rot[i])
axis('off')
# Add title
title(labels[0], fontsize=20)
Expand Down
12 changes: 6 additions & 6 deletions adv_freezingpt_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
def adv_freezingpt_slice ():

# Path to ocean history file
file_path = '/short/m68/kaa561/advection/c4_l/ocean_his_6july.nc'
file_path = '/short/m68/kaa561/advection/c4_l/ocean_his_8aug.nc'
# Timestep to plot
tstep = 1 #188
tstep = 1 #221
# i-index to plot (1-based)
i_val = 1250
# Deepest depth to plot
depth_min = -100
# Bounds on colour scale
scale_max = 0.3
scale_tick = 0.1
scale_max = 0.5
scale_tick = 0.25
# Bounds on latitudes to plot
lat_min = -78
lat_max = -72
lat_min = -71
lat_max = -67
save = True
fig_name = 'adv_freezingpt_slice.png'

Expand Down
23 changes: 17 additions & 6 deletions adv_mld.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def adv_mld ():
tstep = 1 #236 if all one file of daily averages for entire simulation

# Bounds and ticks for colour scales
max_abs = 300
tick_abs = 100
max_anom = 200
tick_anom = 100
max_abs = 800
tick_abs = 200
max_anom = 400
tick_anom = 200

# Degrees to radians conversion factor
deg2rad = pi/180.
Expand All @@ -33,6 +33,11 @@ def adv_mld ():
# Boundary of regular grid to embed circle in
circle_bdry = -70+90

lon_ticks = array([-120, -60, 60, 120, 180])
lat_ticks = array([-44, -42, -42, -44, -41])
lon_labels = [r'120$^{\circ}$W', r'60$^{\circ}$W', r'60$^{\circ}$E', r'120$^{\circ}$E', r'180$^{\circ}$']
lon_rot = [-60, 60, -60, 60, 0]

# Read mixed layer depth from U3_LIM simulation; also grid and mask
# variables
id = Dataset(paths[0]+file_tail, 'r')
Expand All @@ -46,7 +51,7 @@ def adv_mld ():
# Mask out the ice shelf cavities and switch sign on mixed layer depth
index = zice != 0
mask[index] = 0.0
data = ma.masked_where(zice!=0, -data)
data0 = ma.masked_where(zice!=0, -data)

# Land mask
land = ma.masked_where(mask==1, mask)
Expand All @@ -57,6 +62,9 @@ def adv_mld ():
# Coordinates of centre of missing circle
x_c = -(lat_c+90)*cos(lon_c*deg2rad+pi/2)
y_c = (lat_c+90)*sin(lon_c*deg2rad+pi/2)
# Longitude labels
x_ticks = -(lat_ticks+90)*cos(lon_ticks*deg2rad+pi/2)
y_ticks = (lat_ticks+90)*sin(lon_ticks*deg2rad+pi/2)
# Regular grid to embed missing circle in
x_reg, y_reg = meshgrid(linspace(-circle_bdry, circle_bdry, num=100), linspace(-circle_bdry, circle_bdry, num=100))
# Mask everything except the circle out of the regular grid
Expand All @@ -73,6 +81,9 @@ def adv_mld ():
# Shade the mixed layer depth (pcolor not contourf so we don't misrepresent
# the model grid)
img0 = pcolor(x, y, data0, vmin=0, vmax=max_abs, cmap='jet') #cmaps.viridis)
# Add longitude labels
for i in range(size(x_ticks)):
text(x_ticks[i], y_ticks[i], lon_labels[i], ha='center', rotation=lon_rot[i])
axis('off')
# Add title
title(labels[0], fontsize=20)
Expand All @@ -85,7 +96,7 @@ def adv_mld ():
for sim in range(1, len(paths)):
# Read mixed layer depth
id = Dataset(paths[sim]+file_tail, 'r')
data = id.variables['Hsbl'][tstep-1,:350,:]
data = id.variables['Hsbl'][tstep-1,:350,1:]
id.close()
# Mask out the ice shelf cavities and switch sign
data = ma.masked_where(zice!=0, -data)
Expand Down
31 changes: 14 additions & 17 deletions adv_polynyas.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,55 +14,52 @@ def adv_polynyas ():
# File name: daily average for 23 August
file_tail = 'iceh.1992-08-23.nc'
# Longitude and latitude bounds
lon_min = 100
lon_max = 140
lat_min = -67.1
lat_max = -64.9
# Bounds on labels for latitude
lat_min_label = -67
lat_max_label = -65
lon_min = 67
lon_max = 86
lat_min = -70
lat_max = -65

# Set up figure
fig = figure(figsize=(18,6))
# Loop over simulations
for sim in range(2):
# Read sea ice concentration in the region of interest
id = Dataset(paths[sim]+file_tail, 'r')
data = id.variables['aice'][0,70:280,350:750]
data = id.variables['aice'][0,50:250,250:400]
if sim == 0:
# For the first simulation, also read the grid
lon = id.variables['TLON'][70:280,350:750]
lat = id.variables['TLAT'][70:280,350:750]
lon = id.variables['TLON'][50:250,250:400]
lat = id.variables['TLAT'][50:250,250:400]
id.close()
ax = fig.add_subplot(1, 2, sim+1)
# Shade the data (pcolor not contourf so we can show each individual
# model cell)
img = pcolor(lon, lat, data, vmin=0, vmax=1, cmap='jet')
# Configure plot
title(labels[sim], fontsize=20)
xlabel('Longitude', fontsize=16)
ylabel('Latitude', fontsize=16)
xlabel('Longitude', fontsize=18)
ylabel('Latitude', fontsize=18)
xlim([lon_min, lon_max])
ylim([lat_min, lat_max])
if sim == 1:
# Add a colorbar on the right
cbaxes = fig.add_axes([0.93, 0.25, 0.015, 0.5])
cbar = colorbar(ticks=arange(0, 1+0.25, 0.25), cax=cbaxes)
cbar.ax.tick_params(labelsize=14)
cbar.ax.tick_params(labelsize=16)

# Set ticks the way we want them
lon_ticks = arange(lon_min, lon_max+10, 10)
lon_ticks = arange(lon_min+3, lon_max, 5)
ax.set_xticks(lon_ticks)
lon_labels = []
for val in lon_ticks:
lon_labels.append(str(int(round(val))) + r'$^{\circ}$E')
ax.set_xticklabels(lon_labels, fontsize=14)
lat_ticks = arange(lat_min_label, lat_max_label+1, 1)
ax.set_xticklabels(lon_labels, fontsize=16)
lat_ticks = arange(lat_min, lat_max, 2)
ax.set_yticks(lat_ticks)
lat_labels = []
for val in lat_ticks:
lat_labels.append(str(int(round(-val))) + r'$^{\circ}$S')
ax.set_yticklabels(lat_labels, fontsize=14)
ax.set_yticklabels(lat_labels, fontsize=16)
# Add main title
suptitle('Sea ice concentration on 23 August', fontsize=22)

Expand Down
Loading

0 comments on commit b5a2c75

Please sign in to comment.