This Notebook demonstrates the VCS Principles.

In [1]:

```
# VCS Objects definitions
import vcs
import cdms2
import os
vcs.download_sample_data_files()
with cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) as f:
clt = f("clt")
u = f("u")
v = f("v")
with cdms2.open(os.path.join(vcs.sample_data,"sampleCurveGrid4.nc")) as f:
curv = f("sample")
with cdms2.open(os.path.join(vcs.sample_data,"sampleGenGrid3.nc")) as f:
gen = f("sample")
x = vcs.init(geometry=(600,400),bg=True)
# Styling for notebook
from IPython.core.display import HTML
HTML("""
<style>
.output_png {
display: table-cell;
text-align: center;
vertical-align: middle;
}
</style>
""")
```

Out[1]:

VCS Allows scientists to produce highly customized plots. Everything can be precisely and logically controlled, without any *guessing* game.

Essentially a vcs plot can be broken down into three parts:

**WHAT** is plotted (e.g data and labels) **HOW** it is rendered (isolines, boxfill, isofill, vectors, etc...) and **WHERE** (location on the page each elements is to be plotted).

This is the scientific piece of information that the user is trying to represent for others (or self) to understand. It can be as raw as a simple NumPy object. But it is recommended to use CDMS's transient variables. CDMS transient variables contain metadata such as name, units, and geospatial information that can be used by VCS to represent data better.

The [tutorials] section has many documents for CDMS. The CDMS documentation can be found here.

This describes the data representation. At the highest level it is a `graphics method`

i.e. *boxfill*, *isofill*, *vectors*, *streamlines*, *line plot*, etc... However it also contains information to further control these plot types, e.g. which colors to use, which levels and lines thickness, etc...

