-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove a pattern #77
Comments
You can't remove a Pattern that is being used by a Junction. If you want to remove the Pattern, you need to remove it from all associated Junctions first. Alternatively, you can modify the Pattern or create a new Pattern and assign it to the Junction. |
Is it possible to loop through all junctions and remove a pattern? I cant find in the references something like a "remove_pattern" method. As for the alternatives, when I assign a new Pattern, the simulation ignores the previous? Say for example in a prolonged simulation I dynamically add "pattern1", then "fire_pattern", then "pattern_2". |
It seems that an easy method for doing this is needed. In the meantime, here is how to do it manually (using Net3.inp as an example, removing pattern ‘2’)
>> wn.remove_pattern('2')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/xxxxx/WNTR-master/wntr/network/model.py", line 647, in remove_pattern
self._pattern_reg.__delitem__(name)
File "/Users/xxxxx/WNTR-master/wntr/network/base.py", line 471, in __delitem__
self._usage[key])
RuntimeError: ('cannot remove %s %s, still used by %s', 'PatternRegistry', '2', {('123', 'Junction'), })
>> wn.patterns.get_usage('2')
{('123', 'Junction'), }
>> node = wn.get_node('123')
>> node.demand_timeseries_list
<Demands: [<TimeSeries: base=6.30901964e-05, pattern='2', category='EN2 base'>]>
>> node.demand_timeseries_list[0]
<TimeSeries: base=6.30901964e-05, pattern='2', category='EN2 base'>
>> node.demand_timeseries_list[0].pattern_name = None
>> node.demand_timeseries_list[0]
<TimeSeries: base=6.30901964e-05, pattern=None, category='EN2 base'>
>> wn.patterns.remove_usage('2', ('123', 'Junction'))
>> wn.remove_pattern('2')
>>
I hope that we can add to the @pattern_name.setter function to do the registry add_usage and remove_usage automatically farily soon, and that in the meantime this helps. The result from patterns.get_usage(‘patternname’) is a set, so yes, you can loop through it.
From: dionikolop <notifications@github.com>
Reply-To: USEPA/WNTR <reply@reply.github.com>
Date: Tuesday, March 19, 2019 at 10:06 AM
To: USEPA/WNTR <WNTR@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>
Subject: [EXTERNAL] Re: [USEPA/WNTR] Remove a pattern (#77)
Is it possible to loop through all junctions and remove a pattern? I cant find in the references something like a "remove_pattern" method. As for the alternatives, when I assign a new Pattern, the simulation ignores the previous? Say for example in a prolonged simulation I dynamically add "pattern1", then "fire_pattern", then "pattern_2".
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#77 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AFQ5SdU2IiBB1gdKYuUaC3Z3y3wOfh_tks5vYQsAgaJpZM4b7zt1>.
|
This is still not working for me, even after removing all demands from all nodes with . clear()
workaround is to write a temporary inp file and load it again (be aware that every node has a standard demand of 0 now):
|
Hello,
I am not sure how to remove a pattern from a wntr.network.model.WaterNetworkModel object. I get the error:
('cannot remove %s %s, still used by %s', 'PatternRegistry', 'PDD10', {('10', 'Junction'), }).
However, I cannot find a way to delete patterns from PatternRegistry.
Thanks in advance!
Dionysis
The text was updated successfully, but these errors were encountered: