Beispiel #1
0
    def movie(self):
        import matplotlib as mpl
        mpl.rcParams['axes.labelcolor'] = 'white'
        pl.close(1)
        pl.figure(1, (8, 4.5), facecolor='k')
        miv = np.ma.masked_invalid
        figpref.current()
        jd0 = pl.date2num(dtm(2005, 1, 1))
        jd1 = pl.date2num(dtm(2005, 12, 31))
        mp = projmaps.Projmap('glob')
        x, y = mp(self.llon, self.llat)
        for t in np.arange(jd0, jd1):
            print pl.num2date(t)
            self.load(t)

            pl.clf()
            pl.subplot(111, axisbg='k')
            mp.pcolormesh(x,
                          y,
                          miv(np.sqrt(self.u**2 + self.v**2)),
                          cmap=cm.gist_heat)
            pl.clim(0, 1.5)
            mp.nice()
            pl.title(
                '%04i-%02i-%02i' % (pl.num2date(t).year, pl.num2date(t).month,
                                    pl.num2date(t).day),
                color='w')
            pl.savefig('/Users/bror/oscar/norm/%03i.png' % t,
                       bbox_inches='tight',
                       facecolor='k',
                       dpi=150)
Beispiel #2
0
 def movie(self):
     import matplotlib as mpl
     mpl.rcParams['axes.labelcolor'] = 'white'
     pl.close(1)
     pl.figure(1,(8,4.5),facecolor='k')
     miv = np.ma.masked_invalid
     figpref.current()
     jd0 = pl.date2num(dtm(2005,1,1))
     jd1 = pl.date2num(dtm(2005,12,31))
     mp = projmaps.Projmap('glob')
     x,y = mp(self.llon,self.llat)
     for t in np.arange(jd0,jd1):
         print pl.num2date(t)
         self.load(t)
     
         pl.clf()
         pl.subplot(111,axisbg='k')
         mp.pcolormesh(x,y,
                       miv(np.sqrt(self.u**2 +self.v**2)),
                       cmap=cm.gist_heat)
         pl.clim(0,1.5)
         mp.nice()
         pl.title('%04i-%02i-%02i' % (pl.num2date(t).year,
                                      pl.num2date(t).month,
                                      pl.num2date(t).day),
                  color='w')
         pl.savefig('/Users/bror/oscar/norm/%03i.png' % t,
                    bbox_inches='tight',facecolor='k',dpi=150)
Beispiel #3
0
    def plot_onereg(self, regid):
        """Plot mintime of connectivity for one individual region"""
        tomat = self.llat * np.nan
        for i,v in enumerate(self.mintmat[1:,regid]):
            tomat[self.regmat==(i+1)] = v
        frmat = self.llat * np.nan
        for i,v in enumerate(self.mintmat[regid,1:]):
            frmat[self.regmat==(i+1)] = v
        djtk,lim = djdticks(max(np.nanmax(tomat), np.nanmax(frmat)))
        figpref.current()
        pl.close(1)
        fig = pl.figure(1,(8,8))
        pl.clf()
        pl.suptitle("Connectivity for region %i" % regid)

        mask = self.regmat == regid
        x,y = self.gcm.mp(self.llon[mask], self.llat[mask])
        pl.subplots_adjust(hspace=0, top=0.95,bottom = 0.15)

        pl.subplot(2,1,1, axisbg="0.8")
        self.gcm.pcolor(frmat, cmap=WRY(), rasterized=True)
        pl.clim(0,lim)
        self.gcm.mp.text(70,60,'Time from region')
        self.gcm.mp.scatter(x,y,5,'b')

        pl.subplot(2,1,2, axisbg="0.8")
        self.gcm.pcolor(tomat, cmap=WRY(), rasterized=True)
        pl.clim(0,lim)
        self.gcm.mp.text(70,60,'Time to region')
        self.gcm.mp.scatter(x,y,5,'b')

        if 'mycolor' in sys.modules:
            mycolor.freecbar([0.2,0.12,0.6,0.025], djtk, cmap=WRY())
        pl.savefig('figs/onereg_%02i_%02i_%06i.png' %
                   (self.regdi, self.regdj, regid))
Beispiel #4
0
 def plot_mintmin(self, regdij):
     """ Plot the min time for connection between regions """
     fname = 'data/mintime_ecco025ecco025_%02i_%02i.npz'
     regmat  = np.load(fname % (regdij,regdij))['regmat'].astype(np.float)
     mintmat = np.load(fname % (regdij,regdij))['mintmat'].astype(np.float)
     figpref.current()
     pl.close(1)
     fig = pl.figure(1,(8,9))
     pl.subplot(2,1,1, axisbg="0.7")
     regmat[regmat==0] = np.nan
     self.gcm.pcolor(regmat)
     pl.subplot(2,1,2)
     pl.pcolormesh(miv(mintmat))
     pl.clim(0,365*3)
     pl.colorbar()
     pl.suptitle('reg size = %i gridcells' % regdij)
     pl.savefig('figs/mintmin_%03i.png' % regdij)
Beispiel #5
0
    def plot_numreg(self, maxdays, regdi=5, regdj=5):
        """Plot number of regions connected to each region"""
        if not hasattr(self,'mintmat'):
            self.read_mintmat(self,regdi=regdi, regdj=regdj)

        def calc_numregmat(loc="to"):
            axis = 1 if loc is "to" else 0
            numreg = self.regmat[:] * np.nan
            numvec = np.sum(np.where(self.mintmat<=maxdays, 1, 0), axis=axis)
            for r,n in zip(np.arange(1,self.nreg+1), numvec[1:]):
                numreg[self.regmat==r] = n
            return numreg
    
        numregfrom = calc_numregmat("from")
        numregto   = calc_numregmat("to")
        lim = max(np.nanmax(numregto,   axis=None),
                  np.nanmax(numregfrom, axis=None))

        figpref.current()
        pl.close(1)
        fig = pl.figure(1,(8,11))
        pl.clf()
        pl.suptitle("Connectivity after %i days" % maxdays)

        pl.subplots_adjust(hspace=0, top=0.95,bottom = 0.15)
        pl.subplot(3,1,1, axisbg="0.8")
        self.gcm.pcolor(miv(numregfrom), cmap=WRY(), rasterized=True)
        pl.clim(0,lim)
        self.gcm.mp.text(70,60,'Number of source regions')
        
        pl.subplot(3,1,2, axisbg="0.8")
        self.gcm.pcolor(miv(numregto), cmap=WRY(), rasterized=True)
        pl.clim(0,lim)
        self.gcm.mp.text(70,60,'Number of sink regions')

        pl.subplot(3,1,3, axisbg="0.8")
        self.gcm.pcolor(miv(numregto-numregfrom), cmap=GBRY(), rasterized=True)
        pl.clim(-lim,lim)
        self.gcm.mp.text(70,60,'Difference, sinks-sources')

        if 'mycolor' in sys.modules:
            mycolor.freecbar([0.2,0.12,0.6,0.025],[-lim,-lim/2,0,lim/2,lim],
                             cmap=GBRY())
        pl.savefig('data/numreg_%03i.pdf' % maxdays)