-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add weighted_average_lat #39
Conversation
e5902ec
to
fb86e46
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #39 +/- ##
==========================================
+ Coverage 94.39% 94.62% +0.22%
==========================================
Files 7 7
Lines 357 372 +15
==========================================
+ Hits 337 352 +15
Misses 20 20 ☔ View full report in Codecov by Sentry. |
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.
Thanks! Just a few comments.
src/Var.jl
Outdated
maximum(lats) >= 0.5π || | ||
@warn "Detected latitudes are small. If units are radians, results will be wrong" | ||
|
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.
maximum(lats) >= 0.5π || | |
@warn "Detected latitudes are small. If units are radians, results will be wrong" | |
maximum(abs(lats)) >= 0.5π || | |
@warn "Detected latitudes are small. If units are radians, results will be wrong" | |
(it is common to take e.g. southern hemisphere mean, and this way the warning wouldn't show up for that case)
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.
Thank you!
|
||
weights[index_tuple...] .= weights_1d | ||
end | ||
var.data .*= weights |
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.
If _reduce_over takes the average, the weights here should be divided by the average weights?
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.
Right, I need to normalize the weights!
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.
If you do this the average of var should be sum(var.data) instead of mean(var.data), because the sum of the weights is 1 now? Alternatively we can do weights ./= mean(weights_1d)
I think.
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.
Yes, thank you! I changed to mean
@cmschmitt519 You can use this once it's merged. |
@szy21 can you have another look? |
And add option to add weights to `average_lat`
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.
Thanks!
@cmschmitt519 If you need this, it is available in the most recent version (0.5.6) |
And add option to add weights to
average_lat
,I didn't make it default to maintain backwards compatibility, but we can make it default in the future.
Closes #38