예제 #1
0
msk_roms = grd.variables['mask_rho'][:]
msk_romsv = grd.variables['mask_v'][:]
h_roms = grd.variables['h'][:]
sh2 = msk_roms.shape
etamax, ximax = sh2

theta_b = 0.4
theta_s = 5.0
tcline = 100.
klevels = 40
Vtransform = 2
Vstretching = 4
Spherical = True

if Vstretching==4:
  scoord = s_coordinate_4(h_roms, theta_b, theta_s, tcline, klevels)   #zeta is not used in the computation 
elif Vstretching==2:
  scoord = s_coordinate_2(h_roms, theta_b, theta_s, tcline, klevels)
elif Vstretching==1:
  scoord = s_coordinate(h_roms, theta_b, theta_s, tcline, klevels)

zr = -scoord.z_r[:]
 
zc=np.array([0])

zc=zc[::-1]

uavg=avgfile['u_eastward'][:]

vavg=avgfile['v_northward'][:]
예제 #2
0
theta_s = 5.0
tcline = 100.
klevels = 40
Vtransform = 2
Vstretching = 4
fname_grd='azul_son_case1_newBAT_2_Mcu.nc'
grd = dat(fname_grd)
x_roms = grd.variables['lon_rho'][:]
y_roms = grd.variables['lat_rho'][:]
msk_roms = grd.variables['mask_rho'][:]
msk_romsv = grd.variables['mask_v'][:]
h_roms = grd.variables['h'][:]
sh2 = msk_roms.shape
etamax, ximax = sh2

scoord = s_coordinate_4(h_roms, theta_b, theta_s, tcline, klevels)
zr = scoord.z_r[:]

a,b=np.meshgrid(x_roms[0,:],zr[:,0,0])

fig, ax1 = plt.subplots()
AB=ax1.pcolor(a, zr[:,0,:], temp[-1,::], vmin=-0.8, vmax=0.8, cmap = 'seismic')
#AB=ax1.pcolor(a, zr[:,0,:], temp[0,::])
ax1.axis('tight')
cbar=fig.colorbar(AB, shrink=0.9, extend='both')
cbar.ax.set_ylabel('v(m/s)', rotation=270)
cbar.ax.get_yaxis().labelpad = 20
text = cbar.ax.yaxis.label
font = matplotlib.font_manager.FontProperties(family='times new roman', style='normal', size=15)
text.set_font_properties(font)
#plt.savefig('bry_south.png')
예제 #3
0
h_roms_p = file['h'][:]
h_roms_p = h_roms_p[::-1, :]
h_roms_p = h_roms_p[imxla - lim:imla + lim, iml - lim:imxl + lim]

theta_b_p = float(file['theta_b'][:])
theta_s_p = float(file['theta_s'][:])
tcline_p = float(file['Tcline'][:])
Vstretching_p = float(file['Vstretching'][:])
klevels_p = numlevels

ZETA = np.zeros(x_fm.shape)

if Vstretching_p == 4:
    scoord = s_coordinate_4(h_roms_p,
                            theta_b_p,
                            theta_s_p,
                            tcline_p,
                            klevels_p,
                            zeta=ZETA)  #zeta is not used in the computation
elif Vstretching_p == 2:
    scoord = s_coordinate_2(h_roms_p,
                            theta_b_p,
                            theta_s_p,
                            tcline_p,
                            klevels_p,
                            zeta=ZETA)
elif Vstretching_p == 1:
    scoord = s_coordinate(h_roms_p,
                          theta_b_p,
                          theta_s_p,
                          tcline_p,
                          klevels_p,
예제 #4
0
def get_ROMS_vgrid(gridid, zeta=None):
    """
    vgrid = get_ROMS_vgrid(gridid)
    Load ROMS vertical grid object. vgrid is a s_coordinate or
    a z_coordinate object, depending on gridid.grdtype.
    vgrid.z_r and vgrid.z_w (vgrid.z for a z_coordinate object)
    can be indexed in order to retreive the actual depths. The
    free surface time serie zeta can be provided as an optional
    argument. Note that the values of zeta are not calculated
    until z is indexed, so a netCDF variable for zeta may be passed,
    even if the file is large, as only the values that are required
    will be retrieved from the file.
    """

    nc = Dataset(gridid)

    #Get vertical grid
    try:
        h = nc.variables['h'][:]
    except:
        raise ValueError('NetCDF file must contain the bathymetry h')

    try:
        hraw = nc.variables['hraw'][:]
    except:
        hraw = None

    gridinfo_type = 'roms'
    if gridinfo_type == 'roms':
        Vtrans = 4
        theta_b = 0.4
        theta_s = 5.0
        Tcline = 100
        N = 40
        if Vtrans == 1:
            vgrid = s_coordinate(h,
                                 theta_b,
                                 theta_s,
                                 Tcline,
                                 N,
                                 hraw=hraw,
                                 zeta=zeta)
        elif Vtrans == 2:
            vgrid = s_coordinate_2(h,
                                   theta_b,
                                   theta_s,
                                   Tcline,
                                   N,
                                   hraw=hraw,
                                   zeta=zeta)
        elif Vtrans == 4:
            vgrid = s_coordinate_4(h,
                                   theta_b,
                                   theta_s,
                                   Tcline,
                                   N,
                                   hraw=hraw,
                                   zeta=zeta)
        elif Vtrans == 5:
            vgrid = s_coordinate_5(h,
                                   theta_b,
                                   theta_s,
                                   Tcline,
                                   N,
                                   hraw=hraw,
                                   zeta=zeta)
        else:
            raise Warning('Unknown vertical transformation Vtrans')

    elif gridinfo_type == 'z':
        N = gridinfo.N
        depth = gridinfo.depth
        vgrid = z_coordinate(h, depth, N)

    else:
        raise ValueError('Unknown grid type')

    return vgrid