Home > pointing > calcAzElCs.m

calcAzElCs

PURPOSE ^

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

SYNOPSIS ^

function [az, el] = calcAzElCs(d)

DESCRIPTION ^

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

 function [az, el] = calcAzElCs(d)

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

  sjcm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

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