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'])
import vcs import sys import cdms2 import vtk import os import MV2 import numpy bg = not args.show x = vcs.init() x.drawlogooff() if bg: x.setbgoutputdimensions(1200, 1091, units="pixels") x.setcolormap("rainbow") gm = vcs.createvector() gm.scale = args.scale nm_xtra = "" xtra = {} #Creates 4x5 grid dlat = 180. / args.nlat lats = cdms2.createAxis(numpy.arange(-90 + dlat / 2., 90, dlat)) lats.id = "latitude" lats.units = "degrees_north" lons = cdms2.createAxis(numpy.arange(0, 360, 360. / args.nlon)) lons.id = "longitude" lons.units = "degrees_east" print len(lats), len(lons) if args.angle in [-45, 0, 45]: u = MV2.ones((args.nlat, args.nlon)) elif args.angle in [-135, -180, 135]:
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") 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")