% program runs POC data before strutton calibration and regresses data 

% (once) run C:\Documents and Settings\Lisa Taylor\My Documents\Data\COASOSU\compile-noref.m
  % to get ps-compile.mat (Strutton data)
% (daily) run plot_apex_data.m to get apex_data_comparison.mat (Float 0005 profile data)
  
close all
clear all
warning('off')

%% APEX DATA, FLOAT 0005
load 'C:\Documents and Settings\Lisa Taylor\My Documents\Data\APEX\0005\apex_data_comparison'

% apex_data_comparison.mat contains:
  % pressure_apex
  % temp_apex
  % sal_apex
  % oxygen_apex
  % blueRef_apex
  % blueSig_apex
  % LSSRef_apex
  % LSSSig_apex
  % theta_apex
  % sigma_apex
  % O2sat_apex
  % O2_apex
  % Chl_apex
  % B_LSS_apex
  % date_apex (y m d h m s)
  % tt_apex, which is datenum(2004,6,17)+data_apex(:,16)
  % t_apex, which is 168+data_apex(:,16);
  % B_LSS_b_apex=(LSSSig_apex-51.8)*0.00004637; % instrument calibration ONLY
  % cp_apex, which is B_LSS_apex*63;
  % cp_b_apex, which is B_LSS_b_apex*63;
  % chl_b_apex, which is (((blueSig_apex-25)*0.01079772) instrument-calibrated ONLY
  % POC_b_apex, which is 10000* the corrected B_LSS_b_apex;

allApex=[date_apex, pressure_apex, temp_apex, sal_apex, oxygen_apex, chl_b_apex, B_LSS_b_apex]; % create one array to work with

%clear unnecessary variables from workspace
clear dat0*;
clear dat1*;
clear date0*; 
clear date1*;
clear pos*; 

%% STRUTTON DATA (other than chl night)
load 'C:\Documents and Settings\Lisa Taylor\My Documents\Data\COASOSU\ps-compile'
% ps-compile.mat contains:
  % PsCompile (6977x38), containing:
  % 1 date_pscompile (all arrays 6977x1)
  % 2 exceldate_pscompile
  % 3 year_day_pscompile
  % 4 lon_pscompile
  % 5 lat_pscompile
  % 6 flr_2m_pscompile
  % 7 chl_2m_pscompile
  % 8 flr_10m_pscompile
  % 9 chl_10m_pscompile
  % 10 flr_15m_pscompile
  % 11 chl_15m_pscompile
  % 12 b100_2m_pscompile
  % 13 b125_2m_pscompile
  % 14 b150_2m_pscompile
  % 15 b_back_2m_pscompile
  % 16 b100_10m_pscompile
  % 17 b125_10m_pscompile
  % 18 b150_10m_pscompile
  % 19 b_back_10m_pscompile
  % 20 b100_15m_pscompile
  % 21 b125_15m_pscompile
  % 22 b150_15m_pscompile
  % 23 b_back_15m_pscompile
  % 24 par_1m_pscompile
  % 25 unknown_1m_pscompile
  % 26 par_5m_pscompile
  % 27 flr_5m_pscompile
  % 28 par_10m_pscompile
  % 29 c_10m_pscompile
  % 30 par_20m_pscompile
  % 31 flr_20m_pscompile
  % 32 par_35m_pscompile
  % 33 c_35m_pscompile
  % 34 poc_bb_2m_pscompile
  % 35 poc_bb_10m_pscompile
  % 36 poc_beamc_10m_pscompile DATA USED IN THIS M-FILE
  % 37 poc_bb_15m_pscompile
  % 38 poc_beamc_35m_pscompile DATA USED IN THIS M-FILE

% set apex depth range to match with Strutton POC
I1=find(allApex(:,2)<11.1 & allApex(:,2)>4.9); % apex depths from 5 to 11m (231 points)
I2=find(allApex(:,2)<17.1 & allApex(:,2)>11.9); % apex depths from 12 to 17m (222 points)
I3=find(allApex(:,2)<22.1 & allApex(:,2)>17.9); % apex depths from 18 to 22m (205 points)
I4=find(allApex(:,2)<38.1 & allApex(:,2)>31.9); % apex depths from 32 to 38m (226 points)
I5=find(allApex(:,2)<40.1 & allApex(:,2)>29.9); % apex depths from 30 to 40m (445 points)

apex10m(:,1)=date_apex(I1);
apex10m(:,2)=pressure_apex(I1);
apex10m(:,3)=temp_apex(I1);
apex10m(:,4)=sal_apex(I1);
apex10m(:,5)=oxygen_apex(I1);
apex10m(:,6)=chl_b_apex(I1);
apex10m(:,7)=B_LSS_b_apex(I1);

apex35m(:,1)=date_apex(I5);
apex35m(:,2)=pressure_apex(I5);
apex35m(:,3)=temp_apex(I5);
apex35m(:,4)=sal_apex(I5);
apex35m(:,5)=oxygen_apex(I5);
apex35m(:,6)=chl_b_apex(I5);
apex35m(:,7)=B_LSS_b_apex(I5);

% NOT FINISHED - if we use Strutton data, use plots_strut_apex.m to finish
% up POC similar to how we did chl and bb

