% C:\Documents and Settings\Lisa Taylor\My Documents\Data\MODIS
% gets MODIS data that have been ringed

% gets arrays:
  % from chlor_a_modis_dilate_2004_2007.mat
    % chlor_a1 (2601x2641) modis chl values (rows 1 through 2403) for each 51x51 grid
        % (2601 columns) around Float 0005 for a given datetime (next row is next
        % 51x51 grid for next datetime) -1=cloud cover -999=missing data
    % dt_modis (2641x1): modis dates (IDL julian format) from 06/12/04 to 05/02/07
  % from dist.mat:
    % dist (1x2601)
    % distgrid (2641x2601): distance of each pixel in 51x51 grid around
      % Float 0005 (located at 26,26)
% saves modis_chl_dilate.mat containing:
  % modisChl [date, chl] (2464x2602)
  % modis_chl_ts (2641x2601) just chlorophyll
  % distgrid (2641x2601)
  
close all
clear all

load 'C:\Documents and Settings\Lisa Taylor\My Documents\Data\0005\MODIS\data\original downloads\08-23-07\chlor_a_modis_dilate_2004_2007.mat'

% fix the time stamp to Matlab's
% t_offset=dt_modis(1)-datenum(2004,6,12,14,45,0);
t_offset=1721058.5;
date_modis=dt_modis-t_offset; % record 1,1 should be 12-Jun-2004 14:45:00

date_modis(date_modis==0)=NaN; % replace 0s with NaNs

chlor_a1(chlor_a1==-1)=NaN; % replace -1s (cloud cover) in 51x51chl grid with NaNs
chlor_a1(chlor_a1==-999)=NaN; % replace -999s (missing data) in 51x51 chl grid with NaNs
justChl=chlor_a1'; % now 2464x2601
modisChl=[date_modis,justChl]; % array of both date (col 1) and chl (remaining 2601 cols) 2464x2602
modis_chl_ts=chlor_a1'; % now 2464x2601

load dist

% clear unecessary variables from workspace
clear date_modis dt_modis dist justChl chlor_a1 t_offset;

save modis_chl_dilate -v6

