Пример #1
0
    def image(self,var,time,level=0,clip=None,mono=False,illuminate=None):
        """Plot a colour map.

        var: CFvariable
        time: time slice
        level: horizontal slice
        clip: only display data where clip>0.
        mono: convert colour to mono
        illuminate: azimuth of light source (default None)
        """
        
        clipped = False
        if clip in ['topg','thk','usurf','is'] :
            cvar = CFvariable(var.cffile,clip)
            self.clip(cvar.getGMTgrid(time),0.1)
            clipped = True
        if mono:
            args="-M"
        else:
            args=""

        illu = False
        if illuminate in ['topg','thk','usurf','is'] :
            illu = True
            illu_var = CFvariable(var.cffile,illuminate)
            illu_grd = illu_var.getGMTgrid(time,velogrid=var.isvelogrid)
            illu_arg = "=1 -G.__illu.grd -A0 -Ne0.6"
            gridcommand('grdgradient',illu_arg,illu_grd,verbose=self.verbose)
            args = "%s -I.__illu.grd"%args
            
        PyGMT.AreaXY.image(self,var.getGMTgrid(time,level=level),var.colourmap.cptfile,args=args)
        if clipped:
            self.unclip()
        if illu:
            os.remove('.__illu.grd')
Пример #2
0
    def land(self,time,grey='180',illuminate=None):
        """Plot area above sea level.

        time: time slice
        grey: grey value."""


        args=""

        cvar = CFvariable(self.file,'topg')
        cvar_grd = cvar.getGMTgrid(time)
        if illuminate in ['topg','thk','is'] :
            illu_arg = "=1 -G.__illu.grd -A0 -Ne0.6"
            gridcommand('grdgradient',illu_arg,cvar_grd,verbose=self.verbose)
            args = "%s -I.__illu.grd"%args

        # create colour map
        cmap = open('.__grey.cpt','w')
        cmap.write('-15000 255     255     255  0 255     255     255\n')
        cmap.write('0 %s %s %s 10000  %s %s %s \n'%(grey,grey,grey,grey,grey,grey))
        cmap.close()

        
        PyGMT.AreaXY.image(self,cvar_grd,'.__grey.cpt',args=args)
        os.remove('.__grey.cpt')
Пример #3
0
    def land(self,time,grey='180',illuminate=None):
        """Plot area above sea level.

        time: time slice
        grey: grey value."""


        args=""

        cvar = CFvariable(self.file,'topg')
        cvar_grd = cvar.getGMTgrid(time)
        if illuminate in ['topg','thk','is'] :
            illu_file = tempfile.NamedTemporaryFile(suffix='.grd')
            illu_arg = "=1 -G%s -A0 -Ne0.6"%(illu_file.name)
            gridcommand('grdgradient',illu_arg,cvar_grd,verbose=self.verbose)
            args = "%s -I%s"%(args,illu_file.name)

        # create colour map
        cmap = tempfile.NamedTemporaryFile(suffix='.cpt')
        cmap.write('-15000 255     255     255  0 255     255     255\n')
        cmap.write('0 %s %s %s 10000  %s %s %s \n'%(grey,grey,grey,grey,grey,grey))
        cmap.flush()

        
        PyGMT.AreaXY.image(self,cvar_grd,cmap.name,args=args)
        cmap.close()
Пример #4
0
    def land(self,time,grey='240'):
        """Plot area above sea level.

        time: time slice
        grey: grey value."""

        cvar = CFvariable(self.file,'topg')
        self.clip(cvar.getGMTgrid(time),0.1)
        self.line('-W -L -G%s'%grey,[self.ll[0],self.ur[0],self.ur[0],self.ll[0]],[self.ll[1],self.ll[1],self.ur[1],self.ur[1]])
        self.unclip()
Пример #5
0
    def extent(self, args, time, cffile=None, cntrtype="c"):
        """Plot ice extent.

        args: further arguments
        time: time slice
        cntrtype: contourtype, c for normal contour, a for annotated"""

        if cffile == None:
            cffile = self.file
        extent = CFvariable(cffile, "thk").getGMTgrid(time)
        extent.data = extent.data - 0.1 + cffile.time(time)
        PyGMT.AreaXY.contour(self, extent, [cffile.time(time)], args, cntrtype)
