API reference¶
- class lsmaker.lsmaker.LinesinkData(infile=None, GFLOW_lss_xml=None)[source]¶
Bases:
object
- dtypes = {'AutoSWIZC': <class 'numpy.int64'>, 'DefaultResistance': <class 'float'>, 'Depth': <class 'float'>, 'Drain': <class 'numpy.int64'>, 'EndInflow': <class 'numpy.int64'>, 'EndStream': <class 'numpy.int64'>, 'EndingHead': <class 'float'>, 'Evapotranspiration': <class 'float'>, 'Farfield': <class 'bool'>, 'Gallery': <class 'numpy.int64'>, 'HeadSpecified': <class 'float'>, 'InletStream': <class 'numpy.int64'>, 'Label': <class 'str'>, 'Lake': <class 'numpy.int64'>, 'OutletStream': <class 'numpy.int64'>, 'OutletTable': <class 'str'>, 'OverlandFlow': <class 'numpy.int64'>, 'Precipitation': <class 'float'>, 'Resistance': <class 'float'>, 'Routing': <class 'numpy.int64'>, 'ScenFluxName': <class 'str'>, 'ScenResistance': <class 'str'>, 'StartingHead': <class 'float'>, 'TotalDischarge': <class 'numpy.int64'>, 'Width': <class 'float'>, 'chkScenario': <class 'bool'>}¶
- fcodes = {'Intermittent': 46003, 'Perennial': 46006, 'Uncategorized': 46000}¶
- classmethod load_configuration(infile)[source]¶
Load Linesink-maker YAML configuration into a dictionary.
- Parameters:
- infilestr or pathlike
Linesink-maker configuration file in YAML format.
- Returns:
- cfgdict
Configuration dictionary
- load_poly(shapefile, dest_crs=None)[source]¶
Load a polygon shapefile and return a multipolygon of multiple features, or single polygon of one feature, projected in the destination coordinate system.
- map_outsegs()[source]¶
from Mat2, returns dataframe of all downstream segments (will not work with circular routing!)
- maxlines = 4000¶
- preprocess(save=True)[source]¶
This method associates attribute information in the NHDPlus PlusFlowVAA and Elevslope tables, and the model domain configuration (nearfield, farfield, and any other polygon areas) with the NHDPlus Flowlines and Waterbodies datasets. The following edits are made to the Flowlines and waterbodies: * remove farfield streams lower than <min_farfield_order> * remove waterbodies that aren’t lakes, and lakes smaller than <min_waterbody_size> * convert lakes from polygons to lines; merge the lakes with the with flowlines
- prototype(nftol=[10, 50, 100, 200, 500], fftol=500)[source]¶
Function to compare multiple simplification distance tolerance values for the model nearfield.
- set_configuration(cfg)[source]¶
Set the Linesink-maker configuration from a configuration dictionary.
- Parameters:
- cfgdict
Configuration dictionary, as produced by the LinesinkData.set_configuration_from_yaml method.
- set_configuration_from_yaml(infile)[source]¶
Set the Linesink-maker configuration from a YAML file.
- Parameters:
- infilestr or pathlike
Linesink-maker configuration file in YAML format.
- set_crs(epsg=None, proj_str=None, prjfile=None)[source]¶
Set the projected coordinate reference system, and the BasemapUnits. If no arguments are supplied, default to existing BasemapUnits.
- Parameters:
- epsg: int
EPSG code identifying Coordinate Reference System (CRS) for features in df.geometry (optional)
- proj_str: str
proj_str string identifying CRS for features in df.geometry (optional)
- prjfile: str
File path to projection (.prj) file identifying CRS for features in df.geometry (optional)
- Returns:
- sets the LinesinkData.pyproj_crs attribute.
- simplify_lines(nearfield_tolerance=None, routed_area_tolerance=None, farfield_tolerance=None, nearfield_refinement={})[source]¶
Reduces the number of vertices in the GIS linework representing streams and lakes, to within specified tolerances. The tolerance values represent the maximum distance in the coordinate system units that the simplified feature can deviate from the original feature.
- Parameters:
- nearfield_tolerancefloat
Tolerance for the area representing the model nearfield
- farfield_tolerancefloat
Tolerance for the area representing the model farfield
- Returns:
- dfDataFrame
A copy of the df attribute with a ‘ls_geom’ column of simplified geometries, and a ‘ls_coords’ column containing lists of coordinate tuples defining each simplified line.
- lsmaker.lsmaker.add_projection(line, point)[source]¶
Add vertex to line at point, if the closest point on the line isn’t an end.
- Parameters:
- lineLineString
- pointPoint
- Returns:
- newlineLineString
Line with point added, or original line, if point coincides with end.
- lsmaker.lsmaker.add_vertices_at_testpoints(lssdf, tpgeoms, tol=200)[source]¶
Add vertices to LinesinkData at locations of testpoints (so that modeled flow observations are correct)
- Parameters:
- lssdfDataFrame
DataFrame of linesink strings. Must contain ‘geometry’ column of shapely LineStrings defining geometries of linesink strings, in same coordinate system as testpoints.
- tpgeomslist
List of testpoint geometries.
- tolfloat
Tolerance, in coordinate system units, for considering lines near the testpoints.
- Returns:
- geomslist of geometries
New geometry column with added vertices.
- lsmaker.lsmaker.closest_vertex_ind(point, shape_coords)[source]¶
Returns index of closest vertices in shapely geometry object Ugly but works
- lsmaker.lsmaker.get_elevation_from_epqs(lon, lat, units='feet')[source]¶
Returns an elevation value at a point location.
Notes
- example url for -91, 45:
http://nationalmap.gov/epqs/pqs.php?x=-91&y=45&units=Feet&output=json
Examples
>>> get_elevation_from_epqs(-91, 45) 1139.778277
- lsmaker.lsmaker.get_elevations_from_epqs(points, units='feet')[source]¶
From list of shapely points in lat, lon, returns list of elevation values
- lsmaker.lsmaker.lake_width(area, total_line_length, lmbda)[source]¶
Estimate conductance width from lake area and length of flowlines running through it
- class lsmaker.lsmaker.linesinks(*args, **kwargs)[source]¶
Bases:
LinesinkData
- lsmaker.lsmaker.name(x)[source]¶
Abbreviations for naming LinesinkData from names in NHDPlus GFLOW requires linesink names to be 32 characters or less
- lsmaker.lsmaker.w_parameter(B, lmbda)[source]¶
Compute w parameter for estimating an effective conductance term (i.e., when simulating Lakes using Linesinks instead of GFLOW’s lake package)
If only larger lakes are simulated (e.g., > 1 km2), w parameter will be = lambda
see Haitjema 2005, “Dealing with Resistance to Flow into Surface Waters”