utils

Utils contains functions and objects that provide VCS with useful utilities.

Creates a ‘logo’ object

This also to draw a logo either from a text string or a picture (png) file. Picture will be shrunk to fit within the canvas if it’s too big to fit

Example
>>> import os, sys
>>> x=vcs.init()
>>> x.open()
>>> path=os.path.join(vcs.vcs_egg_path,"cdat.png")
>>> logo1=vcs.utils.Logo(path)
>>> logo1.x=.7
>>> logo1.y=.8
>>> logo2 = vcs.utils.Logo("My Test Logo")
>>> logo2.x = .2
>>> logo2.y = .2
>>> logo1.plot(x)
>>> logo2.plot(x)
plot(canvas, bg=True)[source]

Plot the logo onto a given Canvas

Example
>>> import os, sys
>>> x=vcs.init()
>>> x.open()
>>> path=os.path.join(vcs.vcs_egg_path, "uvcdat.png")
>>> logo1 = vcs.utils.Logo(path)
>>> logo1.x=.7
>>> logo1.y=.8
>>> logo2 = vcs.utils.Logo("My Test Logo")
>>> logo2.x = .2
>>> logo2.y = .2
>>> logo1.plot(x)
>>> logo2.plot(x)
Parameters
  • canvas (vcs.Canvas.Canvas) – Canvas onto which you desire plotting the logo

  • bg (bool) – do we plot in background (offscreen) mode or not? True/False

exception vcs.utils.VCSUtilsError(args=None)[source]
vcs.utils.creategraphicsmethod(gtype, gname='default', name=None)[source]

Creates a graphics method of the type given by gtype.

Example
>>> cgm=vcs.creategraphicsmethod # alias long name
>>> cgm('Gfm') # meshfill inherits default; name generated
<vcs.meshfill.Gfm ...>
>>> cgm('boxfill','polar') # boxfill inherits polar; name generated
<vcs.boxfill.Gfb ...>
>>> cgm('Gfi',name='my_gfi') # isofill inherits default; user-named
<vcs.isofill.Gfi ...>
Parameters
  • gtype (str) – String name of the type of graphics method object to create.

  • gname (str) – String name of the specific graphics method for the new graphics method to inherit.

  • name (str or None) – String name for the new object. If None, a unique name will be generated.

Returns

A graphics method object

vcs.utils.download_sample_data_files(path=None)[source]

Downloads sample data to be used with VCS. Default download directory is vcs.sample_data, but if __path__ is provided then data will be downloaded to that path.

Example
>>> import os # use this to check if sample data already exists
>>> if not os.path.isdir(vcs.sample_data):
...     vcs.download_sample_data_files()
Parameters

path (str or None) – String of a valid filepath. If None, sample data will be downloaded into the vcs.sample_data directory.

vcs.utils.drawLinesAndMarkersLegend(canvas, templateLegend, linecolors, linetypes, linewidths, markercolors, markertypes, markersizes, strings, scratched=None, stringscolors=None, stacking='horizontal', bg=False, render=True, smallestfontsize=None, backgroundcolor=None)[source]

Draws a legend with line/marker/text inside a template legend box Auto adjust text size to make it fit inside the box Auto arrange the elements to fill the box nicely

Example
>>> import vcs
>>> x = vcs.init()
>>> t = vcs.createtemplate()
>>> vcs.utils.drawLinesAndMarkersLegend(x,t.legend,
...     ["red","blue","green"], ["solid","dash","dot"],[1,4,8],
...     ["blue","green","red"], ["cross","square","dot"],[3,4,5],
...     ["sample A","type B","thing C"], bg=True)
>>> x.png("sample")
Parameters
  • canvas (vcs.Canvas.Canvas) – a VCS canvas object onto which to draw the legend

  • templateLegend – a template legend object used to determine the coordinates of the box and the box line type

  • linecolors (list) – list containing the colors of each line to draw. Colors must be specified as either integers, (r,g,b,opacity), or string color names.

  • linetypes (list) – list containing the type of each line to draw. values must be int or line type strings

  • linewidths (list) – list containing each line width. line widths must be of type float.

  • markercolors (list) – list of the markers colors to draw. Colors must be specified as either integers, (r,g,b,opacity), or string color names.

  • markertypes (list) – list of the marker types to draw. Marker type must be int or string of marker type names.

  • markersizes (list) – list of the size of each marker to draw. marker size must be of type float.

  • strings (list) – list of the string to draw next to each line/marker

  • scratched (None or list) – None (off) or list. list contains False where no scratch is needed. For scratched, provide True or line type to use for scratch. Color will match that of text.

  • stringscolors (`string`_) – A list of the strings colors to draw. Colors are represented as either an int from 0-255, an rgba tuple, or a string color name.

  • stacking – Prefered direction to stack element (‘horizontal’ or ‘vertical’)

  • bg (bool) – Boolean value indicating to draw in background (True), Or foreground (False).

  • render (bool) – Boolean value indicating whether or not to render the new lines and markers.

  • smallestfontsize – Integer value indicating the smallest font size we can use for rendering None means no limit, 0 means use original size. Downscaling will still be used by algorigthm to try to fit everything in the legend box.

  • backgroundcolor

    A list indicating the background color of the legended box.

    Colors are represented as either an int from 0-255, an rgba tuple, or a string color name.

    type markercolors

    list

vcs.utils.drawVectorLegend(canvas, templateLegend, linecolor, linetype, linewidth, unitString, maxNormInVp=1.0, maxNorm=1.0, minNormInVp=0.0, minNorm=0.0, bg=False, render=True, reference=1e+20)[source]

Draws a legend with vector line/text inside a template legend box Auto adjust text size to make it fit inside the box

Example
>>> import vcs
>>> x = vcs.init()
>>> t = vcs.createtemplate()
>>> vcs.utils.drawVectorLegend(x,t.legend,
...     "red", "solid", 1, "sample A", bg=True)
Parameters
  • canvas (vcs.Canvas.Canvas) – a VCS canvas object onto which to draw the legend

  • templateLegend – a template legend object used to determine the coordinates of the box and the box line type

  • linecolor (`string`_) – color of vector to draw. The color must be specified as either integers, (r,g,b,opacity), or string color name.

  • linetype (`string`_) – type of the vector line to draw. values must be int or line type string

  • linewidth (`string`_) – vector line width. line width must be of type float.

  • unitString (`string`_) – unit for maxNorm

: param maxNormInVp: maxNorm in viewport coordinates : type maxNormInVp: float

: param maxNorm: maxNorm in world coordinates : type maxNorm: float

: param minNormInVp: minNorm in viewport coordinates. If None, we don’t

to show minNorm legend

: type minNormInVp: float

: param minNorm: minNorm in world coordinates : type minNorm: float

Parameters
  • bg (bool) – Boolean value indicating to draw in background (True), Or foreground (False).

  • render (bool) – Boolean value indicating whether or not to render the new lines.

: param reference: Desired length of reference vector in plot legend. The

default is to choose a reasonable size for the max vector in the legend based on the amount of space available. This behavior can be overridden by providing the “reference” parameter, and then the size of the arrow will be computed to match. Be aware this may cause the arrow to be very large (not fitting nicely within the legend) or very small, even invisible.

: type reference: float

vcs.utils.dumpToDict(obj, skipped=[], must=[])[source]

Takes a VCS object and serializes its properties and their associated values in a Python dict .

Example
>>> b=vcs.getboxfill()
>>> t=vcs.gettemplate()
>>> bd=vcs.dumpToDict(b) # serializes all properties
>>> td=vcs.dumpToDict(t, skipped=['legend']) # skip legend property
>>> 'legend' in td[0].keys() # 'legend' should not be in dictionary
False
Parameters
  • obj (A VCS object) – An instance of a VCS object to serialize

  • skipped (list) – A list of strings, associated with property names to skip.

  • must (list) – A list of strings, associated with property names which must be captured in the serialization.

