Cross-section Plots

From WikiROMS
Jump to navigationJump to search
Cross-section Plots

The ROMS plotting package allows you to plot cross-sections. You can also overlay a reference field.

Configuration

There are two files that that control the output of the ROMS Plotting Package: default.cnt and the csec.in (or ccnt.in for Contour Plots) file. The default.cnt file controls the internal plotting parameters while the .in file determines what data to plot and how it will appear. At first you will not need to edit the default.cnt file so we will start with the .in file.

NOTE: default.cnt and the .in file can be named anything you want. This will become clear as we continue.

We suggest that you copy csec.in and default.cnt to the directory where you wish to create your plots. If you have already copied default.cnt while following the Contour Plot tutorial you will NOT need to copy it again. I will be plotting vertical velocity with a temperature overlay from output from the upwelling test case.

  cp ~/MyDir/src/External/csec.in csec_upwelling.in
  cp ~/MyDir/Data/default.cnt default.cnt

You may name the file whatever you like. Open the file (csec_upwelling.in in this example) with your favorite editor. The first line of this file allows you to specify the year and starting year-day for your plots. If you do not want a time label make the year-day value less than 0:

  2007 -1      : year and starting year-day (use yearday<0, for no time label)

The next four lines are the plot title. Blank lines are fine but there must be four lines here. The text that you see on lines 2-5 are only a suggestion; you can put any text you like. I will not actually be plotting the title lines but it's good to have for later reference

  ROMS 3.0
  Upwelling Test Case
  Default Setup
  Vertical Velocity with Temperature overlay

The plotting options begin on line six and have short descriptions of what they do. For complete documentation on the plotting options read the Plotting Options page. I will annotate the options section to explain the choices I've made.

I only wish to plot one field (the overlay is handled below) and 23 is the field ID for potential temperature (FLDID).

  1     NFIELDS: number of fields to plot. Line below, field(s) types:
  23             field identification: FLDID(1:NFIELDS)

The next three options determine range and frequency of data that will be plotted from your input file(s). I have chosen "0" for all three which tells the plotting package to plot all records from my model output file.

  0     FRSTD  : first day (>0) or time record (<0) to plot
  0     LASTD  : last day (>0) or time record (<0) to plot
  0     DSKIP  : plot every other DSKIP day/record (see below)

FINDX can be ignored for this example but the line MUST remain in the file.

  1     FINDX  : forecast record to process, if any (atmospheric files only).

I want to plot using grid units.

  0     ISECPOS: section positions: [0] grid units, [1] Cartesian, [2] spherical

The next four lines specify the location of the cross-section. Keep in mind that this is in grid units since we chose 0 for ISECPOS. Since the upwelling test case is an east-west periodic channel, I want a north-south cross section. I will take my cross-section near the middle of the channel. The channel has 41 RHO-points in the I-direction (east-west) so I will set XSEC1 and XSEC2 to 21. The channel has 80 RHO-points in the J-direction (north-south) I want to go all the way across the channel so I set YSEC1 to 1 and YSEC2 to 82. I use 82 instead of 80 because there is a U-point at both ends of the domain in the J-direction.

  21    XSEC1  : starting section X-position (grid units, or km, or degrees).
  1     YSEC1  : starting section Y-position (grid units, or km, or degrees).
  21    XSEC2  : ending section X-position (grid units, or km, or degrees).
  82    YSEC2  : ending section Y-position (grid units, or km, or degrees).

A horizontal grid spacing of 1.0 will work fine for this case.

  1.0   DELS   : section horizontal grid spacing (km or degrees).

The channel in the upwelling test case is 150 meters deep and I would like to plot the entire water column.

  0     SZTOP  : shallowest section depth to consider (meters).
  150   SZBOT  : deepest section depth to consider (meters).

The upwelling test case has 16 vertical levels.

  16    KMS    : number of refiment section levels between SZTOP and SZBOT.

I am going to stick with linear interpolation so I leave this as "0"

  0     VINTRP : vertical interpolation scheme: 0=linear, 1:cubic splines

