GSSHA Model

GSSHAModel

class gsshapy.modeling.GSSHAModel(project_directory, project_name=None, mask_shapefile=None, auto_clean_mask_shapefile=False, grid_cell_size=None, elevation_grid_path=None, simulation_timestep=30, out_hydrograph_write_frequency=10, roughness=None, land_use_grid=None, land_use_grid_id=None, land_use_to_roughness_table=None, load_rasters_to_db=True, db_session=None, project_manager=None)[source]

This class manages the generation and modification of models for GSSHA.

Parameters:
  • project_directory (str) – Directory to write GSSHA project files to.
  • project_name (Optional[str]) – Name of GSSHA project. Required for new model.
  • mask_shapefile (Optional[str]) – Path to watershed boundary shapefile. Required for new model.
  • auto_clean_mask_shapefile (Optional[bool]) – Chooses the largest region if the input is a multipolygon. Default is False.
  • grid_cell_size (Optional[str]) – Cell size of model (meters). Required for new model.
  • elevation_grid_path (Optional[str]) – Path to elevation raster used for GSSHA grid. Required for new model.
  • simulation_timestep (Optional[float]) – Overall model timestep (seconds). Sets TIMESTEP card. Required for new model.
  • out_hydrograph_write_frequency (Optional[str]) – Frequency of writing to hydrograph (minutes). Sets HYD_FREQ card. Required for new model.
  • roughness (Optional[float]) – Value of uniform manning’s n roughness for grid. Mutually exlusive with land use roughness. Required for new model.
  • land_use_grid (Optional[str]) – Path to land use grid to use for roughness. Mutually exlusive with roughness. Required for new model.
  • land_use_grid_id (Optional[str]) – ID of default grid supported in GSSHApy. Mutually exlusive with roughness. Required for new model.
  • land_use_to_roughness_table (Optional[str]) – Path to land use to roughness table. Use if not using land_use_grid_id. Mutually exlusive with roughness. Required for new model.
  • load_rasters_to_db (Optional[bool]) – If True, it will load the created rasters into the database. IF you are generating a large model, it is recommended to set this to False. Default is True.
  • db_session (Optional[database session]) – Active database session object. Required for existing model.
  • project_manager (Optional[ProjectFile]) – Initialized ProjectFile object. Required for existing model.

Model Generation Example:

from datetime import datetime, timedelta
from gsshapy.modeling import GSSHAModel

model = GSSHAModel(project_name="gssha_project",
                   project_directory="/path/to/gssha_project",
                   mask_shapefile="/path/to/watershed_boundary.shp",
                   auto_clean_mask_shapefile=True,
                   grid_cell_size=1000,
                   elevation_grid_path="/path/to/elevation.tif",
                   simulation_timestep=10,
                   out_hydrograph_write_frequency=15,
                   land_use_grid='/path/to/land_use.tif',
                   land_use_grid_id='glcf',
                   load_rasters_to_db=False,
                   )
model.set_event(simulation_start=datetime(2017, 2, 28, 14, 33),
                simulation_duration=timedelta(seconds=180*60),
                rain_intensity=2.4,
                rain_duration=timedelta(seconds=30*60),
                )
model.write()