swn.modflow.SwnModflow.set_segment_data_from_segments#
- SwnModflow.set_segment_data_from_segments(name: str, data)#
Set segment data from a series indexed by segments.
Modifies
segment_data
orsegment_data_ts
.- Parameters:
- namestr
Name for dataset, from
segment_data
columns.- dataint, float, dict, pandas.Series or pandas.DataFrame
Data to assigned from segments. If a pandas Series, then this is applied for each index matched by segnum. If a dict, then each item is applied for each key matched by segnum.
See also
set_segment_data_from_scalar
Set all segment data to one value.
set_segment_data_from_diversions
Set all segment data from diversions.
Examples
>>> import flopy >>> import geopandas >>> import swn >>> lines = geopandas.GeoSeries.from_wkt([ ... "LINESTRING (60 100, 60 80)", ... "LINESTRING (40 130, 60 100)", ... "LINESTRING (70 130, 60 100)"]) >>> lines.index += 100 >>> n = swn.SurfaceWaterNetwork.from_lines(lines) >>> m = flopy.modflow.Modflow(version="mf2005") >>> _ = flopy.modflow.ModflowDis( ... m, nrow=3, ncol=2, delr=20.0, delc=20.0, xul=30.0, yul=130.0, ... top=15.0, botm=10.0) >>> _ = flopy.modflow.ModflowBas(m) >>> nm = swn.modflow.SwnModflow.from_swn_flopy(n, m) >>> nm.set_segment_data_from_segments("runoff", {101: 2.2}) >>> print(nm.segment_data[["segnum", "runoff"]]) segnum runoff nseg 1 101 2.2 2 102 0.0 3 100 0.0 >>> nm.set_segment_data_from_segments("runoff", {100: 3.3}) >>> print(nm.segment_data[["segnum", "runoff"]]) segnum runoff nseg 1 101 2.2 2 102 0.0 3 100 3.3