Output object only an associated variable named POLLUT_CONC_0 #550
-
I would like to record the values of multiple pollutants in each step, but when I open the Output object, it doesn't seem to be able to derive the appropriate dictionary, only an associated variable named POLLUT_CONC_0. This results in me needing to traverse the Nodes(sim) object multiple times in the run. Originally posted by @sausagechen in #503 (comment) |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments
-
Current Workaround until this effort gets planned in: |
Beta Was this translation helpful? Give feedback.
-
So how should I get the corresponding multiple pollutant concentration values according to the time and node? |
Beta Was this translation helpful? Give feedback.
-
I tried this again, but there was no time I needed in either 'step' or 'sim' or 'node', so I had to iterate and set the time by myself?'current_time','report_start','' |
Beta Was this translation helpful? Give feedback.
-
You should use sim.current_time |
Beta Was this translation helpful? Give feedback.
-
This is the parameter in my 'inp'. The interval I get using 'sim.current_time' is 20 seconds. The interval I expect should be one day. But I set 'ROUTING_STEP 24:00:00' and got the wrong time too. |
Beta Was this translation helpful? Give feedback.
-
Can you share the “options” section of your input file? |
Beta Was this translation helpful? Give feedback.
-
ok, START_DATE 02/29/2004 INERTIAL_DAMPING PARTIAL |
Beta Was this translation helpful? Give feedback.
-
I tried it again, but I still had two questions:
|
Beta Was this translation helpful? Give feedback.
-
SWMM uses enumerations to compute the index in the outfile from which to start parsing data. You can think of the output file as a long sequence of bytes. Various data are encoded in that sequence, some are timeseries data, some are object names, datetimes etc. If you arbitrarily increase the attribute enum beyond the actual number of attributes , swmm will think you want to parse an extra time series that does not exist. For example, if you have five pollutants in your model and you tell pyswmm to read the sixth (which does not exist), it will return the first attribute of the next node or link instead because that is where the sixth pollutant would be written in the output file if it did exist. pyswmm doesn't have a good way of extending the attribute enums right now. It really depends on the user to know what they are doing. You can however use swmm pandas, which handles the enumeration extension for you.
import swmm.pandas as spd
out = spd.Output('./swmm_toc/out1.out')
series = out.link_series(
attribute=('dtprsmg','b8wttak'), # pollutant names can also be found in out.link_attributes
link='C1' # link names can also be found out.links
)
series.plot() I have not updated swmm-pandas since numpy 2.0 dropped, so I only guarantee it working with numpy<2 (although most of it may work with numpy 2.
|
Beta Was this translation helpful? Give feedback.
-
@karosc thanks |
Beta Was this translation helpful? Give feedback.
SWMM uses enumerations to compute the index in the outfile from which to start parsing data. You can think of the output file as a long sequence of bytes. Various data are encoded in that sequence, some are timeseries data, some are object names, datetimes etc.
If you arbitrarily increase the attribute enum beyond the actual number of attributes , swmm will think you want to parse an extra time series that does not exist. For example, if you have five pollutants in your model and you tell pyswmm to read the sixth (which does not exist), it will return the first attribute of the next node or link instead because that is where the sixth pollutant would be written in the output file if it di…