In [37]:
import vcs
import cdms2
In [38]:
# MAke sure sample data is here
vcs.download_sample_data_files()
In [39]:
f=cdms2.open(vcs.sample_data+"/clt.nc")
In [40]:
# LOAS SAMPLE DATA
s=f("clt")
In [41]:
# Create vcs canvas (basically X window to draw in)
x=vcs.init()
In [42]:
# plot data as is
In [43]:
#because we are in jupyter using bg=True to plot thing in background (no flashing on your screen)
bg=True
x.plot(s,bg=bg)
Out[43]:
In [44]:
# Now let's explore some graphics methods available
print vcs.listelements()
In [45]:
# Let's create a isofill
gm = vcs.createisofill()
In [46]:
# Let's see what we can set/do with this
gm.list()
The Graphic Method Controls How Things are Drawn datawc stands for dataworldcoordinates x/yticlabels are the labels to useon x/y axes (python dictionaries {location_value:"string"} x/ymtics are the ticks w/o strings missing is color to use for misssing values (index in colormap, (r,g,b,o) or "string") fillarea are the contour properties
In [47]:
gm.datawc_x1 = -10
gm.datawc_x2 = 60
gm.datawc_y1= 15
gm.datawc_y2 = 65
gm.xticlabels1 = {0:"Greenwich", 20:"20E"}
gm.yticlabels2 = {0:"Equator",60:"Arctic Circle", 45:"45N"}
levels = range(0,101,5) # iso contours to use
colors = vcs.getcolors(levels) # automatically picks colors spread accross your color map
gm.levels = levels
gm.fillareacolors = colors
x.clear()
x.plot(s,gm,bg=bg)
Out[47]:
In [48]:
# now to control the LOCATION of elements we use a *template*
t = vcs.createtemplate()
In [49]:
# t.list() would list all properties we can set
t.list()
x/y coordinate are in % of page priority is the layer higher means on top of other objects, 0 means turn off
important eleements are dataname, title, mean, max, min, units values come from data plotted
data is the area where to plot the data legend is the area used by the legend/colorbar
see bellow for more info on text objects, but they are basically contrlled via textorientation and texttable objects properties
In [50]:
t.min.priority =0 # turn off min
s.id = "I AM LEARNING" # change dataname
s.title = "THSI IS MY TITLE"
s.units= "SOME WEIRD UNIT"
t.reset('x',.2,.5,t.data.x1,t.data.x2) # reset template to go from 20% to %0% of page (left essentially)
x.clear()
x.plot(s,gm,t)
Out[50]:
In [51]:
#Let's preserve the aspect ratio
x.clear()
x.plot(s,gm,t,ratio="autot")
Out[51]:
In [ ]: