
rawfile = '/home/ulili/programs/ladcp/sondemo/data/ladcp/d1002001.adp';
instclass = son;
step = 1;
range = [1 2200];
yearbase = 1998;

rr = read(son, rawfile, 'yearbase', yearbase, 'vars', 'all',...
          'irange', range);
dd = restruct(son,rr);


fileroot = rawfile(1:end-4)
[ts, ts2, vel, vstd, amp, noise, dday] = adp(fileroot, 'ts', 'ts2', ...
                'vel', 'std', 'amp', 'noise', 1, [1 2200]);


% fid = fopen(rawfile, 'r', 'ieee-le');
% fseek(fid, 0, 'bof')
% sensor      = read_sencfg(instclass, fid)
% adpsetup    = read_adpcfg(instclass, fid)
% usersetup    = read_usercfg(instclass, fid)
% profheader = read_prfhdr(instclass, fid, ftell(fid))
% fclose(fid);   



%        ts: NPx5 array.  Columns are heading, pitch, roll, temperature,
%              and pressure.  Units are degrees, degrees C, and decibars.
%        ts2: NPx5 array.  Columns are Xflux, Yflux, Zflux,
%              compass temperature, and voltage.  Units are
%              microteslas, degrees C, and Volts.


aa.heading = ts(:,1);
aa.pitch = ts(:,2);
aa.roll = ts(:,3);
aa.temperature = ts(:,4);
aa.pressure = ts(:,5);
aa.xflux = ts2(:,1);
aa.yflux = ts2(:,2);
aa.zflux = ts2(:,3);
aa.ctemperature = ts2(:,4);
aa.voltage = ts2(:,5);
aa.dday = dday;
aa.vel1=squeeze(vel(:,1,:));
aa.vel2=squeeze(vel(:,2,:));
aa.vel3=squeeze(vel(:,3,:));
aa.vel4=squeeze(vel(:,4,:));
aa.amp1=squeeze(amp(:,1,:));
aa.amp2=squeeze(amp(:,2,:));
aa.amp3=squeeze(amp(:,3,:));
aa.amp4=squeeze(amp(:,4,:));
aa.bins = [1:length(amp(:,1,1))]';

