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

No interpolation for non-continuous fields #13

Closed
wants to merge 2 commits into from

Conversation

holgerpieta
Copy link

This PR solves #12

Some forecast fields are non-continuous, i.e. do not contain valid data for each forecast time point.
Instead they just contain "-".
Number.parseFloat() will parse that as NaN, causing the interpolation to fail and return NaN as well.
Except for files that are fully in the future, nothing but NaN will be returned, because interpolation will always fail.

With this fix, the node first checks the previous forecast for NaN and only interpolates if it's a valid number.
Resulting behavior:

  • Both values are numbers: Normal interpolation.
  • First value is NaN: Take second value without interpolation.
    Obviously, if the second the value is NaN, too, the result will still be NaN.
  • Second value is NaN: Result is also NaN.

Some forecast fields are non-continuous, i.e. do not contain valid data for each forecast time point.
Instead they just contain "-".
Number.parseFloat() will parse that as NaN, causing the interpolation to fail and return NaN as well.
Except for files that are fully in the future, nothing but NaN will be returned, because interpolation will always fail.

With this fix, the node first checks the previous forecast for NaN and only interpolates if it's a valid number.
Resulting behavior:
- Both values are numbers: Normal interpolation.
- First value is NaN: Take second value without interpolation.
	Obviously, if the second the value is NaN, too, the result will still be NaN.
- Second value is NaN: Result is also NaN.
@c5te1n
Copy link
Owner

c5te1n commented Apr 13, 2020

Merged this into master.

@c5te1n c5te1n closed this Apr 13, 2020
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