Contour Plots: Difference between revisions
No edit summary (change visibility) |
No edit summary (change visibility) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<div class="title">Contour Plots</div> | <div class="title">Contour Plots</div> | ||
The ROMS plotting package allows you to plot results for most variables at any depth. You can also overlay a reference field. | The ROMS plotting package allows you to plot results for most variables at any depth. You can also overlay a reference field. | ||
<!-- Edit Template:Plot_TOC to modify this Table of Contents--> | <!-- Edit Template:Plot_TOC to modify this Table of Contents--> | ||
{{Plot TOC}} | <div style="float: left;margin: 0 20px 0 0;">{{Plot TOC}}</div>__TOC__ | ||
<div style="clear: both"></div> | |||
==Configuration== | ==Configuration== | ||
Line 74: | Line 76: | ||
1 JVINC : vector grid sampling in the Y-direction (1 for default)</span> | 1 JVINC : vector grid sampling in the Y-direction (1 for default)</span> | ||
The next five values control the overlay or reference field. I want a special overlay of cross-section lines that will be specified in a special file named <span class="forestGreen">fort.35</span>. The | The next five values control the overlay or reference field. I want a special overlay of cross-section lines that will be specified in a user created, special file named <span class="forestGreen">fort.35</span>. The format of this file will be detailed later in this tutorial. To overlay specified user data from a <span class="forestGreen">fort.35</span> file set <span class="blue">IREF</span> to '''-2'''. The rest of this section is ignored because <span class="blue">IREF</span> is not set to '''1''' or '''2'''. If you do not wish to overlay anything set <span class="blue">IREF</span> to '''0'''. For more information see the '''[[Plotting Options#IREF|Plotting Options]]''' page. | ||
<span class="blue">-2 | <span class="blue">-2 IREF : secondary or reference field option (see below) | ||
25 IDOVER : overlay field identification (for IREF=1,2 only) | 25 IDOVER : overlay field identification (for IREF=1,2 only) | ||
1 LEVOVER: level of the overlay field (set to 0 if same as current FLDLEV) | 1 LEVOVER: level of the overlay field (set to 0 if same as current FLDLEV) | ||
Line 141: | Line 143: | ||
<span class="forestGreen">philip_hraw_b.nc</span> | <span class="forestGreen">philip_hraw_b.nc</span> | ||
The fifth file is you secondary NetCDF file. Some times the data you want to overlay will be in a different file. If that is the case you | The fifth file is you secondary NetCDF file. Some times the data you want to overlay will be in a different file. If that is the case you need to set <span class="blue">IREF</span> to 2, then put the name of the file your overlay data should come from here. However, my overlay data is in a special <span class="forestGreen">fort.35</span> 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 <span class="blue">IREF</span> check the '''[[Plotting Options#IREF|Plotting Options]]''' page. | ||
<span class="forestGreen">philip_hraw_b.nc</span> | <span class="forestGreen">philip_hraw_b.nc</span> | ||
Line 149: | Line 151: | ||
<span class="forestGreen">philip_hraw_b.nc</span> | <span class="forestGreen">philip_hraw_b.nc</span> | ||
The seventh file is you coastlines file. There are several coastline files in the <span class="forestGreen">Data</span> directory. My coastline file is named <span class="forestGreen">philip_high.cst</span>. If <span class="blue">CST</span> | The seventh file is you coastlines file. There are several coastline files in the <span class="forestGreen">Data</span> directory. My coastline file is named <span class="forestGreen">philip_high.cst</span>. If you don't want or need coastlines (for example when plotting the upwelling test case), set <span class="blue">CST</span> to '''F''' and this line will be ignored. | ||
<span class="forestGreen">philip_high.cst</span> | <span class="forestGreen">philip_high.cst</span> | ||
Save the <span class="forestGreen">ccnt_hraw.in</span> file. Now we just need our <span class="forestGreen">fort.35</span> file specifying our cross-section lines. | Save the <span class="forestGreen">ccnt_hraw.in</span> file. Now we just need to create our <span class="forestGreen">fort.35</span> file specifying our cross-section lines. | ||
===fort.35=== | ===fort.35=== | ||
Create a new file named <span class="forestGreen">fort.35</span> and open it with your favorite editor. The format of a <span class="forestGreen">fort.35</span> is pretty simple. Each shape block begins with '''999.000000''' then an RGB color specification (''i.e.'' 0 255 0 would be green). | |||
<span class="blue"> 999.000000 0 255 0</span> | <span class="blue"> 999.000000 0 255 0</span> | ||
all between | all lines between the above line and the next shape block beginning line ('''999.000000''') are ordered pairs of points. You need at least 2 points for anything to show up. The following 3 lines tell the plotting package to overlay a horizontal green (0 255 0) line from 8.8°N, 118°E to 8.8°N, 128°E. | ||
<span class="blue"> 999.000000 0 255 0 | <span class="blue"> 999.000000 0 255 0 | ||
Line 214: | Line 216: | ||
<span class="red">> ccnt < ccnt_temp.in</span> | <span class="red">> ccnt < ccnt_temp.in</span> | ||
You will see some information about each frame scroll by. When the program finishes you will have | You will see some information about each frame scroll by. When the program finishes you will have an '''NCAR Computer Graphics Metafile (NCGM)''' named '''gmeta''' in the current directory. Now you can use <span class="red">idt</span> to view your plots. | ||
<span class="red">> idt gmeta &</span> | <span class="red">> idt gmeta &</span> |
Latest revision as of 21:04, 25 June 2010
The ROMS plotting package allows you to plot results for most variables at any depth. You can also overlay a reference field.
Plotting Package Menu |
---|
1. Installation |
2. Contour Plots |
3. Cross-section Plots |
4. Internal Plotting Parameters |
5. Plotting Options |
6. Plotting Fields |
7. Raster Scripts |
Configuration
There are two files that that control the output of the ROMS Plotting Package: default.cnt and the ccnt.in (or csec.in for Cross-section 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 ccnt.in and default.cnt to the directory where you wish to create your plots.
> cd ~/MyPlots
> cp ~/MyDir/src/External/ccnt.in ccnt_hraw.in
> cp ~/MyDir/Data/default.cnt default.cnt
You may name the file whatever you like. I chose ccnt_hraw.in because I will be plotting temperature. Open the .in file (ccnt_hraw.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
Philippine Archipelago Straits
Bathymetry (hraw)
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 and 63 is the field ID for "Raw Bathymetry at RHO-points (m)" (FLDID).
1 NFIELDS: number of fields to plot. Line below, field(s) types:
63 field identification: FLDID(1:NFIELDS)
Bathymetry is a special case that has only one level so use the following options.
1 NLEVELS: number of depths/levels/isopycnals to plot (0 for all levels)
0 depths (<0), levels (>0) or isopycnals (>1000) to plot
The next three options determine range and frequency of data that will be plotted from your input file(s). The bathymetry (hraw) I want is at the first time record so I have chosen -1 for FRSTD and LASTD. DSKIP is irrelevant since I am only plotting one record.
-1 FRSTD : first day (>0) or time record (<0) to plot
-1 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 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 range 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.
-6000 PMIN : field minimum value for color palette (0.0 for default)
1000 PMAX : field maximum value for color palette (0.0 for default)
I want contour lines between the color bands so I will set the next option to 1.
1 ICNT : draw contours between color bands: 0=no, 1=yes
I am not plotting an iso-surface so I leave this at 0.0
0.0 ISOVAL : iso-surface value to process (see below)
The next four options control how vectors are drawn. I am not drawing vectors in this plot so I can ignore these.
1.2 VLWD : vector line width (1.0 for default)
4.0 VLSCL : vector length scale (1.0 for default)
2 IVINC : vector grid sampling in the X-direction (1 for default)
1 JVINC : vector grid sampling in the Y-direction (1 for default)
The next five values control the overlay or reference field. I want a special overlay of cross-section lines that will be specified in a user created, special file named fort.35. The format of this file will be detailed later in this tutorial. To overlay specified user data from a fort.35 file set IREF to -2. The rest of this section is ignored because IREF is not set to 1 or 2. If you do not wish to overlay anything set IREF to 0. For more information see the Plotting Options page.
-2 IREF : secondary or reference field option (see below)
25 IDOVER : overlay field identification (for IREF=1,2 only)
1 LEVOVER: level of the overlay field (set to 0 if same as current FLDLEV)
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)
This determines the spacing between grid lines in the plot. 2.0 is good for this example.
2.0 LGRID : Desired longitude/latitude grid spacing (degrees)
The next four options control the map projection for the plots. I want a Mercator projection so I set IPROJ to 2.
2 IPROJ : map projection (see below).
0.0 PLON : projection Pole longitude (west values are negative).
0.0 PLAT : projection Pole latitude (south values are negative).
0.0 ROTA : projection rotation angle (clockwise; degrees).
I want color contours on land so I do not want to color mask the land. The levels are discussed in the Plotting Options page.
0 LMSK : flag to color mask land: [0] no, [>0] yes (see below)
I want one plot per page and I want to preserve the plot aspect ratio so I set NPAGE to -1.
-1 NPAGE : number of plots per page (currently 1, 2, or 4)
I don't want grid positions computed from the specified grid or history file.
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.
F WRTBLAB: logical switch to write out the plot bottom title.
F 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.
They are several coastline files in the Data directory of the source code but I have a special one for my plot that will be specified later.
T CST : logical switch to read and plot coastlines and islands.
If you leave these values at 0.0 the plotting package will take the entire domain of your output file. I will set the domain I want to plot.
6.0 14.0 : bottom and top map latitudes (south values are negative).
118.0 128.0 : left and right map longitudes (west values are negative).
The next seven 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 gebco1.pal file.
~/Mydir/Palettes/gebco1.pal
The third file sets the internal plotting parameters. We will discuss this file in detail later. An example file exists in the Data directory and I will use it.
~/Mydir/Data/default.cnt
The fourth file is your primary NetDCF file. I have my bathymetry in a separate NetCDF file.
philip_hraw_b.nc
The fifth file is you secondary NetCDF file. Some times the data you want to overlay will be in a different file. If that is the case you need to set IREF to 2, then put the name of the file your overlay data should come from here. However, my overlay data is in a special fort.35 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.
philip_hraw_b.nc
The sixth file is your grid NetCDF file. As mentioned above, I don't want my grid positions computed from a grid file so it doesn't matter what I put here because it will be ignored. I will use my primary NetCDF file again.
philip_hraw_b.nc
The seventh file is you coastlines file. There are several coastline files in the Data directory. My coastline file is named philip_high.cst. If you don't want or need coastlines (for example when plotting the upwelling test case), set CST to F and this line will be ignored.
philip_high.cst
Save the ccnt_hraw.in file. Now we just need to create our fort.35 file specifying our cross-section lines.
fort.35
Create a new file named fort.35 and open it with your favorite editor. The format of a fort.35 is pretty simple. Each shape block begins with 999.000000 then an RGB color specification (i.e. 0 255 0 would be green).
999.000000 0 255 0
all lines between the above line and the next shape block beginning line (999.000000) are ordered pairs of points. You need at least 2 points for anything to show up. The following 3 lines tell the plotting package to overlay a horizontal green (0 255 0) line from 8.8°N, 118°E to 8.8°N, 128°E.
999.000000 0 255 0
8.800000 118.000000
8.800000 128.000000
I have 6 cross-section lines to draw so my fort.35 file looks like this:
999.000000 0 255 0
8.800000 118.000000
8.800000 128.000000
999.000000 237 107 172
11.300000 119.650000
11.300000 122.010000
999.000000 153 0 204
12.200000 120.250000
12.200000 121.050000
999.000000 255 255 0
6.000000 121.300000
12.250000 121.300000
999.000000 255 255 255
8.550000 123.100000
9.030000 123.100000
999.000000 255 0 0
9.000000 125.320000
10.500000 125.320000
999.000000 999.000000
The 999.000000 999.000000 line tells the plotting package there are no more shapes to draw. You can draw any geometric shape by specifying more points in a shape block. For example, if you wanted to draw a red box you would make a block like the following:
999.000000 255 0 0
9.000000 125.320000
10.500000 125.320000
10.500000 124.000000
9.000000 124.000000
9.000000 125.320000
999.000000 999.000000
Plotting
Now that we have created an input file for ccnt we can start creating our plots. First, let's make sure ccnt and idt are in our path and the NCARG_ROOT environment variable is set.
> which ccnt
/home/robertson/bin/ccnt
> which idt
/home/robertson/ncl-5.0.0/bin/idt
> printenv NCARG_ROOT
/home/robertson/ncl-5.0.0
if your shell cannot find ccnt 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 ccnt does not replace it. To create the plots execute the following command.
> ccnt < ccnt_temp.in
You will see some information about each frame scroll by. When the program finishes you will have an 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 button. My bathymetry plot is shown below.
Clicking the button repeatedly will advance to the frames of the gmeta file if you plotted more than one record and/or field. I suggest you take some time to experiment with the controls in the idt window.