unified1D

# Unification of all 1D gms

class vcs.unified1D.G1d(name, name_src='default')[source]

This graphics method displays a line plot from 1D data array (i.e. a plot of Y(x), where y represents the 1D coordinate values, and x can be either Y’s axis or another 1D arrays). The example below shows how to change line and marker attributes for the Yxvsx graphics method.

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

Make a Canvas object:

You’ll need a Canvas object to work with.

# VCS Canvas constructor
a=vcs.init()
Create a new instance of Yxvsx:
1
2
3
4
# Copies content of 'quick' to 'new'
yxx=a.create1D('new','quick')
# Copies content of 'default' to 'new'
yxx=a.create1D('new')
Modify an existing Yxvsx:
  • Get a YXvsX object to work with:

    yxx=a.get1D('AMIP_psl')
    
  • Overview of YXvsX attributes:

    • To view YXvsX attributes:

      # Will list all the Yxvsx attribute values
      yxx.list()
      
    • To set the projection attribute:

      yxx.projection='linear'
      

      Note

      YXvsX projection attribute can only be ‘linear’ i.e. lon30={-180:‘180W’,-150:‘150W’,0:’Eq’}

    • To set axis attributes:

       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      yxx.xticlabels1=lon30
      yxx.xticlabels2=lon30
      # Will set them both
      yxx.xticlabels(lon30, lon30)
      yxx.xmtics1=''
      yxx.xmtics2=''
      # Will set them both
      yxx.xmtics(lon30, lon30)
      yxx.yticlabels1=lat10
      yxx.yticlabels2=lat10
      # Will set them both
      yxx.yticlabels(lat10, lat10)
      yxx.ymtics1=''
      yxx.ymtics2=''
      # Will set them both
      yxx.ymtics(lat10, lat10)
      yxx.datawc_y1=-90.0
      yxx.datawc_y2=90.0
      yxx.datawc_x1=-180.0
      yxx.datawc_x2=180.0
      # Will set them all
      yxx.datawc(-90, 90, -180, 180)
      yxx.xaxisconvert='linear'
      
    • To specify the Yxvsx line type:

       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      # same as yxx.line = 'solid'
      yxx.line=0
      # same as yxx.line = 'dash'
      yxx.line=1
      # same as yxx.line = 'dot'
      yxx.line=2
      # same as yxx.line = 'dash-dot'
      yxx.line=3
      # same as yxx.line = 'long-dash
      yxx.line=4
      
    • To specify the Yxvsx line color:

      1
      2
      3
      4
      # color range: 16 to 230, default color is black
      yxx.linecolor=16
      # width range: 1 to 100, default color is 1
      yxx.linewidth=1
      
    • To specify the Yxvsx marker type:

       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
      35
      36
      # Same as yxx.marker='dot'
      yxx.marker=1
      # Same as yxx.marker='plus'
      yxx.marker=2
      # Same as yxx.marker='star'
      yxx.marker=3
      # Same as yxx.marker='circle'
      yxx.marker=4
      # Same as yxx.marker='cross'
      yxx.marker=5
      # Same as yxx.marker='diamond'
      yxx.marker=6
      # Same as yxx.marker='triangle_up'
      yxx.marker=7
      # Same as yxx.marker='triangle_down'
      yxx.marker=8
      # Same as yxx.marker='triangle_left'
      yxx.marker=9
      # Same as yxx.marker='triangle_right'
      yxx.marker=10
      # Same as yxx.marker='square'
      yxx.marker=11
      # Same as yxx.marker='diamond_fill'
      yxx.marker=12
      # Same as yxx.marker='triangle_up_fill'
      yxx.marker=13
      # Same as yxx.marker='triangle_down_fill'
      yxx.marker=14
      # Same as yxx.marker='triangle_left_fill'
      yxx.marker=15
      # Same as yxx.marker='triangle_right_fill'
      yxx.marker=16
      # Same as yxx.marker='square_fill'
      yxx.marker=17
      # Draw no markers
      yxx.marker=None
      
    • There are four possibilities for setting the marker color index:

      1
      2
      3
      4
      5
      6
      7
      8
      # Same as below
      yxx.markercolors=22
      # Same as below
      yxx.markercolors=(22)
      # Will set the markers to a specific color index
      yxx.markercolors=([22])
      # Color index defaults to Black
      yxx.markercolors=None
      
    • To set the Yxvsx Marker size:

      1
      2
      3
      4
      5
      yxx.markersize=5
      yxx.markersize=55
      yxx.markersize=100
      yxx.markersize=300
      yxx.markersize=None
      
    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

Parameters

xaxisconvert () – (Ex: ‘linear’) converting xaxis linear/log/log10/ln/exp/area_wt

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.create1d('1d_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 g_type

the 1d graphics method type

list()[source]

Lists the current values of object attributes

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

Saves out a copy of the yxvsx 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.getyxvsx()
>>> 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.

setLineAttributes(line)[source]

Set attributes linecolor, linewidth and linetype from line l. l can be a line name defined in vcs.elements or a line object

property smooth

beta parameter for kaiser smoothing

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 1d after setting the mtics and template, refer to vcs.Canvas.plot() or vcs.Canvas.1d().

Example
1
2
3
4
5
>>> a=vcs.init()
>>> ex=vcs.create1d()
>>> 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.create1d()
>>> 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.

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 1d after setting the mtics and template, refer to vcs.Canvas.plot() or vcs.Canvas.1d().

Example
1
2
3
4
5
>>> a=vcs.init()
>>> ex=vcs.create1d()
>>> ex.xmtics("lat5") # 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.create1d()
>>> 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.

Jupyter Notebooks