예제 #1
0
파일: invert.py 프로젝트: jinbow/isQG
def invertit(filein, fileout):
    from isqg import isqg_data
    from scipy.io import loadmat, savemat
    
    
    d = isqg_data()
    
    f = loadmat(filein,squeeze_me=True)
    
    for key in f.keys():
        if key[:2]!='__':
            print "read ",key
            setattr(d,key,f[key])
    
    d.solve_sqg()
    d.solve_psii()
    
    
    outvar = ['us','vs','ui','vi','ut','vt','psis','psii','psit','ssh','ssd',
              'rhos','rhoi','rho0','f0','z','zf','zc',
              'lon','lat','vorticity']
    
    dout = {}
    for ov in outvar:
        dout[ov] = getattr(d,ov)
    
    savemat(fileout, dout)
예제 #2
0
파일: invert.py 프로젝트: whigg/isQG
def invertit(filein, fileout):
    from isqg import isqg_data
    from scipy.io import loadmat, savemat

    d = isqg_data()

    f = loadmat(filein, squeeze_me=True)

    for key in f.keys():
        if key[:2] != '__':
            print "read ", key
            setattr(d, key, f[key])

    d.solve_sqg()
    d.solve_psii()

    outvar = [
        'us', 'vs', 'ui', 'vi', 'ut', 'vt', 'psis', 'psii', 'psit', 'ssh',
        'ssd', 'rhos', 'rhoi', 'rho0', 'f0', 'z', 'zf', 'zc', 'lon', 'lat',
        'vorticity'
    ]

    dout = {}
    for ov in outvar:
        dout[ov] = getattr(d, ov)

    savemat(fileout, dout)
예제 #3
0
 import numpy as np
 import pylab as plt
 import isqg
 
 lon = np.linspace(0,10,50)
 lat = np.linspace(30,40,50)
 x,y = isqg.lonlat2xy(lon,lat)
 radi = 1e5 # a gaussian eddy with 200km radius
 gauss = lambda x,y,r: np.exp(- ( 
                  ( x-x.mean() )**2 + ( y-y.mean() )**2 
                    )  /2./r**2 )
 ssd = 0.1*gauss(x,y,radi)
 z = np.linspace(0,-2000,30)
 n2 = np.ones_like(z)* 1e-5
 
 d = isqg.isqg_data(n2=n2,z=z,rhosorg=ssd-ssd.mean(),lon=lon,lat=lat,rho0=1035.)
 ssda=ssd-ssd.mean()
 ssdm = np.ones_like(ssd)*ssd.mean()
 rhom = isqg.N2rho(ssdm, isqg.twopave(n2), np.diff(z))
 d.bottomboundary='psi=0'
 d.solve_sqg()
 d.ssh = np.roll(1.2*d.psis[0,:,:]*d.f0/9.81,5,axis=1)
 d.solve_psii()
         
 ssda = ssda+ssdm
 d.rhos = d.rhos+rhom
 
 plt.figure()
 plt.subplot(221)
 plt.contourf(ssda,levels=np.arange(-0.06,0.11,0.02))
 plt.colorbar()
예제 #4
0
파일: optimize.py 프로젝트: whigg/isQG
if __name__ == '__main__':
    import numpy as np
    import pylab as plt
    import isqg

    lon = np.linspace(0, 10, 50)
    lat = np.linspace(30, 40, 50)
    x, y = isqg.lonlat2xy(lon, lat)
    radi = 1e5  # a gaussian eddy with 200km radius
    gauss = lambda x, y, r: np.exp(-((x - x.mean())**2 +
                                     (y - y.mean())**2) / 2. / r**2)
    ssd = 0.1 * gauss(x, y, radi)
    z = np.linspace(0, -2000, 30)
    n2 = np.ones_like(z) * 1e-5

    d = isqg.isqg_data(n2=n2, z=z, lon=lon, lat=lat, rho0=1035.)
    ssda = ssd - ssd.mean()
    ssdm = np.ones_like(ssd) * ssd.mean()
    rhom = isqg.N2rho(ssdm, isqg.twopave(n2), np.diff(z))
    d.bottomboundary = 'psi=0'
    d.solve_sqg()
    d.ssh = np.roll(1.2 * d.psis[0, :, :] * d.f0 / 9.81, 5, axis=1)
    d.solve_psii()

    ssda = ssda + ssdm
    d.rhos = d.rhos + rhom

    plt.figure()
    plt.subplot(221)
    plt.contourf(ssda, levels=np.arange(-0.06, 0.11, 0.02))
    plt.colorbar()