Exemplo n.º 1
0
def inertial_period(lat):
    r"""
    Calculate the inertial period as:

    .. math::
        Ti = \\frac{2\\pi}{f} = \\frac{T_{sd}}{2\\sin\\phi}

    Parameters
    ----------
    lat : array_like
          latitude in decimal degress north [-90..+90]

    Returns
    -------
    Ti : array_like
         period in seconds

    Examples
    --------
    >>> import seawater.extras.sw_extras as swe
    >>> lat = 30
    >>> swe.inertial_period(lat)/3600
    23.934472399219292

    Modifications: Filipe Fernandes, 2010
                   10-01-26. Filipe Fernandes, first version.
    """
    # Convert input to numpy arrays
    lat = np.asarray(lat)

    Ti = 2 * np.pi / sw.cor(lat)

    return Ti
Exemplo n.º 2
0
filename = "/home/rsoutelino/phd/fm/BC-NBUC_FM.mat"
fm = FeatureModel(filename)
depth = np.arange(0, 1520, 20)


# getting the rho profile in the core of the jets at 19 S
lon0, lat0 = -37.411, -19.015 # as result from a ginput
line, col = near2d(fm.lon, fm.lat, lon0, lat0)

temp = fm.temp[:, line, col]
salt = fm.salt[:, line, col]
rho  = sw.dens(salt, temp, depth)
N2   = brunt_vaissala(rho, depth)
H    = depth.max()
f    = sw.cor(lat0)
R    = 100000 # abrolhos bank: ~100km
Bu   = burger(N2, H, f, R)

#plt.figure()
#plt.plot(Bu, -depth)
#plt.grid()
#plt.title("Burger Number Profile")
#plt.show()

fBC = near(depth, 200)[0][0]
BuBC = Bu[:fBC].mean()
BuNBUC = Bu[fBC:].mean()

print "\n The Burger Number for BC is: %s \n" %str(BuBC)
print "\n The Burger Number for NBUC is: %s \n" %str(BuNBUC)
Exemplo n.º 3
0
vd = np.copy(ud)


k = 0
for i in range(0,time.size,24):
    ud[:,:,k] = u[:,:,i:i+24].mean(axis=2)
    vd[:,:,k] = v[:,:,i:i+24].mean(axis=2)
    if i == 0:
        timei = datetime(time[i].year,time[i].month,time[i].day)
    else:
        timei = np.append(timei,datetime(time[i].year,time[i].month,time[i].day))
    k = k+1

umy,umx,ut = sp.gradient(ud,dx,dy,dt)
vmy,vmx,vt = sp.gradient(vd,dx,dy,dt)
f = sw.cor(lat)
ix,jx,kx = ut.shape
f = np.repeat(f,kx).reshape(ix,jx,kx)
zeta = (vmx-umy)/np.abs(f)
zeta = np.ma.masked_array(zeta,np.abs(zeta)>10.)

#
# plotting
#

xgm1,ygm1 = m(data['lon'],data['lat'])

dec=2

for i in range(timei.size):
Exemplo n.º 4
0
filename = mainpath + "phd/fm/BC-NBUC_FM.mat"
fm = FeatureModel(filename)

# BURGER NUMBER ################

# getting the rho profile in the core of the jets at 19 S
lon0, lat0 = -37.411, -19.015  # as result from a ginput
line, col = romslab.near2d(fm.lon, fm.lat, lon0, lat0)

temp = fm.temp[:, line, col]
salt = fm.salt[:, line, col]
depth = fm.depth
rho = sw.dens(salt, temp, depth)
N2 = brunt_vaissala(rho, depth)
H = depth.max()
f = sw.cor(lat0)
R = 100000  # abrolhos bank: ~100km (the most wide one)
Bu = compute_burger(N2, H, f, R)

fBC = romslab.near(depth, 300)[0][0]
BuBC = Bu[:fBC].mean()
BuNBUC = Bu[fBC:].mean()

# ROSSBY NUMBER ################

