vfiles = sorted(glob.glob(''.join([homedir, nemodir, vdir, '*']))) # --------------------------------------------------------------------------- # # If we're not loading the data, then loop over all the available files and # calculatet the average KE. if save_output: # Preallocate the output variable. meanke = np.ndarray(shape=[len(ufiles), nz + 1]) # Loop over the U/V files and load the surface velocity. for k in range(len(ufiles)): print ufiles[k] # Load & mask the current U velocity field. u = np.squeeze(nemo.load_field('vozoce3u', '', '', ufiles[k], 'U')) u = nemo.mask_field(u, umask) e3u = np.squeeze(nemo.load_field('e3u', '', '', ufiles[k], 'U')) e3u = nemo.mask_field(e3u, umask) u = u / e3u e3u = None # Load and mask the current V velocity field. v = np.squeeze(nemo.load_field('vomece3v', '', '', vfiles[k], 'V')) v = nemo.mask_field(v, vmask) e3v = np.squeeze(nemo.load_field('e3v', '', '', vfiles[k], 'V')) e3v = nemo.mask_field(e3v, vmask) v = v / e3v e3v = None # Calculate the KE for the current velocity fields ke = nemo.calc_ke(u.data, v.data, nx, ny, nz, tmask)
# --------------------------------------------------------------------------- # # Load the coordinates. glamt = np.squeeze(nemo.load_field('glamt', homedir, nemodir, gridfile, 'T')) gphit = np.squeeze(nemo.load_field('gphit', homedir, nemodir, gridfile, 'T')) # Load the relevant mask. tmask = np.squeeze(nemo.load_field('tmask', homedir, nemodir, gridfile, 'T'))[:, :, 0:1] # Load the mixed layer fields remask them. somxlr103_01 = np.squeeze( np.load(''.join( [homedir, nemodir, 'TIDY/ARCHIVE/POST/', 'somxlr103_01_1952-1952.npy']))) somxlr103_01 = nemo.mask_field(somxlr103_01[:, :, None], tmask) somxlr103_08 = np.squeeze( np.load(''.join( [homedir, nemodir, 'TIDY/ARCHIVE/POST/', 'somxlr103_08_1952-1952.npy']))) somxlr103_08 = nemo.mask_field(somxlr103_08[:, :, None], tmask) # --------------------------------------------------------------------------- # # Set the max mxl that I want to plot. max_mxl = 100. # Create a new figure window. plt.figure(figsize=(8.0, 8.0)) # Specify some things to make the plot look nice.
filename = 'siconc_DJF_1951-1954.npy' # --------------------------------------------------------------------------- # # Load the coordinates. gphit = np.squeeze(nemo.load_field('gphit', homedir, nemodir, gridfile, 'T')) glamt = np.squeeze(nemo.load_field('glamt', homedir, nemodir, gridfile, 'T')) # Load the relevant mask. tmask = np.squeeze(nemo.load_field('tmask', homedir, nemodir, gridfile, 'T'))[:, :, 0:1] # --------------------------------------------------------------------------- # ice = np.load(''.join([homedir, nemodir, 'POST/', filename])) ice = nemo.mask_field(ice, tmask) # --------------------------------------------------------------------------- # # Set the max mxl that I want to plot. max_ice = 1. # Create a new figure window. plt.figure(figsize=(8.0, 8.0)) # Specify some things to make the plot look nice. map = Basemap(projection='spstere', boundinglat=-35, lon_0=-150, round='true') # Draw grid lines and label the longitudes. map.drawparallels(np.arange(-80, 0, 20), linewidth=0.5, color='w') map.drawmeridians(np.arange(-180, 180, 30),
# Load the coordinates. gphit = np.squeeze(nemo.load_field('gphit', homedir, nemodir, gridfile, 'T')) glamt = np.squeeze(nemo.load_field('glamt', homedir, nemodir, gridfile, 'T')) # Load the relevant mask. tmask = np.squeeze(nemo.load_field('tmask', homedir, nemodir, gridfile, 'T'))[:, :, 0:1] # Load the field to plot and remask it. icethic = np.squeeze( np.load(''.join([ homedir, nemodir, 'TIDY/ARCHIVE/POST/', 'siconc_sithic_OND_1952-1954.npy' ]))) icethic = nemo.mask_field(icethic[:, :, None], tmask) # --------------------------------------------------------------------------- # # Create a new figure window. plt.figure(figsize=(8.0, 8.0)) # Specify some things to make the plot look nice. map = Basemap(projection='spaeqd', boundinglat=-35, lon_0=-150, round='true') # map.shadedrelief() # map.fillcontinents(color='black', lake_color='white') # Draw grid lines and label the longitudes. map.drawparallels(np.arange(-80, 0, 20), linewidth=0.25) map.drawmeridians(np.arange(-180, 180, 30), labels=12 * [True], linewidth=0.25) map.drawmapboundary(fill_color='black')
ufiles = sorted(glob.glob(''.join([homedir, nemodir, udir, '*']))) # --------------------------------------------------------------------------- # # If we're not loading the data, then loop over all the available files and # calculate the ice volume. if save_output: # Preallocate the output variable. wind = np.ndarray(shape=[len(ufiles), 2]) # Loop over the U/V files and load the surface velocity. for k in range(len(ufiles)): print(ufiles[k]) # Load & mask the current ice fraction field. zonalwind = nemo.load_field('sozotaux', '', '', ufiles[k], 'U') zonalwind = nemo.mask_field(zonalwind, umask) # Calculate the area of the grid box covered in ice. total = (e1u[0:nx - 1, :, :] * e2u[0:nx - 1, :, :] * zonalwind[0:nx - 1, :, :]).sum() # Store the total area for output. wind[k, 0] = ufiles[k].split('/ORCH0083-LIM3_', 1)[1].split('_U', 1)[0] wind[k, 1] = total # --------------------------------------------------------------------------- # # Spit the numbers out to file, if requested. if save_output: np.save( ''.join([homedir, nemodir, 'TIDY/ARCHIVE/POST/zonalwindinput_m01']), wind)
glamt = np.expand_dims( np.squeeze(nemo.load_field('LONGITUDE', homedir, nemodir, filename)), 1) # Load the coordinates. gphit = np.expand_dims( np.squeeze(nemo.load_field('LATITUDE', homedir, nemodir, filename)), 1) glamt = np.expand_dims( np.squeeze(nemo.load_field('LONGITUDE', homedir, nemodir, filename)), 1) glamt, gphit = np.meshgrid(glamt, gphit) # Load the field to plot and remask it. mxl = nemo.load_field('DEPTH_MIXED_LAYER', homedir, nemodir, filename) mxlmask = np.isfinite(mxl) mxl[np.isnan(mxl)] = 0.0 mxl = nemo.mask_field(mxl, mxlmask) # --------------------------------------------------------------------------- # # Set the max mxl that I want to plot. max_mxl = 500. # Create a new figure window. plt.figure(figsize=(8.0, 8.0)) # Specify some things to make the plot look nice. map = Basemap(projection='spstere', boundinglat=-35, lon_0=-150, round='true') map.drawparallels(np.arange(-80, 0, 20), linewidth=0.5, color='w') map.drawmeridians(np.arange(-180, 180, 30), labels=12 * [True], linewidth=0.5,
ifiles = sorted(glob.glob(''.join([homedir, nemodir, idir, '*']))) # --------------------------------------------------------------------------- # # If we're not loading the data, then loop over all the available files and # calculate the ice volume. if save_output: # Preallocate the output variable. icearea = np.ndarray(shape=[len(ifiles), 2]) # Loop over the U/V files and load the surface velocity. for k in range(len(ifiles)): print(ifiles[k]) # Load & mask the current ice fraction field. icefrac = nemo.load_field('siconc', '', '', ifiles[k], 'T') icefrac = nemo.mask_field(icefrac, tmask) # Calculate the area of the grid box covered in ice. area = (e1t * e2t * icefrac).sum() # Store the total area for output. icearea[k, 0] = ifiles[k].split('/ORCH0083-LIM3_', 1)[1].split('_I', 1)[0] icearea[k, 1] = area # --------------------------------------------------------------------------- # # Spit the numbers out to file, if requested. if save_output: np.save(''.join([homedir, nemodir, 'TIDY/ARCHIVE/POST/icearea']), icearea) # --------------------------------------------------------------------------- #
tfiles = sorted(glob.glob(''.join([homedir, nemodir, tdir, '*']))) # --------------------------------------------------------------------------- # # If we're not loading the data, then loop over all the available files and # calculatet the average KE. if save_output: # Preallocate the output variable. meansalty = np.ndarray(shape=[len(tfiles), nz + 1]) # Loop over the U/V files and load the surface velocity. for k in range(len(tfiles)): print tfiles[k] # Load & mask the current theta field. salty = np.squeeze(nemo.load_field('vosale3t', '', '', tfiles[k], 'T')) salty = nemo.mask_field(salty, tmask) # Load & mask the current e3t field. e3t = np.squeeze(nemo.load_field('e3t', '', '', tfiles[k], 'T')) e3t = nemo.mask_field(e3t, tmask) # Calculate the area average surface temperature. meansalty[k, 0] = tfiles[k].split('/ORCH0083-LIM3_', 1)[1].split('_T', 1)[0] meansalty[k, 1:] = np.sum(salty * area, axis=(0, 1)) / np.sum(e3t * area, axis=(0, 1)) # --------------------------------------------------------------------------- # # Spit the numbers out to file, if requested. if save_output:
# Load the zonal grid spacing and latitudes e1t = np.squeeze(nemo.load_field('e1t', homedir, nemodir, gridfile, 'T')) gphit = np.squeeze(nemo.load_field('gphit', homedir, nemodir, gridfile, 'T')) # Load the relevant mask. tmask = np.squeeze(nemo.load_field('tmask', homedir, nemodir, gridfile, 'T'))[:, :, 0:1] # --------------------------------------------------------------------------- # # Load the temperature fields and remask them. sst2 = np.squeeze( np.load(''.join( [homedir, nemodir, 'TIDY/ARCHIVE/POST/', 'sosstsqu_ANN_1952-1954.npy']))) sst2 = nemo.mask_field(sst2[:, :, None], tmask) sst = np.squeeze( np.load(''.join( [homedir, nemodir, 'TIDY/ARCHIVE/POST/', 'sosstsst_ANN_1952-1954.npy']))) sst = nemo.mask_field(sst[:, :, None], tmask) # Calculate the temperature variance. tvar = sst2 - sst * sst # Integrate the temperature variance. nemo_tvar_exp00 = (tvar * e1t[:, :, None] * tmask).sum(axis=0) / \ (e1t[:, :, None] * tmask).sum(axis=0) # --------------------------------------------------------------------------- #
gphit = np.squeeze(nemo.load_field('gphit', homedir, nemodir, gridfile, 'T')) # Load the grid spacings. e2u = nemo.load_field('e2u', homedir, nemodir, gridfile, 'U') # Load the relevant mask. tmask = np.squeeze(nemo.load_field('tmask', homedir, nemodir, gridfile, 'T'))[:, :, 0:1] umask = np.squeeze(nemo.load_field('umask', homedir, nemodir, gridfile, 'U')) # Load the velocity fields and remask them. uvele3u = np.squeeze( np.load(''.join( [homedir, nemodir, 'TIDY/ARCHIVE/POST/', 'vozoce3u_ANN_1952-1954.npy']))) uvele3u = nemo.mask_field(uvele3u, umask) # --------------------------------------------------------------------------- # # Calculate the barotropic streamfunction. psi = uvele3u.sum(axis=2) psi = np.cumsum(psi.data[:, :, None] * umask[:, :, 0:1] * e2u[:, :, 0:1], axis=1) psi = nemo.mask_field(psi, umask[:, :, 0:1]) # --------------------------------------------------------------------------- # # Create a new figure window. plt.figure(figsize=(8.0, 8.0)) # Specify some things to make the plot look nice.
nz = 75 # --------------------------------------------------------------------------- # # Load the coordinates. glamt = np.squeeze(nemo.load_field('glamt', homedir, nemodir, gridfile, 'T')) gphit = np.squeeze(nemo.load_field('gphit', homedir, nemodir, gridfile, 'T')) # Load the relevant mask. tmask = np.squeeze(nemo.load_field('tmask', homedir, nemodir, gridfile, 'T')[:, :, 0:1]) # Load the temperature fields and remask them. flux = np.squeeze(np.load(''.join([homedir, nemodir, 'TIDY/ARCHIVE/POST/', 'sohefldo_ANN_1952-1954.npy']))) flux = nemo.mask_field(flux, tmask) # --------------------------------------------------------------------------- # # Create a new figure window. plt.figure(figsize=(8.0, 8.0)) # Specify some things to make the plot look nice. map = Basemap(projection='spaeqd', boundinglat=-35, lon_0=-150, round='true') # Draw grid lines and label the longitudes. map.drawparallels(np.arange(-80, 0, 20), linewidth=0.25, color='w') map.drawmeridians(np.arange(-180, 180, 30), labels=12*[True], linewidth=0.25, color='w') map.drawmapboundary(fill_color='black')
ifiles = sorted(glob.glob(''.join([homedir, nemodir, idir, '*']))) # --------------------------------------------------------------------------- # # If we're not loading the data, then loop over all the available files and # calculatet the ice volume. if save_output: # Preallocate the output variable. thickness = np.ndarray(shape=[len(ifiles), 2]) # Loop over the U/V files and load the surface velocity. for k in range(len(ifiles)): print(ifiles[k]) # Load & mask the current U velocity field. icethick = nemo.load_field('sithic', '', '', ifiles[k], 'T') icethick = nemo.mask_field(icethick, tmask) iceconc = nemo.load_field('siconc', '', '', ifiles[k], 'T') iceconc = nemo.mask_field(iceconc, tmask) # Calculate the KE for the current velocity fields thick = (e1t * e2t * icethick * iceconc).sum() / (e1t * e2t * tmask).sum() # Calculate the area average surface KE. thickness[k, 0] = ifiles[k].split('/ORCH0083-LIM3_', 1)[1].split('_I', 1)[0] thickness[k, 1] = thick # --------------------------------------------------------------------------- # # Spit the numbers out to file, if requested. if save_output:
homedir, nemodir, gridfile, 'T'))[:, :, 0:1] # --------------------------------------------------------------------------- # # Find the number of files in the directory that we want to calculate KE for. ifiles = sorted(glob.glob(''.join([homedir, nemodir, idir, '*']))) # --------------------------------------------------------------------------- # # Loop over the U/V files and load the surface velocity. for k in range(0, len(ifiles)+1, 5): print(ifiles[k]) # Load the velocity fields and remask them. siconc = nemo.load_field('siconc', '', '', ifiles[k], 'T') siconc = nemo.mask_field(siconc, tmask) # Create a new figure window. plt.figure(figsize=(4.0, 4.0)) # Specify some things to make the plot look nice. map = Basemap(projection='spaeqd', boundinglat=-35, lon_0=180, round='true') # Draw grid lines and label the longitudes. map.drawparallels(np.arange(-80, 0, 20), linewidth=0.25) map.drawmeridians(np.arange(-180, 180, 30), fontsize=4, labels=12*[True], linewidth=0.25) map.drawmapboundary(fill_color='black') # Draw the contour plot.
# Specify the number of grid boxes. nx = 4320 ny = 2000 nz = 75 # --------------------------------------------------------------------------- # # Load the coordinates. glamt = np.squeeze(nemo.load_field('glamt', homedir, nemodir, gridfile, 'T')) gphit = np.squeeze(nemo.load_field('gphit', homedir, nemodir, gridfile, 'T')) # Load the relevant mask. tmask = np.squeeze(nemo.load_field('tmask', homedir, nemodir, gridfile, 'T')) e3t_0 = np.squeeze(nemo.load_field('e3t_0', homedir, nemodir, gridfile, 'T')) depth = (e3t_0 * tmask).sum(axis=2) depth = nemo.mask_field(depth[:, :, None], tmask[:, :, 0:1]) # --------------------------------------------------------------------------- # # Create a new figure window. plt.figure(figsize=(8.0, 8.0)) # Specify some things to make the plot look nice. map = Basemap(projection='spaeqd', boundinglat=-35, lon_0=-150, round='true') # Draw grid lines and label the longitudes. map.drawparallels(np.arange(-80, 0, 20), linewidth=0.25, color='w') map.drawmeridians(np.arange(-180, 180, 30), labels=12 * [True], linewidth=0.25, color='w')
filename = 'TIDY/ARCHIVE/1952/d01/T/ORCH0083-LIM3_19521231_T_d01.nc' gridfile = 'TIDY/ARCHIVE/MESH/mesh_mask.nc' # --------------------------------------------------------------------------- # # Load the coordinates. gphit = np.squeeze(nemo.load_field('gphit', homedir, nemodir, gridfile, 'T')) glamt = np.squeeze(nemo.load_field('glamt', homedir, nemodir, gridfile, 'T')) # Load the relevant mask. tmask = np.squeeze(nemo.load_field('tmask', homedir, nemodir, gridfile, 'T'))[:, :, 0:1] # Load the field to plot and remask it. mxl = nemo.load_field('somxlr103', homedir, nemodir, filename, 'T') mxl = nemo.mask_field(mxl, tmask) # --------------------------------------------------------------------------- # # Set the max mxl that I want to plot. max_mxl = 100. # Create a new figure window. plt.figure(figsize=(8.0, 8.0)) # Specify some things to make the plot look nice. map = Basemap(projection='spaeqd', boundinglat=-10, lon_0=180, round='true') # map.shadedrelief() # map.fillcontinents(color='black', lake_color='white')
# --------------------------------------------------------------------------- # # Load the coordinates. glamt = np.squeeze(nemo.load_field('glamt', homedir, nemodir, gridfile, 'T')) gphit = np.squeeze(nemo.load_field('gphit', homedir, nemodir, gridfile, 'T')) # Load the relevant mask. tmask = np.squeeze(nemo.load_field('tmask', homedir, nemodir, gridfile, 'T'))[:, :, 0:1] # Load the velocity fields and remask them. ssh2 = np.squeeze( np.load(''.join( [homedir, nemodir, 'TIDY/ARCHIVE/POST/', 'sosssh2_ANN_1952-1954.npy'])))[:, :, None] ssh2 = nemo.mask_field(ssh2, tmask) ssh = np.squeeze( np.load(''.join( [homedir, nemodir, 'TIDY/ARCHIVE/POST/', 'sossheig_ANN_1952-1954.npy'])))[:, :, None] ssh = nemo.mask_field(ssh, tmask) # --------------------------------------------------------------------------- # # Calculate the SSH variance. sshvar = ssh2 - ssh * ssh # --------------------------------------------------------------------------- # # Create a new figure window. plt.figure(figsize=(8.0, 8.0))
tfiles = sorted(glob.glob(''.join([homedir, nemodir, tdir, '*']))) # --------------------------------------------------------------------------- # # If we're not loading the data, then loop over all the available files and # calculatet the average KE. if save_output: # Preallocate the output variable. meansss = np.ndarray(shape=[len(tfiles), 2]) # Loop over the U/V files and load the surface velocity. for k in range(len(tfiles)): print(tfiles[k]) # Load & mask the current sss field. sss = nemo.load_field('sosaline', '', '', tfiles[k], 'T') sss = nemo.mask_field(sss, tmask) # Calculate the area average surface temperature. meansss[k, 0] = tfiles[k].split('/ORCH0083-LIM3_', 1)[1].split('_T', 1)[0] meansss[k, 1] = (sss * area).sum() / area.sum() # --------------------------------------------------------------------------- # # Spit the numbers out to file, if requested. if save_output: np.save(''.join([homedir, nemodir, 'TIDY/ARCHIVE/POST/meansss']), meansss) # --------------------------------------------------------------------------- # # If we're not saving the number, we're loading them. if not save_output: meansss = np.load(''.join(
filename = 'TIDY/ARCHIVE/1948/V/ORCH0083-LIM3_19481227_V_d05.nc' gridfile = 'TIDY/ARCHIVE/MESH/mesh_mask.nc' # --------------------------------------------------------------------------- # # Load the coordinates. glamv = np.squeeze(nemo.load_field('glamv', homedir, nemodir, gridfile, 'V')) gphiv = np.squeeze(nemo.load_field('gphiv', homedir, nemodir, gridfile, 'V')) # Load the relevant mask. vmask = np.squeeze(nemo.load_field('umask', homedir, nemodir, gridfile, 'V'))[:, :, 0:1] # Load the field to plot and remask it. ssv = nemo.load_field('sossvssv', homedir, nemodir, filename, 'V') ssv = nemo.mask_field(ssv, vmask) # --------------------------------------------------------------------------- # # Create a new figure window. plt.figure() # Specify some things to make the plot look nice. map = Basemap(projection='spaeqd', boundinglat=-10, lon_0=180, round='true') # map.shadedrelief() # map.fillcontinents(color='black', lake_color='white') # Draw grid lines and label the longitudes. map.drawparallels(np.arange(-80, 0, 20), linewidth=0.25) map.drawmeridians(np.arange(-180, 180, 30), labels=12 * [True], linewidth=0.25)
# --------------------------------------------------------------------------- # # Load the zonal grid spaing and latitudes e1t = np.squeeze(nemo.load_field('e1t', homedir, nemodir, gridfile, 'T')) gphit = np.squeeze(nemo.load_field('gphit', homedir, nemodir, gridfile, 'T')) # Load the relevant mask. tmask = np.squeeze(nemo.load_field('tmask', homedir, nemodir, gridfile, 'T'))[:, :, 0:1] # --------------------------------------------------------------------------- # # Load the field to plot and remask it. sss = nemo.load_field('vosaline', homedir, nemodir, 'INIT/vosaline.1949.nc', 'T')[:, :, 0:1, 0] sss = nemo.mask_field(sss, tmask) # Integrate the temperature variance. nemo_sss_init = (sss * e1t[:, :, None] * tmask).sum(axis=0) / \ (e1t[:, :, None] * tmask).sum(axis=0) # --------------------------------------------------------------------------- # # Load the temperature fields and remask them. sss = np.squeeze( np.load(''.join( [homedir, nemodir, 'TIDY/ARCHIVE/POST/', 'sosaline_01_1948-1948.npy']))) sss = nemo.mask_field(sss[:, :, None], tmask) # Integrate the temperature variance.
# Specify the names of the different files that I want to load from. filename = ''.join([nemodir, year, '/ORCA025-N401_2010y01T.nc']) gridfile = ''.join([homedir, 'examples/data/fields/mesh_hgr_matt.nc']) # --------------------------------------------------------------------------- # # Load the coordinates. gphit = np.squeeze(nemo.load_field('gphit', homedir, nemodir, gridfile, 'T')) glamt = np.squeeze(nemo.load_field('glamt', homedir, nemodir, gridfile, 'T')) gdept = np.squeeze(nemo.load_field('gdept_0', homedir, nemodir, gridfile)) tmask = np.squeeze(nemo.load_field('tmask', homedir, nemodir, gridfile, 'T'))[:, :, 0:1] # Load the field and remask it. transect = nemo.load_field('sossheig', homedir, nemodir, filename, 'T') transect = nemo.mask_field(transect, tmask) #--------------------------------------------------------------------------- # # Create a new figure window. plt.figure(figsize=(12.0, 12.0)) #Define polar projection map and fill background black. map = Basemap(projection='spaeqd', boundinglat=-10, lon_0=-150, round='true') map.drawmapboundary(fill_color='aqua') # Plot the contour. transplt = map.contourf(glamt.T, gphit.T, np.squeeze(transect).T, np.arange(-2., 2., 0.025), latlon='true',
filename = 'TIDY/ARCHIVE/1948/U/ORCH0083-LIM3_19481227_U_d05.nc' gridfile = 'TIDY/ARCHIVE/MESH/mesh_mask.nc' # --------------------------------------------------------------------------- # # Load the coordinates. glamu = np.squeeze(nemo.load_field('glamu', homedir, nemodir, gridfile, 'U')) gphiu = np.squeeze(nemo.load_field('gphiu', homedir, nemodir, gridfile, 'U')) # Load the relevant mask. umask = np.squeeze(nemo.load_field('umask', homedir, nemodir, gridfile, 'U'))[:, :, 0:1] # Load the field to plot and remask it. ssu = nemo.load_field('sossussu', homedir, nemodir, filename, 'U') ssu = nemo.mask_field(ssu, umask) # --------------------------------------------------------------------------- # # Create a new figure window. plt.figure() # Specify some things to make the plot look nice. map = Basemap(projection='spaeqd', boundinglat=-10, lon_0=180, round='true') # map.shadedrelief() # map.fillcontinents(color='black', lake_color='white') # Draw grid lines and label the longitudes. map.drawparallels(np.arange(-80, 0, 20), linewidth=0.25) map.drawmeridians(np.arange(-180, 180, 30), labels=12 * [True], linewidth=0.25)
filename = 'TIDY/ARCHIVE/1951/d01/T/ORCH0083-LIM3_19511231_T_d01.nc' gridfile = 'TIDY/ARCHIVE/MESH/mesh_mask.nc' # --------------------------------------------------------------------------- # # Load the coordinates. gphit = np.squeeze(nemo.load_field('gphit', homedir, nemodir, gridfile, 'T')) glamt = np.squeeze(nemo.load_field('glamt', homedir, nemodir, gridfile, 'T')) # Load the relevant mask. tmask = np.squeeze(nemo.load_field('tmask', homedir, nemodir, gridfile, 'T'))[:, :, 0:1] # Load the field to plot and remask it. sst = nemo.load_field('sosstsst', homedir, nemodir, filename, 'T') sst = nemo.mask_field(sst, tmask) # --------------------------------------------------------------------------- # # Create a new figure window. plt.figure(figsize=(8.0, 8.0)) # Use: plt.savefig('sst.png', bbox_inches='tight', dpi=1200) # Specify some things to make the plot look nice. map = Basemap(projection='spaeqd', boundinglat=-35, lon_0=180, round='true') # map.shadedrelief() # map.fillcontinents(color='black', lake_color='white') # Draw grid lines and label the longitudes. map.drawparallels(np.arange(-80, 0, 20), linewidth=0.25)
ny = 2000 nz = 75 # --------------------------------------------------------------------------- # # Load the coordinates. glamt = np.squeeze(nemo.load_field('glamt', homedir, nemodir, gridfile, 'T')) gphit = np.squeeze(nemo.load_field('gphit', homedir, nemodir, gridfile, 'T')) # Load the relevant mask. tmask = np.squeeze(nemo.load_field('tmask', homedir, nemodir, gridfile, 'T'))[:, :, 0:1] # Load the salinity fields and remask them. sss2 = nemo.load_field('sosalsqu', homedir, nemodir, sfilename, 'T') sss2 = nemo.mask_field(sss2, tmask) sss = nemo.load_field('sosaline', homedir, nemodir, sfilename, 'T') sss = nemo.mask_field(sss, tmask) # --------------------------------------------------------------------------- # # Calculate the temperature variance. svar = sss2 - sss * sss # --------------------------------------------------------------------------- # # Create a new figure window. plt.figure(figsize=(8.0, 8.0)) # Specify some things to make the plot look nice. map = Basemap(projection='spaeqd', boundinglat=-35, lon_0=-150, round='true')
# Load the coordinates. gphit = np.squeeze( nemo.load_field('gphit', homedir, nemodir, gridfile, 'T')) glamt = np.squeeze( nemo.load_field('glamt', homedir, nemodir, gridfile, 'T')) gdept = np.squeeze(nemo.load_field('gdept_0', homedir, nemodir, gridfile)) # Load the mask tmask_1 = np.squeeze( nemo.load_field('tmask', homedir, nemodir, gridfile, 'T')) # Load the field and remask it. ntemp = np.squeeze( nemo.load_field('vosaline', homedir, nemodir, filename, 'T')) ntemp = nemo.mask_field(ntemp, tmask_1) # --------------------------------------------------------------------------- # # Create a new figure window. plt.figure(figsize=(12.0, 12.0)) # Draw the contour plot. transplt = plt.contourf(np.repeat(gphit[1039:1040, :].T, 75, axis=1), -np.repeat(gdept.T[:, None], 1021, axis=1).T, np.squeeze(ntemp[1039:1040, :, :]), np.arange(34., 38., .05), cmap='viridis', vmin=34., vmax=38., extend='both')
# --------------------------------------------------------------------------- # # If we're not loading the data, then loop over all the available files and # calculatet the average KE. if save_output: # Preallocate the output variable. tacc = np.ndarray(shape=[len(ufiles), 2]) # Loop over the U/V files and load the surface velocity. for k in range(len(ufiles)): print(ufiles[k]) bounds = [2599, 2600, 0, 1999, 0, 74] # Load & mask the current U velocity field. uoce = nemo.load_field('vozoce3u', '', '', ufiles[k], 'U')[2599:2600, :, :] uoce = nemo.mask_field(uoce, umask) # Calculate the Drake Passage transport. tacc[k, 0] = ufiles[k].split('/ORCH0083-LIM3_', 1)[1].split('_U', 1)[0] tacc[k, 1] = (uoce * e2u * umask).sum() / 1.E6 # --------------------------------------------------------------------------- # # Spit the numbers out to file, if requested. if save_output: np.save(''.join([homedir, nemodir, 'TIDY/ARCHIVE/POST/tacc']), tacc) # --------------------------------------------------------------------------- # # If we're not saving the number, we're loading them. if not save_output: tacc = np.load(''.join([homedir, nemodir, 'TIDY/ARCHIVE/POST/tacc.npy']))
# Specify the number of grid boxes. nx = 4320 ny = 2000 nz = 75 # Choose whether to save/load KE values. save_output = 1 # --------------------------------------------------------------------------- # # Load the relevant mask. vmask = np.squeeze(nemo.load_field('vmask', homedir, nemodir, gridfile, 'V')) # Load the grid spacings. e2v = nemo.load_field('e2v', homedir, nemodir, gridfile, 'V') e2v = nemo.mask_field(e2v, vmask[:, :, 0:1]) # --------------------------------------------------------------------------- # # Find the number of files in the directory that we want to calculate KE for. if save_output: vfiles = sorted(glob.glob(''.join([homedir, nemodir, vdir, '*']))) # --------------------------------------------------------------------------- # # If we're not loading the data, then loop over all the available files and # calculatet the average KE. if save_output: # Preallocate the output variable. amoc = np.ndarray(shape=[len(vfiles), 2])
# Specify the names of the different files that I want to load from. tfilename = 'OUTPUTS/ORCH0083-LIM3_1h_19480101_19480101_grid_T_1948010101-1948010101.nc' gridfile = 'TIDY/ARCHIVE/MESH/mesh_mask.nc' # --------------------------------------------------------------------------- # e1t = nemo.load_field('e1t', homedir, nemodir, gridfile, 'T') e2t = nemo.load_field('e2t', homedir, nemodir, gridfile, 'T') e3t_0 = np.squeeze(nemo.load_field('e3t_0', homedir, nemodir, gridfile, 'T')) # Load the relevant mask. tmask = np.squeeze(nemo.load_field('tmask', homedir, nemodir, gridfile, 'T')) # Mask the e3's. e3t_0 = nemo.mask_field(e3t_0, tmask) # --------------------------------------------------------------------------- # e3t = np.squeeze(nemo.load_field('e3t', homedir, nemodir, tfilename, 'T')) e3t = nemo.mask_field(e3t, tmask) # --------------------------------------------------------------------------- # vt_0 = e1t * e2t * e3t_0 vt_0 = vt_0.sum() print 'vt_0 =', vt_0 vt = e1t * e2t * e3t vt = vt.sum() print 'vt =', vt
# --------------------------------------------------------------------------- # # Find the number of files in the directory that we want to calculate KE for. tfiles = sorted(glob.glob(''.join([homedir, nemodir, tdir, '*']))) # --------------------------------------------------------------------------- # # Loop over the U/V files and load the surface velocity. for k in range(0, len(tfiles) + 1, 1): print tfiles[k] # Load the velocity fields and remask them. age = np.squeeze( nemo.load_field('voagee3t', '', '', tfiles[k], 'T')[3250:3251, :, :]) age = nemo.mask_field(age, tmask) e3t = np.squeeze( nemo.load_field('e3t', '', '', tfiles[k], 'T')[3250:3251, :, :]) e3t = nemo.mask_field(e3t, tmask) # Factor out the layer thickness. age = age / e3t e3t = None # Create a new figure window. plt.figure(figsize=(4.0, 4.0)) # Draw the contour plot. cs_age = plt.contourf(np.repeat(gphit[3250:3251, :].T, 75, axis=1), -np.repeat(gdept.T[:, None], 2000, axis=1).T, age,
tfiles = sorted(glob.glob(''.join([homedir, nemodir, tdir, '*']))) # --------------------------------------------------------------------------- # # If we're not loading the data, then loop over all the available files and # calculate the mean ssh. if save_output: # Preallocate the output variable. ssheight = np.ndarray(shape=[len(tfiles), 2]) # Loop over the U/V files and load the surface velocity. for k in range(len(tfiles)): print(tfiles[k]) # Load & mask the current U velocity field. ssh = nemo.load_field('sossheig', '', '', tfiles[k], 'T') ssh = nemo.mask_field(ssh, tmask) # Calculate the KE for the current velocity fields avessh = (e1t * e2t * ssh).sum() / (e1t * e2t).sum() # Calculate the area average surface KE. ssheight[k, 0] = tfiles[k].split('/ORCH0083-LIM3_', 1)[1].split('_T', 1)[0] ssheight[k, 1] = avessh # --------------------------------------------------------------------------- # # Spit the numbers out to file, if requested. if save_output: np.save(''.join([homedir, nemodir, 'TIDY/ARCHIVE/POST/ssheight']), ssheight) # --------------------------------------------------------------------------- # # If we're not saving the number, we're loading them.
# --------------------------------------------------------------------------- # # If we're not loading the data, then loop over all the available files and # calculatet the average KE. if save_output: # Preallocate the output variable. meanke = np.ndarray(shape=[len(ufiles), nz]) # Loop over the U/V files and load the surface velocity. for k in range(len(ufiles)): print(ufiles[k]) # Load & mask the current UU velocity field. uu = np.squeeze( nemo.load_field('vozocrtx2', '', '', ufiles[k], 'U', nx, ny)) uu = nemo.mask_field(uu, umask) # Load and mask the current VV velocity field. vv = np.squeeze( nemo.load_field('vomecrty2', '', '', vfiles[k], 'V', nx, ny)) vv = nemo.mask_field(vv, vmask) # Calculate the KE for the current velocity fields ke = nemo.calc_ke(uu.data, vv.data, nx, ny, nz, tmask) # Load & mask the current e3t field. e3t = np.squeeze(nemo.load_field('e3t', '', '', tfiles[k], 'T', nx, ny)) e3t = nemo.mask_field(e3t, tmask) # Calculate the area average surface temperature.