I have a sea surface temperature time series, and I want to calculate the (Pearson) correlation coefficients among the nodes in the tropics (30.0N to 30S). In the time series, the land information is present as masked. I do not know how to handle masked data in correlation calculation. Please help. The data I used here is in this link https://drive.google.com/file/d/1SVKQ4uBDEZOuN7_ftd5tqpF9_NGKY3pZ/view?usp=sharing
I tried the following code, which did not work:
temp5 = 'sst.day.mean.1983.nc'
fh5 = Dataset(temp5, mode = 'r')
sst5 = fh5.variables['sst'][:365]
time = fh5.variables['time'][:]
lat = fh5.variables['lat'][210:510][::35] #tropics latitude
lon = fh5.variables['lon'][::45]
mar_05=[]
for i in range(len(lat)):
for j in range(len(lon)):
for m in range(len(lat)):
for n in range(len(lon)):
mar_05.append(np.corrcoef(sst5[59:90,i,j],sst5[59:90, m,n][0,1]))
df = pd.DataFrame(data = mar_05)
sst5
NaN values, including the masked elements? $\endgroup$lat=
andlon=
don't do what you seem to think they do. They don't set which parts of the axes are active/visible when you referencesst5
, they just make lists of the lats and lons that you're interested in, butsst5
knows nothing about their contents. I'll edit my answer. $\endgroup$