pyHMT2D API¶
pyHMT2D base classes, constants, and tools¶
- class HydraulicData(name)[source]¶
Hydraulic data base class
- name¶
name of the hydraulic mode that this data is for, e.g., SRH-2D, HEC-RAS, or just the name of the data set, e.g., terrain, flow
- Type:
- gMax_Nodes_per_Element¶
maximum number of nodes for an element
- gMax_Elements_per_Node¶
maximum number of elements for a node
Miscellaneous classes and tools¶
Package summary for Misc
- class RAS_to_SRH_Converter(RASPlanResultFileName, TerrainFileName, SRHCaseName)[source]¶
A Python class to convert HEC-RAS case, mainly mesh and material (Manning’s n), to SRH-2D case
Typical work flow is as follows: 1. create 2D case in HEC-RAS 2. call RAS to SRH converter: create srhgeom and srhmat files 3. manually create and adjust srhhydro file 4. run SRH-2D
- SRHCaseName¶
Case name for SRH-2D; the resulted files will be SRHCaseName.srhgeom, SRHCaseName.srhmat
- Type:
- class Terrain(name)[source]¶
A Python class for terrain data I/O, creation, and manipulation
Typical work flow is as follows:
create the Terrain object
create the terrain (elevation, pixel_width/height): user can either call some pre-defined terrains such as constant slope, or create the terrain by themsleves and then call set_terrain(…), and set_pixel_size(…)
set the georeferencing by calling set_georeference(…)
save the terrain to file by calling save_terrain_to_file(…)
- elevation¶
elevation of the terrain (2D numpy array)
- Type:
numpy.ndarray
- EPSGCode¶
EPSG (European Petroleum Survey Group) code that defines the coordinate reference system
- Type:
Terrain class constructor
- Parameters:
name (str) – name of the terrain
- add_bedform(channel_lenx, channel_leny, Lb, Hb, alpha_lee, a_stoss, rotation=0, perturbation=0, perturb_distribution=0)[source]¶
Add bedform feature to the terrain
Typical use scenario is firstly to create a constant slope channel and then add the bedform features.
- Parameters:
channel_lenx (float) – channel length in x
channel_leny (float) – channel length in y
Lb (float) – bed form length
Hb (float) – bed form height
alpha_lee (float) – bed-form’s lee side slope angle (in degrees)
a_stoss (float) – bed-form’s stoss size sine function amplitude
rotation (float) – optional rotation angle of the domain in degrees (default is zero)
perturbation (float) – optional perturbation added to the terrain (default is zero)
perturb_distribution (integer) – optional perturbation distribution type: 0-uniform, 1-normal (mean=0, sd=perturbation/1.96)
- add_composite_channel(channel_lenx, channel_leny, L1, B, D, alpha)[source]¶
Add composite channel to the terrain
Typical use scenario is firstly to create a constant slope channel and then add the composite channel.
- Parameters:
- create_constant_slope_channel_elevation(slope, channel_lenx, channel_leny, pixel_width, pixel_height, elevation_origin=0, extra_len=0)[source]¶
Create a constant slope channel elevation
The slope is in the x direction only. The slope in the y direction is zero.
- Parameters:
slope (float) – slope in x
channel_lenx (float) – channel length in x
channel_leny (float) – channel length in y
elevation_origin (float) – the elevation at the origin (top left; does not account for the extra fringe)
extra_len (float) – optional extra fringe length added to the channel domain (to have some free room in developing 2D models in e.g., SMS or HEC-RAS.
- get_elevation()[source]¶
Get the elevation array
- Returns:
elevation – elevation 2D array
- Return type:
numpy.array
- save_terrain_to_file(terrainFileName, geoDriverName='GTiff')[source]¶
save terrain to file, such as GeoTiff
- set_elevation(elevation)[source]¶
Set the elevation array
- Parameters:
elevation (numpy.ndarray) – elevation 2D array
- gmsh2d_to_srh(gmsh2d_fileName, srh_caseName, shift_x=0.0, shift_y=0.0, units='Meters', bAddMonitoringLines=False, monitoringLines=[], monitoringlineTol=0.001)[source]¶
Convert Gmsh 2D mesh into SRH-2D format with the option to add monitoring lines.
It generates two files: srhgeom for mesh and srhmat for Manning’s n
The srhhydro file has to be generated separately.
For monitoring lines: SRH-2D treats the monitoring lines similarly as boundaries. Both are nodeStrings in the srhgeom file. However, Gmsh2d does not directly support internal boundary such as the monitoring lines. Thus, for any monitoring line, we need to add it to the nodeStrings list here.
- Parameters:
gmsh2d_fileName (str) – file name of the Gmsh MSH file
srh_caseName (str) – case name for SRH-2D.
shift_x (float) – shift of coordinates in x direction
shift_y (float) – shift of coordinates in y direction
units (str, default Meters) – length units of Gmsh file
bAddMonitoringLines (whether add monitoring lines)
monitoringLines (list of monitoring lines. Currently only straightlines are supported.)
monitoringlineTol (a float tolerance to check whether a node is close to the monitoring line)