Home > reduc > test_pipe.m

test_pipe

PURPOSE ^

SYNOPSIS ^

function test_pipe(outputdir,start_date,end_date)

DESCRIPTION ^

 Function to read in data and test pipeline, and count output files produced
 Runs as test_pipe() by default.

 outputdir (optional) - specfiy your own dir for the pipelines generated files
                      - defaults to test_DATE_TIME_err.txt (DATE TIME from when code was run). 


 start_date (optional), end_date (optional) - choose start and end to test. Defaults to def_start
                                            -- and def_end otherwise

 JL 14/8/2012

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function test_pipe(outputdir,start_date,end_date)
0002   %
0003   % Function to read in data and test pipeline, and count output files produced
0004   % Runs as test_pipe() by default.
0005   %
0006   % outputdir (optional) - specfiy your own dir for the pipelines generated files
0007   %                      - defaults to test_DATE_TIME_err.txt (DATE TIME from when code was run).
0008   %
0009   %
0010   % start_date (optional), end_date (optional) - choose start and end to test. Defaults to def_start
0011   %                                            -- and def_end otherwise
0012   %
0013   % JL 14/8/2012
0014 
0015   % Default data period:
0016   def_start = '11-Nov-2011:00:01:47';
0017   def_end = '11-Nov-2011:01:41:32';
0018 
0019   path_to_redscript='reduc/redScript.red';
0020   errcount =0;
0021 
0022   % generate a timestamp
0023   TempTime=clock;
0024   ts = [num2str(TempTime(1),'%02.0f') num2str(TempTime(2),'%02.0f') num2str(TempTime(3),'%02.0f') '_' num2str(TempTime(4),'%02.0f') num2str(TempTime(5),'%02.0f') num2str(TempTime(6),'%02.0f')];
0025 
0026   if(~exist('outputdir'))
0027     outputdir = ['test_',ts];
0028   end 
0029 
0030   if(exist('start_date','var'))
0031     def_start=start_date;
0032   end
0033 
0034   if(exist('end_date','var'))
0035     def_end=end_date;
0036   end
0037   
0038   [home,installeddir]=where_am_i();
0039   location = [home,'/',installeddir];
0040 
0041   % Setup and open logfile
0042   logfile = ['test_',ts,'_errs.txt'];  
0043   logfilepath = [location,'/',logfile];
0044   disp(['test_pipe:: Writing errors to ',logfilepath]);
0045   logfile = fopen(logfilepath,'w');
0046 
0047  try
0048     disp(['test_pipe:: READING Obs ', def_start,' ---- ',def_end]);
0049 
0050     fprintf(logfile,'%s\n',['test_pipe:: READING Obs ', def_start,' ---- ',def_end]);
0051     d=read_arc(def_start,def_end);
0052 
0053  catch exception
0054         error_string= ['test_pipe:: FAILED TO READ ',def_start,' ---- ',def_end];
0055     disp(error_string);
0056     rep = getReport(exception, 'basic');
0057     fprintf(logfile,'%s\n',error_string);
0058     fprintf(logfile,'%s\n',rep);
0059         disp(rep);
0060         errcount = errcount + 1;               
0061 end; %endtry
0062 
0063 try
0064     disp(['test_pipe:: REDUCING Obs ',def_start,' ---- ',def_end]);
0065         fprintf(logfile,'%s\n',['test_pipe: REDUCING Obs ',def_start,' ---- ',def_end]); 
0066     dcal = reduceData(d, path_to_redscript, 0, outputdir);
0067 
0068  catch exception
0069         error_string = ['test_pipe:: FAILED TO REDUCE ',def_start,' ---- ',def_end];
0070     disp(error_string);
0071     rep = getReport(exception, 'basic');
0072     fprintf(logfile,'%s\n',error_string);
0073     fprintf(logfile,'%s\n',rep);
0074         disp(rep);
0075         errcount = errcount +1;
0076  end;  %endtry
0077 
0078 disp_string = ['test_pipe:: Control returned to test_pipe routine. Now checking for expected files and dirs...'];
0079 disp(disp_string);
0080 fprintf(logfile,'%s\n',disp_string);
0081 
0082 % Output File existence checks
0083 if (exist(['reduc/',outputdir],'file'))
0084  disp_string = ['test_pipe:: PASS: Output directory ',outputdir,' successfully created.'];
0085  disp(disp_string);
0086  fprintf(logfile,'%s\n',disp_string);
0087 
0088  %%%%%%%%%
0089  % Now get name of the subdir
0090  [status, subdir] = unix(['ls ','reduc/',outputdir]);
0091  subdir = regexprep(subdir,'\r\n|\n|\r',''); % strip carriage return from subdir
0092  disp_string = ['test_pipe:: INFO: Sub directory ',subdir,' successfully created.'];
0093  disp(disp_string);
0094  fprintf(logfile,'%s\n',disp_string);
0095 
0096  disp('----------------------------------------------------------------');
0097  disp('test_pipe:: INFO: Checking sub dirs for fits files...');
0098  test_dir_read(outputdir,'fits',logfile);
0099  disp('----------------------------------------------------------------');
0100  disp('test_pipe:: INFO: Checking sub dirs for png files...');
0101  test_dir_read(outputdir,'png',logfile);
0102  disp('----------------------------------------------------------------');
0103  disp('test_pipe:: INFO: Checking sub dirs for html files...');
0104  test_dir_read(outputdir,'html',logfile);
0105 
0106 
0107 else 
0108 
0109  disp_string = ['test_pipe:: FAIL: Output directory ',outputdir,' not created.'];
0110  disp(disp_string);
0111  fprintf(logfile,'%s\n',disp_string);
0112  errcount = errcount+1;
0113 
0114 end;
0115 
0116 if (errcount==0)
0117   disp_string = 'test_pipe:: SUCCESS:  No gross errors caught during pipeline test.';
0118   disp(disp_string);
0119   fprintf(logfile,'%s\n',disp_string);
0120  else
0121   disp_string = ['test_pipe:; FAIL:  Caught ',errcount,' errors during pipeline test. Fix these before commiting code.'];
0122   disp(disp_string);
0123   fprintf(logfile,'%s\n',disp_string);
0124 end
0125 
0126 disp(['test_pipe:: INFO: See ',logfilepath,' for full error report.']);
0127 
0128 fclose(logfile);
0129 
0130 
0131 
0132 
0133 
0134 
0135

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