예제 #1
0
def n2p(b,z):
    """Calculate n2 as part of PV.
    N2 is at the bottom of the lower-left corner of the first cell
    at the same depth as w points. This function does not add n2 to
    the dgl output array"""
    n2 = n2_calc(b,z)
    n2 = mit.four_cell_average(n2)
    return n2
예제 #2
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