예제 #1
0
 def testAspectRatio(self):
     ret = 0
     gm = vcs.createisofill()
     s = self.clt("clt", time=slice(0,1), squeeze=1)
     for ratio in ["1t", "2t", ".5t", "autot"]:
         ret += self.plotRatio(s, gm, ratio)
     self.assertEqual(ret, 0)
     return ret
예제 #2
0
    def testVCSreset1only(self):
        for gtype in vcs.listelements():
            b0 = vcs.listelements(gtype)
            if gtype == 'colormap':
                b = vcs.createcolormap()
                xtra = vcs.createisofill()
                untouched = vcs.listelements("isofill")
            elif gtype == "template":
                b = vcs.createtemplate()
            elif gtype == "textcombined":
                b = vcs.createtextcombined()
            elif gtype == "textorientation":
                b = vcs.createtextorientation()
            elif gtype == "texttable":
                b = vcs.createtexttable()
            elif gtype == "fillarea":
                b = vcs.createfillarea()
            elif gtype == "projection":
                b = vcs.createprojection()
            elif gtype == "marker":
                b = vcs.createmarker()
            elif gtype == "line":
                b = vcs.createline()
            elif gtype in ["display", "font", "fontNumber", "list", "format"]:
                vcs.manageElements.reset()
                continue
            else:
                b = vcs.creategraphicsmethod(gtype)
            if gtype != "colormap":
                xtra = vcs.createcolormap()
                untouched = vcs.listelements("colormap")
            b1 = vcs.listelements(gtype)
            self.assertNotEqual(b0, b1)
            vcs.manageElements.reset(gtype)
            b2 = vcs.listelements(gtype)
            self.assertEqual(b0, b2)
            if gtype == "colormap":
                self.assertEqual(untouched, vcs.listelements("isofill"))
            else:
                self.assertEqual(untouched, vcs.listelements("colormap"))
            vcs.manageElements.reset()
            if gtype == "colormap":
                self.assertNotEqual(untouched, vcs.listelements("isofill"))
            else:
                self.assertNotEqual(untouched, vcs.listelements("colormap"))

        # case for 1d weirdness
        sc = vcs.createscatter()
        vcs.manageElements.reset()
예제 #3
0
 def testUpdateArray(self):
     f = cdms2.open(
         os.path.join(cdat_info.get_sampledata_path(),
                      "ta_ncep_87-6-88-4.nc"))
     data = f("ta")
     levels = vcs.mkscale(*vcs.minmax(data))
     levels.insert(0, 1.e20)
     levels.append(1.e20)
     colors = vcs.getcolors(levels)
     isof = vcs.createisofill()
     isof.levels = levels
     isof.fillareacolors = colors
     isol = vcs.createisoline()
     isol.levels = levels
     tmpl = self.x.gettemplate("top_of2")
     self.x.portrait()
     self.x.plot(data, isof, tmpl)
     tmpl = self.x.gettemplate("bot_of2")
     disp = self.x.plot(data, isof, tmpl)
     kw = {"time": slice(3, 4), "level": slice(6, 7)}
     new = disp.array[0](**kw)
     self.x.backend.update_input(disp.backend, new)
     self.checkImage("test_vcs_update_array_extensions.png")
예제 #4
0
import os, sys, vcs, cdms2, testing.regression as regression

f = cdms2.open(vcs.sample_data+"/clt.nc")
s = f("clt", time=slice(0, 1), squeeze=1)
x = regression.init()
iso = vcs.createisofill("isoleg")
iso.levels = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
iso.fillareastyle = "pattern"
iso.fillareacolors = vcs.getcolors([0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100])
iso.fillareaindices = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
x.plot(s, iso, bg=1)
fnm = "test_vcs_patterns.png"
regression.run(x, fnm, threshold=regression.defaultThreshold+5.)
예제 #5
0
import vcs, numpy, cdms2, MV2, os, sys

src = sys.argv[1]
pth = os.path.join(os.path.dirname(__file__), "..")
sys.path.append(pth)
import checkimage

f = cdms2.open(vcs.prefix + "/sample_data/clt.nc")
s = f("clt", time=slice(0, 1), squeeze=1)
x = vcs.init()
x.drawlogooff()
x.setbgoutputdimensions(1200, 1091, units="pixels")
iso = vcs.createisofill("isoleg")
iso.levels = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
iso.fillareacolors = vcs.getcolors(
    [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100])
iso.fillareastyle = "pattern"
iso.fillareindices = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
x.plot(s, iso, bg=1)
fnm = "test_vcs_patterns.png"
x.png(fnm)

print "fnm:", fnm
print "src:", src
ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold)
sys.exit(ret)
예제 #6
0
import vcs
import cdms2
import sys
import os
import MV2
import vcs,numpy,cdms2,MV2,os,sys
src=sys.argv[1]
pth0 = os.path.dirname(_file__)
pth = os.path.join(pth0,"..")
sys.path.append(pth)
import checkimage

f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
s=f("clt",time=slice(0,1),squeeze=1)
gm=vcs.createisofill()

