|
1 | 1 | """ |
2 | | -# VCS Visualization and Control System - (VCS) module |
3 | | -# |
4 | | -################################################################################# |
5 | | -# # |
6 | | -# Module: vcs module # |
7 | | -# # |
8 | | -# Authors: PCMDI Software Team # |
9 | | -# support@pcmdi.llnl.gov # |
10 | | -# http://cdat.sf.net/cdat # |
11 | | -# # |
12 | | -# Description: Python command wrapper for VCS's functionality. VCS is computer # |
13 | | -# software for the selection, manipulation, and display of # |
14 | | -# scientific data. By specification of the desired data, the # |
15 | | -# graphics method, and the display template, the VCS user gains # |
16 | | -# virtually complete control of the appearance of the data # |
17 | | -# display and associated text and animation. # |
18 | | -# # |
19 | | -# Upgrade to VTK: # |
20 | | -# Author: Charles Doutriaux # |
21 | | -# Description: Took out all C code and used VTK's python bindings instead # |
22 | | -# # |
23 | | -################################################################################# |
| 2 | +===================================== |
| 3 | +VCS: Visualization and Control System |
| 4 | +===================================== |
| 5 | +
|
| 6 | +------- |
| 7 | +Authors |
| 8 | +------- |
| 9 | +
|
| 10 | +Creator: Dean Williams (LLNL, AIMS Team) |
| 11 | +
|
| 12 | +Lead Developer: Charles Doutriaux (LLNL, AIMS Team) |
| 13 | +
|
| 14 | +Contributors: https://github.com/UV-CDAT/uvcdat/graphs/contributors |
| 15 | +
|
| 16 | +Support Email: uvcdat-support@llnl.gov |
| 17 | +
|
| 18 | +Project Site: http://uvcdat.llnl.gov/ |
| 19 | +
|
| 20 | +Project Repo: https://github.com/UV-CDAT/uvcdat/graphs/contributors |
| 21 | +
|
| 22 | +----------- |
| 23 | +Description |
| 24 | +----------- |
| 25 | +VCS is a visualization library for scientific data. It has a simple |
| 26 | +model for defining a plot, that is decomposed into three parts: |
| 27 | +
|
| 28 | +1. **Data**: If it's iterable, we'll plot it... or at least try! |
| 29 | + Currently we support numpy arrays, lists (nested and not), |
| 30 | + and CDMS2 variables (there's some special support for metadata |
| 31 | + from CDMS2 that gives some niceties in your plot, but it's not |
| 32 | + mandatory). |
| 33 | +2. **Graphics Method**: We have a variety of plot types that we |
| 34 | + support out-of-the box; you can easily customize every aspect |
| 35 | + of them to create the effect that you're looking for. If you can't, |
| 36 | + we also support defining your own graphics methods, which you can |
| 37 | + share with other users using standard python infrastructure (conda, pip). |
| 38 | +3. **Template**: Templates control the appearance of everything that |
| 39 | + *isn't* your data. They position labels, control fonts, adjust borders, |
| 40 | + place legends, and more. They're very flexible, and give the fine-grained |
| 41 | + control of your plot that is needed for the truly perfect plot. Once you've |
| 42 | + customized them, you can also save them out for later use, and distribute |
| 43 | + them to other users. |
24 | 44 | """ |
| 45 | + |
25 | 46 | _doValidation = True |
26 | 47 | next_canvas_id = 1 |
27 | 48 | import cdat_info # noqa |
|
223 | 244 | vcs.scriptrun(user_init) |
224 | 245 |
|
225 | 246 | canvaslist = [] |
226 | | -# |
227 | | -# |
228 | | -# Construct a VCS Canvas Object. # |
229 | | -# |
230 | | -# |
231 | 247 |
|
232 | 248 |
|
233 | 249 | def init(mode=1, pause_time=0, call_from_gui=0, size=None, |
234 | 250 | backend="vtk", geometry=None, bg=None): |
235 | 251 | ''' |
236 | | - Function: init # Initialize, Construct a VCS Canvas Object |
237 | | -
|
238 | | - Description of Function: |
239 | | - Construct the VCS Canas object. |
240 | | -
|
241 | | - Example of Use: |
242 | | - import vcs,cdms2 |
243 | | -
|
244 | | - file=cdms2.open('filename.nc') |
245 | | - slab=file.getslab('variable') |
246 | | - a=vcs.init() # This examples constructs 4 VCS Canvas |
247 | | - a.plot(slab) # Plot slab using default settings |
248 | | - b=vcs.init() # Construct VCS object |
249 | | - template=b.gettemplate('AMIP') # Get 'example' template object |
250 | | - b.plot(slab,template) # Plot slab using template 'AMIP' |
251 | | - c=vcs.init() # Construct new VCS object |
252 | | - isofill=c.getisofill('quick') # Get 'quick' isofill graphics method |
253 | | - c.plot(slab,template,isofill) # Plot slab using template and isofill objects |
254 | | - d=vcs.init() # Construct new VCS object |
255 | | - isoline=c.getisoline('quick') # Get 'quick' isoline graphics method |
256 | | - c.plot(isoline,slab,template) # Plot slab using isoline and template objects |
| 252 | + Initialize and construct a VCS Canvas object. |
| 253 | +
|
| 254 | + :Example: |
| 255 | +
|
| 256 | +:: |
| 257 | +
|
| 258 | + import vcs |
| 259 | +
|
| 260 | + # Portrait orientation of 1 width per 2 height |
| 261 | + portrait = vcs.init(size=.5) |
| 262 | + # also accepts "usletter" |
| 263 | + letter = vcs.init(size="letter") |
| 264 | + a4 = vcs.init(size="a4") |
| 265 | +
|
| 266 | + import vtk |
| 267 | + # Useful for embedding VCS inside another application |
| 268 | + my_win = vtk.vtkRenderWindow() |
| 269 | + embedded = vcs.init(backend=my_win) |
| 270 | +
|
| 271 | + dict_init = vcs.init(geometry={"width": 1200, "height": 600}) |
| 272 | + tuple_init = vcs.init(geometry=(1200, 600)) |
| 273 | +
|
| 274 | + bg_canvas = vcs.init(bg=True) |
| 275 | +
|
| 276 | +:param size: Aspect ratio for canvas (width / height) |
| 277 | +:param backend: Which VCS backend to use |
| 278 | +:param geometry: Size (in pixels) you want the canvas to be. |
| 279 | +:param bg: Initialize a canvas to render in "background" mode (without displaying a window) |
| 280 | +:type size: float or case-insensitive str |
| 281 | +:type backend: str, `vtk.vtkRenderWindow` |
| 282 | +:type geometry: dict or tuple |
| 283 | +:type bg: bool |
| 284 | +:return: an initialized canvas |
| 285 | +:rtype: `vcs.Canvas.Canvas` |
257 | 286 | ''' |
258 | 287 | canvas = Canvas.Canvas( |
259 | 288 | mode=mode, |
|
0 commit comments