function m_cruis2(file, year_base, varargin)
%--------------------------------------------------------------------------
% 
% m_cruis2.m -- Plot Cruise track in an M_MAP projection
% 
% Author          : Jaccard Pierre
% Created On      : 2000/08/17 13:16:37
% Last Modified By: Jaccard Pierre
% Last Modified On: 2001/10/31 14:58:23
% Directory       : /home5/jaccard/pcd/codas/2000-11-21/codas3/gfi/matlab/matlab50/
% ----------------------------------------------------------------------- +
% VERSION CONTROL: 
% 
%   $Author$
%   $Date$
%   $Id$
%   $Name$
%   $Revision$
%   $State$
%   $Log$
% 
% --------------------------------------------------------------------------
%
% SYNOPSIS
%
%   m_cruis2( nav_file, year_base, [ options ] )
%
% DESCRIPTION
%
%   Plot the cruise track on an M_MAP generated projection. Output is saved 
%   into file "m_cruis.ps". Unless a MAP_SCRIPT is specified to generate
%   the map, the GSHHS data are used. Coast resolution for these data can
%   be specified as an option.
%
% PARAMETERS
%
%   nav_file   - Name of file containing time and navigation data
%   year_base  - Year base to use for time conversions
%
% OPTIONS
%
%   'longitude_180', N
%      If N is non-zero, use longitude values between -180 and +180.
%
%   'plot_stuf', { ... }
%      List of parameters to send to plotstuf() for additional information
%      to be printed on the plot.
%
%   'map_script', 'script_name'
%      Specify a MATLAB script for generating the projection, drawing the
%      coast and bathymetry. 
%
%   'coast_res', R
%      Use coastal resolution R for GSHHS data. 
%
%   'line_style', { ... }
%      Object properties to be sent to the plot functions. 
%
%--------------------------------------------------------------------------


%--- Arguments

[ draw_topo, longitude_180, plot_stuf, map_script, coast_res, line_style ] = ...
		parsearg( varargin, ...
		'draw_topo', 1, ...					
		'longitude_180', 0, ...
		'plot_stuf', { '-title' , 'Cruise Track' }, ...
		'map_script', '', ...
		'coast_res', 'i', ...
		'line_style', { 'LineStyle', 'none', 'Marker', '.', 'MarkerSize', 5 });

%--- Read data:

d = read_asc(file);
d = d';
it = 1; ilon = 2; ilat = 3;

if longitude_180,
	ii = find(d(ilon,:) >= 180.0);
	if ~isempty(ii),
		d(ilon,ii) = d(ilon,ii) - 360.0;
	end
end

%--- Get ranges:

lon_range = [ min(d(ilon,:)), max(d(ilon,:)) ];
lat_range = [ min(d(ilat,:)), max(d(ilat,:)) ];
lon_delta = 0.05 * (lon_range(2) - lon_range(1));
lat_delta = 0.05 * (lat_range(2) - lat_range(1));

%--- Initialize figure:

figure;
orient tall;

%--- Plot track:

subplot('position', [ 0.1, 0.5, 0.8, 0.4 ]);

if(length(map_script)),
	feval(map_script, 'topo', draw_topo);
else
	m_proj('mercator', ...
			'lon', [ lon_range(1) - lon_delta, lon_range(2) + lon_delta ], ...
			'lat', [ lat_range(1) - lat_delta, lat_range(2) + lat_delta ]);
	eval([ 'm_gshhs_' coast_res '(\'patch\', [ .7 .7 .7 ]);' ]);
end
m_grid;
m_line(d(ilon,:), d(ilat,:), line_style{:});

%--- Plot LON and LAT:

subplot('position', [ 0.1, 0.3, 0.8, 0.15 ]);
plot(d(it,:), d(ilon,:));
grid on;
ylabel('Longitude');

subplot('position', [ 0.1, 0.1, 0.8, 0.15 ]);
plot(d(it,:), d(ilat,:));
grid on;
ylabel('Latitude');
xlabel([ int2str(year_base) ' decimal days (' ...
			to_date(year_base, min(d(it,:))) ' to ' ...
			to_date(year_base, max(d(it,:))) ')' ]);

%--- Plot the rest and save file:
plotstuf(plot_stuf{:});

print -dps m_cruise.ps;

return;








