Home > rfi_tuning > param_rfi.m

param_rfi

PURPOSE ^

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

SYNOPSIS ^

function [pArray_f pArray_p] = param_rfi(basedir)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  function r = param_rfi()

   13-Jan-2012 (MAS): Created.
   17-Jan-2012 (MAS): Massively modified to handle version 2 tuning.
   25-Jan-2012 (MAS): Modified to work in the automated tuning method.

   Choose parameters based upon false positive threshholds.

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [pArray_f pArray_p] = param_rfi(basedir)
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %  function r = param_rfi()
0005 %
0006 %   13-Jan-2012 (MAS): Created.
0007 %   17-Jan-2012 (MAS): Massively modified to handle version 2 tuning.
0008 %   25-Jan-2012 (MAS): Modified to work in the automated tuning method.
0009 %
0010 %   Choose parameters based upon false positive threshholds.
0011 %
0012 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0013 
0014 
0015 % These are the false positive threshholds that will be used...
0016 %false_pos_lims = [1e-3 2.6e-4 6.4e-5 1.6e-5 4e-6 1e-6];
0017 false_pos_lims = [1e-4 3.2e-5 1e-5 3.2e-6 1e-6];
0018 nLims = length(false_pos_lims);
0019 
0020 
0021 
0022 for l=1:2
0023     
0024     % Read in the folded histograms...
0025     switch l
0026         case 1
0027             foldFile = open([basedir 'fold_flag_results_filtered.mat']);
0028         case 2
0029             foldFile = open([basedir 'fold_flag_results_polonly.mat']);
0030     end
0031     
0032     s_A = foldFile.s_A;
0033     s_B = foldFile.s_B;
0034     l_A = foldFile.l_A;
0035     l_B = foldFile.l_B;
0036 
0037     %dataUtc = tuneFile.dataUtc;
0038 
0039     falseNum = foldFile.falseNum;
0040 
0041 
0042 
0043     % Initialize the parameter array.
0044     pArray = zeros(9,nLims);
0045 
0046 
0047 
0048     % Begin the tuning...
0049     disp('Beginning the parameter determination...');
0050 
0051 
0052     % We loop over the threshhold values:
0053     for k=1:nLims
0054 
0055         % How many false positives are allowed?
0056         numFP = falseNum * false_pos_lims(k);
0057 
0058 
0059 
0060         % Look at the four cuts, choosing parameter values within the acceptable
0061         % false positive range.
0062 
0063 
0064         % First comparison:
0065         if sum(s_A(1,:) <= numFP) > 0
0066 
0067             sizeSA = size(s_A);
0068             [M, I] = max(s_A(2,:) .* (s_A(1,:) <= numFP));
0069 
0070             if M > 0
0071                 p1 = mod(I,sizeSA(2));
0072                 I = (I - p1) / sizeSA(2) + 1;
0073                 p2 = mod(I,sizeSA(3));
0074                 I = (I - p2) / sizeSA(3) + 1;
0075                 p3 = mod(I,sizeSA(4));
0076             else
0077                 p1 = 0;
0078                 p2 = 0;
0079                 p3 = 0;        
0080             end
0081         else
0082             p1 = -10;
0083             p2 = -10;
0084             p3 = -10;
0085         end
0086 
0087 
0088         % Second comparison:
0089         if sum(s_B(1,:) <= numFP) > 0
0090 
0091             [M, I] = max(s_B(2,:) .* (s_B(1,:) <= numFP));
0092 
0093             if M > 0
0094                 p4 = I;
0095             else
0096                 p4 = 0;
0097             end
0098         else
0099             p4 = -10;
0100         end
0101 
0102 
0103         % Third comparison:
0104         if sum(l_A(1,:) <= numFP) > 0
0105             sizeLA = size(l_A);
0106             [M, I] = max(l_A(2,:) .* (l_A(1,:) <= numFP));
0107 
0108             if M > 0
0109                 p5 = mod(I,sizeLA(2));
0110                 I = (I - p5) / sizeLA(2) + 1;
0111                 p6 = mod(I,sizeLA(3));
0112                 I = (I - p6) / sizeLA(3) + 1;
0113                 p7 = mod(I,sizeLA(4));
0114             else
0115                 p5 = 0;
0116                 p6 = 0;
0117                 p7 = 0;
0118             end
0119         else
0120             p5 = -10;
0121             p6 = -10;
0122             p7 = -10;
0123         end
0124 
0125 
0126         % Fourth comparison:
0127         if sum(l_B(1,:) <= numFP) > 0
0128             sizeLB = size(l_B);
0129             [M, I] = max(l_B(2,:) .* (l_B(1,:) <= numFP));
0130 
0131             if M > 0
0132                 p8 = mod(I,sizeLB(2));
0133                 I = (I - p8) / sizeLB(2) + 1;
0134                 p9 = mod(I,sizeLB(3));
0135             else
0136                 p8 = 0;
0137                 p9 = 0;
0138             end
0139         else
0140             p8 = -10;
0141             p9 = -10;
0142         end
0143 
0144         % Get the recommended RFI flagging values:
0145         pArray(:,k) = 0.1 * [p1 p2 p3 p4 p5 p6 p7 p8 p9];
0146 
0147 
0148     end
0149 
0150 
0151     switch l
0152         case 1
0153             pArray_f = pArray;
0154         case 2
0155             pArray_p = pArray;
0156     end
0157     
0158 end
0159 
0160 % Write the parameter array to a file.
0161 disp('Parameter determination complete.  Writing out...');
0162 outfile = [basedir 'params.mat'];
0163 save(outfile, 'pArray_f', 'pArray_p');
0164 
0165 
0166 end

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