Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find negative and positive values in numpy array

I have a numpy array what contains data of m/s wind speed. Both negative and positive values. Now i need to calculate the average number of the wind speed over the negative values and do the same for the positive values. Is this possible ? It's important that the data stays in the array. I had tryed something with numpy.average but without success, as he takes the average of the whole array both positive and negative values.

Thank you!

like image 649
user3408380 Avatar asked Jan 10 '23 19:01

user3408380


1 Answers

The nice thing about numpy is that you can write things like:

 negavg = numpy.mean(windspeed[windspeed < 0.0])
 posavg = numpy.mean(windspeed[windspeed > 0.0])
like image 186
Jakob S. Avatar answered Jan 18 '23 06:01

Jakob S.