def test_setlineattributes(self): l = vcs.createline("vcs_test_set_line") l.color = 242 l.width = 5.6 l.type = "dash" self.assertEqual(l.color, [242]) self.assertEqual(l.width, [5.6]) self.assertEqual(l.type, ["dash"]) v = vcs.createvector() v.setLineAttributes("vcs_test_set_line") self.assertEqual(v.linecolor, 242) self.assertEqual(v.linewidth, 5.6) self.assertEqual(v.linetype, "dash") yx = vcs.create1d() yx.setLineAttributes(l) self.assertEqual(yx.linecolor, 242) self.assertEqual(yx.linewidth, 5.6) self.assertEqual(yx.linetype, "dash") iso = vcs.createisoline() # Note "solid" is a line name. iso.setLineAttributes([l, "solid", l]) self.assertEqual(iso.linecolors, [242, 1, 242]) self.assertEqual(iso.linewidths, [5.6, 1, 5.6]) self.assertEqual(iso.linetypes, ['dash', 'solid', 'dash'])
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")
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('0') p.type = ptype gm.projection = p xtra = {} gm.datawc_y1 = -90.0 gm.datawc_y2 = 0.0 xtra["latitude"] = (-90.0, 0.0) f = cdms2.open(os.path.join(vcs.prefix, 'sample_data', 'clt.nc')) s = f("clt", **xtra) x.plot(s, gm, bg=bg) x.png('test_vcs_basic_isoline_0_proj_SH_via_gm.png')
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))
lat2=80 lon1=0 lon2=360 # Wind speed --- data['wnd'] = MV.sqrt(data['ua']**2+data['va']**2) iso = canvas.createisofill() iso.datawc_x1 = lon1 iso.datawc_x2 = lon2 iso.datawc_y1 = lat1 iso.datawc_y2 = lat2 canvas.setcolormap('blue_to_orange') canvas.plot(data['wnd'],iso,template) # Geopotential height field --- lines1 = vcs.createisoline() lines1.datawc_x1 = lon1 lines1.datawc_x2 = lon2 lines1.datawc_y1 = lat1 lines1.datawc_y2 = lat2 lines1.linecolors = ['black'] lines1.line=['solid'] lines1.label = 'y' lines1.textcolors=['black'] canvas.plot(data['zg'],lines1,template) # T field --- lines2 = vcs.createisoline() lines2.datawc_x1 = lon1 lines2.datawc_x2 = lon2 lines2.datawc_y1 = lat1
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 = 'aeqd' 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_aeqd_proj.png')
cl2_djfclimatology.id='' x.drawlogooff() bg=False M=EzTemplate.Multi(rows=2,columns=1) M.legend.direction='horizontal' #M.legend.direction='horizontal' M.margins.left=.07 M.margins.right=.07 M.margins.bottom=.1 M.margins.top=.08 M.legend.thickness=.3 M.spacing.vertical=.1 M.legend.fat=.09 x.setcolormap('bl_to_darkred') t=M.get(legend='local') lines=vcs.createisoline() header=x.createtext() header.To.height=24 header.To.halign="center" header.To.valign="top" header.x=.5 header.y=.98 header.string=plot_title x.plot(header,bg=1) iso.yticlabels1={100000:"1000",90000:"900",80000:"800",70000:"700",60000:"600",50000:"500",40000:"400",30000:"300",20000:"200",10000:"100"} x.plot(cl_djfclimatology,t, iso) lines.yticlabels1={100000:"1000",90000:"900",80000:"800",70000:"700",60000:"600",50000:"500",40000:"400",30000:"300",20000:"200",10000:"100"} lines.levels=levs x.plot(cl_djfclimatology,t,lines)
lat2 = 80 lon1 = 0 lon2 = 360 # Wind speed --- data['wnd'] = MV.sqrt(data['ua']**2 + data['va']**2) iso = canvas.createisofill() iso.datawc_x1 = lon1 iso.datawc_x2 = lon2 iso.datawc_y1 = lat1 iso.datawc_y2 = lat2 canvas.setcolormap('blue_to_orange') canvas.plot(data['wnd'], iso, template) # Geopotential height field --- lines1 = vcs.createisoline() lines1.datawc_x1 = lon1 lines1.datawc_x2 = lon2 lines1.datawc_y1 = lat1 lines1.datawc_y2 = lat2 lines1.linecolors = ['black'] lines1.line = ['solid'] lines1.label = 'y' lines1.textcolors = ['black'] canvas.plot(data['zg'], lines1, template) # T field --- lines2 = vcs.createisoline() lines2.datawc_x1 = lon1 lines2.datawc_x2 = lon2 lines2.datawc_y1 = lat1
txt = x.createtext() txt.string = "Moscow" txt.height = 20 txt.x = .28 txt.y = .62 # Create another label txt2 = x.createtext() txt2.x = .73 txt2.y = .33 txt2.string = "Pakistan" txt2.priority = 10 txt2.height = 20 # Change the color so we can see this label a little better txt2.color = 242 txt2.angle = -45 # Plot the cfsr variable from lat 25 to lat 75.6, and from lon 25 to lon 85 using the isofill defined above x.plot(s, iso, continents = 4) # Create, initialize, and plot an isoline to delimit the fill zones lines = vcs.createisoline() lines.levels = levs x.plot(s, lines) # Plot the labels we defined x.plot(txt) x.plot(txt2) x.png("plot_colors.png")
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")
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))
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")