% loadssp
%
% useage: loadssp
% mbp 3 March 2001

clear all

A = load( 'meanjan15.txt' );

x = A( :, 1 );  % latitude
y = A( :, 2 );  % longitude
z = A( :, 3 );  % depth
c = A( :, 4 );  % sound speed

imagesc( c ); colorbar

xi = linspace( 30, 35, 20 );
yi = linspace( -124, -118, 20 );
zi = linspace( 0, 500, 21 );

[ X, Y, Z ] = meshgrid( xi, yi, zi );
w = griddata3( x, y, z, c, X, Y, Z );

for islice = 1:size( w, 3 )
  pcolor( squeeze( w( :, :, islice ) ) ); shading interp; caxis( [1530 1540 ] ); colorbar
  xlabel( 'Latitude (degrees)' )
  ylabel( 'Longitude (degrees)' )
  pause( 1 ); drawnow
end


slice( X, Y, -Z, w, min( x ), min( y ), -zi( 1 : 5 : end ) )
xlabel( 'Latitude (degrees)' )
ylabel( 'Longitude (degrees)' )
zlabel( 'Depth (m)' )
colorbar

% extract a single profile

ssp = squeeze( w( 10, 10, : ) );
zz  = squeeze( Z( 10, 10, : ) );

figure
hh = plot( ssp, zz )
view( 0, -90 );    
xlabel( 'Sound Speed (m/s)' )
ylabel( 'Depth (m)' )

foo = set( hh, 'LineWidth', 3 );

B = [ zz ssp ];

%save -ascii ssp.env B

