load ~/NC/grid.mat
load ~/NC/area_1.9_2.5.mat
load ~/Aerosol_Variaiton/IRUN/AOD/ncfile/AOD_monthly.mat
month=1:1800;

AOD_SD_MONTH=zeros(144,96);

for i=1:144
    for j=1:96
        AOD_SD_MONTH(i,j)=std(AOD_MONTH(i,j,:));
    end
end

AOD_SD_MONTH_LAT=zeros(96,1);
AOD_SD_MONTH_LAT(:)=mean(AOD_SD_MONTH,1);

AOD_SD_MONTH_LAT(isnan(AOD_SD_MONTH_LAT))=0;


save('AOD_SD_RSD_monthly_lat.mat','AOD_SD_MONTH_LAT')

nccreate('AOD_SD_RSD_monthly_lat.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('AOD_SD_RSD_monthly_lat.nc','lat', lat)
ncwriteatt('AOD_SD_RSD_monthly_lat.nc','lat','units','degrees_north')
ncwriteatt('AOD_SD_RSD_monthly_lat.nc','lat','long_name','Latitude')
nccreate('AOD_SD_RSD_monthly_lat.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('AOD_SD_RSD_monthly_lat.nc','lon', lon)
ncwriteatt('AOD_SD_RSD_monthly_lat.nc','lon','units','degrees_east')
ncwriteatt('AOD_SD_RSD_monthly_lat.nc','lon','long_name','Longitude')
nccreate('AOD_SD_RSD_monthly_lat.nc','AOD_SD_MONTH_LAT','Dimensions',{'lat',96},'Format','classic')
ncwrite('AOD_SD_RSD_monthly_lat.nc','AOD_SD_MONTH_LAT', AOD_SD_MONTH_LAT)
ncdisp('AOD_SD_RSD_monthly_lat.nc')