Returns

A tuple containing:

  • a dictionary with mappings of the object’s property names

    to the values associated with those property names.

  • a dictionary with mappings of more complex properties’ names

    to sets containing any associated property values.

Return type

tuple

vcs.utils.dumpToJson(obj, fileout, skipped=['info', 'member', 'attributes'], must=[], indent=1, sort_keys=True)[source]

Uses vcs.utils.dumpToDict() and json.dumps to construct a JSON representation of a VCS object’s property values.

Example
>>> box=vcs.getboxfill()
>>> vcs.dumpToJson(box, 'box.json') # output properties to file
>>> vcs.dumpToJson(box,None) # returns JSON string
'{...}'
Parameters
  • obj (A VCS object) – An instance of a VCS object to serialize

  • fileout (str or file) – A file or a string name of a file into which the JSON will be written.

  • skipped (list) – A list of strings, associated with property names to skip.

  • must (list) – A list of strings, associated with property names which must be captured in the serialization.

  • indent (int or None) –

    An integer representing whether to pretty-print the JSON.

    • If indent is a non-negative integer, JSON will be printed with proper

      indentation levels.

    • If indent is None, 0, or negative, JSON will be printed in its most

      compact form.

  • sort_keys (bool) – Boolean value indicating whether output should be sorted by key (True), or not (False)

Returns

The VCS object’s properties serialized into a JSON formatted str . OR None, if fileout was specified.

Return type

str or None

vcs.utils.generate_time_labels(d1, d2, units, calendar=135441)[source]

Generates a dictionary of time labels for an interval of time, in a user defined units system.

Example
# Two ways to generate a dictionary of time labels
>>> import cdtime
>>> lbls = vcs.generate_time_labels(cdtime.reltime(0,'months since 2000'),
...     cdtime.reltime(12,'months since 2000'),
...     'days since 1800') # for the year 2000 in units of 'days since 1800'
>>> lbls = vcs.generate_time_labels(cdtime.reltime(0,'months since 2000'),
...     cdtime.comptime(2001),
...     'days since 1800') # for the year 2000 in units of 'days since 1800'
>>> lbls = vcs.generate_time_labels(0, 12, 'months since 2000') # time labels for year 2000
Parameters
  • d1 (cdtime object or int or long or float) – The beginning of the time interval to be labelled. Expects a cdtime object. Can also take int, long, or float, which will be used to create a cdtime object with the given units parameter.

  • d2 (cdtime object or int or long or float) – The end of the time interval to be labelled. Expects a cdtime object. Can also take int, long, or float, which will be used to create a cdtime object with the given units parameter.

  • units (str) – String with the format ‘[time_unit] since [date]’.

  • calendar – A cdtime calendar

Returns

Dictionary of time labels over the given time interval

Return type

dict

vcs.utils.get_png_dims(fnm)[source]

Given the path to a png, return width, height of the png.

Example
>>> a=vcs.init(bg=True)
>>> box=vcs.getboxfill('polar')
>>> array=[range(10) for _ in range(10)]
>>> a.plot(box,array) # plot something on canvas
<vcs.displayplot.Dp ...>
>>> a.png('box.png', width=1536, height=1186) # make a png
>>> vcs.get_png_dims('box.png') # get (width, height) of 'box.png'
(1536, 1186)
Parameters

fnm (str) – String specifying the path to a .png file

Returns

A tuple containing (width, height) of the given png.

Return type

tuple

vcs.utils.getcolorcell(cell, obj=None)[source]

Gets the colorcell of the provided object’s colormap at the specified cell index. If no object is provided, or if the provided object has no colormap, the default colormap is used.