Graphic methods also describe how axes and labels should be represented (e.g which axes values to show and which text to use for it. For example, the user might want to show the `-20`

latitude represented as `20S`

or the date `2020-01-15`

shown as `Jan 2020`

Currently VCS supports the following graphic methods:

Boxfill is used to represent 2 dimensional arrays, filling each array cell with a color representing its value. In the case of rectilinear grids (x and y axes can be represented by a 1 dimension array) represented via CDMS, we use the axes **bounds** to determine the extent of each cell. This is especially useful if an axis is not increasing constantly (e.g, gaussian grid, pressure levels).

For more information on boxfill please see the dedicated tutorial.

In [2]:

```
gm = vcs.createboxfill()
x.plot(clt, gm)
```

Out[2]:

Isoline is a line on a map, chart, or graph connecting points of equal value.

For more information on isolines please see the dedicated tutorial.

In [3]:

```
gm = vcs.createisoline()
x.clear()
x.plot(clt,gm)
```

Out[3]:

Isofill is similar to isolines (and usually plotted in conjunction with it) except that the area between two consecutive isolines is filled with a color representing the range of values in this area.

For more information on isofill please see the dedicated tutorial.

In [4]:

```
x.clear()
gm = vcs.createisofill()
x.plot(clt,gm)
```

Out[4]:

Meshfill is very similar to boxfill, but is used to represent data on generic grids (a.k.a native representation). Based on the input data and a *mesh*.

For more information on meshfill please see the dedicated tutorial.

In [5]:

```
x.clear()
gm = x.createmeshfill()
gm.mesh = True
x.plot(gen, gm)
```

Out[5]:

For more information on streamlines please see the dedicated tutorial.

In [6]:

```
x.clear()
gm = vcs.createstreamline()
x.plot(u,v,gm)
```

Out[6]:

Vector plot are a collection of arrows with a given magnitude and direction, each attached to a point in the plane.

For more information on vector plots please see the dedicated tutorial.

In [7]:

```
x.clear()
gm = vcs.createvector()
x.plot(u,v, gm)
```

Out[7]:

A graph that shows frequency of data along a number line.

For more information on 1D line plots please see the dedicated tutorial.

Also of interest are the EzPlot Addons.

In [8]:

```
x.clear()
gm = vcs.create1d()
x.plot(clt[:,34,23]) # extract time serie at one point and plot in 1D
```

Out[8]:

Taylor diagrams are mathematical diagrams designed to graphically indicate which of several approximate representations (or models) of a system, process, or phenomenon is most realistic. This diagram, invented by Karl E. Taylor in 1994 (published in 2001) facilitates the comparative assessment of different models. It is used to quantify the degree of correspondence between the modeled and observed behavior in terms of three statistics: the Pearson correlation coefficient, the root-mean-square error (RMSE) error, and the standard deviation. Taylor diagrams have widely been used to evaluate models designed to study climate and other aspects of Earthâ€™s environment. [See Wiki and Taylor (2001) for details]

For more detailed information on Taylor Diagrams see this dedicated tutorial.

In [9]:

```
corr = [.2, .5, .7, .85, .9, .95, .99]
std = [1.6, 1.7, 1.5, 1.2 , .8, .9, .98]
data = cdms2.MV2.array(zip(std, corr))
gm = vcs.createtaylordiagram()
x.clear()
x.plot(data,gm)
```

Out[9]:

This is the most complicated part of VCS but also one of the most powerful. This controls precisely the location of every component on the plot, these *control* objects are called `templates`

. Templates also contain one exception to the WHAT/HOW/WHERE rule as they control text information, albeit via primary objects.

Secondary object positioning is based on a double system.

The most basic is called **world coordinate** by changing a secondary object's `worldcoordinate`

attribute you can control the coordinates of the rectangular area within which the object will be plottted.

All coordinates (`.x`

and `.y`

) are relative to the worldcoordinate attribute (defautling to 0->1).

Any coordinate/segment extending beyond the `viewport`

rectangle is cropped.

See figure bellow for a visual explanation, along with the vcs script to generate it:

Text objects allow you to insert text anywhere on the plot. Text objects are made by combining two different secondary objects: a text orientation object and a text table object.

For more details on text in vcs see this dedicated tutorial.

In [10]:

```
x.clear()
txt = vcs.createtext()
txt.string="A Text Object"
txt.height=25
txt.x = [.5]
txt.y=[.5]
txt.list()
x.plot(txt)
```

Out[10]:

Line objects allow you to draw lines on the plot. By closing the line you can draw a polygon.

For more details on lines in vcs see this dedicated tutorial.

In [11]:

```
x.clear()
line = vcs.createline()
line.x = [0.1, .5, 0.9]
line.y = [0.1, .2, 0.9]
x.plot(line)
```

Out[11]:

Allows you to draw a filled polygon on the plot.

For more details on filled polygons in vcs see this dedicated tutorial.

In [12]:

```
x.clear()
filled = vcs.createfillarea()
filled.x = [0.1, .5, 0.9]
filled.y = [0.1, .2, 0.9]
x.plot(filled)
```

Out[12]:

Allows you to draw one or many markers on a plot.

In [13]:

```
x.clear()
mrk = vcs.createmarker()
mrk.type = "hurricane"
mrk.x = [.5]
mrk.y = [.5]
mrk.size = 15
x.plot(mrk)
```

Out[13]:

Colormap objects are used to control the colors on vcs plots. They can be attached to secondary objects, graphic methods or canvases. Values are in percenages (0 to 100) and the four attributes to specify are red, green, blue, and opacity.

For more detail see this dedicated tutorial.

In [14]:

```
cmap = vcs.createcolormap()
cmap.setcolorcell(100,0,0,50) # 50% transparent red color
```

When plotting lat/lon plots (2d graphic methods) you can specifiy and control the projection associated with it. The projection object is then attached to the graphic method.

For more detail see this dedicated tutorial.

In [15]:

```
x.clear()
gm = vcs.createisofill()
proj = vcs.createprojection()
proj.type="lambert"
proj.list()
proj.originlatitude=30.
gm.projection = proj
x.plot(clt(latitude=(10,50),longitude=(-130,-70)), gm)
```

Out[15]: