Пример #1
0
    def __init__(self,projname, casename="", datadir="", datafile="", ormdir=""):
        self.projname = projname
        if len(casename) == 0:
            self.casename = projname
        else:
            self.casename = casename
        self.datadir = datadir
        if ormdir:
            self.ormdir = ormdir
        else:
            self.ormdir = os.getenv('ORMDIR')

        self.isobase = datetime.datetime(2004,1,1)
        
        self.conn = psycopg2.connect (host="localhost", database="partsat")
        self.c = self.conn.cursor()
        self.tablename = ("%s%s" % (projname ,casename)).lower()

        self.nlgrid = nlt.parse('/%s/projects/%s/%s_grid.in' %
                            (self.ormdir,self.projname,self.projname))
        self.nlrun = nlt.parse('/%s/projects/%s/%s_run.in' %
                            (self.ormdir,self.projname,self.casename))
        if datadir:
            self.datadir = datadir
        else:
            self.datadir = self.nlrun.outDataDir
        if datafile:
            self.datafile = datafile
        else:
            self.datafile=self.nlrun.outDataFile

        self.base_iso = pl.date2num(dtm(
             self.nlgrid.baseYear,
             self.nlgrid.baseMon,
             self.nlgrid.baseDay))-1
        self.imt = self.nlgrid.IMT
        self.jmt = self.nlgrid.JMT

        if projname == 'oscar':
            import oscar
            self.gcm = oscar.Oscar()
        elif projname=="topaz":
            griddir  = '/projData/TOPAZ/1yr_1d/'
            gridname = '/22450101.ocean_daily.nc' 
            g = pycdf.CDF(griddir + gridname)
            lon = g.var('xu_ocean')[:]
            lat = g.var('yu_ocean')[:]
            #self.lon[self.lon<-180] = self.lon[self.lon<-180] + 360
            self.llon,self.llat = np.meshgrid(lon, lat)
        elif projname=="casco":
            import casco
            self.gcm = casco.GCM()
            self.region = "casco"
            self.base_iso = pl.date2num(dtm(2004,1,1))
        elif projname=="gompom":
            n = pycdf.CDF(griddir + 'grid.cdf')
            self.llon = n.var('x')[:]    
            self.llat = n.var('y')[:]
            self.base_iso = pl.date2num(dtm(2004,1,1))
        elif projname=="jplSCB":
            import jpl
            self.gcm = jpl.SCB()
            self.region = "scb"
            self.base_iso = pl.date2num(dtm(2001,1,1))-3./24
        elif projname=="jplNow":
            import jpl
            self.gcm = jpl.NOW()
            self.region = "scb"
        elif projname=="rutgersNWA":
            import rutgers
            self.gcm = rutgers.NWA()
            self.region = "nwa_small"
            
        if hasattr(self,'gcm'):
            self.gcm.add_landmask()
            self.landmask = self.gcm.landmask
            self.llon = self.gcm.llon
            self.llat = self.gcm.llat
Пример #2
0
 def parse(od, pn, cn, sfx):
     gridfile = '/%s/projects/%s/%s_%s.in' % (od, pn, cn, sfx)
     if not os.path.isfile(gridfile):
         raise IOError("Can't find the file %s" % gridfile)
     return nlt.parse(gridfile)
Пример #3
0
 def parse(od, pn, cn, sfx):
     gridfile = "/%s/projects/%s/%s_%s.in" % (od, pn, cn, sfx)
     if not os.path.isfile(gridfile):
         raise IOError("Can't find the file %s" % gridfile)
     return nlt.parse(gridfile)