%
%    addpath ' /Molly/work/matlab/seawater_ver3_0 
% 1. cd /Molly/work/WBTS/data/abaco/ab1202/Data
% 2. make_cruise_dir (?CTD?)
% 3. edit CTD/mfiles/register_cruise.m
%   change cruiseid
%   filename prefix, source_data_dir, region etc
%   check cal dirs
% 4. register_cruise_ab1202
% 5. getpref
% 6. getpref(?ab1202_ctd_calibration?)
%    check these paths are ok


bl = load_bl_molly('ab1202');
btl = load_new_btl('ab1202');
[cnv cnv_load] = load_new_cnv_molly('ab1202');

compare_ctd_sensors_molly % must be done from cal_data_directory

compare_tsplot_old('ab1202')

process_autosal_ab1202
% must be run from within the salts directory

clear salts
salts = load_salts_molly('ab1202');
%
% Note: this is *not* the same as the salts structure created from reading
% the database salts_bd.mat located in the salts directory.  This salts
% structure is used by ctdcal and looks like:
%   salts
%    station
%    niskin_bottle
%    sample_bottle
%    cond_ratio_2
%    salinity
%


cnv_fill = fill_surface2 ('ab1202');

despike1('ab1202')
% don't want to deal with despiking the data now, just do this:
cnv_ds1 = cnv_fill;
save ab1202_db.mat cnv cnv_fill cnv_load cnv_ds1 btl bl salts

despike2('ab1202')
%
% this is going to require some work to sort through.
% don't like *any* of these - for one thing they are assigning
% cnv_ds2 = cnv_ds1 
% right off the bat!  That's replacing the secondary with despiked primary!
% What the heck!  Should see if the variable for that station number exists
% and prompt the user to be sure you want to overwrite it!
% Good news is that if you just despike one and only one station, the
% cnv_ds2 variable is created and you can move to the next step!
% or just do this:
cnv_ds2 = cnv_fill;
save ab1202_db.mat cnv cnv_fill cnv_load cnv_ds1 btl bl salts cnv_ds2


cnv_dlp = deloop_molly('ab1202');
%
% dlp should make a log file of what's removed.
% there should also be some log of the NANs - which need to be interpolated
% over.
%

cond_match=make_cond_sumfile_molly('ab1202');

correct_temp
% could use this to fix our primary T sensor


oxy = load_oxy_new ('ab1202');
%
%   cruiseid
%    station
%    niskin
%    sample_bottle
%    thio_vol
%    oxygen
%    units
make_oxy_sumfile('ab1202');


check_bad_salt_CF1('ab1202')

compare_cond('ab1202',0,10)

cond_calfit_w ('ab1202')


check_bad_oxy
compare_oxy

oxy_cal_new_equation1
apply_calibration
make_cal_sumfile
eval_calibration_cond
eval_calibration_oxy
write_aoml3
save_final_results
make_woce_bottle_file


