栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Python 处理数组中的共同缺测问题

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Python 处理数组中的共同缺测问题

在大气和海洋科学领域,常常会遇到的一个问题是有两个数组,A,B,A和B在不同的位置均有缺测值的问题,而我们一般的情况下建模或者进行数据分析时候需要把A和B数组的缺测和非缺测的位置都设置为一致,基本的原理是当A和B在某个位置有数据缺测时候,则A和B均为缺测。处理这个问题的其中一种方法是基于np.isnan, np.logical_or, np.where相结合来解决。

以下是一个实际案例(7个数组):

ind1 =  np.isnan(obs_prec_fc24)
ind2 =  np.logical_or(np.isnan(prec_fc24), ind1)
ind1 =  ind2
ind2 =  np.logical_or(np.isnan(hgt_fc24), ind1)
ind1 =  ind2
ind2 =  np.logical_or(np.isnan(pw_fc24), ind1)
ind1 =  ind2
ind2 =  np.logical_or(np.isnan(omega_fc24), ind1)
ind1 =  ind2
ind2 =  np.logical_or(np.isnan(tem_fc24), ind1)
ind1 =  ind2
ind2 =  np.logical_or(np.isnan(rh_fc24), ind1)
ind1 =  ind2

obs_prec_f24= np.where(ind1, np.nan, obs_prec_fc24)
prec_f24    = np.where(ind1, np.nan, prec_fc24)
hgt_f24     = np.where(ind1, np.nan, hgt_fc24)
pw_f24      = np.where(ind1, np.nan, pw_fc24)
omega_f24   = np.where(ind1, np.nan, omega_fc24)
tem_f24     = np.where(ind1, np.nan, tem_fc24)
rh_f24      = np.where(ind1, np.nan, rh_fc24)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/834756.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号