Ejemplo n.º 1
0
def pv1_calc(v,b,x,z,w = None):
    """pv1_calc(dgl) calculates pv1 from vz and b_x"""
    zlen = len(z)
    vz = n2_calc(v,z) #This is below the v-point
    vz = 0.5*(np.roll(vz,1,axis=1) + vz) #This is at the lower-left cell corner
    bx = mit.ddx(b,x) #This is on u-points
    bx = 0.5*(bx[:,:,0:zlen-1] + bx[:,:,1:zlen]) #This is below u-points
    bx = 0.5*(np.roll(bx,1,0) + bx) #This is at the lower-left cell corner
    w_exists =  isinstance(w, np.ndarray)
    if not w_exists:
        pv1 = (-vz)*bx
    else:
        wy = mit.ddy(w,y) #This is below tracer points
        wy = mit.four_cell_average(wy) #This is at the lower-left cell corner
        pv1 = (wy-vz)*bx

    return pv1
Ejemplo n.º 2
0
def vbyz(dgl):
    """Calculate the effect on stratification of differential meridional
    buoyancy fluxes"""
    #First ensure that the correct vertical field is present
    fld_exists = mit.check_field(dgl,'pvz')
    if not fld_exists:
        dgl = mit.add_field(dgl,'pvz')
        zlen = len(dgl[0]['z'])
        dgl[0]['pvz'] = 0.5*(dgl[0]['z'][0:zlen-1] + dgl[0]['z'][1:zlen])
    import eosmit   #This routine checks if buoyancy is already loaded before running
    eos = 'jmd'
    dgl = eosmit.buoy_dgl(dgl,eos=eos)
    fld_exists = mit.check_field(dgl,'vbxz')
    if not fld_exists:
        dgl = mit.add_field(dgl,'vbyz')
    dgl[0]['vbyz'] = dgl[0]['v']*mit.ddy(dgl[0]['b'],dgl[0]['y'])

    return dgl
Ejemplo n.º 3
0
def pv2_calc(u,b,y,z,w =  None):
    """pv2(dgl) calculates pv2 from uz and b_y"""
    zlen = len(z)
    uz = n2_calc(u,z) #This is below u-points
    uz = 0.5*(np.roll(uz,1,0) + uz) #This is at the lower-left cell corner
    by = mit.ddy(b,y) #This is at v-points
    by = 0.5*(by[:,:,0:zlen-1] + by[:,:,1:zlen]) #This is below v-points
    by = 0.5*(np.roll(by,1,1) + by) #This is at the lower-left cell corner
    w_exists =  isinstance(w, np.ndarray)
    if not w_exists:
        pv2 = (uz)*by
    else:
        wx = mit.ddx(w,x) #This is below the lower-left hand corner
        pv2 = (uz-wx)*by



    return pv2
Ejemplo n.º 4
0
def rib_calc(b,f,x,y,z):
    """rib_calc(b,f,xy,,z) caclulate the balanced Richardson number fN^2  |/nabla b|^2/f"""

    zlen = len(z)
    n2 = n2p(b,z) #This is at the lower-left cell corner
    bx = mit.ddx(b,x) #This is on u-points
    bx = 0.5*(bx[:,:,0:zlen-1] + bx[:,:,1:zlen]) #This is below u-points
    bx = 0.5*(np.roll(bx,1,0) + bx) #This is at the lower-left cell corner
    by = mit.ddy(b,y) #This is at v-points
    by = 0.5*(by[:,:,0:zlen-1] + by[:,:,1:zlen]) #This is below v-points
    by = 0.5*(np.roll(by,1,1) + by) #This is at the lower-left cell corner
    #import matplotlib.pyplot as plt
    #fig, ax = plt.subplots()
    #cm = ax.pcolormesh(n2[:,0,:])
    #cbar = plt.colorbar(cm)

    plt.show()
    grad_b_squared = bx**2 + by**2
    rib = (f**2) * n2/grad_b_squared
    return rib