isofill

# Isofill (Gfi) module

class vcs.isofill.Gfi(Gfi_name, Gfi_name_src='default')[source]

The Isofill graphics method fills the area between selected isolevels (levels of constant value) of a two-dimensional array with a user-specified color. The example below shows how to display an isofill plot on the VCS Canvas and how to create and remove isofill isolevels.

This class is used to define an isofill table entry used in VCS, or it can be used to change some or all of the isofill attributes in an existing isofill table entry.

Useful Functions:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# VCS Canvas Constructor
a=vcs.init()
# Show predefined isofill graphics methods
a.show('isofill')
# Show predefined fillarea objects
a.show('fillarea')
# Show predefined template objects
a.show('template')
# Change the VCS color map
a.setcolormap("AMIP")
# Create a template
a.createtemplate('test')
# Create a fillarea
a.createfillarea('fill')
# Get an existing template
a.gettemplate('AMIP')
# Get an existing fillarea
a.getfillarea('def37')
# Plot array 's' with isofill 'i' and template 't'
a.isofill(s,i,t)
# Updates the VCS Canvas at user's request
a.update()
Creating an isofill object:
1
2
3
4
5
6
7
#Create a VCS Canvas
a=vcs.init()
#Create a new instance of isofill:
# Copies content of 'quick' to 'new'
iso=a.createisofill('new','quick')
# Copies content of 'default' to 'new'
iso=a.createisofill('new')
Modifying an existing isofill:
iso=a.getisofill('AMIP_psl')
Overview of isofill attributes:
  • List all isofill attribute values:

    iso.list()
    
  • Set isofill attributes:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    iso.projection='linear'
    lon30={-180:'180W',-150:'150W',0:'Eq'}
    iso.xticlabels1=lon30
    iso.xticlabels2=lon30
    # Will set them both
    iso.xticlabels(lon30, lon30)
    iso.xmtics1=''
    iso.xmtics2=''
    # Will set them both
    iso.xmtics(lon30, lon30)
    iso.yticlabels1=lat10
    iso.yticlabels2=lat10
    # Will set them both
    iso.yticlabels(lat10, lat10)
    iso.ymtics1=''
    iso.ymtics2=''
    # Will set them both
    iso.ymtics(lat10, lat10)
    iso.datawc_y1=-90.0
    iso.datawc_y2=90.0
    iso.datawc_x1=-180.0
    iso.datawc_x2=180.0
    # Will set them all
    iso.datawc(-90, 90, -180, 180)
    iso.xaxisconvert='linear'
    iso.yaxisconvert='linear'
    # Will set them both
    iso.xyscale('linear', 'area_wt')
    iso.missing='black'
    iso.legend=None
    ext_1='n'
    ext_2='y'
    # Will set them both
    iso.exts('n', 'y' )
    
  • Setting the isofill levels:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    # 1) When levels are all contiguous:
        iso.levels=([0,20,25,30,35,40],)
        iso.levels=([0,20,25,30,35,40,45,50])
        iso.levels=[0,20,25,30,35,40]
        iso.levels=(0.0,20.0,25.0,30.0,35.0,40.0,50.0)
    
    # 2) When levels are not contiguous:
        iso.levels=([0,20],[30,40],[50,60])
        iso.levels=([0,20,25,30,35,40],[30,40],[50,60])
    
  • Setting the fillarea color indices:

    iso.fillareacolors=([22,33,44,55,66,77])
    iso.fillareacolors=(16,19,33,44)
    iso.fillareacolors=None
    
  • Setting the fillarea style:

    iso.fillareastyle = 'solid'
    iso.fillareastyle = 'hatch'
    iso.fillareastyle = 'pattern'
    
  • Setting the fillarea hatch or pattern indices:

    iso.fillareaindices=([1,3,5,6,9,20])
    iso.fillareaindices=(7,1,4,9,6,15)
    
Using the fillarea secondary object (Ex):
  • Create a new instance of fillarea:

    f=createfillarea('fill1')
    
  • Create a new isofill:

    1
    2
    3
    4
    # Copies 'quick' to 'new'
    fill=a.createisofill('new','quick')
    # Copies 'default' to 'new'
    fill=a.createisofill('new')
    
  • Modify an existing isofill:

    fill=a.getisofill('def37')
    
  • Set index using fillarea

    1
    2
    3
    4
    5
    6
    7
    8
    9
    iso.fillareaindices=(7,fill,4,9,fill,15)
    # list fillarea attributes
    fill.list()
    # change style
    fill.style='hatch'
    # change color
    fill.color='black'
    # change style index
    fill.index=3
    
Attribute descriptions:
xmtics1(str/{float:str})

