lsmatott / ostrich-swmm

A toolset for connecting the OSTRICH optimization software toolkit with the SWMM simulation model.
GNU General Public License v2.0
29 stars 19 forks source link

AttributeError: 'SwmmExtract' object has no attribute 'TypeCheck' #15

Open melissagqc opened 4 years ago

melissagqc commented 4 years ago

(ostrich) C:\Git\pub\ostrich-swmm>ostrich-swmm run OSTRICH input for subcat S1##PP1_1 had too many lid units, changing to max number 41 OSTRICH input for subcat S2##RB1_2 had too many lid units, changing to max number 65 OSTRICH input for subcat S2##PP1_2 had too many lid units, changing to max number 10 OSTRICH input for subcat S3##PP1_3 had too many lid units, changing to max number 70

... EPA-SWMM 5.1 (Build 5.1.13)

o Retrieving project data o Simulation complete

... EPA-SWMM completed in 0.00 seconds. Traceback (most recent call last): File "C:\Users\gqc\Envs\ostrich\Scripts\ostrich-swmm-script.py", line 11, in load_entry_point('ostrich-swmm==0.6.0', 'console_scripts', 'ostrich-swmm')() File "build\bdist.win-amd64\egg\ostrich_swmm__main__.py", line 247, in main File "build\bdist.win-amd64\egg\ostrich_swmm__main__.py", line 116, in run_cmd File "build\bdist.win-amd64\egg\ostrich_swmm\run.py", line 43, in perform_run File "build\bdist.win-amd64\egg\ostrich_swmm\extract.py", line 332, in perform_extraction_steps File "build\bdist.win-amd64\egg\ostrich_swmm\extract.py", line 43, in perform_node_extraction AttributeError: 'SwmmExtract' object has no attribute 'TypeCheck'

Args: binary_output (swmmtoolbox.SwmmExtract): The output to extract from. node_output_file (file): The file to output extracted data to. node_names (Iterable): A list of node names to extract data for. statistics (Iterable): A list of statistics to extract. event_threshold_flow_rate (Number): The flow rate above which a node is considered to have flow. Defaults to 0. """

Get the indicies of the relevant data in the binary output.

node_type = binary_output.TypeCheck('node')
node_total_inflow_variable_index = next(
    index
    for index, name
    in binary_output.varcode[node_type].items()
    if name == 'Total_inflow'
)
kmmacro commented 4 years ago

@melissagqc can you share what your config.json file looks like? Did you define the correct output file name? https://github.com/ubccr/ostrich-swmm/blob/9553b9d84e3f5ac7d5de9024a7a3ce65d78d8015/templates/ostrich-swmm-config.json#L2

melissagqc commented 4 years ago

Yes, the output file name is correct. This is the JSON File: { "binary_output_path": "swmm.out", "input_template_path": "ModelTemplate.inp", "input_parameters_path": "submodel_input_parameters.json", "input_path": "swmm.inp", "report_output_path": "swmm.rpt", "summary_dir": ".", "swmm_path": "swmm5", "extract": { "steps": [ { "type": "node", "enabled": true, "output_path": "swmm_nodes.csv", "statistics": [ "node_name", "num_flow_events", "total_flow_volume", "total_flow_duration", "first_flow_start", "first_flow_end", "first_flow_duration", "first_flow_volume", "last_flow_start", "last_flow_end", "last_flow_duration", "last_flow_volume", "max_volume_flow_start", "max_volume_flow_end", "max_volume_flow_duration", "max_volume_flow_volume", "max_duration_flow_start", "max_duration_flow_end", "max_duration_flow_duration", "max_duration_flow_volume" ], "nodes": [ ], "event_threshold_flow_rate": 0 } ] } }

melissagqc commented 4 years ago

Sorry did not mean to close this issue

melissagqc commented 4 years ago

The binary output file is being generated. I have attached it in the zip file. image

This is the error we are getting when we run it in debug. image

swmm.zip

kmmacro commented 4 years ago

@melissagqc I think your issue is that you don't have anything defined for "nodes" in the json file, it is just an empty list.

You need to list one or more nodes that you want to extract results for: "nodes": ["J1", "J2"],

Given those nodes, OSTRICH-SWMM will generate "swmm_nodes.csv", where the columns are the attributes under "statistics" and each row contains the values for each node in the "nodes" list.

kmmacro commented 4 years ago

@melissagqc In addition to editing your json file, it looks like this is an error coming from a newer version of swmmtoolbox. Please see the commit referenced above for a temporary fix. I plan to update all the packages to be Python 3 compatible soon.