Пример #1
0
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,
                          zeta=ZETA)

z_parent = scoord.z_r[:]

##interp s layers to son's grid

z_parent_i = np.zeros((z_parent.shape[0], ) + x_roms.shape)
Пример #2
0
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'][:]

time=avgfile['ocean_time'][:]/(24*60*60)
Пример #3
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