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

Bug fix/storm speed #104

Merged
merged 7 commits into from
Jul 25, 2024
Merged

Bug fix/storm speed #104

merged 7 commits into from
Jul 25, 2024

Conversation

WPringle
Copy link
Contributor

@WPringle WPringle commented Jun 25, 2024

Fixing storm speed and direction computation for forecasts.

The previous implementation computed only the same speed and direction uniformly for each unique datetime based on the first Lat, Lon values in the unique set, even though these times span across different forecasts with different coordinates.

New implementation computes for each row independently in series with correction where the new forecast starts to find the last previous valid datetime. NaNs that occur for the repeated rows across different isotachs are filled by pandas forward fill function.

WPringle added 2 commits June 25, 2024 16:17
…utation uniformly for all unique datetimes even though they can be across different forecasts
…for the first time which was previously set to be 0, now the next time is propagated backward
@WPringle WPringle requested a review from SorooshMani-NOAA July 8, 2024 19:51
@SorooshMani-NOAA SorooshMani-NOAA self-assigned this Jul 8, 2024
Comment on lines +1086 to +1089
if (advisory_data["datetime"] < this_time).sum() == 0:
shifted_indices[counter] = advisory_data["datetime"][
advisory_data["datetime"] > this_time
].index[0]
Copy link
Collaborator

Choose a reason for hiding this comment

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

@WPringle can you please explain what this does? It says that if there's no time in the dataframe smaller than the current row we're processing, then the shifted time ("previous time") should be the first time that is larger than the current time. Why?! This gives us opposite bearing, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point about the bearing! This could be a bug that needs fixing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems all the tests are passing. The coverage test runs into a timeout issue. Do you want me to go ahead with this merge and then later explore the bearing issue in a separate ticket or do you want me to wait for you to test the potential bearing issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for this! Please wait until I double check everything. I will let you know once happy.

Copy link
Contributor Author

@WPringle WPringle Jul 25, 2024

Choose a reason for hiding this comment

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

OK for the bearing when the shifted time is larger than the current time, we can use the forward_azimuth instead of inverse_azimuth. The change has been added in latest commit. Note this is overall a rare case.

Comment on lines +1118 to +1119
speeds.ffill(inplace=True)
bearings.ffill(inplace=True)
Copy link
Collaborator

@SorooshMani-NOAA SorooshMani-NOAA Jul 22, 2024

Choose a reason for hiding this comment

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

@WPringle where would we get nan to carry forward? We already are getting all indices, we shouldn't run into a case of nan that needs to be filled forward for different isotachs. If possible can you share an example where this happens?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does geodetic.inv return nans when locations are same?

Copy link
Contributor Author

@WPringle WPringle Jul 22, 2024

Choose a reason for hiding this comment

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

For the same forecast time but different isotachs the result will be nan because the time difference is zero. So we just want to repeat the result from the first line of the same forecast time.

… forward_azimuth for computing bearing (usually inverse_azimuth)
Copy link

codecov bot commented Jul 25, 2024

Codecov Report

Attention: Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.74%. Comparing base (784b95c) to head (0f93840).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
stormevents/nhc/track.py 96.15% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #104      +/-   ##
==========================================
- Coverage   91.75%   91.74%   -0.01%     
==========================================
  Files          19       19              
  Lines        2000     2012      +12     
==========================================
+ Hits         1835     1846      +11     
- Misses        165      166       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@SorooshMani-NOAA SorooshMani-NOAA merged commit 201daf0 into main Jul 25, 2024
12 of 13 checks passed
@SorooshMani-NOAA SorooshMani-NOAA deleted the bug_fix/storm_speed branch July 25, 2024 19:45
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