year=2001:2016;
lat=ncread('/Users/yang146/Aerosol_Variaiton/CERES/dat/CERES_EBAF-Surface_Ed2.8_Subset_200003-201602.nc','lat');
lon=ncread('/Users/yang146/Aerosol_Variaiton/CERES/dat/CERES_EBAF-Surface_Ed2.8_Subset_200003-201602.nc','lon');

FNSC=ncread('/Users/yang146/Aerosol_Variaiton/CERES/ncfile/FNSC_2001_2016_DJF.nc','FNSC_DJF');

temp=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/WIND/ncfile/WIND_NCEP_1949_2016.nc','WIND_DJF');
WIND=temp(:,:,2001-1949+1:2016-1949+1);
WIND_ECHINA=zeros(length(year),1);
WIND_ECHINA(:)=mean(mean(WIND(45:50,19:29,:),2),1);


corr=zeros(length(lon),length(lat));
temp=zeros(length(year),1);
for i=1:length(lon)
    for j=1:length(lat)
        temp(:)=FNSC(i,j,:);
        temp2=corrcoef(temp,WIND_ECHINA);
        corr(i,j)=temp2(1,2);
    end
end

corr(isnan(corr))=-999;



save('corr_FNSC_WIND.mat','corr')

nccreate('corr_FNSC_WIND.nc','lat','Dimensions',{'lat',length(lat)},'Format','classic')
ncwrite('corr_FNSC_WIND.nc','lat', lat)
ncwriteatt('corr_FNSC_WIND.nc','lat','units','degrees_north')
ncwriteatt('corr_FNSC_WIND.nc','lat','long_name','Latitude')
nccreate('corr_FNSC_WIND.nc','lon','Dimensions',{'lon',length(lon)},'Format','classic')
ncwrite('corr_FNSC_WIND.nc','lon', lon)
ncwriteatt('corr_FNSC_WIND.nc','lon','units','degrees_east')
ncwriteatt('corr_FNSC_WIND.nc','lon','long_name','Longitude')
nccreate('corr_FNSC_WIND.nc','corr','Dimensions',{'lon',length(lon),'lat',length(lat)},'Format','classic')
ncwrite('corr_FNSC_WIND.nc','corr', corr)
ncdisp('corr_FNSC_WIND.nc')