import os, sys, cdms2, vcs, vcs.testing.regression as regression f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) s = f("clt",slice(0,1),squeeze=1) x = regression.init() gm = x.createboxfill() gm.boxfill_type = "custom" gm.levels = [1.e20,1.e20] gm.ext_1 = "y" gm.ext_2 = "y" x.plot(s, gm, bg=1) fnm = os.path.split(__file__)[1][:-3] + ".png" regression.run(x, fnm, sys.argv[1])
# Create the fill area and the text annotations fill_test = x.createfillarea('fill_hatches_patterns') fill_test.style = style_list fill_test.index = index_list fill_test.color = color_list fill_test.x = x_list fill_test.y = y_list fill_test.pixelspacing = [15, 15] fill_test.pixelscale = 15.0 fill_info = x.createtext('fill_info') fill_info.angle = 45 fill_info.height = 12 fill_info.color = 241 # Black fill_info.string = txt_str_list fill_info.x = txt_x_list fill_info.y = txt_y_list # Create a title plot_title = x.createtext('plot_title') plot_title.height = 40 plot_title.string = ['Testing hatches and patterns in VCS/CDAT'] plot_title.x = [.01] plot_title.y = [.9] # Initialize and use a second graphics canvas x.plot(plot_title, bg=1) x.plot(fill_test, bg=1) x.plot(fill_info, bg=1) regression.run(x, "test_vcs_hatches_patterns.png")
ySize = 500 else: xSize = 800 ySize = 400 pth = os.path.join(os.path.dirname(__file__), "..") sys.path.append(pth) f = cdms2.open(vcs.sample_data + "/" + testConfig[plot][0]) s = f(testConfig[plot][1]) x = regression.init(bg=bg, geometry=(xSize, ySize)) # graphics method if (plot.find('boxfill') != -1): gm = x.getboxfill(plot) elif (plot.find('meshfill') != -1): gm = x.getmeshfill(plot) elif (plot.find('isofill') != -1): gm = x.getisofill(plot) elif (plot.find('isoline') != -1): gm = x.getisoline(plot) else: print "Invalid plot" sys.exit(13) x.setantialiasing(0) x.drawlogooff() x.plot(s, gm, ratio="autot") name = "test_vcs_autot_axis_titles_" + plot[2:] + "_" + x_over_y + "_" + str( bg) + ".png" regression.run(x, name, sys.argv[1])
import vcs, numpy, os, sys, vcs.testing.regression as regression s = numpy.sin(numpy.arange(100)) s = numpy.reshape(s,(10,10)) x = regression.init() x.plot(s, bg=1) regression.run(x, "test_vcs_boxfill_10x10_numpy.png")
import vcs, numpy, cdms2, MV2, os, sys, vcs.testing.regression as regression f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) T=f('clt') v = regression.init() v.plot(T,bg=1) regression.run(v, 'first_png_blank.png')
for i in range(12): cont_index = i % 6 + 1 cont_line = vcs.createline() cont_line.width = i % 3 + 1 cont_line.type = line_styles[i % 5] print "Cont_line_rtype:",line_styles[i % 5] cont_line.color = i + 200 template = multitemplate.get(i) if cont_index != 3 and i != 4 and i != 11: canvas.plot(clt, template, boxfill, continents=cont_index, continents_line=cont_line, bg=1) elif cont_index == 3: canvas.setcontinentsline(cont_line) canvas.setcontinentstype(3) canvas.plot(clt, template, boxfill, bg=1) elif i == 4: canvas.setcontinentstype(0) # Make sure absolute path works path = os.path.join(vcs.prefix, "share", "vcs", "data_continent_political") canvas.plot(clt, template, boxfill, continents=path, continents_line=cont_line, bg=1) elif i == 11: # Make sure the dotdirectory other* works dotdir = vcs.getdotdirectory() current_dotdir = os.environ.get(dotdir[1], dotdir[0]) os.environ["UVCDAT_DIR"] = os.path.join(vcs.prefix, "share", "vcs") # Should pick up the other7 continents canvas.plot(clt, template, boxfill, continents=7, continents_line=cont_line, bg=1) os.environ["UVCDAT_DIR"] = current_dotdir regression.run(canvas, "test_continents.png")
import cdms2 import os import sys import vcs.testing.regression as regression import vcs import numpy data = sys.argv[2] level = sys.argv[3] levels = {'0': range(-5,36,5), '1': [-1000, -15, 35], '2': [-300, -15, 0, 15, 25], '3': range(190, 320, 10)} x=regression.init(bg=1) f=cdms2.open(data) if (level == '3'): s=f("test") else: s=f("sst") iso=x.createisofill() iso.levels=levels[level] x.plot(s,iso) regression.run(x, "test_vcs_isofill_level%s.png"%level)
import vcs, numpy, cdms2, MV2, os, sys, vcs.testing.regression as regression f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) T = f('clt') v = regression.init() v.plot(T, bg=1) regression.run(v, 'first_png_blank.png')
import vcs, numpy, cdms2, MV2, os, sys, vcs.testing.regression as regression x = regression.init() d = numpy.sin(numpy.arange(100)) b = x.createboxfill() x.plot(d,b,bg=1) regression.run(x, "test_1d_in_boxfill.png", sys.argv[1])
import vcs, numpy, os, sys, cdms2, vcs.testing.regression as regression x=regression.init() f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) data=f("clt",slice(0,1,)) gm = x.createisoline() gm.levels = range(0,110,10) gm.linecolors = ["green","red","blue","bisque","yellow","grey", [100,0,0,50], [0,100,0],"salmon",[0,0,100,75]] x.plot(data,gm,bg=True) regression.run(x, 'test_vcs_settings_color_name_rgba_isoline.png')
import vcs, numpy, os, sys, cdms2, vcs.testing.regression as regression x = regression.init() f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) data=f("clt",slice(0,1,)) gm = x.createboxfill() gm.boxfill_type = "custom" gm.levels = range(0,110,10) gm.fillareacolors = ["green","red","blue","bisque","yellow","grey", [100,0,0,50], [0,100,0],"salmon",[0,0,100,75]] x.plot(data,gm,bg=True) regression.run(x, 'test_vcs_settings_color_name_rgba_boxfill.png')
import vcs,numpy,cdms2,MV2,os,sys import vcs.testing.regression as regression x = regression.init() m = x.createmarker() M=1 m.worldcoordinate=[0,M,0,M] m.type = "w07" m.color=[242,] m.size=[1.,2.,5.] m.x = [[.25,],[.5,],[.75]] m.y = [.5,] x.plot(m,bg=1) fnm = 'wmo_marker.png' x.png(fnm) regression.run(x, "wmo_marker.png")
isoline = canvas.createisoline() isoline.label = "y" texts = [] colors = [] bcolors = [] bopacities = [] for i in range(10): text = canvas.createtext() random.seed(i*200) text.color = random.randint(1, 255) text.height = 12 random.jumpahead(i * 100) colors.append(random.randint(1, 255)) random.jumpahead(i * 20) bcolors.append(random.randint(1, 255)) bopacities.append(random.randint(0, 100)) if i % 2 == 0: texts.append(text.name) else: texts.append(text) isoline.text = texts isoline.labelbackgroundcolors = bcolors isoline.labelbackgroundopacities = bopacities isoline.labelskipdistance = 15.0 # First test using isoline.text[...].color canvas.plot(data, isoline, bg=1) baseline = os.path.splitext(sys.argv[1]) baselineImage = "%s%s" % baseline regression.run(canvas, baselineImage)
import os, sys, cdms2, vcs, vcs.testing.regression as regression import matplotlib sp = matplotlib.__version__.split(".") if int(sp[0])*10+int(sp[1])<15: # This only works with matplotlib 1.5 and greater sys.exit() # Load the clt data: dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) clt = dataFile("clt") clt = clt(latitude=(-90.0, 90.0), longitude=(-180., 175.), squeeze=1, time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0')) # Initialize canvas: canvas = regression.init() canvas.setcolormap(vcs.matplotlib2vcs("viridis")) canvas.plot(clt, bg=1) regression.run(canvas, "test_matplotlib_colormap.png")
import os, sys, cdms2, vcs, vcs.testing.regression as regression x = regression.init() x.backgroundcolor = (255, 255, 255) x.open() regression.run(x, "test_backgroundcolor_white.png")
import os, sys, cdms2, vcs, vcs.testing.regression as regression dataset = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) data = dataset("clt") canvas = regression.init() isoline = canvas.createisoline() isoline.label = "y" isoline.labelskipdistance = 15.0 texts = [] colors = [] for i in range(10): text = canvas.createtext() text.color = 20 * i text.height = 12 colors.append(255 - text.color) if i % 2 == 0: texts.append(text.name) else: texts.append(text) isoline.text = texts isoline.linecolors = colors # Next plot the isolines with labels canvas.plot(data, isoline, bg=1) regression.run(canvas, "test_vcs_isoline_labelskipdistance.png")
0.059503571833625334 0.059503571833625334 0.05664014775641405 0.05193557222118004 0.04777129850801233 0.0407139313814465 0.029382624830271705 0.018469399844287374 0.0162382275289592 0.02646680241827459 0.04792041732949079 0.0689138797030203 0.08167038620212037 0.09273558459066569 0.11266293431057901 0.13663018925347364 0.15229174546388072 0.15284435880966177 0.13423845476113883 0.09945904378274077 0.07032267160267985 0.05551039827020481 0.045537187647785464 0.040532491867244946 0.03577527125478327 -999. -999. -999. -0.058062458673116 -0.08764922509099882 -0.11697036914487152 -0.14836133615864944 -0.17956528904564023 -0.21109198032585794 -0.23846429237248942 -0.2598536549218765 -0.27795672866320387 -0.2939939095159731 -0.30541031366330024 -0.307643559333884 -0.30078421139811795 -0.2841339526883441 -0.26485737397202497 -0.24287299694779327 -0.22379014890999907 -0.20121548204699846 -0.1746486732156772 -0.14585019344118372 -0.12070675757803526 -0.0997891159111037 -0.08229393660994214 -0.06779720501287469 -0.057213385470859794 -0.04875768191096844 -0.0402377347189964 -0.030169328367807245 -0.017560662894847895 -0.006968922654137132 0.0009773980274431048 0.007054306637034288 0.010472286514133042 0.010702384151997032 0.009231553701801242 0.007544033101056543 0.004639797857203645 -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. """.split() data = numpy.array(data, dtype=numpy.float) data = MV2.masked_less(data, -900) x.plot(data, yx, bg=1) regression.run(x, "test_vcs_1D_datawc_missing.png")
import vcs.testing.regression as regression x = regression.init() yx = x.createyxvsx() data = """-11.14902417 -9.17390922 -7.29515002 -7.51774549 -8.63608171 -10.4827395 -9.93859485 -7.3394366 -5.39241468 -5.74825567 -6.74967902 -7.09622319 -5.93836983 -4.04592997 -2.65591499 -1.68180032 -0.86935245 -0.40114047 -0.54273785 -1.36178957 -2.67488251 -3.87524401 -4.84708491 -5.49186142 -5.28618944 -4.30557389 -2.89804038 -1.53825408 -1.84771029 -2.74948361 -2.23517037 -1.73306118 -0.71200646 0.76416785 1.51511193 -0.04018418 -1.54564706 -1.88664877 -0.43751604 0.89988184 0.33437949 -1.70341844 -3.79880014 -4.03570169 -4.7740073 -5.04626101 -3.77609961 -3.18667176 -2.21038272 -1.3666902 -0.54267951 -0.16472441 -0.52871418 -0.83520848 -0.90315403 -0.21747426 0.01922666 0.89621996 1.75691927 3.12657503 4.55749531 6.04921304 7.20744489 7.65294958""".split( ) data = numpy.array(data, dtype=numpy.float) data = MV2.array(data) yx.datawc_x1 = 0 yx.datawc_x2 = 80 yx.datawc_y1 = -12 yx.datawc_y2 = 12 x.plot(data, yx, bg=1) regression.run(x, "test_vcs_1D_datawc.png", src)
elif args.src == "canvas": ## Still setting vcs to make sure it is not used vcs._colorMap = "blue2green" x.setcolormap("blue2grey") else: ## Still setting vcs and canvas to make sure it is not used vcs._colorMap = "blue2green" x.setcolormap("blue2grey") gm.colormap = "blue2orange" if args.gm != "meshfill": f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) if args.gm == "vector": u = f("u")[...,::2,::2] v = f("v")[...,::2,::2] gm.scale = 8. else: s=f("clt",slice(0,1)) else: f=cdms2.open(os.path.join(vcs.sample_data,'sampleCurveGrid4.nc')) s=f("sample") if args.gm == "vector": x.plot(u,v,gm,bg=True) else: x.plot(s,gm,bg=True) fnm = "test_vcs_colormaps_source_%s_%s.png" % (args.gm,args.src) x.png(fnm) baselineImage = args.baseline ret = regression.run(x, fnm, baselineImage)
import os, sys, cdms2, vcs, vcs.testing.regression as regression f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) s = f("clt") x = regression.init() iso = x.createisoline() t = x.createtext() t.color = 243 t.height = 25 to = x.createtextorientation() to.height = 55 tt = x.createtexttable() tt.color = 245 iso.textcolors = [None, None, None, 242, 244] iso.text = [t, tt, to] iso.label = "y" x.plot(s, iso, bg=1) regression.run(x, "test_vcs_isoline_labels_multi_label_input_types.png")
import os, sys, numpy, vcs, vcs.testing.regression as regression x = regression.init() data = numpy.array([1, 2, 3, 4]) blon = numpy.array([-1, 1, 1, 0, -1]) blat = numpy.array([0, 0, 1, 2, 1]) acell = numpy.array([blat, blon]) bcell = numpy.array([blat, blon + 2.5]) ccell = numpy.array([blat + 2.5, blon + 2.5]) dcell = numpy.array([blat + 2.5, blon]) mesh = numpy.array([acell, bcell, ccell, dcell]) m = x.createmeshfill() x.plot(data, mesh, m, bg=1) regression.run(x, "test_vcs_gen_meshfill.png")
import os, sys, cdms2, vcs, vcs.testing.regression as regression x = regression.init() f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) s = f("clt") x.meshfill(s, bg=1) regression.run(x, "test_vcs_meshfill_regular_grid.png")
import os, sys, numpy, cdms2, MV2, vcs, vcs.testing.regression as regression x = regression.init() t = cdms2.createAxis(numpy.arange(120)) t.designateTime() t.id = "time" t.units = "months since 2014" data = MV2.arange(120,0,-1) data.id = "data" data.setAxis(0,t) x = regression.init() x.plot(data,bg=1) fnm = 'test_vcs_monotonic_decreasing_yxvsx_default.png' regression.run(x, fnm)
import os, sys, cdms2, vcs, vcs.testing.regression as regression import matplotlib sp = matplotlib.__version__.split(".") if int(sp[0])*10+int(sp[1])<15: # This only works with matplotlib 1.5 and greater sys.exit() # Load the clt data: dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) clt = dataFile("clt") clt = clt(latitude=(-90.0, 90.0), longitude=(-180., 175.), squeeze=1, time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0')) # Initialize canvas: canvas = regression.init() canvas.setcolormap(vcs.matplotlib2vcs("viridis")) canvas.plot(clt, bg=1) fnm = os.path.split(__file__)[1][:-3] + ".png" regression.run(canvas, fnm)
'w20', 'w21', 'w22', 'w23', 'w24', 'w25', 'w26', 'w27', 'w28', 'w29', 'w30', 'w31', 'w32', 'w33', 'w34', 'w35', 'w36', 'w37', 'w38', 'w39', 'w40', 'w41', 'w42', 'w43', 'w44', 'w45', 'w46', 'w47', 'w48', 'w49', 'w50', 'w51', 'w52', 'w53', 'w54', 'w55', 'w56', 'w57', 'w58', 'w59', 'w60', 'w61', 'w62', 'w63', 'w64', 'w65', 'w66', 'w67', 'w68', 'w69', 'w70', 'w71', 'w72', 'w73', 'w74', 'w75', 'w76', 'w77', 'w78', 'w79', 'w80', 'w81', 'w82', 'w83', 'w84', 'w85', 'w86', 'w87', 'w88', 'w89', 'w90', 'w91', 'w92', 'w93', 'w94', 'w95', 'w96', 'w97', 'w98', 'w99', 'w100', 'w101', 'w102'] x = regression.init() m = x.createmarker() M=7 m.worldcoordinate=[0,M,0,M] m.type = wmo m.color=[242,] m.size=[10.,] xs = [] ys=[] for Y in range(7): for X in range(15): ys.append([M-M*(Y+1)/8.,]) xs.append([M*(X+1)/16.,]) m.x = xs m.y = ys m.list() x.plot(m, bg=1) regression.run(x, "wmo_markers.png");
import vcs, cdms2, sys, os, vcs.testing.regression as regression zoom = sys.argv[2] f = cdms2.open(os.path.join(vcs.sample_data, 'clt.nc')) s = f("clt", slice(0, 1), squeeze=1) x = regression.init() i = x.createisofill() p = x.getprojection("polar") i.projection = p if (zoom == 'none'): x.plot(s, i, bg=1) elif (zoom == 'subset'): x.plot(s(latitude=(-50, 90), longitude=(30, -30)), i, bg=1) else: i.datawc_x1 = 30 i.datawc_x2 = -30 i.datawc_y1 = -50 i.datawc_y2 = 90 if (zoom == 'datawc1'): i.datawc_x1, i.datawc_x2 = i.datawc_x2, i.datawc_x1 if (zoom == 'datawc2'): i.datawc_y1, i.datawc_y2 = i.datawc_y2, i.datawc_y1 x.plot(s, i, bg=1) file = "test_vcs_polar_zoom_" + zoom + ".png" regression.run(x, file)
import vcs, numpy, cdms2, MV2, os, sys, vcs.testing.regression as regression x = regression.init() f=cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc")) vr = "ta" s=f(vr,slice(0,1),longitude=slice(90,91),squeeze=1) x.plot(s,bg=1) regression.run(x, 'test_vcs_flipY.png')
import vcs, numpy, cdms2, MV2, os, sys import vcs.testing.regression as regression x = regression.init() m = x.createmarker() M = 1 m.worldcoordinate = [0, M, 0, M] m.type = "w07" m.color = [ 242, ] m.size = [1., 2., 5.] m.x = [[ .25, ], [ .5, ], [.75]] m.y = [ .5, ] x.plot(m, bg=1) fnm = 'wmo_marker.png' x.png(fnm) regression.run(x, "wmo_marker.png")
import os, sys, numpy, cdms2, MV2, vcs, vcs.testing.regression as regression x = regression.init() f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) s = f("clt") box = x.createboxfill() # Should ignore the string here box.xmtics1 = {i:"Test" for i in range(-180, 180, 15) if i % 30 != 0} box.ymtics1 = {i:"Test" for i in range(-90, 90, 5) if i % 10 != 0} box.xmtics2 = "lon15" box.ymtics2 = "lat5" template = x.createtemplate() template.xmintic1.priority = 1 template.ymintic1.priority = 1 template.xmintic2.priority = 1 template.xmintic2.y2 += template.xmintic1.y1 - template.xmintic1.y2 template.ymintic2.priority = 1 x.plot(s, template, box, bg=1) regression.run(x, "test_vcs_mintics.png")
import cdms2 import os import sys import vcs import vcs.testing.regression as regression # Load the clt data: dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) clt = dataFile("clt") clt = clt(latitude=(-90.0, 90.0), longitude=(-180., 175.), squeeze=1, time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0')) # Initialize canvas: canvas = regression.init() # Create and plot quick boxfill with default settings: boxfill=canvas.createboxfill() # Change the type boxfill.boxfill_type = 'custom' levels = range(20,81,10) boxfill.levels=levels boxfill.ext_2="y" boxfill.fillareacolors=vcs.getcolors(boxfill.levels) canvas.plot(clt, boxfill, bg=1) regression.run(canvas, "test_boxfill_custom_ext2.png")
import os, sys, cdms2, vcs, vcs.testing.regression as regression x = regression.init() f = cdms2.open(vcs.sample_data + "/clt.nc") s = f("clt", slice(0, 1), squeeze=1) b = x.createboxfill() b.level_1 = 20 b.level_2 = 80 b.ext_1 = "y" x.plot(s, b, bg=1) regression.run(x, "test_boxfill_lev1_lev2_ext1.png")
import os, sys, cdms2, vcs, vcs.testing.regression as regression f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) s = f("clt", slice(0, 1), squeeze=1) x = regression.init() gm = x.createboxfill() gm.boxfill_type = "custom" gm.levels = [1.e20, 1.e20] gm.ext_1 = "y" gm.ext_2 = "y" x.plot(s, gm, bg=1) regression.run(x, "test_box_custom_as_def_vistrails_exts.png", sys.argv[1])
import os, sys, numpy, cdms2, MV2, vcs, vcs.testing.regression as regression x = regression.init() x.setcolormap("classic") m = x.createmarker() m.x = [[ 0., ], [ 5, ], [ 10., ], [15.]] m.y = [[ 0., ], [ 5, ], [ 10., ], [15.]] m.worldcoordinate = [-5, 20, -5, 20] #m.worldcoordinate=[-10,10,0,10] m.type = ['plus', 'diamond', 'square_fill', "hurricane"] m.color = [242, 243, 244, 242] m.size = [20, 20, 20, 5] x.plot(m, bg=1) regression.run(x, "test_markers.png")
import cdms2, os, sys, vcs, cdtime, vcs.testing.regression as regression # Test that we can restrict the plot using datawc along a time axis dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) clt = dataFile("clt") clt = clt(latitude=(-90.0, 90.0), longitude=(0.), squeeze=1, time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0')) # Initialize canvas: canvas = regression.init() # Create and plot quick boxfill with default settings: boxfill = canvas.createboxfill() # Change the type boxfill.boxfill_type = 'custom' boxfill.datawc_y1 = 12 canvas.plot(clt, boxfill, bg=1) # Load the image testing module: # Create the test image and compare: regression.run(canvas, "test_vcs_boxfill_datawc_time.png")
import vcs, numpy, cdms2, MV2, os, sys, vcs.testing.regression as regression x = regression.init() f = cdms2.open(os.path.join(vcs.sample_data, "ta_ncep_87-6-88-4.nc")) vr = "ta" s = f(vr, slice(0, 1), longitude=slice(90, 91), squeeze=1) x.plot(s, bg=1) regression.run(x, 'test_vcs_flipY.png')
import vcs, numpy, cdms2, MV2, os, sys, vcs.testing.regression as regression x = regression.init() d = numpy.sin(numpy.arange(100)) d = numpy.reshape(d,(10,10)) one = x.create1d() x.plot(d,one,bg=1) regression.run(x, "test_vcs_1D_with_manyDs.png", sys.argv[1])
import vcs, cdms2, os, sys, vcs.testing.regression as regression f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) s = f("clt", longitude=slice(34, 35), squeeze=1) x = regression.init() x.plot(s, bg=1) regression.run(x, "test_vcs_auto_time_labels.png", sys.argv[1])
import os, sys, cdms2, vcs, vcs.testing.regression as regression import matplotlib sp = matplotlib.__version__.split(".") if int(sp[0]) * 10 + int(sp[1]) < 15: # This only works with matplotlib 1.5 and greater sys.exit() # Load the clt data: dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) clt = dataFile("clt") clt = clt(latitude=(-90.0, 90.0), longitude=(-180., 175.), squeeze=1, time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0')) # Initialize canvas: canvas = regression.init() canvas.setcolormap(vcs.matplotlib2vcs("viridis")) canvas.plot(clt, bg=1) regression.run(canvas, "test_matplotlib_colormap.png")
import os, sys, cdms2, vcs, vcs.testing.regression as regression f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) s = f("clt") x = regression.init() iso = x.createisofill() p = x.createprojection() p.type = "lambert" iso.projection = p x.plot(s(latitude=(20, 60), longitude=(-140, -20)), iso, bg=True) regression.run(x, "test_vcs_lambert.png")
import os import sys import vcs import vcs.testing.regression as regression # Load the clt data: dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) clt = dataFile("clt") clt = clt(latitude=(-90.0, 90.0), longitude=(-180., 175.), squeeze=1, time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0')) # Initialize canvas: canvas = regression.init() # Create and plot quick boxfill with default settings: boxfill = canvas.createboxfill() # Change the type boxfill.boxfill_type = 'custom' levels = range(20, 81, 10) boxfill.levels = levels boxfill.ext_2 = "y" boxfill.fillareacolors = vcs.getcolors(boxfill.levels) canvas.plot(clt, boxfill, bg=1) fnm = os.path.split(__file__)[1][:-3] + ".png" regression.run(canvas, fnm)
import os, sys, numpy, cdms2, MV2, vcs, vcs.testing.regression as regression x = regression.init() x.setcolormap("classic") m = x.createmarker() m.x = [[0.0], [5], [10.0], [15.0]] m.y = [[0.0], [5], [10.0], [15.0]] m.worldcoordinate = [-5, 20, -5, 20] # m.worldcoordinate=[-10,10,0,10] m.type = ["plus", "diamond", "square_fill", "hurricane"] m.color = [242, 243, 244, 242] m.size = [20, 20, 20, 5] x.plot(m, bg=1) regression.run(x, "test_markers.png")
import os, sys, numpy, cdms2, MV2, vcs, vcs.testing.regression as regression x = regression.init() f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) s = f("clt") box = x.createboxfill() # Should ignore the string here box.xmtics1 = {i: "Test" for i in range(-180, 180, 15) if i % 30 != 0} box.ymtics1 = {i: "Test" for i in range(-90, 90, 5) if i % 10 != 0} box.xmtics2 = "lon15" box.ymtics2 = "lat5" template = x.createtemplate() template.xmintic1.priority = 1 template.ymintic1.priority = 1 template.xmintic2.priority = 1 template.xmintic2.y2 += template.xmintic1.y1 - template.xmintic1.y2 template.ymintic2.priority = 1 x.plot(s, template, box, bg=1) regression.run(x, "test_vcs_mintics.png")
import os, sys, cdms2, vcs, vcs.testing.regression as regression f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) s = f("clt") s3 = f("clt",longitude=(0,360)) x = regression.init() x.plot(s,bg=1) x.clear() x.plot(s3,bg=1) regression.run(x, "test_lon_axes_freak_out.png")
import os, sys, cdms2, vcs, vcs.testing.regression as regression x = regression.init() f = cdms2.open(vcs.sample_data+"/clt.nc") s = f("clt", slice(0,1), squeeze=1) b = x.createboxfill() b.level_1 = 20 b.level_2 = 80 b.ext_1 = "y" b.ext_2 = "y" x.plot(s, b, bg=1) regression.run(x, "test_boxfill_lev1_lev2_ext1_ext2.png")
import cdms2, os, sys, vcs, cdtime, vcs.testing.regression as regression # Test that we can restrict the plot using datawc along a time axis dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) clt = dataFile("clt") clt = clt(latitude=(-90.0, 90.0), longitude=(0.), squeeze=1, time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0')) # Initialize canvas: canvas = regression.init() # Create and plot quick boxfill with default settings: boxfill=canvas.createboxfill() # Change the type boxfill.boxfill_type = 'custom' boxfill.datawc_y1 = 12 canvas.plot(clt, boxfill, bg=1) # Load the image testing module: # Create the test image and compare: regression.run(canvas, "test_vcs_boxfill_datawc_time.png")
import sys, os, vcs, MV2, vcs.testing.regression as regression data = MV2.array([[-0.50428531,-0.8505522 ,], [ 0.70056821,-0.27235352,], [ 0.05106154, 0.23012322,], [-0.26478429, 0.11950427,], [ 0.85760801,-0.08336641,], [ 1.14083397,-0.78326507,]]) x = regression.init() td = x.createtaylordiagram('new') td.quadrans = 2 x.plot(data, td, skill = td.defaultSkillFunction, bg=1) regression.run(x, "test_vcs_taylor_2quads.png")
import vcs, numpy, cdms2, MV2, os, sys, vcs.testing.regression as regression x = regression.init() d = numpy.sin(numpy.arange(100)) d = numpy.reshape(d, (10, 10)) one = x.create1d() x.plot(d, one, bg=1) regression.run(x, "test_1D_with_manyDs.png", sys.argv[1])
import os, sys, cdms2, vcs, vcs.testing.regression as regression flip = False if (len(sys.argv) == 3): flip = True fileName = os.path.basename(__file__) fileName = os.path.splitext(fileName)[0] if (flip): fileName = fileName + '_flip' fileName = fileName + '.png' f = cdms2.open(os.path.join(vcs.sample_data, "sampleCurveGrid4.nc")) s = f("sample") x = regression.init() m = x.createmeshfill() # m.mesh = True m.datawc_x1 = -20 m.datawc_x2 = 20 if (flip): m.datawc_x1, m.datawc_x2 = m.datawc_x2, m.datawc_x1 m.datawc_y1 = -20 m.datawc_y2 = 20 x.plot(s, m, bg=1) regression.run(x, fileName)
import os, sys, MV2, numpy, vcs, cdms2, vcs.testing.regression as regression src = sys.argv[1] pth0 = os.path.dirname(__file__) f = cdms2.open(os.path.join(pth0, "celine.nc")) s = f("data") x = regression.init() x.setantialiasing(0) x.setcolormap("classic") x.scriptrun(os.path.join(pth0, "celine.json")) i = x.getisofill("celine") x.plot(s, i, bg=1) fnm = "test_celine_iso.png" regression.run(x, fnm)
import cdms2, os, sys, vcs, vcs.testing.regression as regression cdmsfile = cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) data = cdmsfile('clt') x = regression.init() t=x.gettemplate('default') x.plot(data, t, bg=True) # This should force the image to update x.setcolormap('blue2darkorange') regression.run(x, "test_vcs_setcolormap.png")
import vcs, os, sys, cdms2, vcs.testing.regression as regression f = cdms2.open(os.path.join(vcs.sample_data, "sampleCurveGrid4.nc")) s = f("sample") x = regression.init() x.plot(s, bg=1) regression.run(x, "test_plot_unstructured_via_boxfill.png")
import cdms2, os, sys, vcs, vcs.testing.regression as regression # Load the clt data: dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) clt = dataFile("clt") clt = clt(latitude=(-90.0, 90.0), longitude=(-180., 175.), squeeze=1, time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0')) # Initialize canvas: canvas = regression.init() # Create and plot quick boxfill with default settings: boxfill=canvas.createboxfill() # Change the type boxfill.boxfill_type = 'custom' levels = range(20,81,10) boxfill.levels=levels boxfill.fillareacolors=vcs.getcolors(levels) canvas.plot(clt, boxfill, bg=1) regression.run(canvas, "test_boxfill_custom_no_default_levels.png")