我正在try 使用swmm_api
包中的LID_USAGE
为SWMM中的每个子汇流提取单独的LID设置.我遵循了https://markuspichler.gitlab.io/swmm_api/examples/how_to_add_LIDs.html的示例,然而,出现了一个错误.我想知道如何修复代码?我附上了SWMM模型供您参考,谢谢.
example SWMM model (input file)的售价为https://1drv.ms/u/s!AnVl_zW00EHemH5cu620m6vxqXdN?e=S5VSCA美元.我使用的是swmm-api 0.4.37.
from swmm_api import SwmmInput
from swmm_api.input_file.section_labels import SUBAREA,SUBCATCHMENTS,LID_CONTROLS,LID_USAGE
import numpy as np
import pandas as pd
inp = SwmmInput.read_file('Example2.inp')
inp.LID_CONTROLS # LID_CONTROLS works smoothly!
inp.LID_USAGE # LID_USAGE is not working...
inp.LID_USAGE
Traceback (most recent call last):
File C:\ProgramData\miniconda3\envs\swmm\lib\site-packages\swmm_api\input_file\helpers.py:780 in from_inp_line
return cls(*line_args)
TypeError: __init__() takes from 8 to 12 positional arguments but 17 were given
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
Cell In[6], line 1
inp.LID_USAGE
File C:\ProgramData\miniconda3\envs\swmm\lib\site-packages\swmm_api\input_file\inp.py:948 in LID_USAGE
return self[LID_USAGE]
File C:\ProgramData\miniconda3\envs\swmm\lib\site-packages\swmm_api\input_file\inp.py:193 in __getitem__
self._convert_section(key)
File C:\ProgramData\miniconda3\envs\swmm\lib\site-packages\swmm_api\input_file\inp.py:214 in _convert_section
self._data[key] = convert_section(key, self._data[key], self._converter)
File C:\ProgramData\miniconda3\envs\swmm\lib\site-packages\swmm_api\input_file\helpers.py:939 in convert_section
return section_.from_inp_lines(lines)
File C:\ProgramData\miniconda3\envs\swmm\lib\site-packages\swmm_api\input_file\helpers.py:849 in from_inp_lines
return cls.create_section(lines)
File C:\ProgramData\miniconda3\envs\swmm\lib\site-packages\swmm_api\input_file\helpers.py:831 in create_section
sec.add_inp_lines(lines_iter)
File C:\ProgramData\miniconda3\envs\swmm\lib\site-packages\swmm_api\input_file\helpers.py:360 in add_inp_lines
self.add_multiple(*self._section_object._convert_lines(multi_line_args))
File C:\ProgramData\miniconda3\envs\swmm\lib\site-packages\swmm_api\input_file\helpers.py:866 in _convert_lines
yield cls.from_inp_line(*line_args)
File C:\ProgramData\miniconda3\envs\swmm\lib\site-packages\swmm_api\input_file\helpers.py:782 in from_inp_line
raise TypeError(f'{e} | {cls.__name__}{line_args}\n\n__init__{signature(cls.__init__)}\n\n{getdoc(cls.__init__)}')
TypeError: __init__() takes from 8 to 12 positional arguments but 17 were given | LIDUsage('2', 'Bioretention', '1', '5000', '0', '10', '70', '1', '"E:\\Python', 'Examples\\SWMM', 'Calibration\\Example-Yang\\For', 'Calibration\\LID', 'Reports\\S2', 'Bioretention.txt"', '*', '0')
__init__(self, subcatchment, lid, n_replicate, area, width, saturation_init, impervious_portion, route_to_pervious=0, fn_lid_report=nan, drain_to=nan, from_pervious=nan)
Assignment of LID controls to subcatchments.
Args:
subcatchment (str): Name of the subcatchment using the LID process.
lid (str): Name of an LID process defined in the [LID_CONTROLS] section.
n_replicate (int): Number of replicate LID units deployed.
area (float): Area of each replicate unit (ft^2 or m^2 ).
width (float): Width of the outflow face of each identical LID unit (in ft or m). This
parameter applies to roofs, pavement, trenches, and swales that use
overland flow to convey surface runoff off of the unit. It can be set to 0 for
other LID processes, such as bio-retention cells, rain gardens, and rain
barrels that simply spill any excess captured runoff over their berms.
saturation_init (float): For bio-retention cells, rain gardens, and green roofs this is the degree to
which the unit's soil is initially filled with water (0 % saturation
corresponds to the wilting point moisture content, 100 % saturation has
the moisture content equal to the porosity). The storage zone beneath
the soil zone of the cell is assumed to be completely dry. For other types
of LIDs it corresponds to the degree to which their storage zone is
initially filled with water
impervious_portion (float): Percent of the impervious portion of the subcatchment’s non-LID area
whose runoff is treated by the LID practice. (E.g., if rain barrels are used
to capture roof runoff and roofs represent 60% of the impervious area,
then the impervious area treated is 60%). If the LID unit treats only direct
rainfall, such as with a green roof, then this value should be 0. If the LID
takes up the entire subcatchment then this field is ignored.
route_to_pervious (int): A value of 1 indicates that the surface and drain flow from the LID unit
should be routed back onto the pervious area of the subcatchment that
contains it. This would be a common choice to make for rain barrels,
rooftop disconnection, and possibly green roofs. The default value is 0.
fn_lid_report (str): Optional name of a file to which detailed time series results for the LID
will be written. Enclose the name in double quotes if it contains spaces
and include the full path if it is different than the SWMM input file path.
Use ‘*’ if not applicable and an entry for DrainTo follows
drain_to (str): Optional name of subcatchment or node that receives flow from the unit’s
drain line, if different from the outlet of the subcatchment that the LID is
placed in.
from_pervious (float): optional percent of the pervious portion of the subcatchment’s non-LID area
whose runoff is treated by the LID practice. The default value is 0
.