% C:\Documents and Settings\Lisa Taylor\My Documents\Data\APEX\0015\Seawifs
% gets seawifs data

% gets arrays:
  % from chlor_a.mat:
  % clat (1x1033)
  % clon (1x1033)
  % data containing chl values for each 13x13 grid (169x1033) 
        % -1=cloud cover -999=missing data
  % dt_im containing seawifs dates (IDL julian format) from 08/23/05 to 06/03/07
  % from dist_seawifs.mat:
    % dist (1x169)
    % distgrid (1033x169): distance of each pixel in 13x13 grid around
      % Float 0015 (located at 7,7)
% saves seawifs_chl.mat containing:
  % seawifsChl [date, chl] (1033x170)
  % seawifs_chl_ts (1033x169) just chlorophyll
  % distgrid (1033x169)
  % clat (1x1033)
  % clon (1x1033)
  
close all
clear all

load data/chlor_a
dd=dt_im+0.5; % add 1/2 day to correct processing error per Peter B.

%fix the time stamp to Matlab's
load offset_time
date_seawifs=dd-offset;

date_seawifs(date_seawifs==0)=NaN; % replace 0s with NaNs
date_seawifs=date_seawifs'; % now 1276x1
data(data==-1)=NaN; % replace -1s (cloud cover) in 51x51 grid with NaNs
data(data==-999)=NaN; % replace -999s (missing data) in 51x51 grid with NaNs
justChl=data'; % now 1033x169

seawifsChl=[date_seawifs,justChl]; % array of both date (col 1) and chl (remaining 170 cols) 1033x170
% seawifs_chl_ts=justChl'; % now 169x1276
seawifs_chl_ts=justChl;

load dist_seawifs % (1033x169)
distgrid_seawifs=distgrid;

% clear unecessary variables from workspace
clear dt_im;
clear data;
clear dist distgrid;
clear date_seawifs;
clear justChl;

save seawifs_chl -v6

clear clat clon distgrid_seawifs seawifs_chl_ts;

% save seawifs date and chl data to dataFiles folder
save 'C:\Documents and Settings\Lisa Taylor\My Documents\Data\APEX\0015\dataFiles\seawifsChl.mat'

