Exemple #1
0
 def testHistogram1(self):
     h = vcsaddons.createhistogram(x=self.x)
     f = cdms2.open(os.path.join(cdat_info.get_sampledata_path(), 'clt.nc'))
     s = f("clt")
     h.datawc_x1 = -.5
     h.datawc_x2 = 119.5
     h.datawc_y1 = 0.
     h.datawc_y2 = 105
     self.x.plot(s[:, 6, 8], h)
     self.checkImage("test_vcsaddons_histogram_00.png")
x = regression.init()

cdmsfile = cdms2.open(vcs.sample_data + "/clt.nc")
clt = cdmsfile("clt")

levels = [10, 20, 30, 40, 60, 70, 80, 90, 100]
histo = vcsaddons.histograms.Ghg()
histo.bins = levels
histo.line = ["solid", "dash", "dash-dot"]
histo.linewidth = [1, 2, 3]
histo.linecolors = ["red", "green", "blue"]
histo.fillareastyles = ["solid", "hatch", "pattern", "solid"]
histo.fillareaindices = [1, 2, 3, 4]
histo.fillareacolors = ["blue", "green", "red", "orange"]

histo2 = vcsaddons.createhistogram(source=histo)

print "Checking all inherited attributes..."
assert histo2.bins == histo.bins
assert histo2.line == histo.line
assert histo2.linewidth == histo.linewidth
assert histo2.linecolors == histo.linecolors
assert histo2.fillareastyles == histo.fillareastyles
assert histo2.fillareacolors == histo.fillareacolors
assert histo2.fillareaindices == histo.fillareaindices
print "Inherited all values."

histo2.levels = [10, 20, 10, 100, 110, 50, 20]
histo3 = vcsaddons.createhistogram(source=histo2.name, x=x)

print "Checking name-based inheritance"
import vcsaddons, os

import vcs
x = vcs.init()
import vcs.test.support
bg = vcs.test.support.bg

h = vcsaddons.createhistogram(x=x)

import sys, cdms2
cdms2.setAutoBounds("on")
f = cdms2.open(os.path.join(vcs.sample_data, 'clt.nc'))
s = f("clt")

h.datawc_x1 = -.5
h.datawc_x2 = 119.5
h.datawc_y1 = 0.
h.datawc_y2 = 105

x.plot(s[:, 6, 8], h, bg=bg)
vcs.test.support.check_plot(x)
x = regression.init()

cdmsfile = cdms2.open(vcs.sample_data + "/clt.nc")
clt = cdmsfile("clt")

levels = [10, 20, 30, 40, 60, 70, 80, 90, 100]
histo = vcsaddons.histograms.Ghg()
histo.bins = levels
histo.line = ["solid", "dash", "dash-dot"]
histo.linewidth = [1, 2, 3]
histo.linecolors = ["red", "green", "blue"]
histo.fillareastyles = ["solid", "hatch", "pattern", "solid"]
histo.fillareaindices = [1, 2, 3, 4]
histo.fillareacolors = ["blue", "green", "red", "orange"]

histo2 = vcsaddons.createhistogram(source=histo)

print "Checking all inherited attributes..."
assert histo2.bins == histo.bins
assert histo2.line == histo.line
assert histo2.linewidth == histo.linewidth
assert histo2.linecolors == histo.linecolors
assert histo2.fillareastyles == histo.fillareastyles
assert histo2.fillareacolors == histo.fillareacolors
assert histo2.fillareaindices == histo.fillareaindices
print "Inherited all values."

histo2.levels = [10, 20, 10, 100, 110, 50, 20]
histo3 = vcsaddons.createhistogram(source=histo2.name, x=x)

print "Checking name-based inheritance"
Exemple #5
0
import vcsaddons,os

import vcs
x=vcs.init()
import vcs.test.support
bg=vcs.test.support.bg

h = vcsaddons.createhistogram(x=x)

import sys,cdms2
cdms2.setAutoBounds("on")
f=cdms2.open(os.path.join(cdms2.__path__[0],'..','..','..','..','sample_data','clt.nc'))
s=f("clt")

h.datawc_x1=-.5
h.datawc_x2=119.5
h.datawc_y1=0.
h.datawc_y2=105

x.plot(s[:,6,8],h,bg=bg)
vcs.test.support.check_plot(x)