Bay-Delta SELFE Tools

Table Of Contents

Previous topic

Preprocessing

Next topic

Model time conversion

Working with SMS

The preprocessing toolkit has some utilities that can help when working with Aquaveo SMS, the main form of mesh generation we use until we are able to distrubute a sufficient open source mesh generator.

Converting an SMS mesh (2dm) file to gr3

The script that converts SMS mesh to SELFE gr3 format is available as a standalone script.

sms2gr3.py

Convert a *.2dm SMS mesh to a *.gr3 SELFE mesh.

usage: sms2gr3.py [-h] [--elev2depth] [--outfile OUTFILE] infile
Positional arguments:
infile name of input file
Options:
--elev2depth=False
 SMS geometry is in terms of elevation and should be flipped in sign.
--outfile name of output file

Getting SMS Polygons for Preprocessor

SMS is able to create mesh coverages that are not mesh generation hints, including spatial properties maps whose polygons have “material properties”. If you save the coverage as a polygon shapefile, the script material_poly.py can help convert the resulting shapefile to the preprocessor yaml format. At the time of writing we do not have a tutorial example of this process.s

material_poly.py

Convert shapefile from SMS into polygon format for SELFE preprocessor

usage: material_poly.py [-h] [--keyfile KEYFILE] [--out OUT] [--type TYPE]
                        [--default DEFAULT]
                        shapefile dset
Positional arguments:
shapefile name of shapefile
dset name of dataset inside shapefile
Options:
--keyfile file mapping material property names to numerical values (space separated).
--out Output polygon file.
--type=min Polygon attribute type (min/max)
--default Global default in polygon specs

Visualizing detailed bathymetry inside SMS

Earlier versions (before 11.2) of SMS had bugs causing incorrect georefercing of DEMs and very poor memory management. It was – and probably still is – impossible to efficiently assign elevations within the software for a large mesh. We have two scripts that were designed to help with this problem: clip_dems.py and stacked_dem_fill.py.

clip_dems.py

Trim each DEM on a prioritized list. The coordinates used for clipping is supplied either directly as an upper left and lower right coordinate or indirectly using the bounding coordinates of a sample image. In practice this script is usually used with images saved from SMS

usage: clip_dems.py [-h] [--coords ul_x ul_y lr_x lr_y] [--image INFILE]
                    [--prefix PREFIX] [--outformat OUTFORMAT] [--verbose]
                    [--hshift]
                    demlist
Positional arguments:
demlist file containing prioritized (high to low) list of dems.
Options:
--coords=(None, None, None, None)
 bounding coordinates to which DEMs will be clipped (upper left, lower right)
--image image or DEM used to infer bounding coordinates for clipping. This argument is mutually exclusive with –coords. If a sample is provided its upper left and lower right corner will be used.
--prefix=clipped
 prefix used for output file names
--outformat=AAIGrid
 output format, default is AAIGrid (ArcInfo ascii.
--verbose=False
 more verbose output.
--hshift=False shift DEM by half cell for applications that incorrectly interpret the location of the origin and data centering of a DEM. This is a bug fix for SMS < 11.1

The script clip_dems.py is used to create mini-DEMs on the fly that are small enough to be brought into the SMS environment as rasters without slowing it down too much. The same The:ref:dem_list_file is used here as elsewhere in the pre-processor.

The normal pattern of work is to zoom into the area of interst in SMS, save the work area as a jpeg image and use it as the -image argument to clip_dems.py. One cut DEM will be produced for each DEM on the dem_list file that intersects the work area, using file names in order of priority (0 highest). The cut DEMs would then be imported and visualized in SMS, ideally using “contours” as the viewing choice and a carefully crafted color map designed to focus on the elevations that are locally most important.

stacked_dem_fill.py

Fill node elevations in a *.2dm SMS mesh or gr3 file using a prioritized list of DEMs.

usage: stacked_dem_fill.py [-h] [--elev2depth] filename demfile
Positional arguments:
filename name of 2dm or gr3 file
demfile file containing list of DEMs. These can be in any form that gdal accepts, which includes ESRI ascii format and GeoTiffs
Options:
--elev2depth=False
 Convert elevation to depth by flipping sign. This is typical when using gr3 format, less so with 2dm.

The script stacked_dem_fill.py is the one we use to populate a mesh with elevations. It can be used on a 2dm file in which case the