Personal tools
You are here: Home CDAT Tips and Tricks File I/O Tips Saving images/plots in CDAT
Document Actions

Saving images/plots in CDAT

by Renata McCoy last modified 2005-10-26 15:59

  Table of Contents Previous Next
Contents Previous Next

Goal: Learn how to save plot/window in CDAT.

There are several methods and fomat files you can save your CDAT plot to. Here are some of them, for more extensive explanation see Basic Plotting Commands tutorial.  

import cdms, vcs, cdutil, os, sys

# open a file to read data
filepath = os.path.join(sys.prefix, 'sample_data/ts_da.nc')
f = cdms.open( filepath)

# read data from an input file
data = f('ts')  

# Initial VCS v = vcs.init()

# Plot data using the default boxfill graphics method:
v.plot(data)

Generate a postscript output file.

v.postscript('test.ps')

Generate a gif output file.

v.gif('test.gif')

Generate a cgm output file.

v.cgm('test.cgm')

Generate a raster output file.

v.raster('test.ras')

Generate a ghostscript output file.

v.gs('test.png')# generate ghostscript png output file

# generate ghostscript tiff output file
v.gs('test.tif', device = 'tiff24nc', orientation = 'l', resolution = '172.x172.')



 

 

  Table of Contents Previous Next
Contents Previous Next

Powered by Plone