Example
>>> a=vcs.init()
>>> b=vcs.createboxfill()
>>> b.colormap='rainbow'
>>> a.getcolorcell(2,b)
[26, 1, 34, 100]
Parameters
  • cell (int) – An integer value indicating the index of the desired colorcell.

  • obj (Any VCS object capable of containing a colormap) – Optional parameter with the object to get a colormap from.

Returns

The RGBA values of the colormap at the specified cell index.

Return type

list

vcs.utils.getcolormap(Cp_name_src='default')[source]

VCS contains a list of secondary methods. This function will create a colormap class object from an existing VCS colormap secondary method. If no colormap name is given, then colormap ‘default’ will be used.

Note

VCS does not allow the modification of ‘default’ attribute sets. However, a ‘default’ attribute set that has been copied under a different name can be modified. (See the createcolormap function.)

Example
>>> a=vcs.init()
>>> a.show('colormap') # Show all  colormap secondary methods
*******************Colormap Names List**********************
...
*******************End Colormap Names List**********************
>>> cp=a.getcolormap() # 'default' colormap
>>> cp2=a.getcolormap('rainbow') # 'rainbow' colormap
Parameters

Cp_name_src (str) – String name of an existing colormap VCS object

Returns

A pre-existing VCS colormap object

Return type

vcs.colormap.Cp

vcs.utils.getcolors(levs, colors=None, split=1, white='white')[source]

For isofill/boxfill purposes Given a list of levels this function returns the colors that would best spread a list of “user-defined” colors (default is 0 to 255, i.e 256 colors), always using the first and last color. Optionally the color range can be split into 2 equal domain to represent <0 and >0 values. If the colors are split an interval goes from <0 to >0 then this is assigned the “white” color the default range of colors to use can be adjusted by setting: vcs.utils.defaultColorsRange = newrange

Example
>>> a=[0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0]
>>> vcs.getcolors (a)
[0, 28, 57, 85, 113, 142, 170, 198, 227, 255]
>>> vcs.getcolors (a,colors=range(16,200))
[16, 36, 57, 77, 97, 118, 138, 158, 179, 199]
>>> vcs.getcolors(a,colors=[16,25,15,56,35,234,12,11,19,32,132,17])
[16, 25, 15, 35, 234, 12, 11, 32, 132, 17]
>>> a=[-6.0, -2.0, 2.0, 6.0, 10.0, 14.0, 18.0, 22.0, 26.0]
>>> vcs.getcolors (a,white=241)
[0, 241, 128, 153, 179, 204, 230, 255]
>>> vcs.getcolors (a,white=241,split=0)
[0, 36, 73, 109, 146, 182, 219, 255]
Parameters
  • levs (list or tuple) – levels defining the color ranges

  • colors (list or tuple) – A list/tuple of the of colors you wish to use

  • split (int) – Integer flag to split colors between two equal domains. 0 : no split 1 : split if the levels go from <0 to >0 2 : split even if all the values are positive or negative

  • white (int or str or tuple) – If split is on and an interval goes from <0 to >0 this color will be used within this interval.

Returns

List of colors

Return type

list

vcs.utils.getfontname(number)[source]

Retrieve a font name for a given font index.

Example
>>> vcs.getfontname(1)
'default'
>>> vcs.getfontname(4)
'Helvetica'
Parameters

number (int) – Index of the font to get the name of.

vcs.utils.getfontnumber(name)[source]

Retrieve a font index for a given font name.

Example
>>> vcs.getfontnumber('default')
1
>>> vcs.getfontnumber('Helvetica')
4
Parameters

name (str) – Name of the font to get the index of.

vcs.utils.getgraphicsmethod(type, name='default')[source]

Retrieves an existing graphics method, given by type and name.

Example
>>> vcs.show('boxfill') # list available boxfills
*******************Boxfill Names List**********************
...
*******************End Boxfill Names List**********************
>>> vcs.getgraphicsmethod('boxfill','polar') # get polar boxfill
<vcs.boxfill.Gfb ...>
Parameters
  • type (str) – String name of a VCS graphics method type

  • name (str) – String name of a VCS graphics method of the given type.