I have chosen to set the next two values because I know my vertical velocity range (in cm/day) already. If you do not know the range of your data you should enter 0.0 and the plotting package will calculate the minimum and maximum values. Using the defaults can lead to other problems because the minimum and maximum values are recalculated for each plot. This means you could end up with a different range and color bar for every frame, making visual analysis very difficult.

  10    PMIN   : field minimum value for color palette (0.0 for default)
  25    PMAX   : field maximum value for color palette (0.0 for default)

I do not want contour lines between the color bands so I will set the next option to 0.

  0     ICNT   : draw contours between color bands: 0=no, 1=yes

The next five values control the overlay or reference field. I want the overlay plotted from my primary input NetCDF file (this will be explained later) so I set IREF to 1. The FLDID for Total Velocity Magnitude is 4 so I set IDOVER to 4. I will allow the plotting package to calculate the minimum and maximum so I set both RMIN and RMAX to 0.0.

  1     IREF   : secondary or reference field option (see below)
  4     IDOVER : overlay field identification (for IREF=1,2 only)
  0.0   RMIN   : overlay field minimum value to consider (0.0 for default)
  0.0   RMAX   : overlay field maximum value to consider (0.0 for default)

I don't want more than one plot per page so I can leave this alone.

  1     NPAGE  : number of plots per page (currently 1, 2, or 4)

There isn't a separate grid NetCDF file for the upwelling test problem but we can read the grid out of our history file so I will set READGRD to T.

  F     READGRD: logical switch to read in positions from grid NetCDF file.

I don't know what this does.

  F     PLTLOGO: logical switch draw Logo.

The next 5 options control plot titles captions and legends.

  F     WRTHDR : logical switch to write out the plot header titles.
  T     WRTBLAB: logical switch to write out the plot bottom title.
  T     WRTRANG: logical switch to write out data range values and CI.
  F     WRTFNAM: logical switch to write out input primary filename.
  F     WRTDATE: logical switch to write out current date.

The next six lines specify the input files for the plots. The first line is the variables ID file. An example file exists in the Data directory of the plotting package source code and I will use it.

  ~/Mydir/Data/varid.dat

The second file sets the color palette file. Several palettes are included in the source code Palettes directory. I'm going to use the natlan1.pal file.

  ~/Mydir/Palettes/natlan1.pal

The third file sets the internal plotting parameters. We will discuss this file in detail later. We copied the an example default.cnt file into the current directory at the beginning of this tutorial.

  default.cnt

The fourth file is your primary NetDCF file, usually model output. I will use my history model output.

  ocean_his.nc

The fifth file is you secondary NetCDF file, also usually model output. Some times the data you want to overlay will be in a different file. If that is the case you would set IREF to 2, then put the name of the file your overlay data should come from here. However, my overlay data was in the primary NetCDF file so it doesn't matter what I set this to so I'll set it to be the same as my primary NetCDF file. For more information about IREF check the Plotting Options page.

  ocean_avg.nc

The sixth file is your grid NetCDF file. As mentioned above, we will read the grid from our history NetCDF file.

  ocean_his.nc

Save the csec_upwelling.in file and you're ready to plot some results.

Plotting

Now that we have created an input file for csec we can start creating our plots. First, let's make sure csec and idt are in our path and the NCARG_ROOT environment variable is set.

  > which csec
  /home/robertson/bin/csec
  
  > which idt
  /home/robertson/ncl-5.0.0/bin/idt
  
  > printenv NCARG_ROOT
  /home/robertson/ncl-5.0.0

if your shell cannot find csec you need to add PLT_BINDIR to your path. The NCARG_ROOT environment variable should be set to the location of your NCL install. See the Installation page for more details. If you have an existing 'gmeta' file that you want to keep you should first rename it so csec does not replace it. To create the plots execute the following command.

  > csec < csec_upwelling.in

You will see some information about each frame scroll by. When the program finishes you will have a NCAR Computer Graphics Metafile (NCGM) named gmeta in the current directory. Now you can use idt to view your plots.

  > idt gmeta &

This will bring up the idt viewer with a blank plot. To see the first frame click the idt play.gif button. You should see a plot similar to the following.

upwelling velmag temp.gif

Clicking the idt play.gif button repeatedly will advance through the frames of the gmeta file. The plot above is the 17th frame of my gmeta file. I suggest you take some time to experiment with the controls in the idt window.


Prev: Contour Plots