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

Apply sign on gradients, not on water levels #1070

Merged

Conversation

leendertvanwolfswinkel
Copy link
Collaborator

No description provided.

@@ -0,0 +1,41 @@
2024-11-29:08:57 INFO [scheduler.py:1611] Waiting for redis to become available
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need all those log files in the repo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I can clean it up a bit

@@ -0,0 +1,114 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this file for the tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having the flow summary is nice, because it contains the information about the simulation (which model was used, sim id, etc.)

@@ -764,7 +752,7 @@ def gradients(
gr=gr,
flowline_ids=flowline_ids,
node_variable="s1",
aggregation_sign=aggregation_sign,
aggregation_sign=AggregationSign(short_name="net", long_name="Net"), # apply sign to gradient, not to s1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a "net" aggregation basically doing nothing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, the AggregationSign does nothing, so in that sense you are right. But the AggregationMethod still does its job. e.g. it is perfectly valid to calculate the net sum, but also valid to calculate the positive sum or negative sum. Or absolute max etc.

@@ -779,7 +767,11 @@ def gradients(
levels_end = levels.T[end_node_indices]
distances = get_lengths(lines)
gradients = (levels_end - levels_start).T / distances
return gradients, time_intervals

# apply sign
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also apply for "bed_level"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AggregationVariable that has bed_level as short_name as defined in constants does not support having a sign, so this not super relevant. But I will add some code to only apply the sign if the aggregation variable is water level.

from .constants import AGGREGATION_VARIABLES, AGGREGATION_METHODS


def test_hybrid_time_aggregate_gradient():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure this test is collected (test this by adding an "assert False")?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

   def test_hybrid_time_aggregate_gradient():
>       assert False
E       assert False

FAILED utils/threedi_result_aggregation/test_threedi_result_aggregation.py::test_hybrid_time_aggregate_gradient

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So yes it is collected :)

Copy link
Contributor

@benvanbasten-ns benvanbasten-ns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just some pointers and questions. You can merge it when you feel these are ok.

@leendertvanwolfswinkel leendertvanwolfswinkel merged commit fde5123 into master Dec 3, 2024
1 check passed
@leendertvanwolfswinkel leendertvanwolfswinkel deleted the leendert-result-aggregation-gradient-bug branch December 3, 2024 15:29
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

Successfully merging this pull request may close these issues.

2 participants