Skip to content
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

Closed
dionikolop opened this issue Mar 19, 2019 · 4 comments
Closed

Remove a pattern #77

dionikolop opened this issue Mar 19, 2019 · 4 comments

Comments

@dionikolop
Copy link

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

@kaklise
Copy link
Collaborator

kaklise commented Mar 19, 2019

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.

@dionikolop
Copy link
Author

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".

@dbhart
Copy link
Collaborator

dbhart commented Mar 19, 2019 via email

@balks
Copy link

balks commented Jun 19, 2020

This is still not working for me, even after removing all demands from all nodes with . clear()

for nid, nd in wn.junctions():
    for demand in nd.demand_timeseries_list:
        demand.pattern_name = None
    nd.demand_timeseries_list.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):

wn.write_inpfile('tmp.inp')
wn = wntr.network.WaterNetworkModel('tmp.inp')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants