Home > webpage_logging > webpipeline.m

webpipeline

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function d = webpipeline(startdate,enddate,root_name)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  Contains commands for runing a basic analysis of pipelined data ready for
  web page viewing:

  Basic steps:
    Main removal
    Deglitch
    Alpha correction
    R-factor correction
    Plot spectrogram
    Plot data via plot_sources
    Write out to Fits file

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 Turn the logging function on

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function d = webpipeline(startdate,enddate,root_name)
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 %  Contains commands for runing a basic analysis of pipelined data ready for
0005 %  web page viewing:
0006 %
0007 %  Basic steps:
0008 %    Main removal
0009 %    Deglitch
0010 %    Alpha correction
0011 %    R-factor correction
0012 %    Plot spectrogram
0013 %    Plot data via plot_sources
0014 %    Write out to Fits file
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 % Turn the logging function on
0018 
0019     diary([root_name,'.log'])
0020     
0021     disp('Starting the data reduction')    
0022 
0023 % JL -- do the piperead
0024   disp('Performing pipe read')
0025   d = pipe_read(startdate,enddate);
0026 
0027     
0028 % First remove the 40Hz aliased harmonics of the mains since these
0029 % are the most obvious and easiest to remove
0030     
0031     disp('Removing 40Hz mains harmonic')
0032     
0033     try
0034     d = mainsWrapper(d,0,0,3);
0035     catch
0036         disp('Failed to remove mains')
0037     end
0038     
0039 % Do a first cut deglitch at 5 sigma above mean of smoothed datastream
0040     disp('Doing a 5-sigma cut on mean of smoothed raw data channels')
0041     try
0042     sigma = 5;
0043     d = first_cut(d,sigma);
0044     catch
0045         disp('Failed to do a first deglitch')
0046     end
0047      
0048 % Applies alpha and r-factor correction
0049 
0050 % 1. Calculate the alpha corrections
0051     disp('Applying the alpha and r-factor corrections')
0052     
0053     try
0054     [t,A,G,T,horiz,equa, offStartPos, onEndPos, offEndPos, onStartPos] = calculateAlpha(d);
0055     catch
0056         disp('(Failed to calculate Alphas')
0057     end
0058     
0059 % 2. Applies the alpha corrections to the data and overwrites the switchData register
0060     try
0061     d = applyAlpha2(d,t,A,G);
0062     catch
0063         disp('Failed to apply the alpha corrections')
0064     end
0065     
0066 % 3. Some pre-processing before before r-factor correction:
0067     try
0068     thisAlpha = [t A G T horiz equa];
0069     d.correction.alpha.indices = [offStartPos' onEndPos' offEndPos' onStartPos'];
0070     d.correction.alpha.values = thisAlpha;
0071     catch
0072         disp('Failed to pre-process data ready for r-factors')
0073     end
0074     
0075 % 4. Calculate the r-factor during the noise diode off events (this is why the above steps need to have been done)
0076     try
0077     r = calculateRfactor(d);
0078     meanr = mean(r)
0079     catch
0080         disp('Failted to calculate r-factors')
0081     end
0082         
0083 % 5. Apply the r-factor, by subtracting a smoothed load signal (scaled by the r factor) from the sky signal.
0084 %    smoothLength is the length of the smoothing window function in seconds. This overwrites the data register.
0085     try
0086     smoothLength = 1
0087     rval =  [1.9,1.8,1.8,1.7];
0088     d = calculateStokes2_samer(d,r,smoothLength,rval);
0089     catch
0090         disp('Failed to apply r-factors')
0091     end
0092 
0093 % Now lets plot the spectrograms of this data to file
0094     
0095     disp('Making spectrograms of data')
0096    
0097     try
0098     makeWebpageSpectrogram(d,0,[root_name,'_spectrogram'])
0099     catch
0100         disp('Failed to plot Spectrogram')
0101     end
0102 
0103 % Now lets plot the spectra of this data to file
0104     
0105     disp('Making spectra of data')
0106    
0107     try
0108     makeWebpageSpectra(d,'noise_stats.txt','scan_stats.txt',[root_name,'_spectra'])
0109     catch
0110         disp('Failed to plot Spectra')
0111     end
0112 
0113 
0114 
0115 % Now let's plot the sources - save the source list in 'sources'
0116 % Doesn't plot to screen but instead to a file (switch = 1)
0117     
0118     disp('Plotting source data to file');
0119     
0120     try
0121     d = applyFlags(d)
0122     [sources] = plot_sourcesAll(d,1,root_name);
0123     catch
0124         disp('Failed to plot source data')
0125     end
0126         
0127 % Now let's write to Fits files ready for mapping
0128     
0129     disp('Writing to a fits file');
0130     
0131     try
0132         flags = d.flags.fast(:,1);
0133     startTimeMJD = d.antenna0.receiver.utc(1);
0134     endTimeMJD = d.antenna0.receiver.utc(length(d.antenna0.receiver.utc));
0135     writeFitsMap([root_name,'.fits'],d,startTimeMJD,endTimeMJD,1,1,flags);
0136     catch
0137      disp('Failed to write to fits')
0138     end
0139  
0140  diary('off')
0141     
0142 return

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