Home > reduc > get_days_obs.m

get_days_obs

PURPOSE ^

SYNOPSIS ^

function [start_dates,end_dates,schedule,source_name] =get_days_obs(file,date)

DESCRIPTION ^

 Usage [start_dates,end_dates,schedule] =get_days_obs('log/obs_log.html','02-Nov-2010')

 Returns an array of start_dates and end_dates which match string 'date'

 Also returns an array of schedule strings (not used much at the moment).

 JL

 MAS (24-May-2012):  Modified to allow days in which no schedules were
 run.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [start_dates,end_dates,schedule,source_name] =get_days_obs(file,date)
0002 %
0003 % Usage [start_dates,end_dates,schedule] =get_days_obs('log/obs_log.html','02-Nov-2010')
0004 %
0005 % Returns an array of start_dates and end_dates which match string 'date'
0006 %
0007 % Also returns an array of schedule strings (not used much at the moment).
0008 %
0009 % JL
0010 %
0011 % MAS (24-May-2012):  Modified to allow days in which no schedules were
0012 % run.
0013 
0014 
0015 %pwd
0016 %disp(['get_days_obs:: Opening file: ',file]);
0017 
0018 fid = fopen(file,'r');
0019 
0020 if fid < 0
0021     disp(['get_days_obs:: File failed to open: ',file]);
0022 end
0023 
0024 
0025 start_dates = {};
0026 end_dates = {};
0027 schedule = {};
0028 i=0;
0029 while 1
0030     
0031     tline = fgetl(fid);
0032     if(~ischar(tline))
0033         disp(['get_days_obs:: Closing file']);
0034         ST = fclose(fid);
0035         break;
0036     end;
0037     
0038     % Modified to ensure that the date appears in the START time.
0039     dloc = regexp(tline,date);
0040     if isempty(dloc)
0041         continue
0042     end
0043     
0044     % Well, is it?
0045     if (dloc(1) < 10)
0046         
0047         % if ( length(regexp(tline,date)) ~=0)
0048         i=i+1;
0049         % disp(tline);
0050         splitline = regexp(tline, '\s+', 'split');
0051         % If the second element contains a / it is a pathname rather than a time
0052         % i.e. no end time was written becuase the control system crashed.
0053         if (~isempty(strfind(char(splitline(2)), '/')) )
0054             start_dates(i) =  {'Error'};
0055             end_dates(i) =  {'Error'};
0056             schedule(i)  =  {'Error'};
0057             source_name(i)={'Error'};
0058         else
0059             start_dates(i) =  splitline(1);
0060             end_dates(i)  =  splitline(2);
0061             schedule(i)  =  splitline(3);
0062             % Grab source name if it is a raster or source scan
0063             if((strfind(char(schedule(i)),'source')))
0064                 source_name(i) = splitline(6);
0065             else
0066           source_name(i) = schedule(i);% Just use sched name
0067             end
0068             
0069         end
0070     end
0071     
0072 end
0073 
0074 end

Generated on Sun 14-Jun-2015 17:12:45 by m2html © 2005