% Script that creates the cruise name (crname) and creates the directory
% format for organizing the raw and calibrated data.  Also copies the
% necessary SBE processed data to the correct folders (This must be
% manually manipulated to correct for each cruise.  Ideally you should just
% have to change the cruise name in the paths).  Finally it loads the
% processed SBE data into the  crname_db.mat to be used through the
% calibration process.
% Author: Jay Hooper 11/11

clear all;
%% Step 1: Define cruise name and directories. Run make_cruise_dir('cruise_name').

%prompts user for the cruise id (ex. ab1104 where 1104=yymm)
crname = input(['Enter cruise id (ex. abyymm) : '], 's');
    
% Creates cruise directories as well as thre m_files (ctdcalpath.m,
% local.m, and register_cruise.m)    
make_cruise_dir(crname);

% Adds necessary paths, creates cruiseid variable, and runs
% register_cruise_cruiseid.m for managing data
local;

%% Step 2: Copy the data of CTD: *.bl, *.btl, and *.cnv(down cast only) into the
%% directories raw_data, proc_data, and bottle
%return
% Change 1 to 0 if you run proc_ctdcal.m more than once.  Not good to keep
% writing over data.
if 1,
% Copy files from data directry... We can create a function to do this...    
[raw_status,raw_m,raw_mid]=copyfile('/Users/jhooper/Documents/Work_data/Abicos/ab1202/ctd/raw_data/*.bl','/Users/jhooper/Documents/Work_data/WBTS/ab1202/raw_data');
[proc_status,proc_m,proc_mid]=copyfile('/Users/jhooper/Documents/Work_data/Abicos/ab1202/ctd/proc_data/d*.cnv', '/Users/jhooper/Documents/Work_data/WBTS/ab1202/proc_data');
[bot_status,bot_m,bot_mid]=copyfile('/Users/jhooper/Documents/Work_data/Abicos/ab1202/ctd/bottle/*.btl', '/Users/jhooper/Documents/Work_data/WBTS/ab1202/bottle');

end;

%% load the .bl, .btl, and .cnv data and save in to a database
%Something not right going on with these processes.  Might just be the
%CLIVAR data.  Check with Abico data.  Put commented lines back in
load_bl(cruiseid)     
load_btl(cruiseid)
load_cnv(cruiseid) % JH added the uM/kg variable for oxygen