function ac = cutadcp(instclass, a, ii)
% function ac = cutadcp(instclass, a, ii)
% Returns subset of "a" with time indices ii.
% It would be nice to have a more automated way of doing this.

% This initialization is not necessary, but it ensures that
% the order of the fields remains the same, even if they are
% changed in read_os.

ac = a;


if isfield(a, 'vel'),    ac.vel =     a.vel(:, :, ii); end
if isfield(a, 'amp'),    ac.amp =     a.amp(:, :, ii); end
if isfield(a, 'pg'),     ac.pg =      a.pg(:, :, ii); end
if isfield(a, 'sw'),     ac.sw =      a.sw(:, :, ii); end
if isfield(a, 'status'), ac.sw =      a.sw(:, :, ii); end
if isfield(a, 'HiV'),    ac.HiV =     a.sw(:, :, ii); end
if isfield(a, 'XmtAmps'),ac.XmtAmps = a.sw(:, :, ii); end



   
if isfield(a, 'bt'),
   ac.bt.vel = a.bt.vel(:,ii);
   ac.bt.range = a.bt.range(:,ii);
   ac.bt.pg = a.bt.pg(:,ii);
end

if isfield(a, 'nav'),
   ac.nav.sec_pc_minus_utc = a.nav.sec_pc_minus_utc(ii);
   ac.nav.txy1 = a.nav.txy1(:,ii);
   ac.nav.txy2 = a.nav.txy2(:,ii);
end



if isfield(a, 'config'),        ac.config    = a.config;       end
if isfield(a, 'info'),          ac.info      = a.info;       end
if isfield(a, 'depth'),         ac.depth     = a.depth;        end
if isfield(a, 'add_to_ens'),    ac.add_to_ens= a.add_to_ens;   end



if isfield(a, 'heading'),         ac.heading     = a.heading(ii);     end
if isfield(a, 'pitch'),           ac.pitch       = a.pitch(ii);       end
if isfield(a, 'roll'),            ac.roll        = a.roll(ii);        end
if isfield(a, 'soundspeed'),      ac.soundspeed  = a.soundspeed(ii);  end
if isfield(a, 'meas_soundspeed'),      ac.meas_soundspeed  = a.meas_soundspeed(ii);  end
if isfield(a, 'temperature'),     ac.temperature = a.temperature(ii); end
if isfield(a, 'aduheading'),      ac.aduheading  = a.aduheading(ii);  end
if isfield(a, 'attdday'),         ac.attdday     = a.attdday(ii);     end
if isfield(a, 'mrms'),            ac.mrms        = a.mrms(ii);        end
if isfield(a, 'brms'),            ac.brms        = a.brms(ii);        end
if isfield(a, 'dday'),          ac.dday      = a.dday(ii);     end
if isfield(a, 'ens_num'),       ac.ens_num   = a.ens_num(ii);  end
if isfield(a, 'num_pings'),     ac.num_pings = a.num_pings(ii);end
if isfield(a, 'RDIens_num'),    ac.RDIens_num    = a.RDIens_num(ii); end
if isfield(a, 'RDIymdhms'),     ac.RDIymdhms    = a.RDIymdhms(ii); end
if isfield(a, 'config_nbytes'), ac.config_nbytes= a.config_nbytes(ii); end
if isfield(a, 'config_nleader'),ac.config_nleader= a.config_nleader(ii); end
