Home > cbassSouthFunctions > CJCThesisFunctions > extract_obslogSa.m

extract_obslogSa

PURPOSE ^

Script to extract data from the obs_log.html script

SYNOPSIS ^

function out=extract_obslog(file,string,varargin)

DESCRIPTION ^

Script to extract data from the obs_log.html script
out = extract_obslog(file,string,varargin)
Inputs- 
file:Obs log file
string:String that will be searched for
Varargin: Optional input arguments to define a start and stop time in
the obs_log string date format e.g 12-May-2010:18:23:53
15 June 2010 CJC

Example Usage :
t=extract_obslog('obs_log.html','cbass_survey_test2.sch') 

returns an cell structure with all the strings containing the string
cbass_survey_test2.sch and the text is split appropriately

t=extract_obslog('obs_log.html','cbass_survey_test2.sch','12-May-2010:18:23:53','15-Jun-2010:18:23:53')
Same as above but with the time interval defined

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function out=extract_obslog(file,string,varargin)
0002 %Script to extract data from the obs_log.html script
0003 %out = extract_obslog(file,string,varargin)
0004 %Inputs-
0005 %file:Obs log file
0006 %string:String that will be searched for
0007 %Varargin: Optional input arguments to define a start and stop time in
0008 %the obs_log string date format e.g 12-May-2010:18:23:53
0009 %15 June 2010 CJC
0010 %
0011 %Example Usage :
0012 %t=extract_obslog('obs_log.html','cbass_survey_test2.sch')
0013 %
0014 %returns an cell structure with all the strings containing the string
0015 %cbass_survey_test2.sch and the text is split appropriately
0016 %
0017 %t=extract_obslog('obs_log.html','cbass_survey_test2.sch','12-May-2010:18:23:53','15-Jun-2010:18:23:53')
0018 %Same as above but with the time interval defined
0019 
0020 out=[];
0021 fprintf('Number of inputs = %d\n', nargin)
0022 %Check the number of arguments
0023 if nargin ==2
0024     disp('Using the entire file-no time interval')
0025 else if nargin ==4
0026      disp('Using the time interval')
0027      disp(varargin(1))
0028      disp('TO')
0029      disp(varargin(2))
0030     else
0031     error('Not correct number of arguments: Either call this function with 2 arguments or with 4 arguments- \n See help extract_obslog for details')    
0032     end
0033 end
0034 
0035 if(nargin==4)
0036     time_start=datevec(varargin(1),'dd-mmm-yyyy:HH:MM:SS');
0037     time_end=datevec(varargin(2),'dd-mmm-yyyy:HH:MM:SS');
0038     tstart_num=datenum(time_start);
0039     tend_num=datenum(time_end);
0040 end
0041 fid = fopen(file,'r');
0042 i=0;
0043 while 1
0044             tline = fgetl(fid);
0045             if ~ischar(tline), break, end
0046             
0047             try
0048                % [A,COUNT,ERRMSG,NEXTINDEX] = sscanf(tline,'%c');
0049                 pat = '\s\s\s';
0050                 tline;
0051                 string;
0052                 t=regexp(tline, pat,'split');
0053                 i;
0054                 t=regexp(tline, pat,'split');
0055            
0056              
0057                 a=strfind(tline,string);
0058                 
0059 
0060                 if a~[];
0061 
0062                   
0063                    
0064 
0065                     %get the times correct
0066                     if nargin ==4 %We need to look in a time interval so need to check the times
0067                         time_startfile=datevec(t{1},'dd-mmm-yyyy:HH:MM:SS');
0068                         
0069                         tstart_filenum=datenum(time_startfile);
0070                         try
0071                             time_endfile=datevec(t{2},'dd-mmm-yyyy:HH:MM:SS');
0072                             tend_filenum=datenum(time_endfile);
0073                         catch
0074                             display('No end data')
0075                         end
0076                         %%
0077                         %if the scan ended before the end of interval
0078                         if (tstart_filenum>tstart_num)
0079                             i=i+1;
0080                             out{i,1}=t{1};
0081                             out{i,2}=t{2};
0082                             out{i,3}=t{3};
0083                         end
0084                     else if nargin==2 %just use the whole obs_log file
0085 
0086                                                         i=i+1;
0087 
0088                             
0089                           
0090                         end
0091                     end
0092                 end
0093             catch
0094                 disp('Error');
0095             end
0096         end
0097 
0098 ST = fclose(fid);

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