Closed jerabekjak closed 3 years ago
What is the reason behind the try-except
clause in your snippet? Maybe we can do an if-else
clause (meaning that we can replace that try-except
with the one you added?).
The try-except is some relict, and i think it had some differnt meaning that the if statement suggested. I just spoke to @kavkapet, and devided to commit the sugested fix in the maste so we can test if it this was the cause of the error with nogis provider. It should be only a temporatl solution!
Okay, in the case it's a relict, I would replace it with the if-else
clause. Because the except
branch used to do exactly what we want to do now. I am afraid that it's better than some workarounds on the nogis level as there we would need to change a lot and touch also other things.
Yes, but the try-except was there in case of some error. I would rather raise
some error in the except
clause instead of puting there if-else, which I dont know how it should look like.
The if (iax < 0) : insurfflow_from_cell = 0
is just workaround so @kubinro2 can test the nogis provider...
The self.inflows used [1] is designes in the way that there is a boundary around the computation domain. In gis providers the loop [1] goes one cell above the uppermost cell in the computaitonal domain, where outflow is zero end use this zero as an inflow in the uppermost cell. WHich is the correct behaviour.
In no gis provider, where there is no empty cells sbove the compatatinal domain, it takes element with index -1 at the index of row from which should flow the first inflow into the compataional domain. In python (if i am corrent) index -1 in numpy arrays takes the last value in the array. wherefore the model took as on infow into the upslope cell an outflow from the last downslope cell.
Quick fix can be (not very systematic though):
[1] https://github.com/storm-fsv-cvut/smoderp2d/blob/fb14b7040d675c27ba2cc9fc76a0fc3be6a811ad/smoderp2d/core/flow.py#L64