correlation calculation of masked array:

115 Views Asked by At

I have a sea surface temperature time series, and I want to calculate the correlation coefficients among the nodes in the tropics(30.0N to 30S). In the time series, the land information is present as masked data. 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 enter image description here

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]
   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)
0

There are 0 best solutions below