-
Notifications
You must be signed in to change notification settings - Fork 31
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
DRAFT: Weighted Average #833
base: main
Are you sure you want to change the base?
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
I've set up the boilerplate for the weighted mean functionality. This should be a good place to get started. We can run over this during today's meeting. |
We have fixed the issue with the |
ASV BenchmarkingBenchmark Comparison ResultsBenchmarks that have improved:
Benchmarks that have stayed the same:
|
…rray/weighted-mean (#866) * updated mean function with weighted arg * updated weighted-mean functionality in dataarray.py * edited weights to dask array --------- Co-authored-by: Rachel Yuen Sum Tam <[email protected]> Co-authored-by: Rachel Yuen Sum Tam <[email protected]>
if self._face_centered(): | ||
grid_dim = "n_face" | ||
# use face areas as weight | ||
weights = da.from_array(self.uxgrid.face_areas.values) |
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.
weights = da.from_array(self.uxgrid.face_areas.values) | |
weights =self.uxgrid.face_areas |
elif self._edge_centered(): | ||
grid_dim = "n_edge" | ||
# use edge magnitude as weight | ||
weights = da.from_array(self.uxgrid.edge_node_distances.values) |
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.
weights = da.from_array(self.uxgrid.edge_node_distances.values) | |
weights = self.uxgrid.edge_node_distances |
total_weight = weights.sum() | ||
|
||
# compute weighted mean #assumption on index of dimension (last one is geometry) | ||
weighted_mean = (self * weights).sum(dim=grid_dim) / total_weight |
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.
weighted_mean = (self * weights).sum(dim=grid_dim) / total_weight | |
weighted_mean = (self.data * weights).sum(dim=grid_dim) / total_weight |
Closes #826
Overview
Expected Usage
PR Checklist
General
Testing
Documentation
_
) and have been added todocs/internal_api/index.rst
docs/user_api/index.rst
Examples
docs/examples/
folderdocs/examples.rst
toctreedocs/gallery.yml
with appropriate thumbnail photo indocs/_static/thumbnails/