Home > cbassSouthFunctions > ACTFunctions > calcAzElCsSa_ACT.m

calcAzElCsSa_ACT

PURPOSE ^

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

SYNOPSIS ^

function [az, el] = calcAzElCsSa(d)

DESCRIPTION ^

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

 function [az, el] = calcAzElCsSa(d)

  calculates the azimuth and elevation of the source to be tracked.

  sjcm
  act - copy of orginal calcAzElCs but hardwired for South Africa position
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [az, el] = calcAzElCsSa(d)
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 % function [az, el] = calcAzElCsSa(d)
0006 %
0007 %  calculates the azimuth and elevation of the source to be tracked.
0008 %
0009 %  sjcm
0010 %  act - copy of orginal calcAzElCs but hardwired for South Africa position
0011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0012 
0013 % definitions
0014 long = d.antenna0.tracker.siteActual(1,1);
0015 lat  = d.antenna0.tracker.siteActual(1,2);
0016 elev = d.antenna0.tracker.siteActual(1,3);
0017 
0018 % LST of data
0019 lst    = d.antenna0.tracker.lst*15;
0020 utc    = d.antenna0.receiver.utc;
0021 indpos = lst > 180;
0022 lst(indpos) = lst(indpos)-360;
0023 lst    = interp1(d.array.frame.utc, lst, utc); % in degrees
0024 indpos = interp1(d.array.frame.utc, indpos, utc, 'nearest');
0025 indpos(isnan(indpos)) = 0;
0026 indpos = logical(indpos);
0027 lst(indpos) = lst(indpos)+360;
0028 
0029 % start with the RA/DEC of the source
0030 ra = interp1(d.array.frame.utc, d.antenna0.tracker.equat_geoc(:,1), utc);
0031 ra = ra*15; % in degrees
0032 dec = interp1(d.array.frame.utc, d.antenna0.tracker.equat_geoc(:,2), utc); % in degrees
0033 ha = lst - ra;  % also in degrees
0034 
0035 % convert all to radians:
0036 HA = ha*pi/180;
0037 de = dec*pi/180;
0038 La = lat*pi/180;
0039 
0040 % now we convert to az/el
0041 [az, el] = hdl2ae(unwrap(HA),de,La);
0042 % hdl2ae is equivalent to the below, which is in the control system.
0043 %el1 = asin( sin(de).*sin(La) + cos(de).*cos(La).*cos(HA));
0044 %az1 = atan2( -cos(de).*sin(HA) , (sin(de).*cos(La) - ...
0045 %    cos(de).*sin(La).*cos(HA)));
0046 
0047 % next we apply a horizontal parallax, if necessary
0048 sources = unique(d.antenna0.tracker.source);
0049 ephemSourceList = {'moon', 'sun', 'jupiter', 'mars', 'mercury', 'neptune', ...
0050     'pluto', 'saturn', 'uranus', 'venus'};
0051 needCorr = 0;
0052 for m=1:length(sources)
0053   if(~isempty(strmatch(sources{m}, ephemSourceList)))
0054     srcIndex  = strmatch(sources{m}, ephemSourceList);
0055     needCorr  = 1;
0056     indSource = zeros(size(d.antenna0.tracker.source,1), 1);
0057     f         = strmatch(ephemSourceList{srcIndex}, d.antenna0.tracker.source(:,1));
0058     indSource(f) = 1;
0059     srcName   = ephemSourceList{srcIndex};
0060   end
0061 end
0062 
0063 % if there is a source name, we need to read in the ephem and interpolate
0064 % accordingly
0065 if(needCorr)
0066   [dist err r_cent] = cbassMatEphem(srcName, d.antenna0.receiver.utc);
0067   
0068   % apply the correction
0069   el = el - atan2( cos(el), dist/r_cent - sin(el));
0070 end
0071 
0072 % next we correct for refraction
0073 % need to re-interpolate the utc for the refraction corrections.
0074 Avals = d.antenna0.tracker.refraction(:,1);  % degrees
0075 Bvals = d.antenna0.tracker.refraction(:,2);  % degress
0076 refraVal = d.antenna0.tracker.refraction(:,3); % degrees
0077 
0078 A = interp1(d.array.frame.utc, Avals, utc) * pi/180;
0079 B = interp1(d.array.frame.utc, Bvals, utc) * pi/180;
0080 
0081 refracCorr = ( A.*cos(el).*(sin(el)).^3 + B.*sin(el).*(cos(el)).^3 ) ./ ( ...
0082     (sin(el)).^4 + A.*(sin(el)).^2 + 3*B.*(cos(el)).^2);
0083 el = el + refracCorr;
0084 
0085 % next the diurnal aberration
0086 %[az, el] = applyDiurnalAberration(az, el);
0087 
0088 % now this is the azapparent and el apparent.
0089 
0090 % next we convert back to degrees and apply the pointing model corrections.
0091 az = az*180/pi;
0092 el = el*180/pi;
0093 az(az<0) = az(az<0)+360;
0094 % we need to add the online pointing model applied
0095 model = [d.antenna0.tracker.flexure(1,:), d.antenna0.tracker.tilts(1,:), ...
0096       d.antenna0.tracker.fixedCollimation(1,:), ...
0097       d.antenna0.tracker.encoder_off(1,:)];
0098 
0099 % apply the pointing model
0100 [az, el] = pointing_model(model, az, el);
0101 
0102 return;

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