Ejemplo n.º 1
0
def nc_div(nc, tidx, grd=None):
    if grd is None:
        grd = nc_grid(nc)
    nc = Dataset(nc)
    u = nc.variables['u'][tidx]
    v = nc.variables['v'][tidx]
    return ( (diff(u, axis=-1)/diff(grd.x_u, axis=-1))[...,1:-1,:] + \
             (diff(v, axis=-2)/diff(grd.y_v, axis=-2))[...,:,1:-1] )
Ejemplo n.º 2
0
def nc_curl(nc, tidx, grd=None):
    if grd is None:
        grd = nc_grid(nc)
    nc = Dataset(nc)
    u = nc.variables['u'][tidx]
    v = nc.variables['v'][tidx]
    return ( diff(v, axis=-1)/diff(grd.x_v, axis=-1) - \
             diff(u, axis=-2)/diff(grd.y_u, axis=-2) )
Ejemplo n.º 3
0
def nc_div(nc, tidx, grd=None):
    if grd is None:
        grd = nc_grid(nc)
    nc = Dataset(nc)
    u = nc.variables['u'][tidx]
    v = nc.variables['v'][tidx]
    return ( (diff(u, axis=-1)/diff(grd.x_u, axis=-1))[...,1:-1,:] + \
             (diff(v, axis=-2)/diff(grd.y_v, axis=-2))[...,:,1:-1] )
Ejemplo n.º 4
0
def nc_curl(nc, tidx, grd=None):
    if grd is None:
        grd = nc_grid(nc)
    nc = Dataset(nc)
    u = nc.variables['u'][tidx]
    v = nc.variables['v'][tidx]
    return ( diff(v, axis=-1)/diff(grd.x_v, axis=-1) - \
             diff(u, axis=-2)/diff(grd.y_u, axis=-2) )
Ejemplo n.º 5
0
def nc_pstrain(nc, tidx, grd=None):
    if grd is None:
        grd = nc_grid(nc)
    nc = Dataset(nc)
    u = nc.variables['u'][tidx]
    v = nc.variables['v'][tidx]
    ex = (diff(u, axis=-1) / diff(grd.x_u, axis=-1))[..., 1:-1, :]
    ey = (diff(v, axis=-2) / diff(grd.y_v, axis=-2))[..., :, 1:-1]
    gamma = shrink ( diff(u, axis=-2)/diff(grd.y_u, axis=-2) + \
                     diff(v, axis=-1)/diff(grd.x_v, axis=-1)  , ex.shape)
    return 0.5*(ex + ey) + sqrt( (0.5*(ex - ey))**2 + (0.5*gamma)**2 ), \
           0.5*(ex + ey) - sqrt( (0.5*(ex - ey))**2 + (0.5*gamma)**2 )
Ejemplo n.º 6
0
def nc_pstrain(nc, tidx, grd=None):
    if grd is None:
        grd = nc_grid(nc)
    nc = Dataset(nc)
    u = nc.variables['u'][tidx]
    v = nc.variables['v'][tidx]
    ex = (diff(u, axis=-1)/diff(grd.x_u, axis=-1))[...,1:-1,:]
    ey = (diff(v, axis=-2)/diff(grd.y_v, axis=-2))[...,:,1:-1]
    gamma = shrink ( diff(u, axis=-2)/diff(grd.y_u, axis=-2) + \
                     diff(v, axis=-1)/diff(grd.x_v, axis=-1)  , ex.shape)
    return 0.5*(ex + ey) + sqrt( (0.5*(ex - ey))**2 + (0.5*gamma)**2 ), \
           0.5*(ex + ey) - sqrt( (0.5*(ex - ey))**2 + (0.5*gamma)**2 )