python统计大于阈值的个数

您所在的位置:网站首页 python统计大于阈值的个数 python统计大于阈值的个数

python统计大于阈值的个数

2023-06-27 02:21| 来源: 网络整理| 查看: 265

我有一个numpy数组,我从一个形状为(930,360,720)的netCDF文件中引入,它被组织为(时间,纬度,经度).

在930个时间戳中的每一个的每个纬度/经度对上,我需要计算该值达到或超过阈值“x”(例如0.2或0.5等)的次数,并最终计算阈值的百分比在每个点超出,然后输出结果,以便稍后绘制它们.

我尝试了很多方法,但这是我最近的方法:

lat_length = len(lats)

#where lats has been defined earlier when unpacked from the netCDF dataset

lon_length = len(lons)

#just as lats; also these were defined before using np.meshgrid(lons, lats)

for i in range(0, lat_length):

for j in range(0, lon_length):

if ice[:,i,j] >= x:

#code to count number of occurrences here

#code to calculate percentage here

percent_ice[i,j] += count / len(time) #calculation

#then go on to plot percent_ice

我希望这是有道理的!我非常感谢任何帮助.我是用Python自学的,所以我可能会遗漏一些简单的东西.

这是使用any()函数的时候吗?什么是最有效的方法来计算超过阈值的次数,然后计算百分比?



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3