(Ex: ‘’) dictionary with location of intermediate tics as keys for 1st side of y axis

xmtics2(str/{float:str})

(Ex: ‘’) dictionary with location of intermediate tics as keys for 2nd side of y axis

ymtics1(str/{float:str})

(Ex: ‘’) dictionary with location of intermediate tics as keys for 1st side of y axis

ymtics2(str/{float:str})

(Ex: ‘’) dictionary with location of intermediate tics as keys for 2nd side of y axis

xticlabels1(str/{float:str})

(Ex: ‘*’) values for labels on 1st side of x axis

xticlabels2(str/{float:str})

(Ex: ‘*’) values for labels on 2nd side of x axis

yticlabels1(str/{float:str})

(Ex: ‘*’) values for labels on 1st side of y axis

yticlabels2(str/{float:str})

(Ex: ‘*’) values for labels on 2nd side of y axis

projection(str/vcs.projection.Proj)

(Ex: ‘default’) projection to use, name or object

datawc_x1(float)

(Ex: 1.E20) first value of xaxis on plot

datawc_x2(float)

(Ex: 1.E20) second value of xaxis on plot

datawc_y1(float)

(Ex: 1.E20) first value of yaxis on plot

datawc_y2(float)

(Ex: 1.E20) second value of yaxis on plot

datawc_timeunits(str)

(Ex: ‘days since 2000’) units to use when displaying time dimension auto tick

datawc_calendar(int)

(Ex: 135441) calendar to use when displaying time dimension auto tick, default is proleptic gregorian calendar

levels([float,...]/[[float,float],...])

Sets the levels range to use, can be either a list of contiguous levels, or list of tuples indicating first and last value of the range.

fillareacolors([int, ...])

Colors to use for each level

fillareastyle(str)

Style to use for levels filling: solid/pattern/hatch

fillareaindices([int, ...])

List of patterns to use when filling a level and using pattern/hatch

legend(None/{float:str})

Replaces the legend values in the dictionary keys with their associated string

ext_1(str)

Draws an extension arrow on right side (values less than first range value)

ext_2(str)

Draws an extension arrow on left side (values greater than last range value)

missing(int)

Color to use for missing value or values not in defined ranges

colors(color1=16, color2=239)[source]

Sets the color_1 and color_2 properties of the object.

Note

color_1 and color_2 control which parts of the colormap to use for the plot. It defaults to the full range of the colormap (0-255), but if you use fewer colors, it will break up your data into precisely that many discrete colors.

Example
1
2
3
4
5
6
>>> a=vcs.init()
>>> array=[range(10) for _ in range(10)]
>>> ex=a.createisofill()
>>> ex.colors(0, 64) # use colorcells 0-64 of colormap
>>> a.plot(ex, array)
<vcs.displayplot.Dp object at 0x...>
Parameters
  • color1 (int) – Sets the color_1 value on the object.

  • color2 (int) – Sets the color_2 value on the object.

datawc(dsp1=1e+20, dsp2=1e+20, dsp3=1e+20, dsp4=1e+20)[source]

Sets the data world coordinates for object

Example
1
2
3
4
5
>>> a=vcs.init()
>>> ex=a.createisofill('isofill_dwc')
>>> ex.datawc(0.0, 0.1, 1.0, 1.1) # sets datawc y1, y2, x1, x2
>>> ex.datawc_y1, ex.datawc_y2, ex.datawc_x1, ex.datawc_x2
(0.0, 0.1, 1.0, 1.1)
Parameters
  • dsp1 (float) – Sets the datawc_y1 property of the object.

  • dsp2 (float) – Sets the datawc_y2 property of the object.

  • dsp3 (float) – Sets the datawc_x1 property of the object.

  • dsp4 (float) – Sets the datawc_x2 property of the object.

property ext_1

Turns on extensions arrows for values before the first level

property ext_2

Turns on extensions arrows for values after the last level

exts(ext1='n', ext2='y')[source]

Sets the ext_1 and ext_2 values on the object.

Example
Parameters
  • ext1 (str or bool) – Sets the ext_1 value on the object. ‘y’ sets it to True, ‘n’ sets it to False. True or False can be used in lieu of ‘y’ and ‘n’.

  • ext2 (str or bool) – Sets the ext_2 value on the object. ‘y’ sets it to True, ‘n’ sets it to False. True or False can be used in lieu of ‘y’ and ‘n’.

property levels

Sets the levels on a graphic method, optionally turns on/off extensions arrows

list()[source]

Lists the current values of object attributes

Example
1
2
3
4
5
>>> a=vcs.init()
>>> obj=a.getisofill() # default
>>> obj.list() # print isofill attributes
---------- ... ----------
...
script(script_filename, mode='a')[source]

