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

Fix NaN handling in calc_wd_mean_radial #68

Merged
merged 4 commits into from
Feb 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions flasc/circular_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,31 @@


import numpy as np
from scipy.stats import circmean

from floris.utilities import wrap_360


def calc_wd_mean_radial(angles_array_deg, axis=0):
# Use unit vectors to calculate the mean
wd_x = np.cos(angles_array_deg * np.pi / 180.)
wd_y = np.sin(angles_array_deg * np.pi / 180.)

mean_wd = np.arctan2(np.sum(wd_y, axis=axis),
np.sum(wd_x, axis=axis))
mean_wd = wrap_360(mean_wd * 180. / np.pi)
def calc_wd_mean_radial(angles_array_deg, axis=0, nan_policy="omit"):
"""
Compute the mean wind direction over a given axis. Assumes that the
input angles are specified in degrees, and returns the mean wind
direction in degrees. Wrapper for scipy.stats.circmean

Inputs:
angles_array_deg - numpy array or pandas dataframe of input
wind directions.
axis - axis of array/dataframe to take average over
nan_policy - option to pass to scipy.stats.circmean; defaults to
'omit'. (Options: 'propagate', 'raise', 'omit')

Outputs:
mean_wd - numpy array of mean wind directions over the provided
axis
"""

return mean_wd
return circmean(angles_array_deg, high=360., axis=axis,
nan_policy=nan_policy)


# def calc_wd_mean_radial_list(angles_array_list):
Expand Down