-
Notifications
You must be signed in to change notification settings - Fork 9
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
max_gap_fix #148
max_gap_fix #148
Conversation
I have changed the code to put the Please go ahead and include a test file where using this parameter makes sense. |
@ecomodeller I added a new line in the case |
@ecomodeller and @daniel-caichac-DHI , I have an example and test on this PR #147. Should I bring it along to here? It will still fail, as it uses |
@daniel-caichac-DHI : I see the gap in your |
@Hendrik1987 I tested with the dfsu with nans for the same reasons you mentioned, but I also tested (maybe I should add another file to the test files? it just seemed redundant) a dfs0 with gaps (non-eq dfs0) and also worked. |
@daniel-caichac-DHI : give me a moment, just bringing the other tests along... |
Could someone please explain the use case to me? I guess >99% of the time, model data will be equidistant and without gaps. If it contains gaps, then I guess you could just convert it to equidistant (and add deletevalues/nan in the gaps)? Am I missing something? Furthermore, if max_gap is a property of the modeldata, then I think it should be specified when defining the ModelResult, as it is not clear in the proposed implementation if it a gap in the measurement or in the model... |
Also, I think it would be nice if max_gap was a timedelta and by default the model timestep. |
Thanks, @Hendrik1987, your example convinced me of its usefulness :-) |
I still think it should be defined on the ModelResult though :-)
|
I submited a new PR with a new test when connecting a non-eq measurement with a non-eq model results, and the test is successful with the current implementation |
I tried to agree in my point 2 - which was maybe not clear :-) |
Added test for a |
with the new test the current implementations fails though , as it is right now implemented only in |
@jsmariegaard I moved the
and then the usual
it also works with Dataframes as model results and I think Xarrays. |
…y; include where missing in model results
@jsmariegaard Now the tests are successful and the I think we are ready to merge as soon as your review is finished. Thanks for fixing it ! |
Thanks for the notebook, @Hendrik1987, would be great to reformulate it as a number of unit tests for the interp_df method 👍 |
Sure @jsmariegaard , where should the tests be placed? |
Place the tests in of the comparison test files. For this it would be nice to have a test_comparison.py but we don't - but it's not super important we can always move them around if we like. I will get back to you on the other questions after the break - I am leaving now :) |
I updated this branch but now I can't seem to be able to add neither |
@@ -295,7 +296,7 @@ def _parse_observation(self, obs) -> PointObservation: | |||
else: | |||
raise ValueError(f"Unknown observation type {type(obs)}") | |||
|
|||
def extract(self) -> PointComparer: | |||
def extract(self, max_model_gap: float=None) -> PointComparer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daniel-caichac-DHI : .extract()
should take max_model_gap
, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, I had a script and tested with this commit and max_gap=3600
in extract()
and it works,
95cd56b
then I tested with the most recent version of this branch and max_model_gap=3600
in extract()
and it does not connect anything :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you maybe add a test that illustrates the problem? expected vs actual...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
When use the old commit (95cd56b ) I get this, 28 points
-
When I use the lastest commit of this branch , I get an error
-
Just for background, I am using the data from the test folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the Connector misses this argument - only the specialized connectors, like PointConnector and TrackConnector has it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add a failing test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added a failing test where connector.extract(max_model_gap=3600)
does not work.
@jsmariegaard : You asked me to reformulate notebook as couple of unit tests. I am generating test data within the notebook with a random component. Is it OK to save those as a few extra .dfs0 as additional test data? Maybe it is getting a bit messy with the test data, but I don't think we have an equivalent yet. |
Please do add more test data preferably with descriptive names 👍 |
Cool, will do! You mean something like |
Thanks @jsmariegaard for picking this up and sorry for not contributing more actively here! |
No worries, @Hendrik1987, I really appreciated the work you did on the notebook! It was a great help finishing this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed together with @ecomodeller IRL
Hi @jsmariegaard / @ecomodeller , I need help :(


I am trying to implement a
max_gap
feature when interpolatingModel dt
toMeasurement dt
to avoid unrealistic interpolations as the followingIt works when I hard-code a max dt with a given value (eg, if my dt is 10min and I want a max interpolation of gap of 1 hour, then when I set
limit=6
in here it works ok)https://github.com/DHI/fmskill/blob/74f15e9e5b0ad1116f4a842297e0010c635bbe7d/fmskill/comparison.py#L1173-L1177
but then I tried to implement this
max_gap
as a user input and failed miserably. I got lost with all the child classes and inheritances.Could you please help me getting this one working? I know it is not far away from being there.