Returns

A graphics method of the given type and name. If such a graphics method doesn’t exist, None will be returned.

Return type

VCS graphics method or None

vcs.utils.getworldcoordinates(gm, X, Y)[source]

Given a graphics method and two axes, calculates correct world coordinates.

Example
>>> import cdms2, os
>>> if not os.path.exists(vcs.sample_data):
...     vcs.download_sample_data_files() # get some data for cdms2
>>> f=cdms2.open(vcs.sample_data + '/clt.nc')
>>> v=f('v') # read variable v from clt.nc
>>> xax=v.getAxis(3) # X axis
>>> yax=v.getAxis(2) # Y axis
>>> box=vcs.getboxfill()
>>> vcs.getworldcoordinates(box, xax, yax)
[-180.0, 180.0, -88.2884, 88.2884]
Parameters
  • gm (graphics method object) – A VCS graphics method object to get worldcoordinates for.

  • X (cdms2.axis.TransientAxis) – A cdms2 transient axs

  • Y (cdms2.axis.TransientAxis) – A cdms2 transient axs

Returns

A list of the worldcoordinates associated with the given graphics method and axes

Return type

list

vcs.utils.listelements(typ=None)[source]

List the elements of a given VCS object type.

Example
>>> vcs.listelements() # list all vcs object types
['1d', '3d_dual_scalar', '3d_scalar', '3d_vector', 'boxfill', ...]
>>> vcs.listelements('1d')
[...]
>>> vcs.listelements('boxfill')
[...]
Parameters

typ (str) – String specifying the type of VCS object to list. If None, list will contain VCS object type names.

Returns

If typ is None, returns a list of VCS object type names. If typ is a VCS object type, returns a list of the object of that type currently present in VCS.

Return type

list

vcs.utils.match_color(color, colormap=None)[source]

Returns the color in the colormap that’s closest to the specified color.

Example
>>> a=vcs.init()
>>> print(vcs.match_color('salmon', 'magma'))
192
>>> print(vcs.match_color('red', 'rainbow'))
242
>>> print(vcs.match_color([0,0,100],'default')) # closest color from blue
52
Parameters
  • color (str or int) – Either a string name, or a rgb value between 0 and 100.

  • colormap (vcs.colormap.Cp) – A VCS colormap object. If not specified, the default colormap is used.

Returns

Integer value representing a matching rgb color

Return type

int

vcs.utils.minmax(*data)[source]

Return the minimum and maximum of a series of array/list/tuples (or combination of these) You can combine list/tuples/arrays pretty much any combination is allowed

Example
>>> s = range(7)
>>> vcs.minmax(s)
(0.0, 6.0)
>>> vcs.minmax([s, s])
(0.0, 6.0)
>>> vcs.minmax([[s, list(s) * 2], 4., [6., 7., s]],[ 5., -7., 8, (6., 1.)])
(-7.0, 8.0)
Parameters

data (list) – A comma-separated list of lists/arrays/tuples

Returns

A tuple in the form (min, max)

Return type

tuple

vcs.utils.mkevenlevels(n1, n2, nlev=10)[source]

Return a series of evenly spaced levels going from n1 to n2. By default 10 intervals will be produced.

Example
>>> vcs.mkevenlevels(0,100)
[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0]
>>> vcs.mkevenlevels(0,100,nlev=5)
[0.0, 20.0, 40.0, 60.0, 80.0, 100.0]
>>> vcs.mkevenlevels(100,0,nlev=5)
[100.0, 80.0, 60.0, 40.0, 20.0, 0.0]
Parameters
  • n1 (int or float) – Beginning of range.

  • n2 (int or float) – End of range. Int or float.

  • nlev (int) – Number of levels by which to split the given range.

Returns

List of floats, splitting range evenly between n1 and n2

Return type

list