Saves out a copy of the isofill graphics method, in JSON or Python format to a designated file.

Note

If the the filename has a ‘.py’ at the end, it will produce a Python script. If no extension is given, then by default a .json file containing a JSON serialization of the object’s data will be produced.

Warning

VCS Scripts Deprecated. SCR script files are no longer generated by this function.

Example
1
2
3
4
>>> a=vcs.init()
>>> ex=a.getisofill()
>>> ex.script('filename.py') # append to 'filename.py'
>>> ex.script('filename','w') # make/overwrite 'filename.json'
Parameters
  • script_filename (str) – Output name of the script file. If no extension is specified, a .json object is created.

  • mode (str) – Either ‘w’ for replace, or ‘a’ for append. Defaults to ‘a’, if not specified.

xmtics(xmt1='', xmt2='')[source]

Sets the xmtics1 and xmtics2 values on the object.

Note

The mtics attributes are not inherently plotted by the default template. The example below shows how to apply a custom template and enable it to plot mtics. To plot a the isofill after setting the mtics and template, refer to vcs.Canvas.plot() or vcs.Canvas.isofill().

Example
1
2
3
4
5
>>> a=vcs.init()
>>> ex=vcs.createisofill()
>>> ex.xmtics("lon5") # minitick every 5 degrees
>>> tmp=vcs.createtemplate() # custom template to plot minitics
>>> tmp.xmintic1.priority = 1 # plotting shows xmtics
Parameters
  • xmt1 (dict or str) – Value for xmtics1. Must be a str, or a dictionary object with float:str mappings.

  • xmt2 (dict or str) – Value for xmtics2. Must be a str, or a dictionary object with float:str mappings.

xticlabels(xtl1='', xtl2='')[source]

Sets the xticlabels1 and xticlabels2 values on the object

Example
1
2
3
4
5
6
7
>>> a = vcs.init()
>>> import cdms2 # Need cdms2 to create a slab
>>> f = cdms2.open(vcs.sample_data+'/clt.nc') # open data file
>>> ex = a.createisofill()
>>> ex.xticlabels({0: "Prime Meridian", -121.7680: "Livermore", 37.6173: "Moscow"})
>>> a.plot(ex, f('u')) # plot shows labels
<vcs.displayplot.Dp object at 0x...>
Parameters
  • xtl1 (dict or str) – Sets the object’s value for xticlabels1. Must be a str, or a dictionary object with float:str mappings.

  • xtl2 (dict or str) – Sets the object’s value for xticlabels2. Must be a str, or a dictionary object with float:str mappings.

xyscale(xat='', yat='')[source]

Sets xaxisconvert and yaxisconvert values for the object.

Example
>>> a=vcs.init()
>>> ex=a.createisofill('isofill_xys') # make a isofill
>>> ex.xyscale(xat='linear', yat='linear')
Parameters
  • xat (str) – Set value for x axis conversion.

  • yat (str) – Set value for y axis conversion.

ymtics(ymt1='', ymt2='')[source]

Sets the xmtics1 and xmtics2 values on the object.

Note

The mtics attributes are not inherently plotted by the default template. The example below shows how to apply a custom template and enable it to plot mtics. To plot a the isofill after setting the mtics and template, refer to vcs.Canvas.plot() or vcs.Canvas.isofill().

Example
1
2
3
4
5
>>> a=vcs.init()
>>> ex=vcs.createisofill()
>>> ex.xmtics("lon5") # minitick every 5 degrees
>>> tmp=vcs.createtemplate() # custom template to plot minitics
>>> tmp.xmintic1.priority = 1 # plotting shows xmtics
Parameters
  • xmt1 (dict or str) – Value for xmtics1. Must be a str, or a dictionary object with float:str mappings.

  • xmt2 (dict or str) – Value for xmtics2. Must be a str, or a dictionary object with float:str mappings.

yticlabels(ytl1='', ytl2='')[source]

Sets the yticlabels1 and yticlabels2 values on the object

Example
1
2
3
4
5
6
7
>>> a = vcs.init()
>>> import cdms2 # Need cdms2 to create a slab
>>> f = cdms2.open(vcs.sample_data+'/clt.nc') # open data file
>>> ex = a.createisofill()
>>> ex.yticlabels({0: "Eq.", 37.6819: "L", 55.7558: "M"})
>>> a.plot(ex, f('u')) # plot shows labels
<vcs.displayplot.Dp object at 0x...>
Parameters
  • ytl1 (dict or str) – Sets the object’s value for yticlabels1. Must be a str, or a dictionary object with float:str mappings.

  • ytl2 (dict or str) – Sets the object’s value for yticlabels2. Must be a str, or a dictionary object with float:str mappings.