I have to remove both nan and inf values from two arrays. I found this post useful https://mcmap.net/q/989185/-pearson-correlation-and-nan-values for removing nan. Is there any similar solution when I can create a mask to remove both nan and inf values?
The example below is just illustrative, I have arrays of large dimensions (400 elements)
import numpy as np
from numpy import nan, inf
a = np.asarray([0.5, 6.2, np.nan, 4.5, np.inf])
b = np.asarray([np.inf, np.inf, 0.3, np.nan, 0.5])
bad = ~np.logical_or(np.isnan(a), np.isnan(b))
X = np.compress(bad, a)
Y = np.compress(bad, b)
BIAS = np.nanmean(X - Y)
RMSE = np.sqrt(np.nanmean((X - Y)**2))
CORR = np.corrcoef(X, Y)
I need this in order to get both the statistics and plots correctly
np.isinf
andnp.isnan
? – AnastigmatXY problem
to me. – Anastigmat