%  ---------------------------------------------------------
%           Res_o2a01
%  ---------------------------------------------------------
%  function adcig1 = res_o2a01(drs,ang,z,adcig);
%  ---------------------------------------------------------
%  Input   Description                    Type      Size
%  ---------------------------------------------------------
% drs      shot-receiver distance        Scalar     1 by 1
%  z       Depth Coordinate              Vector     1 by nz
%  ang     angle coordinate              Vector     1 by nang
%  adcig   angle gathers                 Matrix     nz by nang
%-----------------------------------------------------------
%  Output  Description                    Type      Size
%-----------------------------------------------------------
%  adcig1   angle gathers                 Matrix     nz by nang
%-----------------------------------------------------------
%
function adcig1 = res_o2a01(ang,z,adcig);
%
ang=ang*pi/180;
nz = length(z); dz = z(2) - z(1);
na = length(ang); da = ang(2)-ang(1);

%
adcig1 = zeros(nz,na);
%
adcig = half(1,adcig,dz);
%
%for iz = 1:nz;
    for ia = 1 : na;
        disp(num2str(((ia-1)*da+ang(1))*180/pi));
        for ib=1:na;
            z0 = z*(sec(ang(ib))*sec(ang(ia))-tan(ang(ib))*tan(ang(ia)));
            df = interp1(z,adcig(:,ib),z0);%size(df)
%tira nan
            indn = find(isnan(df));
            df(indn) = 0;
            adcig1(:,ia) = adcig1(:,ia) + df';
            
%            iz0 = floor(1.5+z0/dz);
%            if iz0 <= nz;
%                if iz0 > 1;
%                    adcig1(iz,ia) = adcig1(iz,ia) + adcig(iz0,ib);
%                end;
%            end;
        end;
    end;
%end;
%