Пример #6
0
    def image(self,var,time,level=0,clip=None,mono=False):
        """Plot a colour map.

        var: CFvariable
        time: time slice
        level: horizontal slice
        clip: only display data where clip>0.
        mono: convert colour to mono
        """
        
        clipped = False
        if clip in ['topg','thk','usurf'] :
            cvar = CFvariable(var.cffile,clip)
            self.clip(cvar.getGMTgrid(time),0.1)
            clipped = True
        if mono:
            args="-M"
        else:
            args=""
        PyGMT.AreaXY.image(self,var.getGMTgrid(time,level=level),var.colourmap.cptfile,args=args)
        if clipped:
            self.unclip()
Пример #7
0
    def raw_image(self, cffile, time, grid, colourmap, isvelogrid=False, clip=None, mono=False, illuminate=None):
        """Plot a GMT grid
        
        cffile: cffile
        time: time slice
        grid: is the GMT grid to be plotted
        isvelogrid: boolean whether we are plotting on velogrid
        colourmap: is the colourmap to be used
        clip: only display data where clip>0.
        mono: convert colour to mono
        illuminate: azimuth of light source (default None)
        """

        clipped = False
        if clip in ["topg", "thk", "usurf", "is"]:
            cvar = CFvariable(cffile, clip)
            self.clip(cvar.getGMTgrid(time), 0.1)
            clipped = True
        if mono:
            args = "-M"
        else:
            args = ""

        illu = False
        if illuminate in ["topg", "thk", "usurf", "is"]:
            illu = True
            illu_var = CFvariable(cffile, illuminate)
            illu_grd = illu_var.getGMTgrid(time, velogrid=isvelogrid)
            illu_file = tempfile.NamedTemporaryFile(suffix=".grd")
            illu_arg = "=bf -G%s -A0 -Ne0.6" % illu_file.name
            gridcommand("grdgradient", illu_arg, illu_grd, verbose=self.verbose)
            args = "%s -I%s" % (args, illu_file.name)

        PyGMT.AreaXY.image(self, grid, colourmap, args=args)
        if clipped:
            self.unclip()
        if illu:
            illu_file.close()
Пример #8
0
    def land(self, time, grey="180", illuminate=None):
        """Plot area above sea level.

        time: time slice
        grey: grey value."""

        args = ""

        cvar = CFvariable(self.file, "topg")
        cvar_grd = cvar.getGMTgrid(time)
        if illuminate in ["topg", "thk", "is"]:
            illu_arg = "=1 -G.__illu.grd -A0 -Ne0.6"
            gridcommand("grdgradient", illu_arg, cvar_grd, verbose=self.verbose)
            args = "%s -I.__illu.grd" % args

        # create colour map
        cmap = open(".__grey.cpt", "w")
        cmap.write("-15000 255     255     255  0 255     255     255\n")
        cmap.write("0 %s %s %s 10000  %s %s %s \n" % (grey, grey, grey, grey, grey, grey))
        cmap.close()

        PyGMT.AreaXY.image(self, cvar_grd, ".__grey.cpt", args=args)
        os.remove(".__grey.cpt")
Пример #9
0
    def land(self, time, grey="180", illuminate=None):
        """Plot area above sea level.

        time: time slice
        grey: grey value."""

        args = ""

        cvar = CFvariable(self.file, "topg")
        cvar_grd = cvar.getGMTgrid(time)
        if illuminate in ["topg", "thk", "is"]:
            illu_file = tempfile.NamedTemporaryFile(suffix=".grd")
            illu_arg = "=bf -G%s -A0 -Ne0.6" % (illu_file.name)
            gridcommand("grdgradient", illu_arg, cvar_grd, verbose=self.verbose)
            args = "%s -I%s" % (args, illu_file.name)

        # create colour map
        cmap = tempfile.NamedTemporaryFile(suffix=".cpt")
        cmap.write("-15000 255     255     255  0 255     255     255\n")
        cmap.write("0 %s %s %s 10000  %s %s %s \n" % (grey, grey, grey, grey, grey, grey))
        cmap.flush()

        PyGMT.AreaXY.image(self, cvar_grd, cmap.name, args=args)
        cmap.close()