year=2001:2014;
lat=-89.5:1:89.5;
lon=-179.5:1:179.5;
load ~/Aerosol_Variaiton/IRUN/AOD/ncfile/AOD_monthly_MODIS.mat
area=ncread('/Users/yangyang/NC/area_1X1.nc','gridbox_area');
month=1:length(year)*12;

AOD_SD_MONTH=zeros(360,180);


for i=1:360
    for j=1:180
        AOD_SD_MONTH(i,j)=std(AOD_MONTH(i,j,:));
    end
end

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


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

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