SeaGrid Orthogonal Grid Maker For Matlab
Image courtesy Rich Signell, U.S.G.S., Woods Hole
SeaGridis
aMatlab
5.2+application
for generating an orthogonal grid within a curved perimeter,
suitable for oceanographic modeling.
With SeaGrid, one
can:
Select a conformal map projection.
Manually adjust grid corner points and curved boundaries.
Modify the number of grid-cells and grid-line spacings.
Compute depths, land-masking, and orthogonality.
Save, then later reload a grid for further work.
Port a grid to Matlab on another computer.
Create SCRUM/ROMS-like
and ECOM-like output files.
Get comprehensive built-in help.
Starting
from a conformal projection (such
asMercator)
of the targeted area,SeaGriduses
theIves-Zachariasscheme
to conformally map the curved perimeter to a rectangle, after
which, aPoissonsolver
fills the interior with orthogonally distributed grid points.
Control over such features as the number of grid-cells and the
density of grid lines is provided by menus, dialogs, and direct
graphical manipulation of objects in the program's display window.
Behind the scenes,Seagriduses
a new object-oriented window manager (Presto),
plus some Mex-files. None of these rely on
optionalMathWorkstoolboxes.
Tutorial -- We are
currently working on a tutorial.
The images need to be redone with our Unix system, but the general
layout will be as shown.
Download SeaGrid
1. The current Seagrid software is available using SVN
at http://cmgsoft.repositoryhosting.com/svn_public/cmgsoft_m-cmg/trunk/seagrid/.An
explanation on how to use SVN services can be found athttp://subversion.tigris.org/.
This site also has SVN client software available, if needed. Once
you have checked out the software, add the path to the trunk of the
SVN files directory into your Matlab directory path.
You will find these directories
.\seagrid (contains Seagrid application m-files)
.\seagrid\presto (contains a library that Seagrid depends
upon)
.\seagrid\test_data (contains test data used in the Seagrid
tutorial)
You will also find a number of Mex file subdirectories such
as
.\seagrid\mex_matlab74_win32
.\seagrid\mex_matlab60_linux32
that indicate mex files to be used with specific operating system
and
Matlab version.
If you don't see your operating system listed, you will need to
build
the mex files from source code, which requires both Fortran and
C
compilers. If you don't see your version of Matlab, try one from
a
previous release. Sometimes they will also work.
.\seagrid\mex (contains Seagrid binary mex files for PC
Windows)
2. Add the .\seagrid, .\seagrid\presto and appropriate
.\seagrid\mex__ directory to your matlab path.
3. In Matlab, cd to the .\seagrid\test_data directory, type
"seagrid"
and then follow the Seagrid
SeaGrid Tutorial
This tutorial shows how to use SeaGrid, a Matlab-5 program for
constructing an orthogonal, curvilinear grid, suitable for
oceanographic modeling.
Installing SeaGrid
Download and install all the software, as instructed in
the SeaGrid
Home Page. Be sure to adjust your Matlab path.
Restart Matlab.
Execute "seagrid version" at the Matlab prompt. If Matlab is
unable to find "seagrid", check the Matlab path.
Using SeaGrid
Follow these instructions to reproduce the figures shown
below. Generally speaking, the operations can be performed in
any order that makes sense.
(Note: The grids shown here are not quite orthogonal throughout,
owing to the simple Fourier/Poisson solver that was used on the
Macintosh that made these JPEG pictures. The Unix and PCWIN
versions, implemented through FORTRAN Mex-files, show better
orthogonality. The figures may also display clashing colors,
because the graphical layers were superimposed with the "xor"
drawing mode.)
A -- Getting Started, Loading Data
B -- Corner Points, Edge Points
C -- Orthogonality, Spacers
D -- Saving, Masking
E -- Bathymetry
Start SeaGrid -- Execute "seagrid" (no
argument) at the Matlab prompt. A blank "SeaGrid" window will
appear, as show above.
Help -- "SeaGrid" is supported by a
comprehensive "Help" system, accessible through the "Help" menu.
Topics can be reached through individual menu items, or through the
dialog shown here. (Actual SeaGrid menu headings are surrounded by
triangular brackets, to distinguish them from Matlab's own
menus.)
Load Coastline (optional) -- Select the
"SeaGrid/Load/Coastline File..." menu item, then select the
"amazon_coast.mat" file, located in the "test_data" subfolder. The
Amazon coastline will be drawn in the main "SeaGrid" window. A
coastline consists of one or more closed polygons specified by
(longitude, latitude) pairs, separated by NaNs.
Load Bathymetry (optional) -- Select the
"SeaGrid/Load/Bathymetry File..." menu item, then select the
"amazon_bathy.mat" file, located in the "test_data" subfolder. The
locations of bathymetric points near the Amazon will be drawn in
the main "SeaGrid" window. Zooming (see below) will show them to be
discrete points. The bathymetric data will be gridded below.
Define Corner Points -- In the main
"SeaGrid" window, click on four points with mouse button #1 to
define the grid boundary approximately. Once established, the
corner points can be refined by dragging with mouse button #1. The
starting corner point, marked by an asterisk (*), can be rolled
counter-clockwise to the next corner by selecting the "View/Roll"
menu item. Edge #1 follows counterclockwise from the (*) to the
next corner. Edge #2 is the next one along. Grid-cell spacings are
determined along those two edges. (See "spacer" steps below.)
Add Edge Points -- By clicking with
mouse button #1 on any edge, a point can be added and dragged to a
new position, thereby reshaping the grid boundary. Any number of
edge points can be added. An edge point can be deleted by clicking
on it with mouse button #3. If the updated boundary becomes too
distorted for the conformal mapping method that is used here, a
message will request that the boundary be reshaped.
Zoom -- Zooming can be accomplished by
clicking mouse button #1 on white-space (center and zoom-in x2), or
by stretching out a rectangular fence, to which the plot will be
zoomed. Clicking with mouse button #2 zooms out. Mouse button #3
centers the clicked point. Double-clicking resizes the plot to fit
the window.
Setup Dialog -- Select the
View/Setup..." menu item. Change the grid-sizes to 20 and 30
("Cells Edge 1" and "Cells Edge 2", respectively).
Submit -- Click "Okay" to submit the
dialog and witness the grid being recomputed and drawn with the new
grid counts.
Check Orthogonality -- Select the
"Compute/Orthogonality" menu item to show the orthogonality of the
grid, then select the same menu item again to hide it. The
orthogonality is represented by the largest deviation from a
right-angle amongst the four corners of each grid cell, exclusive
of vertices along the edge of the grid.
Show Spacers -- Select the
"View/Spacers" menu item to hide the boundary points and reveal the
interactive spacers.
Adjust Spacers -- Using mouse button #1,
drag one of the spacers to a new location along its respective
edge. Witness the grid lines rearranging themselves smoothly to
mimic the separations of the spacers themselves. The spacers can be
further manipulated through the "View/Spacer Count..." and
"View/Spacer Setup..." menu items.
Projection -- Change the map projection
to "Stereographic" in the " (View)/Setup..." dialog. The center of
projection can be modified, if needed, using the "Projection
Center" sub-dialog. The default projection is "Mercator", with (0,
0, 0) as the parameters of its center. Both "Mercator" and
"Stereographic" are "conformal" mappings; i.e., they preserve
angles. The geographic graticule can be toggled into view with the
"View/Show-Hide/Graticule" menu item.
Revert to Mercator Projection -- Hide
the map grid, then change the map projection back to "Mercator",
using the "View/Setup..." dialog, then zoom and pan as needed to
bring the model grid into view.
Save the Grid -- Select the
"SeaGrid/SaveAs..." menu item, then enter a filename for saving the
current grid as a "SeaGrid" file. The "SeaGrid" file itself can be
converted to SCRUM or ECOM format, using the standalone M-files
named "seagrid2scrum" and "seagrid2ecom", respectively.
Continue Playing -- Change something
about the grid.
Revert to Saved Grid -- Select the
"SeaGrid/Revert To Saved" menu item. SeaGrid will use those data to
revert to the state of the grid at the time the most recent file
was saved. To choose another saved grid besides the most recent
one, select "SeaGrid/Load/SeaGrid File..." and interact with the
ensuing dialog.
Land Masking -- Select the "Compute/Land
Mask" menu item to have SeaGrid mask the cells whose centers it
determines to lie on the land, as defined by the coastline. Go to
the next step to see the mask. (Since updating the mask can be
slow, users may wish to toggle it off when not needed.)
Masking Tool -- Select the
"Compute/Masking Tool" to make the individual grid cells
interactive. They can be toggled by clicking with mouse button #1.
While the tool is active, the grid may not be reshaped. The masking
tool can be hidden by re-selecting the same menu item.
Erase Land Mask -- The land mask can be
reset by selecting "Compute/Erase Mask". Do so, then hide the
masking tool.
Hide Bathymetry -- The bathymetric
points can be toggled by selecting "View/Show-Hide/Bathymetry". Do
this twice. Similarly, the coastline can be toggled.
Grid Bathymetry -- Select the
"Compute/Depths" to compute the depths in the centers of the grid
cells. Then, select the same menu item again to hide the
depths.
Saved Grid -- The saved grid will
preserve all the features that were current at the time of saving,
including the land mask and gridded bathymetry, if any. The
"SeaGrid" file is a Mat-file that contains a "struct" with
intuitive fieldnames. It is used by the "seagrid2ecom" and
"seagrid2scrum" reformatting programs. Both of those are M-files,
which can be used as examples for designing other reformatting
routines.