seagrid

From WikiROMS
Jump to navigationJump to search
SEAGRID

SeaGrid is a GUI-based Matlab program for creating curvilinear orthogonal grids with 4 corners. SeaGrid allows for flexible, interactive grid design, and includes tools to create ROMS NetCDF grid files.

Information and a tutorial may be found at:

https://github.com/sea-mat/seagrid

The above page has links to a zip file for use on Windows, but the full source code distribution (so you can build the mex-files for Linux, Mac, etc) is also available on Github.

The SeaGrid tutorial does not cover preparation of coastline and bathymetry. For this, some useful additional m-files for working with SeaGrid are:

These tools are part of the RPSstuff Matlab toolbox on Github.

Here is one procedure for preparing coastline and bathymetry for Seagrid using these tools:

  • Go to the Coastline Extractor and extract the coastline for your region, making sure you check the "Matlab format" box instead of the default format. Note that the highest worldwide shoreline is the default World Vector Shoreline, but for the US Waters, there is a higher resolution "NOAA Medium Resolution Shoreline" available. For example here, let's assume that you save the file on your computer as "coast.txt".
  • Load the coastline into Matlab using "load coast.txt". You now have a variable called "coast" in Matlab with two columns. The first column is longitude in decimal degrees, west negative. The second column is latitude in decimal degrees, south negative. Each coastline segment is separated by a pair of NaN values.
  • Assuming you've obtained the m-files from the SVN above, you can now type
>> plot(coast(:,1),coast(:,2));    % plot the coast as line segments
>> fillseg(coast);                 % attempt to fill all line segments separated by NaNs.   

This will probably look bad since in most coastline datasets, coastlines that look continuous are actually composed of many line segments.

You can join together line segments whose ends are closer than a certain tolerance using the "join_cst.m" command:

>> coast_new=join_cst(coast,.0001);   % join coastline segments closer than 0.0001 degrees 

This will also sort the coastline segments so that the longest segment is first. Often this segment is the main coastline, while the rest of the segments are islands. To see what has happened, clear the figure and try "fillseg" again:

>> clf;
>> fillseg(coast_new);

this should look better, but typically you have to add a point to the first coastline segment so that the polygon closes the way you want. Usually just changing the latitude or longitude of the first data pair (2nd line of the coast_new file) to be the appropriate limit of your coastline region will work.

  • Once "fillseg(coast_new)" shows filled polygons in the region you want masked, then save the longitude and latitude values as "lon" and "lat" to a .mat file (you *must* use the names "lon" and "lat"):
>> lon=coast_new(:,1);
>> lat=coast_new(:,2);
>> save seagrid_coast.mat lon lat
  • For bathymetry, try using "read_srtm30plus.m". If you've still got your coastline plot up, type
>> ax=axis;  % grab the lon/lat range
>> lon_range=ax(1:2);
>> lat_range=ax(3:4);
>> [xbathy,ybathy,zbathy]=read_srtm30plus(lon_range,lat_range,60);

This reads in worldwide bathymetry at 60 second (1 minute) resolution. The highest resolution available is 30 second, but you might want to use a lower resolution when you make your grid so that Seagrid doesn't take too long, and then when once you've got your ROMS grid, create higher resolution bathymetry.

  • Seagrid expects bathymetry as three vectors describing bathymetry sounding triplets, with depth positive. Since we've got a grid, we need to construct the lon and lat points using "meshgrid", and then save remembering that Seagrid expects the names "xbathy", "ybathy", "zbathy" and that depths are positive (not negative):
>> [xbathy,ybathy]=meshgrid(xbathy,ybathy);  
>> xbathy =  xbathy(:);   %columnize
>> ybathy =  ybathy(:);   %columnize
>> zbathy = -zbathy(:);   %columnize, and make depth positive
>> save bathy_seagrid.mat xbathy ybathy zbathy
  • Now start up Seagrid and load the coastline and bathymetry data. If your whole screen turns purple when you load the bathymetry, you'll probably want to toggle off the display of the depth values, or reduce the number of depth points.
  • Remember to save often when using SeaGrid, as the GUI has become buggy over then many releases of Matlab since it was designed.