% gets modis data

% loads:
  % chlor_a_modis_2004_2007_complete, downloaded 01-11-08 by Peter Brickley, containing: 
    % chlor_a (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 (2464x1): modis dates (IDL julian format) from 06/12/04 to 05/02/07
  % dist.mat, containing:
    % dist (1x2601)
    % distgrid (2641x2601): distance of each pixel in 51x51 grid around
      % Float 0005 (located at 26,26)

% saves modis_chl.mat containing:
  % modisChl [date, chl] (2464x2602)
  % modis_chl_ts (2464x2601) just chlorophyll
  % distgrid (2464x2601)
% saves modisChl.mat to dataFiles containing:
  % modisChl [date, chl] (2464x2602)

% written by E. Boss, UMaine, 2006
% email: emmanuel.boss@maine.edu
  
close all
clear all

% load modis chl data
load data/chlor_a_modis_2004_2007_complete

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

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

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

load dist

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

save modis_chl -v6
