Mapping Table File¶
File extension: cmt
This file object supports spatial objects (when the mapping table is read into the database, the index maps are read in as well).
File Object¶
-
class
gsshapy.orm.MapTableFile(project_file=None)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base,gsshapy.base.file_base.GsshaPyFileObjectBaseObject interface for the Mapping Table File.
Hydrological parameters are distributed spatially in GSSHA through mapping tables and index maps. Index maps are raster maps of integers. The mapping tables define the hydrological values for each unique index on a map. Most of the mapping tables are abstracted into three objects representing three different parts of the table.
MapTablecontains the data for the mapping table header,MTIndexcontains the data for the indexes defined by the mapping table, andMTValuecontains the actual value of the hydrological parameters defined by the mapping table.In addition, there are two special mapping tables that break the common format: Contaminant/Constituent Transport and Sediment Transport. The data for these mapping tables is contained in the
MTContaminantandSedimentobjects, respectively.The GSSHA documentation used to design this object can be found by following these links: http://www.gsshawiki.com/Mapping_Table:Mapping_Table_File
-
tableName= u'cmt_map_table_files'¶ Database tablename
-
id¶ PK
-
indexMaps¶ RELATIONSHIP
-
mapTables¶ RELATIONSHIP
-
projectFile¶ RELATIONSHIP
-
fileExtension¶ STRING
-
addRoughnessMapFromLandUse(name, session, land_use_grid, land_use_to_roughness_table=None, land_use_grid_id=None)[source]¶ Adds a roughness map from land use file
Example:
from gsshapy.orm import ProjectFile from gsshapy.lib import db_tools as dbt from os import path, chdir gssha_directory = '/gsshapy/tests/grid_standard/gssha_project' land_use_grid = 'LC_5min_global_2012.tif' land_use_to_roughness_table = ''/gsshapy/gridtogssha/land_cover/land_cover_glcf_modis.txt' # Create Test DB sqlalchemy_url, sql_engine = dbt.init_sqlite_memory() # Create DB Sessions db_session = dbt.create_session(sqlalchemy_url, sql_engine) # Instantiate GSSHAPY object for reading to database project_manager = ProjectFile() # Call read method project_manager.readInput(directory=gssha_directory, projectFileName='grid_standard.prj', session=db_session) project_manager.mapTableFile.addRoughnessMapFromLandUse("roughness", db_session, land_use_to_roughness_table, land_use_grid, ) # WRITE OUT UPDATED GSSHA PROJECT FILE project_manager.writeInput(session=db_session, directory=gssha_directory, name='grid_standard')
-
Supporting Objects¶
-
class
gsshapy.orm.MapTable(name, numIDs=None, maxNumCells=None, numSed=None, numContam=None, maxSoilID=None)[source]¶ Bases:
sqlalchemy.ext.declarative.api.BaseObject containing header data for a mapping table.
- See: http://www.gsshawiki.com/Mapping_Table:Mapping_Tables
- http://www.gsshawiki.com/Mapping_Table:Index_Maps
-
tableName= u'cmt_map_tables'¶ Database tablename
-
id¶ PK
-
idxMapID¶ FK
-
mapTableFileID¶ FK
-
mapTableFile¶ RELATIONSHIP
-
indexMap¶ RELATIONSHIP
-
values¶ RELATIONSHIP
-
sediments¶ RELATIONSHIP
-
name¶ STRING
-
numIDs¶ INTEGER
-
maxNumCells¶ INTEGER
-
numSed¶ INTEGER
-
numContam¶ INTEGER
-
class
gsshapy.orm.MTIndex(index, description1=u'', description2=u'')[source]¶ Bases:
sqlalchemy.ext.declarative.api.BaseObject containing mapping table index data. Mapping table index objects link the mapping table values to index maps.
See: http://www.gsshawiki.com/Mapping_Table:Mapping_Tables
-
tableName= u'cmt_indexes'¶ Database tablename
-
id¶ PK
-
idxMapID¶ FK
-
values¶ RELATIONSHIP
-
indexMap¶ RELATIONSHIP
-
index¶ INTEGER
-
description1¶ STRING
-
description2¶ STRING
-
-
class
gsshapy.orm.MTValue(variable, value=None)[source]¶ Bases:
sqlalchemy.ext.declarative.api.BaseObject containing the hydrological variable and value data for mapping tables.
See: http://www.gsshawiki.com/Mapping_Table:Mapping_Tables
-
tableName= u'cmt_map_table_values'¶ Database tablename
-
id¶ PK
-
mapTableID¶ FK
-
mapTableIndexID¶ FK
-
contaminantID¶ FK
-
mapTable¶ RELATIONSHIP
-
index¶ RELATIONSHIP
-
contaminant¶ RELATIONSHIP
-
variable¶ STRING
-
value¶ FLOAT
-
-
class
gsshapy.orm.MTContaminant(name, outputFilename, precipConc, partition, numIDs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.BaseObject containing data in contaminant transport type mapping tables.
See: http://www.gsshawiki.com/Mapping_Table:Constituent_Mapping_Tables
-
tableName= u'cmt_contaminants'¶ Database tablename
-
id¶ PK
-
idxMapID¶ FK
-
indexMap¶ RELATIONSHIP
-
values¶ RELATIONSHIP
-
name¶ STRING
-
outputFilename¶ STRING
-
precipConc¶ FLOAT
-
partition¶ FLOAT
-
numIDs¶ INTEGER
-
-
class
gsshapy.orm.MTSediment(description, specificGravity, particleDiameter, outputFilename)[source]¶ Bases:
sqlalchemy.ext.declarative.api.BaseObject containing data in sediment transport type mapping tables.
See: http://www.gsshawiki.com/Mapping_Table:Sediment_Erosion_Mapping_Tables
-
tableName= u'cmt_sediments'¶ Database tablename
-
id¶ PK
-
mapTableID¶ FK
-
mapTable¶ RELATIONSHIP
-
description¶ STRING
-
specificGravity¶ FLOAT
-
particleDiameter¶ FLOAT
-
outputFilename¶ STRING
-