Astropy weighted circular mean with numpy ndarrays, encountering TypeError: only integer scalar arrays can be converted to a scalar index
Hello all and thank you for any assistance in advance.
I am using the astropy circmean function (https://docs.astropy.org/en/stable/api/astropy.stats.circmean.html) to evaluate the weighted circular mean of an array of angles. The function takes a numpy ndarray for the angles in radians and another ndarray for the weights. I am getting a type error when trying to input a numpy array for the weights. I can reproduce the error with this code:
import numpy as np
from astropy.stats import circmean
circmean(np.array([.05, -np.pi/2, np.pi]), np.array([1, 1, 10]))
Error:
TypeError: only integer scalar arrays can be converted to a scalar index
I tried checking that the arrays were the required data type and changing the data type of the weights entries. The function works without the weights, but I need to use the weighting. I was expecting the function to work and calculate the desired weighted mean.
source https://stackoverflow.com/questions/76309526/astropy-weighted-circular-mean-with-numpy-ndarrays-encountering-typeerror-only
Comments
Post a Comment