Home > pointing > pointing_model.m

pointing_model

PURPOSE ^

[maz,mel]=pointing_model(model,iaz,iel)

SYNOPSIS ^

function [maz,mel]=pointing_model(model,iaz,iel)

DESCRIPTION ^

 [maz,mel]=pointing_model(model,iaz,iel)

 Convert ideal iaz,iel to model maz,mel using pointing model
 parameters tm

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [maz,mel]=pointing_model(model,iaz,iel)
0002 % [maz,mel]=pointing_model(model,iaz,iel)
0003 %
0004 % Convert ideal iaz,iel to model maz,mel using pointing model
0005 % parameters tm
0006 
0007 if(length(model)==9)
0008   model(10) = 0;
0009   model(11) = 0;
0010 end
0011 model(11) = mod(model(11), 360);
0012 
0013 % All input params in degrees - convert to rad
0014 d2r=pi/180;
0015 model=model*d2r;
0016 az=iaz*d2r;
0017 el=iel*d2r;
0018 
0019 % cosine of azimuth
0020 %az = az + model(10).*sin(az);
0021 %el = el + model(11).*cos(az);
0022 
0023 
0024 % Flexure
0025 el=el-model(1)*sin(el);
0026 el=el-model(2)*cos(el);
0027 
0028 % Az tilt
0029 %display('New Az Tilt');
0030 %[az1, el1] = azTiltCheck(model, az, el);
0031 % the two are equivalent.  they're off by about a tenth of an arcsecond.
0032 
0033 % astronomy az is clockwise from north
0034 % but want to work in frame with az anticlock from x as for matlab
0035 % sph2cart function etc. Also x-east, y-north, z-up seems most
0036 % natural.
0037 az=-az+pi/2;
0038 
0039 % Get normal vector to tilt plane
0040 c=cross([1,0,tan(model(3))],[0,1,tan(-model(4))]);
0041 % Find magnitude and dir of tilt
0042 phi=atan2(c(2),c(1));
0043 theta=atan(sqrt(c(1)^2+c(2)^2./c(3)));
0044 % Apply rotation
0045 [x,y,z]=sph2cart(az,el,ones(size(az)));
0046 [x,y,z]=rotaboutz(x,y,z,phi);   % rotate to x along tilt dir
0047 [x,y,z]=rotabouty(x,y,z,theta); % rotate by tilt angle
0048 [x,y,z]=rotaboutz(x,y,z,-phi);  % rotate back
0049 [az,el]=cart2sph(x,y,z);
0050 
0051 % Convert back to az clock from north
0052 az=-az+pi/2;
0053 
0054 
0055 
0056 % El tilt
0057 % There is no way to do this with vector rotation as axes not perp.
0058 % Below is taken from Tim/Martin
0059 el = asin(sin(el)./cos(model(5)));
0060 el(imag(el)~=0)=NaN;
0061 az=az-asin(tan(model(5)).*sin(el)./cos(el));
0062 az(imag(az)~=0)=NaN;
0063 
0064 % Cross-el Collimation
0065    
0066 % There is no way to do cross-el collimation with vector rotation
0067 % Below is taken from Tim/Martin for the case of deck=270
0068 az=az-asin(-sin(model(6))./cos(el));
0069 az(imag(az)~=0)=NaN;
0070 el=asin(sin(el)./cos(model(6)));
0071 el(imag(el)~=0)=NaN;
0072 
0073 % El collimation
0074 % Exactly the same as el zero point shift
0075 el=el+model(7);
0076 
0077 
0078 % term that's proportional to cos(az)
0079 el = el + model(10)*(cos(az + model(11)));
0080 
0081 % Encoder zero points
0082 az=az+model(8);
0083 el=el+model(9);
0084 
0085 
0086 % put phi into 0 to 2pi range
0087 ind=az<0; az(ind)=az(ind)+2*pi;
0088 ind=az>2*pi; az(ind)=az(ind)-2*pi;
0089 
0090 % Convert back to deg
0091 maz=az/d2r;
0092 mel=el/d2r;
0093 
0094 return

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