Raster Scripts

From WikiROMS
Revision as of 21:05, 25 June 2010 by Robertson (talk | contribs)
(change visibility) (diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
Raster Scripts

Two shell scripts, ncgm2www and ncgm2gif, are available to convert the gmeta files into raster (gif) images. As mentioned in the Contour and Cross-section plots sections of this tutorial, gmeta files are NCAR Computer Graphics Metafiles or ncgm files. The ncgm2www script creates one gif image for each frame of your gmeta file while the ncgm2gif script can create an animated gif. Both scripts are needed because ncgm2www calls ncgm2gif.


NoteNote: You need ImageMagick or imtools for these scripts to work. If you wish to use imtools, you will need to modify ncgm2gif setting CONVERT to point to the location of imconv on your system. The ncgm2www and ncgm2gif scripts can be found in the src/Bin directory of the plotting package source. It is recommended that you place both scripts in $HOME/bin where $HOME is your home directory. If you place the scripts elsewhere you will need to edit the ncgm2www to set the correct path to ncgm2gif.



ncgm2www

Once you have an ncgm file from ccnt or csec, you can use ncgm2www to create numbered gif images for each frame of your gmeta file. I often use this script to make animations for PowerPoint. Make sure that your NCARG_ROOT environment variable is set properly.

The syntax for the command is:

  > ncgm2www [ ncgmfile ] [ resolution ] [ outfile ]

For Example:

  > ncgm2www gmeta.ccnttemp 725x725 cnt_temp

Will create the a 725x725 pixel gif image for each frame of the gmeta.ccnttemp file. The resulting gif files will be named sequentially ccnt_temp_001.gif through whatever the maximum frame number in the cgmfile is. If there are 20 frames then the files would be ccnt_temp_001.gif through ccnt_temp_020.gif.

If the outfile argument is missing then "ocean" is assumed. If all arguments are omitted then the following values are assumed:

  ncgmfile   =   gmeta
  resolution =   512x512
  outfile    =   ocean

You can then use other tools to create avi or animated gif files.

ncgm2gif

The ncgm2gif script has different behavior depending on whether your ncgm file has one or more frames. If your ncgm file has multiple frames ncgm2gif will create an animated gif (see note below). Otherwise, it will create a regular gif file. The ncgm2www script splits a multi-frame ncgm file into single-frame ncgm files and runs ncgm2gif on those single-frame ncgm files.


NoteNote: You will need GIFMerge if you wish to create multi-frame animated GIF files.


The syntax for the command is:

  > ncgm2gif [OPTION]...  ncgmfile

The only required argument is ncgmfile. The available options and defaults are:

  -i              Prompt user whenever a file will be overwritten.
                  The default is to overwrite files.
  
  -fmt [ras|vec]  ctrans output format: raster or vector. Often ctrans
                  compiled on 64-bit systems creates corrupt raster files so
                  the vec option is provided as a workaround but requires
                  ImageMagick. The vector format will work with either 32-
                  or 64-bit NCARG libraries.
                  The default is ras.
  
  -res {w}x{h}    Specifies output resolution in pixels where {w} and {h}
                  are integers specifying width and height in pixels.
                  The default is 500x500.
  
  -loop N         For a multi-framed NCGM, indicates how many times you want
                  the GIF animation to loop. N=0 indicates infinite looping,
                  N=1 indicates the animation will be run twice, etc.
                  The default is no looping.
  
  -delay N        If looping is turned on, sets the delay between frames in
                  units of 1/100th of a second.
                  The default is N=50 (0.5 seconds between frames).

Examples:


To convert a single-frame ncgm file called gmeta to a 500x550 pixel GIF file:

  > ncgm2gif gmeta

To convert a single-frame ncgm file called gmeta to a 725x725 pixel GIF file:

  > ncgm2gif -res 725x725 gmeta

To convert a multi-frame ncgm called gmeta.multi to a multi-framed non-looping GIF file that is 200x200 pixels:

  > ncgm2gif -res 200x200 gmeta.multi

To convert a multi-frame ncgm called gmeta.multi to a multi-framed GIF file, and have the animation run 4 times with a delay of 20/100 seconds between each frame:

  > ncgm2gif -loop 3 -delay 20 gmeta.multi

NoteNote: The ROMS plotting package is also distributed with a shell script (src/Bin/plt_html.sh) that you can use as a guide for automating plots of model output. The plt_html.sh script was used to automatically generate plots for the Shallow Water Acoustics 2006 Experiment. The resulting plots can be found here.


Prev: Plotting Fields