% C:\Documents and Settings\Lisa Taylor\My Documents\Data\SeaWIFS
% gets seawifs data 5.1

% gets arrays:
  % from chlor_a_seawifs.mat:
  % clat (1x1859)
  % clong (1x1859)
  % data containing chl values for each 13x13 grid  [169x1859]
        % -1=cloud cover -999=missing data
  % dt_im containing seawifs dates (IDL julian format) from 06/11/04 to 05/05/07 [1x1859]
  % from dist_seawifs.mat:
    % dist (1x169)
    % distgrid (1859x169): distance of each pixel in 13x13 grid around
      % Float 0005 (located at 7,7)
% saves seawifs_chl.mat containing:
  % seawifsChl [date, chl] (1859x170)
  % seawifs_chl_ts (1859169) just chlorophyll
  % distgrid_seawifs (1859x2601)
  % clat (1x1859)
  % clon (1x1859)
  
close all
clear all

load data/chlor_a

% fix the time stamp to Matlab's
t_offset=1721059;
date_seawifs=dt_im-t_offset; % record 1,1 should be 12-Jun-2004 14:45:00

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 chl grid with NaNs
data(data==-999)=NaN; % replace -999s (missing data) in 51x51 chl grid with NaNs
justChl=data'; % now 1276x169

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

load dist_seawifs % (1859x169)
distgrid_seawifs=distgrid;

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

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\dataFiles\seawifsChl.mat'

