%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [horzFlag satFlag] = flagRFI_pos2(d, Antenna) March 17, 2011 (MAS) - Flags data based upon positional proximity to known sources of RFI. March 31, 2011 (MAS) - Also, the Sun and Moon because they mess with my RFI tests. April 15, 2011 (MAS) - Committed. August 8, 2011 (SJCM) - Modified for memory efficiency. will now run on at least 7 hours of data where switchData is not present. August 11, 2011 (MAS) - Split the northern survey into two epochs: pre- and post-filters. ----------------------------------------------------------------------- April 12, 2013 (Paddy) - Major simplification of original flagRFI_pos. Removed Sun & Moon flagging as already done by flagMask/flagData. Removed refraction correction as we compare with apparent Az El which already takes that into account. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function [horzFlag satFlag] = flagRFI_pos2(d, Antenna) 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % function [horzFlag satFlag] = flagRFI_pos2(d, Antenna) 0004 % 0005 % March 17, 2011 (MAS) - Flags data based upon positional proximity to 0006 % known sources of RFI. 0007 % 0008 % March 31, 2011 (MAS) - Also, the Sun and Moon because they mess with my 0009 % RFI tests. 0010 % 0011 % April 15, 2011 (MAS) - Committed. 0012 % August 8, 2011 (SJCM) - Modified for memory efficiency. will now run on 0013 % at least 7 hours of data where switchData is not present. 0014 % 0015 % August 11, 2011 (MAS) - Split the northern survey into two epochs: 0016 % pre- and post-filters. 0017 %----------------------------------------------------------------------- 0018 % April 12, 2013 (Paddy) - Major simplification of original flagRFI_pos. 0019 % Removed Sun & Moon flagging as already done by flagMask/flagData. 0020 % Removed refraction correction as we compare with apparent Az El which 0021 % already takes that into account. 0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0023 0024 %%%%%%%%%%%%%% 0025 % Parameters: 0026 %%%%%%%%%%%%%% 0027 0028 epochN_1 = '15-Jul-2011:00:00:00'; % End of first Northern epoch (pre-filters). 0029 0030 % Horizon positions: 0031 horzAzN_1 = [168.5 318]; 0032 horzAzN_2 = []; 0033 horzAzS = []; 0034 0035 % Horizon radii: 0036 horzRadN_1 = [40 40]; 0037 horzRadN_2 = []; 0038 horzRadS = []; 0039 0040 % Satellite positions: 0041 satAzN_1 = [110.5 119 138.5 146 157.5 170 176.5 183 186.5 190 199.5 202.5 205.5 208]; 0042 satAzN_2 = [110.5]; 0043 satAzS = []; 0044 0045 % Satellite radii: 0046 satRadN_1 = 6; 0047 satRadN_2 = 15; 0048 satRadS = 6; 0049 0050 % Observatory latitudes: 0051 obsLatN = 37.2333; 0052 obsLatS = -30.83; 0053 0054 0055 %%%%%%%%%%%%%%%%%%%%%%%%%% 0056 % Begin the calculations! 0057 %%%%%%%%%%%%%%%%%%%%%%%%%% 0058 0059 0060 % Get azimuth and elevation: 0061 az = d.antenna0.servo.apparent(:,1); 0062 el = d.antenna0.servo.apparent(:,2); 0063 0064 % Get its length. 0065 dLength = length(az); 0066 0067 0068 % North 0069 if Antenna == 1 0070 0071 % MAS: Added second epoch of northern observing (ie, after filters 0072 % installed). 0073 if (d.antenna0.servo.utc < tstr2mjd(epochN_1)) 0074 % disp('flagRFI_pos2:: Pre-'); 0075 horzAz = horzAzN_1; 0076 horzRad = horzRadN_1; 0077 satAz = satAzN_1; 0078 satRad = satRadN_1; 0079 obsLat = obsLatN; 0080 else 0081 % disp('flagRFI_pos2:: Post-'); 0082 horzAz = horzAzN_2; 0083 horzRad = horzRadN_2; 0084 satAz = satAzN_2; 0085 satRad = satRadN_2; 0086 obsLat = obsLatN; 0087 end 0088 0089 % South 0090 elseif Antenna == 2 0091 horzAz = horzAzS; 0092 horzRad = horzRadS; 0093 satAz = satAzS; 0094 satRad = satRadS; 0095 obsLat = obsLatS; 0096 0097 % Invalid choice 0098 else 0099 return; 0100 end 0101 0102 % How many horizon positions? 0103 nHorz = length(horzAz); 0104 % How many satellites? 0105 nSat = length(satAz); 0106 0107 0108 0109 % Calculate the geosynchronous elevations. 0110 satPhi = asind(sqrt(sind(obsLat)^2./(1-sind(satAz).^2*cosd(obsLat)^2))); 0111 satEl = acosd(sind(satPhi) ./ sqrt(1 + 0.178^2 - 2 * 0.178 * cosd(satPhi))); 0112 0113 %%%%%%%%%%%%%%%%%%%%%%%%%%%% 0114 % OK, now do the calc: 0115 %%%%%%%%%%%%%%%%%%%%%%%%%%%% 0116 0117 % SJCM: re-ordering flagging so we can conserve some memory. 0118 0119 % First the horizon flagging. This isn't quite correct... 0120 % MAS: Added check to make sure we have at least one horizon source. 0121 if nHorz > 0 0122 horzFlag = max(acosd( ... 0123 cosd(repmat(el,1,nHorz)) .* ... 0124 cosd(repmat(horzAz,dLength,1) - repmat(az,1,nHorz))) < ... 0125 repmat(horzRad,dLength,1),[],2); 0126 else 0127 horzFlag = false(dLength,1); 0128 end 0129 0130 % SJCM: clear up some memory before the next step. 0131 clear nHorz 0132 0133 0134 % Next the satellite flagging. 0135 0136 % SJCM: again, do a loop instead of the following code. 0137 % satFlag = max(acosd( ... 0138 % sind(repmat(el,1,nSat)) .* sind(satElCorr) + ... 0139 % cosd(repmat(el,1,nSat)) .* cosd(satElCorr) .* ... 0140 % cosd(repmat(satAz,dLength,1) - repmat(az,1,nSat))) ... 0141 % < satRad,[],2); 0142 % MAS: Fixed bug in looped code. Added check to make sure we have at least 0143 % one satellite. 0144 satFlag = false(size(el)); 0145 if nSat > 0 0146 for m=1:nSat 0147 thisSatParam = acosd( sind(el) .* sind(satEl(:,m)) + ... 0148 cosd(el) .* cosd(satEl(:,m)).*cosd(satAz(m) - az)) < satRad; 0149 0150 satFlag = satFlag | thisSatParam; 0151 end 0152 end 0153 0154 clear satEl satAz el az; 0155 0156 end