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

AOD_67th=prctile(AOD_MONTH,67,3);
AOD_33th=prctile(AOD_MONTH,33,3);
PO_Month=zeros(length(lon),length(lat),length(month));
CL_Month=zeros(length(lon),length(lat),length(month));

for i=1:length(lon)
for j=1:length(lat)
for monthID=1:length(month);
    if AOD_MONTH(i,j,monthID)>AOD_67th(i,j)
        PO_Month(i,j,monthID)=1;
    end
    if AOD_MONTH(i,j,monthID)<AOD_33th(i,j)
        CL_Month(i,j,monthID)=1;
    end
end
end
end


save('POCL_Month.mat','PO_Month','CL_Month')

nccreate('POCL_Month.nc','Month','Dimensions',{'time',Inf},'Format','classic')
ncwrite('POCL_Month.nc','Month', month)
ncwriteatt('POCL_Month.nc','Month','long_name','Month')
nccreate('POCL_Month.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('POCL_Month.nc','lat', lat)
ncwriteatt('POCL_Month.nc','lat','units','degrees_north')
ncwriteatt('POCL_Month.nc','lat','long_name','Latitude')
nccreate('POCL_Month.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('POCL_Month.nc','lon', lon)
ncwriteatt('POCL_Month.nc','lon','units','degrees_east')
ncwriteatt('POCL_Month.nc','lon','long_name','Longitude')
nccreate('POCL_Month.nc','PO_Month','Dimensions',{'lon',144,'lat',96,'month',length(month)},'Format','classic')
ncwrite('POCL_Month.nc','PO_Month', PO_Month)
nccreate('POCL_Month.nc','CL_Month','Dimensions',{'lon',144,'lat',96,'month',length(month)},'Format','classic')
ncwrite('POCL_Month.nc','CL_Month', CL_Month)
ncdisp('POCL_Month.nc')