vcs.utils.mklabels(vals, output='dict')[source]

This function gets levels and output strings for nice display of the levels values.

Examples
>>> from __future__ import print_function
>>> scale = vcs.mkscale(2, 20, zero=2)
>>> labels = vcs.mklabels(scale)
>>> keys = sorted(labels.keys())
>>> for key in keys:
...     print(key, ':', labels[key])
0.0 : 0
2.0 : 2
4.0 : 4
6.0 : 6
8.0 : 8
10.0 : 10
12.0 : 12
14.0 : 14
16.0 : 16
18.0 : 18
20.0 : 20
>>> labels=vcs.mklabels([.00002,.00003,.00005])
>>> keys=sorted(labels.keys())
>>> for key in keys:
...     print(key, ':', labels[key])
2e-05 : 2E-5
3e-05 : 3E-5
5e-05 : 5E-5
>>> vcs.mklabels ([.00002,.00005],output='list')
['2E-5', '5E-5']
Parameters
  • vals (list, tuple) – List or tuple of float values

  • output (str) – Specifies the desired output type. One of [‘dict’, ‘list’].

Returns

Dictionary or list of labels for the given values.

Return type

dict or list

vcs.utils.mkscale(n1, n2, nc=12, zero=1, ends=False)[source]

This function return a nice scale given a min and a max

Warning

Not all functionality for the ‘zero’ parameter has been implemented. zero=0 is intended to let the function decide what should be done with zeros, but it has yet to be defined. Do not use zero=0.

Examples
>>> vcs.mkscale(0,100)
[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0]
>>> vcs.mkscale(0,100,nc=5)
[0.0, 20.0, 40.0, 60.0, 80.0, 100.0]
>>> vcs.mkscale(-10,100,nc=5)
[-25.0, 0.0, 25.0, 50.0, 75.0, 100.0]
>>> vcs.mkscale(-10,100,nc=5,zero=-1)
[-20.0, 20.0, 60.0, 100.0]
>>> vcs.mkscale(2,20)
[2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0]
>>> vcs.mkscale(2,20,zero=2)
[0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0]
Parameters
  • n1 (float) – Minimum number in range.

  • n2 (float) – Maximum number in range.

  • nc (int) – Maximum number of intervals

  • zero (int) – Integer flag to indicate how zero should be handled. Flags are as follows -1: zero MUST NOT be a contour 0: let the function decide # NOT IMPLEMENTED 1: zero CAN be a contour (default) 2: zero MUST be a contour

  • end (bool) – Boolean value indicating whether n1 and n2 should be part of the returned labels. Defaults to False.

Returns

List of floats split into nc intervals

Return type

list

vcs.utils.monotonic(x)[source]

Uses numpy.diff to determine whether the data given by x is monotonic in nature.

Example
>>> import numpy, cdms2, os
>>> from random import randint
>>> array=numpy.array([range(10) for _ in range(10)])
>>> mask=[] # we will use this to create a random mask
>>> for _ in range(10):
...     mask.append([randint(0,1) for _ in range(10)])
>>> ma=numpy.ma.MaskedArray(array, mask)
>>> if not os.path.exists(vcs.sample_data):
...     vcs.download_sample_data_files() # get some data for cdms2
>>> f=cdms2.open(vcs.sample_data + '/clt.nc')
>>> v=f('v') # get variable 'v' from clt.nc
>>> vcs.monotonic(array) # monotonicity of 2D numpy array
True
>>> vcs.monotonic(ma) # monotonicity of simple masked array
True
>>> vcs.monotonic(v) # monotonicity of cdms2 variable
False
Parameters

x (numpy.array or numpy.ma.MaskedArray or cdms2 variable) – The variable to test for monotonicity. Can be any variable with an array-like structure. Typical examples are numpy arrays, numpy masked arrays, and cdms2 variables (examples for each shown above).

Returns

A boolean value indicating whether the given data is monotonic.

