在大气和海洋科学领域,常常会遇到的一个问题是有两个数组,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)