def plot_a_ratio(s,gm,ratio):
    ret = 0
    x=vcs.init()
x.drawlogooff()
    x.open()
    x.geometry(400,800)
    y=vcs.init()
    y.open()
    y.geometry(800,400)
    for X in [x,y]:
        X.plot(s,gm,ratio=ratio)
        if X.islandscape():
            orient = "ldscp"
        else:
예제 #7
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))
예제 #8
0
# Get the % difference
scale_factor = new_height / (right_template.data.y2 - right_template.data.y1)
# Move the template to the correct Y position
ydiff = bottom_template.data.y1 - right_template.data.y1
right_template.move(ydiff, "y")
right_template.scale(scale_factor, "xy", font=False)

# Adjust the labels to line up with top_template
right_template.title.y = top_template.title.y
right_template.units.y = top_template.units.y
right_template.crdate.y = top_template.crdate.y

# Create the graphics methods we'll use

# Show fewer xticlabels in order to actually be able to read them
reduced_labels = vcs.createisofill("reduced", "default")
# You use a dictionary that maps values 0 <= x < 360 to strings
reduced_labels.xticlabels1 = {0: "0", 60: "60E", 120: "120E", 180: "180W",
                              240: "120W", 300: "60W", 360: "0"}

# isofill will use the naive minmax approach
isofill = vcs.createisofill("minmax", "reduced")

# Extract the minimum and maximum levels of sphu
# This will extract the minimum and maximum values from
# all time slices, which may be an issue for your dataset.
# If you want to do an animation, it's a good appraoch.
# If you're just looking at a single time slice, you're better off
# using our automatic level generator.
minval, maxval = vcs.minmax(sphu)
# Automatically create levels based on a minimum and maximum value
예제 #9
0
import 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("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")
예제 #10
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))
예제 #11
0
import vcs, cdms2
x = vcs.init()
f = cdms2.open(vcs.sample_data + "/clt.nc")

base_iso = vcs.createisofill("base")
base_iso.levels = range(0, 101, 10)

t = vcs.createtemplate("base")

x.plot(f("clt"), t, base_iso)

pattern_iso = vcs.createisofill("patterned", base_iso)
pattern_iso.fillareastyle = "pattern"
pattern_iso.fillareaindices = range(1, 11)

# Just draw the legend and the data
t2 = vcs.createtemplate("just_data", t.name)
t2.blank()
t2.data.priority = 1
t2.legend.priority = 1
x.plot(f("clt"), t2, pattern_iso)
fname = raw_input("Save?")
if fname:
    x.png(fname)
예제 #12
0
import 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("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")
예제 #13
0
def get_graphics_methods():
    """
    Retrieve and customize all graphics methods used in the visualization
    """
    gm_0 = vcs.createisofill()
    return gm_0
예제 #14
0
    var = datafile('clt')

    left_tmpl = vcs.createtemplate("left")
    left_tmpl.scale(.5, "x")
    left_tmpl.move(-.02, "x")
    
    right_tmpl = vcs.createtemplate("right", left_tmpl)
    right_tmpl.move(.5, "x")

    canvas = vcs.init()
    canvas.bgX = 1500
    canvas.bgY = 750

    levs = levels(var, partition_count=10)

    stat_iso = vcs.createisofill()
    int_levs = []
    for l in levs:
        int_levs.append(int(l))
    stat_iso.levels = int_levs
    stat_iso.ext_2 = True
    stat_iso.ext_1 = True
    stat_iso.missing = 1
    stat_iso.fillareacolors = vcs.getcolors(stat_iso.levels, split=0)
    
    iso = vcs.createisofill()
    v_min, v_max = vcs.minmax(var[0])
    scale = vcs.mkscale(v_min, v_max)
    iso.levels = scale
    iso.ext_2 = True
    iso.ext_1 = True
예제 #15
0
def get_graphics_methods():
    """
    Retrieve and customize all graphics methods used in the visualization
    """
    gm_0 = vcs.createisofill()
    return gm_0
예제 #16
0
markers = {
}

zeroes = cdms2.MV2.ones((180, 360))
lon = cdms2.createAxis(numpy.arange(-180, 180, 1), id="lon")
lat = cdms2.createAxis(numpy.arange(-90, 90, 1), id="lat")
zeroes.setAxis(1, lon)
zeroes.setAxis(0, lat)

for p in geo_data:
    size = int(p["count"] / float(max_count) * 9)
    marker = markers.get(size, None)
    if marker is None:
        marker = vcs.createmarker(source=base_marker)
        marker.x = []
        marker.y = []
        marker.size = range(0, 10)[size] + 2
        markers[size] = marker
    marker.x.append(p["longitude"])
    marker.y.append(p["latitude"])

x = vcs.init()
blanked = vcs.createisofill()
blanked.levels = [1, 1]
blanked.fillareacolors = [0, 0,0,0]

x.plot(zeroes, blanked, template)
for _, marker in markers.items():
    x.plot(marker)

x.png("geo")