예제 #1
0
src=sys.argv[1]
if os.path.exists("test_vcs_dump_json.json"):
    os.remove("test_vcs_dump_json.json")

b = vcs.createboxfill("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createisofill("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createisoline("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createmeshfill("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createoneD("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createfillarea("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createtext("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createline("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createmarker("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createtemplate("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createprojection("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")

assert(filecmp.cmp("test_vcs_dump_json.json",src))


예제 #2
0
import cdms2
import vtk
import os
import MV2

bg = not args.show

x=vcs.init()
x.setantialiasing(0)
x.drawlogooff()
if bg:
  x.setbgoutputdimensions(1200,1091,units="pixels")
x.setcolormap("rainbow")
exec("gm=vcs.create%s()" % gm_type)
if args.projtype != "default":
    p = vcs.createprojection()
    try:
        ptype = int(args.projtype)
    except:
        ptype = args.projtype
    p.type = ptype
    gm.projection = p
nm_xtra=""
xtra = {}
if args.lat1!=args.lat2:
    if args.rg:
        if args.flip:
            gm.datawc_y1=args.lat2
            gm.datawc_y2=args.lat1
            nm_xtra+="_gmflip"
        else:
예제 #3
0
    def basicGm(self,
                gm_type,
                projtype="default",
                lat1=0,
                lat2=0,
                lon1=0,
                lon2=0,
                rg=False,
                flip=False,
                zero=False,
                transparent=False,
                mask=False,
                bigvalues=False):

        self.x.clear()
        self.x.setcolormap(None)
        cdms2.tvariable.TransientVariable.variable_count = 1
        loc = locals()
        exec("gm=vcs.create%s()" % gm_type)
        gm = loc["gm"]
        if projtype != "default":
            p = vcs.createprojection()
            try:
                ptype = int(projtype)
            except BaseException:
                ptype = projtype
            p.type = ptype
            gm.projection = p
        nm_xtra = ""
        xtra = {}
        if lat1 != lat2:
            if rg:
                if flip:
                    gm.datawc_y1 = lat2
                    gm.datawc_y2 = lat1
                    nm_xtra += "_gmflip"
                else:
                    gm.datawc_y1 = lat1
                    gm.datawc_y2 = lat2
            xtra["latitude"] = (lat1, lat2)
            if lat1 < 0:
                nm_xtra += "_SH"
            else:
                nm_xtra += "_NH"
        if lon1 != lon2:
            if rg:
                gm.datawc_x1 = lon1
                gm.datawc_x2 = lon2
            xtra["longitude"] = (lon1, lon2)
            nm_xtra += "_%i_%i" % (lon1, lon2)
        if rg:
            nm_xtra += "_via_gm"
        if gm_type == "meshfill":
            f = cdms2.open(os.path.join(vcs.sample_data,
                                        'sampleCurveGrid4.nc'))
        else:
            f = self.clt
        if gm_type == "vector":
            u = f("u", **xtra)
            v = f("v", **xtra)
            if mask:
                u = MV2.masked_greater(u, 58.)
            if zero:
                u -= u
                v -= v
        elif gm_type == "meshfill":
            s = f("sample", **xtra)
            if mask:
                s = MV2.masked_less(s, 1150.)
            elif bigvalues:
                s[s < 1150] = 1e40
            if zero:
                s -= s
        else:
            s = f("clt", **xtra)
            if mask:
                s = MV2.masked_greater(s, 78.)
            elif bigvalues:
                s[s > 78] = 1e40
            if gm_type in ["1d", "yxvsx", "xyvsy", "xvsy", "scatter"]:
                s = s(latitude=(20, 20, "cob"),
                      longitude=(112, 112, "cob"),
                      squeeze=1)
                s2 = MV2.sin(s)
                if zero:
                    s2 -= s2
            if zero:
                s -= s

        if bigvalues:
            gm.levels = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1.e36]

        if transparent:
            cmap = self.x.createcolormap()
            for i in range(256):  # tweaks all colors
                cmap.setcolorcell(i, 100., 0, 0, i / 2.55)
            self.x.setcolormap(cmap)
            if gm_type == "vector":
                gm.linecolor = [100, 0, 0, 50.]
            elif gm_type in ["yxvsx", "xyvsy", "yvsx", "scatter", "1d"]:
                gm.linecolor = [100, 0, 0, 50.]
                gm.markercolor = [100, 0, 0, 50.]

        if gm_type == "vector":
            gm.scale = 4.
            self.x.plot(u, v, gm, bg=self.bg)
        elif gm_type in ["scatter", "xvsy"]:
            self.x.plot(s, s2, gm, bg=self.bg)
        else:
            self.x.plot(s, gm, bg=self.bg)
        fnm = "test_vcs_basic_%s" % gm_type.lower()
        if mask:
            fnm += "_masked"
        elif bigvalues:
            fnm += "_bigvalues"
        if projtype != "default":
            fnm += "_%s_proj" % projtype
        if zero:
            fnm += "_zero"
        if transparent:
            fnm += "_transparent"
        fnm += nm_xtra
        self.checkImage(fnm + '.png', threshold=20)
예제 #4
0
import sys,os
import vcs
import sys
import cdms2
import vtk
import os
import MV2
bg = not False
x=vcs.init()

x.setcolormap("rainbow")
gm = vcs.createisoline()

p = vcs.createprojection()

ptype = int('-3')
p.type = ptype
gm.projection = p

xtra = {}
f=cdms2.open(os.path.join(vcs.prefix,'sample_data','clt.nc'))
s=f("clt",**xtra)
s=MV2.masked_greater(s,78.)
x.plot(s,gm,bg=bg)




x.png('test_vcs_basic_isoline_masked_-3_proj.png')
예제 #5
0
    os.remove("test_vcs_dump_json.json")

b = vcs.createboxfill("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createisofill("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createisoline("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createmeshfill("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.create1d("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createfillarea("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createvector("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createtext("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createline("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createmarker("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createtemplate("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createprojection("vcs_instance")
b.script("test_vcs_dump_json", "a")

print "Comparing:", os.path.realpath("test_vcs_dump_json.json"), src
assert (filecmp.cmp("test_vcs_dump_json.json", src))
os.remove("test_vcs_dump_json.json")
예제 #6
0
import vcs, os, filecmp
import vcs, numpy, os, sys
src = sys.argv[1]
if os.path.exists("test_vcs_dump_json.json"):
    os.remove("test_vcs_dump_json.json")

b = vcs.createboxfill("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createisofill("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createisoline("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createmeshfill("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createoneD("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createfillarea("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createtext("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createline("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createmarker("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createtemplate("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createprojection("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")

assert (filecmp.cmp("test_vcs_dump_json.json", src))
예제 #7
0
width, height = P.geometry.split("x")
width = int(width)
height = int(height)
if P.output_type in ["png", "postscript", "pdf"]:
    bg = True
else:
    bg = False
if sys.platform == "darwin":
    W = width * 2
    H = height * 2
else:
    W = width
    H = height
x = vcs.init(geometry=(W, H), bg=bg)

projections = {"default": vcs.createprojection()}
for typ in ["lambert", "mollweide", "robinson", "polar", "orthographic"]:
    p = vcs.createprojection()
    p.type = typ
    projections[typ] = p

gm = vcs.createmeshfill()
gm.datawc_x1 = float(P.lon1)
gm.datawc_x2 = float(P.lon2)
gm.datawc_y1 = float(P.lat1)
gm.datawc_y2 = float(P.lat2)
gm.mesh = P.show_mesh
gm.missing = P.missing_color
gm.projection = projections[P.projection]
gm.colormap = P.colormap
if P.levels is not None:
예제 #8
0
    os.remove("test_vcs_dump_json.json")

b = vcs.createboxfill("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createisofill("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createisoline("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createmeshfill("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.create1d("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createfillarea("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createvector("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createtext("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createline("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createmarker("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createtemplate("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createprojection("vcs_instance")
b.script("test_vcs_dump_json","a")

assert(filecmp.cmp("test_vcs_dump_json.json", src))


예제 #9
0
    def gmPatternHatch(self, gm_type="isofill", fill_style="pattern",
                       projtype="default", lat1=-90, lat2=90, lon1=-180, lon2=180, contig=True):

        self.x.setcolormap("classic")

        gm = vcs.creategraphicsmethod(gm_type, "default")
        if projtype != "default":
            p = vcs.createprojection()
            try:
                ptype = int(projtype)
            except BaseException:
                ptype = projtype
            p.type = ptype
            gm.projection = p

        if contig:
            gm.levels = [220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320]
        else:
            gm.levels = [[230, 235], [240, 245], [250, 255], [260, 265], [270, 275],
                         [280, 285], [290, 295], [300, 305], [310, 315], [320, 325]]
        gm.fillareastyle = fill_style
        gm.fillareacolors = [242, 244, 237, 248, 250, 252, 44, 243, 139, 247]
        if fill_style == "hatch":
            gm.fillareaindices = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
            # gm.fillareaindices = [2, 4, 6, 8, 1, 3, 14, 16, 18, 20]
            gm.fillareaopacity = [50, 75, 20, 100, 25, 30, 40, 80, 60, 100]
        else:
            gm.fillareaindices = [1, 3, 5, 7, 9, 11, 18, 15, 17, 19]
            gm.fillareaopacity = [50, 75, 20, 0, 25, 30, 100, 0, 60, 0]

        if gm_type == "boxfill":
            gm.boxfill_type = "custom"

        if gm_type == "meshfill":
            gm.mesh = True

        nm_xtra = ""
        xtra = {}
        if lat1 != lat2:
            gm.datawc_y1 = lat1
            gm.datawc_y2 = lat2
            xtra["latitude"] = (lat1, lat2)
            if lat1 < 0:
                nm_xtra += "_SH"
            else:
                nm_xtra += "_NH"
        if lon1 != lon2:
            xtra["longitude"] = (lon1, lon2)
            nm_xtra += "_%i_%i" % (lon1, lon2)
        if not contig:
            nm_xtra += "_non-contig"

        xtra["time"] = slice(0, 1)
        xtra["squeeze"] = 1
        f = cdms2.open(
            os.path.join(
                vcs.sample_data,
                'tas_ccsr-95a_1979.01-1979.12.nc'))
        s = f("tas", **xtra)
        f.close()
        self.x.clear()
        self.x.plot(s, gm, bg=self.bg)
        fnm = "test_vcs_%s_%s" % (gm_type.lower(), fill_style.lower())
        if projtype != "default":
            fnm += "_%s_proj" % projtype
        fnm += nm_xtra
        self.checkImage(fnm + ".png")