Return type

bool

vcs.utils.pickFrame(data, dimensions_on_plot, frame=0)[source]

Select a specific frame by looping over extra dimensions

vcs.utils.rgba_color(color, colormap)[source]

Try all of the various syntaxes of colors and return 0-100 RGBA values.

Example
>>> cp = vcs.getcolormap() # Get a copy of the default colormap
>>> vcs.rgba_color('black', cp) # Find the rgba equivalent for black
[0.0, 0.0, 0.0, 100]
Parameters
  • color (int or str) – The color to get the rgba value for. Can be an integer from 0-255, or a string name of a color.

  • colormap (vcs.colormap.Cp) – A VCS colormap

Returns

List of 4 floats; the R, G, B, and A values associated with the given color.

Return type

list

vcs.utils.setTicksandLabels(gm, copy_gm, datawc_x1, datawc_x2, datawc_y1, datawc_y2, x=None, y=None)[source]

Sets the labels and ticks for a graphics method made in python

Parameters
  • gm (VCS graphics method) – A VCS graphics method to alter

  • copy_gm (VCS graphics method) – A VCS graphics method object

  • datawc_x1 (float) – Float value to set the graphics method’s datawc_x1 property to.

  • datawc_x2 (float) – Float value to set the graphics method’s datawc_x2 property to.

  • datawc_y1 (float) – Float value to set the graphics method’s datawc_y1 property to.

  • datawc_y2 (float) – Float value to set the graphics method’s datawc_y2 property to.

  • x (str) – If provided, must be the string ‘longitude’

  • y (str) – If provided, must be the string ‘latitude’

Returns

A VCS graphics method object

Return type

A VCS graphics method object

vcs.utils.setcolorcell(obj, num, r, g, b, a=100)[source]

Set a individual color cell in the active colormap. If default is the active colormap, then return an error string.

Note

If the the visual display is 16-bit, 24-bit, or 32-bit TrueColor, then a redrawing of the VCS Canvas is made every time the color cell is changed.

Example
>>> vcs.setcolorcell("AMIP",11,0,0,0)
>>> vcs.setcolorcell("AMIP",21,100,0,0)
>>> vcs.setcolorcell("AMIP",31,0,100,0)
>>> vcs.setcolorcell("AMIP",41,0,0,100)
>>> vcs.setcolorcell("AMIP",51,100,100,100)
>>> vcs.setcolorcell("AMIP",61,70,70,70)
Parameters
  • obj (str or VCS object) – String name of a colormap, or a VCS object

  • num (int) – Integer specifying which color cell to change. Must be from 0-239.

  • r (int) – Integer specifying the red value for the colorcell

  • g (int) – Integer specifying the green value for the colorcell

  • b (int) – Integer specifying the blue value for the colorcell

  • a (int) – Integer specifying the opacity value for the colorcell. Must be from 0-100.

vcs.utils.show(*args)[source]

Show the list of VCS primary and secondary class objects.

Example
>>> vcs.show() # show all vcs object types
['1d', '3d_dual_scalar', '3d_scalar', '3d_vector', 'boxfill', ...]
>>> vcs.show('boxfill') # List boxfill objects
*******************Boxfill Names List**********************
...
*******************End Boxfill Names List**********************
>>> vcs.show('3d_vector') # List 3d_vector objects
*******************3d_vector Names List**********************
...
*******************End 3d_vector Names List**********************
>>> vcs.show('3d_scalar') # List 3d_scalar objects
*******************3d_scalar Names List**********************
...
*******************End 3d_scalar Names List**********************
>>> vcs.show('3d_dual_scalar') # List 3d_dual_scalar objects
*******************3d_dual_scalar Names List**********************
...
*******************End 3d_dual_scalar Names List**********************
>>> vcs.show('1d') # List 1d objects
*******************1d Names List**********************
...
*******************End 1d Names List**********************
Parameters

args (str or None) – String name of a type of object to show, or None