fNBUC = romslab.near(depth, 400)[0][0]
f0 = sw.cor(fm.lat.mean())
L = 150000
Ubc = np.sqrt(fm.u[0, ...].max()**2 + fm.v[0, ...].max()**2)
Unbuc = np.sqrt(fm.u[fNBUC, ...].max()**2 + fm.v[fNBUC, ...].max()**2)
Exemplo n.º 5
0
fm = FeatureModel(filename)


# BURGER NUMBER ################

# getting the rho profile in the core of the jets at 19 S
lon0, lat0 = -37.411, -19.015 # as result from a ginput
line, col = romslab.near2d(fm.lon, fm.lat, lon0, lat0)

temp = fm.temp[:, line, col]
salt = fm.salt[:, line, col]
depth = fm.depth
rho  = sw.dens(salt, temp, depth)
N2   = brunt_vaissala(rho, depth)
H    = depth.max()
f    = sw.cor(lat0)
R    = 100000 # abrolhos bank: ~100km (the most wide one)
Bu   = compute_burger(N2, H, f, R)

fBC = romslab.near(depth, 300)[0][0]
BuBC = Bu[:fBC].mean()
BuNBUC = Bu[fBC:].mean()

# ROSSBY NUMBER ################

fNBUC = romslab.near(depth, 400)[0][0]
f0 = sw.cor(fm.lat.mean())
L = 150000 
Ubc   = np.sqrt(fm.u[0,...].max()**2 + fm.v[0,...].max()**2)
Unbuc = np.sqrt(fm.u[fNBUC,...].max()**2 + fm.v[fNBUC,...].max()**2)
Exemplo n.º 6
0
test_print("eta_SA_SA") #FIXME: diffs are not found in the original
test_print("eta_SA_CT") #FIXME: diffs are not found in the original
test_print("eta_CT_CT") #FIXME: diffs are not found in the original

#pt_SA,  pt_CT = gsw.pt_first_derivatives(SA_chck_cast, CT_chck_cast)
#test_print("pt_SA")
#test_print("pt_CT")

#pt_SA_SA, pt_SA_CT, pt_CT_CT = gsw.pt_second_derivatives(SA_chck_cast, CT_chck_cast)
#test_print("pt_SA_SA")
#test_print("pt_SA_CT")
#test_print("pt_CT_CT")

""" planet earth properties """
from seawater.csiro import cor
f = cor(gsw_cv.lat_chck_cast)
test_print("f")

grav = gsw.grav(gsw_cv.lat_chck_cast, gsw_cv.p_chck_cast)
test_print("grav")

distance = gsw.distance(gsw_cv.long_chck_cast, gsw_cv.lat_chck_cast, gsw_cv.p_chck_cast)
test_print("distance") #FIXME: diffs are not found in the original

""" Absolute Salinity from direct density measurements:- a laboratory function """
SA_from_rho = gsw.SA_from_rho(rho, gsw_cv.t_chck_cast, gsw_cv.p_chck_cast)
test_print("SA_from_rho")

#sigma0_pt = gsw.sigma0_pt(SA_chck_cast, pt0)
#test_print("sigma0_pt")
    dist,ang = sw.dist(loni[:,300],lati[:,300])
    dy = dist.mean()   # [km], about 1 km

    files = sorted(glob.glob(data_path), key=os.path.getmtime) 
    
    Eetaw = np.zeros((lats.size,lons.size,np.array(files).size))
    Eetawf = np.zeros((lats.size,lons.size,np.array(files).size))

    Eugw = np.zeros((lats.size,lons.size,np.array(files).size))
    Eugwf = np.zeros((lats.size,lons.size,np.array(files).size))

    Evgw = np.zeros((lats.size,lons.size,np.array(files).size))
    Evgwf = np.zeros((lats.size,lons.size,np.array(files).size))

    # constant for geostrophic vel.
    f = np.repeat(sw.cor(lats),lons.size).reshape(lats.size,lons.size)
    C = 9.81/f

    kk = 0
    for file in sorted(files):
        
        data = np.load(file)
        print kk

        ix,jx,kx = data['eta'].shape
        etai = np.zeros((lats.size,lons.size,kx))
        ugi = np.zeros((lats.size,lons.size,kx))
        vgi = np.zeros((lats.size,lons.size,kx))

        # mask bad data
        ETA = data['eta']