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

Improvement to statistics.py module #138

Merged
merged 4 commits into from Jun 7, 2019

Conversation

@andersy005
Copy link
Member

commented Jun 6, 2019

Checklist

  • Enable and install pre-commit to ensure style-guides and code checks are followed.
  • Include documentation when adding new features.
  • Include new tests or update existing tests when applicable.
  • Fixes #137
  • Refactors test_statistics.py
@andersy005 andersy005 marked this pull request as ready for review Jun 7, 2019
@andersy005 andersy005 requested a review from mnlevy1981 Jun 7, 2019
Copy link
Contributor

left a comment

I verified that this PR lets me drop the dim= argument to esmlab.statistics.weighted_mean():

$ git diff marbl_diags
diff --git a/marbl_diags/analysis_ops.py b/marbl_diags/analysis_ops.py
index cd6f8d6..506053e 100644
--- a/marbl_diags/analysis_ops.py
+++ b/marbl_diags/analysis_ops.py
@@ -125,8 +125,8 @@ def _plot_climo(AnalysisElement, valid_time_dims):
 def _compute_stats(field, TAREA):
     fmin = np.nanmin(field)
     fmax = np.nanmax(field)
-    fmean = esmlab.statistics.weighted_mean(field, dim=field.dims, weights=TAREA).load().values
-    fRMS = np.sqrt(esmlab.statistics.weighted_mean(field*field, dim=field.dims, weights=TAREA).load().values)
+    fmean = esmlab.statistics.weighted_mean(field, weights=TAREA).load().values
+    fRMS = np.sqrt(esmlab.statistics.weighted_mean(field*field, weights=TAREA).load().values)

Thanks for updating this!

@andersy005

This comment has been minimized.

Copy link
Member Author

commented Jun 7, 2019

Awesome! @mnlevy1981, thank you for confirming that this PR addresses the issue.

@andersy005 andersy005 merged commit bbad55c into NCAR:master Jun 7, 2019
4 checks passed
4 checks passed
ci/circleci: docs-build Your tests passed on CircleCI!
Details
ci/circleci: linting Your tests passed on CircleCI!
Details
ci/circleci: python-3.6 Your tests passed on CircleCI!
Details
ci/circleci: python-3.7 Your tests passed on CircleCI!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.