function [times, pass_times, urllist, url] = dycat(CS, time, ranges)
%----------------------------------------------------------------------------
%
% This function generates a time and file name for URI AVHRR images
%
% 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 decimal years (years and fractions) for all hits.
% pass_times: This is a matrix of time with the year, day and hour
% of each hit. Note that the day here is the calendar day.
%
%----------------------------------------------------------------------------

%
% $Log: dycat.m,v $
% Revision 1.1  2000/03/09 17:36:48  kwoklin
% Share one cat_m_file dycat.m.   klee
%

% $Id: dycat.m,v 1.1 2000/03/09 17:36:48 kwoklin Exp $
% Replacing URI Avhrr catalog files.   klee 03/01/2000 

pass_times = []; url=[]; urllist = []; times = []; prefix = [];

if findstr(CS, 'htn.dat'), prefix = 'HTN_Avhrr';
elseif findstr(CS, 'glk.dat'), prefix = 'GLK_Avhrr';
elseif findstr(CS, 'fth.dat'), prefix = 'FTH_Avhrr';
elseif findstr(CS, 'avhrr.dat'), prefix = 'URI_Avhrr';
end

% Get beginning and ending of time interval.
StartTime = max(time(1), ranges(4,1));
LastTime = min(time(2), ranges(4,2));

Constraint = ['DODS_URL,DODS_Decimal_Year(',prefix,')&decimal_year("',num2str(StartTime,9),'","',num2str(LastTime,9),'")'];
URL = [CS,'?',Constraint];
url = URL;
loaddods(url);

%deref string vector DODS_URL
urla = eval('DODS_URL');
urllist = derefurl(urla);

%deref string vector DODS_Decimal_Year
times = derefdat(DODS_Decimal_Year);
pass_times = [pass_times; times];

return;
