function [times, pass_times, url] = nsc30cat(catalog_server, time, ranges)
%----------------------------------------------------------------------------
%
% Consult the nscat30 catalog server to find images that fall within the time
% range given by the user.
%
% Formal parameters:
% catalog_server: URL of the catalog server.
% time: The time range of the data set.
%
% The return values are:
% times: The time in years (and fractions, see note below) for all hits.
% pass_times: This is a matrix of time with the year and day
% url: dummy return value to satisfy cat function type signature.
%
% $Id: nsc30cat.m,v 1.1 1999/05/13 02:55:20 dbyrne Exp $
%
%----------------------------------------------------------------------------

% $Log: nsc30cat.m,v $
% Revision 1.1  1999/05/13 02:55:20  dbyrne
%
%
% New palettes, dataset files with shortened names, and a few new scripts for
% release 3.0.0. -- dbyrne 99/05/12
%
% Revision 1.1  1999/05/13 01:22:22  root
% These are all files that had names shortened from something longer.
%
% Revision 1.7  1999/03/04 13:13:31  root
% All changes since AGU week.
%
% Revision 1.10  1998/11/30 00:49:09  dbyrne
%
%
% Fixed bug in unpack that deleted all returning names for datasets with
% no empty strings in the required fields.  Fixed vectorization of day2year
% and add workaround for a FLOP bug I found on ix86 machines.  Fixed calendar
% day to yearday conversion error in nscat30cat.m.  Added workaround for writeval
% bug in nscat30.m (2 server lines force 2 loaddods calls).  Fixed a bunch
% of bugs in new SSM/I code submitted by Rob Morris, JPL.  Added SSM/I, CZCS,
% Levitus (1982), World Ocean Atlas monthly, seasonal, and annual datasets and
% Mauna Loa CO2 record.  Fixed a logic error in urieccat.m. -- dbyrne, 98/11/29
%
% Revision 1.5  1998/10/23 15:26:07  root
% updating NSCAT 3.0
%
% Revision 1.4  1998/10/22 18:30:29  root
% updating.
%
% Revision 1.3  1998/09/13 15:41:00  root
% meshed James' changes.
%
% Revision 1.5  1998/09/13 02:29:01  dbyrne
% Modified so it loads nscat30_cat.mat, not nscat30_cat3.mat
%
% Revision 1.4  1998/07/13 20:29:30  jimg
% Fixes from the final test of the new build process
%
% Revision 1.3  1998/05/14 21:59:35  dbyrne
% Many small fixes.  DAB 98/05/14
% $Log: nsc30cat.m,v $
% Revision 1.1  1999/05/13 02:55:20  dbyrne
%
%
% New palettes, dataset files with shortened names, and a few new scripts for
% release 3.0.0. -- dbyrne 99/05/12
%
% Revision 1.1  1999/05/13 01:22:22  root
% These are all files that had names shortened from something longer.
%
% Revision 1.7  1999/03/04 13:13:31  root
% All changes since AGU week.
%
% Revision 1.10  1998/11/30 00:49:09  dbyrne
%
%
% Fixed bug in unpack that deleted all returning names for datasets with
% no empty strings in the required fields.  Fixed vectorization of day2year
% and add workaround for a FLOP bug I found on ix86 machines.  Fixed calendar
% day to yearday conversion error in nscat30cat.m.  Added workaround for writeval
% bug in nscat30.m (2 server lines force 2 loaddods calls).  Fixed a bunch
% of bugs in new SSM/I code submitted by Rob Morris, JPL.  Added SSM/I, CZCS,
% Levitus (1982), World Ocean Atlas monthly, seasonal, and annual datasets and
% Mauna Loa CO2 record.  Fixed a logic error in urieccat.m. -- dbyrne, 98/11/29
%
% Revision 1.5  1998/10/23 15:26:07  root
% updating NSCAT 3.0
%
% Revision 1.4  1998/10/22 18:30:29  root
% updating.
%
% Revision 1.3  1998/09/13 15:41:00  root
% meshed James' changes.
%
% Revision 1.2  1998/09/09 15:04:30  dbyrne
% Eliminating all global variables.
%
% Revision 1.1  1998/05/17 14:18:08  dbyrne
% *** empty log message ***
%
% Revision 1.1  1997/12/11 06:20:45  jimg
% Switched to full archive of data. Added catalog server.
%

% N.B. ranges are space and time constraint info.
load nscat30_cat.mat
% must substract 1 from day to go from CALENDAR DAY (where Jan 1 is
% Day 1) to DECIMAL DAY (where Jan 1 is day 0.)  We want middle of the
% day, to we add 0.5 day back in.  Result: subtract 0.5 from the day.
times_cat = day2year(pass_times_cat(:,2)-0.5,pass_times_cat(:,1));

pass_times = [];
times = [];
% dummy initialization to match other Cat_m_Files
% url = [];
% URL is a STRING!
url = '';
% Get beginning and ending of time interval.

start_time = max(time(1), ranges(4,1));
end_time = min(time(2), ranges(4,2));

start_year = floor(start_time);
start_day = year2day(start_time, start_year);

end_year = floor(end_time);
end_day = year2day(end_time, end_year);

ncat = size(times_cat,2);
i = find(times_cat > start_time & times_cat < end_time);
times = times_cat(i);
pass_times = pass_times_cat(i,:);

return;
