%%% Matlab commands I used in class on Tuesday, 2 June. 
%%% Data is here: http://aviris.jpl.nasa.gov/data/free_data.html

%% Demo of AVIRIS Data Cube

%%% !display f960705t01p02_r02.ql.jpg
% Use your favorite picture processing software to display the visual
% image. 

% Next line is for my laptop.  You'll have to change it.
cd /home/cdimarzio/Documents/working/12026/hsidata/AVIRIS/f960705t01p02r02c

% Increase this as much as you like (or as much as you can, depending
on the memory you have available).  I think there are about 3 frames
of 512 lines each.  
linestoread=512;

%  read the image file.
fid=fopen('f960705t01p02_r02c_img');
data=fread(fid,224*614*linestoread,'137536*uint16');
cube=reshape(data,224,614,linestoread);
clear data;pack; % pack frees up some memory. 
cube=permute(cube,[2,3,1]);

% Get the wavelengths.  There's a lot more you can get here, but this
% is all I used.  See the readme file for more. 
specdata=load('f960705t01p02_r02.spc');
lambda=specdata(:,1);
figure;plot(1:length(lambda),lambda,'-o');grid on;


hsi4(cube,lambda,[0,2^16]);

figure;imagesc(squeeze(cube(:,:,10))');
axis image;colormap(gray);colorbar;title('Lambda(10)');

figure;imagesc(squeeze(sum(cube(:,:,5:41),3))');
axis image;colormap(gray);colorbar;title('Vis');

figure;imagesc(squeeze(sum(cube(:,:,1:224),3))');
axis image;colormap(gray);colorbar;title('All')

figure;imagesc(squeeze(sum(cube(:,:,56:224),3))');
axis image;colormap(gray);colorbar;title('IR');

% Google maps flight track is a straight line between these two
% locations, east of Muncie, Indiana which is in what we call the
% midwest in the US.  
% 40 12 30 n 85 08 54 w
% 40 18 30 n 85 08 54 w
