Home > RFI > characterizeRfi_I.m

characterizeRfi_I

PURPOSE ^

SYNOPSIS ^

function characterizeRfi_I(starttime, stoptime, savefilename)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function characterizeRfi_I(starttime, stoptime, savefilename)
0002 cbass_startup
0003 
0004 % This code bins the timestream and determines the RMS of each bin. This in
0005 % turn allows us to look at the top RFI events across the entire
0006 % timestream. If we didn't bin, the top RFI events could all be part of the
0007 % same overall event.
0008 close all
0009 clc
0010 
0011 %starttime = '08-jun-2014:21:27:00';
0012 %stoptime  = '09-jun-2014:10:52:00';
0013 %stoptime  = '08-jun-2014:21:52:00';
0014 
0015 
0016 d = read_arcSouth_nojunk(starttime, stoptime, {'array.frame.utc double', ...
0017     'array.frame.features double', 'array.frame.received', ...
0018     'antenna0.roach1.utc double',  'antenna0.roach2.utc double', ...
0019     'antenna0.roach1.LLfreq double',  'antenna0.roach2.LLfreq double', ...
0020     'antenna0.roach1.RRfreq double',  'antenna0.roach2.RRfreq double', ...
0021     'antenna0.roach1.Qfreq double',  'antenna0.roach2.Qfreq double', ...
0022     'antenna0.roach1.Ufreq double',  'antenna0.roach2.Ufreq double'});
0023 
0024 % try removing the steps
0025 % This didn't work, and caused issues on cyclops, so I removed it.
0026 
0027 % Determine the intensity:
0028 % I = (LL1 + LL2 + RR1 + RR2)/4
0029 
0030 Intensity = (d.antenna0.roach1.LLfreq + d.antenna0.roach2.LLfreq + d.antenna0.roach1.RRfreq + d.antenna0.roach2.RRfreq)./4;
0031 
0032 
0033 
0034 % Establish bin size:
0035 
0036 % Note: a smaller binsize results in the top 10 rms hits all being part of
0037 % the same RFI event. Bigger bin size gets more events, but smoothes the
0038 % rms value across a larger sample value ie possibly including more RFI
0039 % events in one sample
0040 
0041 binsize = 100;
0042 nbins = lower(length(Intensity)/binsize);
0043 
0044 % Determine rms for each bin:
0045 
0046 for m = 1:nbins - 1
0047     rmsval(m) = sqrt(var(Intensity((m-1)*100+1:m*100)));
0048 end
0049 
0050 % Sort the rms values into highest to lowest:
0051 
0052 [rmssort I] = sort(rmsval,'descend');
0053 
0054 
0055 top_ten = rmssort(1,1:10); % top 10 RFI rms values
0056 top_ten_bin = I(1,1:10); % bin numbers relating to top 10 RFI rms values
0057 
0058 
0059 
0060 %pick the RMS which are 5 sigma above the median rms
0061 brightRmsLimit = 4*median(rmsval);
0062 
0063 f = find(rmsval > brightRmsLimit);
0064 % with those N points, we want to read in the full data, and look at a
0065 % spectrum for each
0066 
0067 for m=1:size(f,2)
0068     if(f(m)==1)
0069         tstart = d.antenna0.roach1.utc(1)-1/24/60/60;
0070     else
0071         tstart = d.antenna0.roach1.utc((f(m)-1)*100)-1/24/60/60;
0072     end
0073     tstop  = d.antenna0.roach1.utc(f(m)*100)+1/24/60/60;
0074     drfi{m} = read_arcSouth(mjd2string(tstart), mjd2string(tstop));
0075    
0076 end
0077 %size(drfi)
0078 drfisave = drfi;
0079 numEvents = length(drfi);
0080 if(numEvents >100)
0081     disp('splitting it up');
0082     numFiles = ceil(numEvents/100);
0083     for m=1:numFiles
0084         if(m==numFiles)
0085             dd = drfisave((m-1)*100+1:numEvents);
0086         else
0087             dd = drfisave((m-1)*100+1:(m-1)*100);
0088         end
0089         newsavefile = strcat(savefilename, '_', num2str(m));
0090         drfi = dd;
0091         
0092         txt = sprintf('save %s drfi', newsavefile);        
0093         eval(txt);
0094     end
0095 else
0096     txt = sprintf('save %s drfi', savefilename);
0097     eval(txt);
0098 end
0099 %plotfigs(drfi);
0100 
0101 end % function

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