%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [az, el] = calcAzEl2(az,el,d) applies the corrections to the a set of az/el values (az,el inputs)in order to iteratively remove the poining corrections. Uses pointing/refraction data stored in the d data structure- charles copley-borrowed from SJCM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function [az, el] = calcAzEl2(az,el,d) 0002 0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0004 % 0005 % function [az, el] = calcAzEl2(az,el,d) 0006 % 0007 % applies the corrections to the a set of az/el values (az,el inputs)in order to 0008 % iteratively remove the poining corrections. Uses pointing/refraction 0009 % data stored in the d data structure- 0010 % 0011 % 0012 % charles copley-borrowed from SJCM 0013 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0014 0015 % % 0016 utc = d.antenna0.receiver.utc; 0017 azVal = az; 0018 elVal = el; 0019 0020 0021 % need to re-interpolate the utc for the refraction corrections. 0022 Avals = d.antenna0.tracker.refraction(:,1); 0023 Bvals = d.antenna0.tracker.refraction(:,2); 0024 A = interp1(d.array.frame.utc, Avals, utc); 0025 B = interp1(d.array.frame.utc, Bvals, utc); 0026 % apply refraction corrections 0027 Pvals = d.array.weather.pressure; 0028 Tvals = d.array.weather.airTemperature; 0029 P = interp1(d.array.frame.utc, Pvals, utc); 0030 T = interp1(d.array.frame.utc, Tvals, utc); 0031 0032 long =d.antenna0.tracker.siteActual(1,1); 0033 lat =d.antenna0.tracker.siteActual(1,2); 0034 el =d.antenna0.tracker.siteActual(1,3); 0035 0036 0037 0038 %% load the model for the time period. 0039 if(lat < 0) 0040 modelfile = 'constants/pointing_models_south.txt'; 0041 else 0042 modelfile = 'constants/pointing_models_north.txt'; 0043 end 0044 [daymod nightmod] = getModelParams(d.array.frame.utc(1), modelfile); 0045 0046 %% determine whether to aplpy day/night. 0047 [sunel sunaz] = calcSunLoc(d); 0048 daz = deriv(sunaz); 0049 del = deriv(sunel); 0050 % if the sun is above 13 and rising, it's day, if it's above 0 and falling, 0051 % it's day (this brackets sunrise/sunset and applies a nighttime model to 0052 % sunrise) 0053 indday = (sunel > 15 & del>0) | (sunel > 0 & del <0 ); 0054 indnight = ~indday; 0055 0056 0057 0058 0059 % now we calculate the lst 0060 %jd = utc + 2400000.5; 0061 %jd0 = floor(utc) + 2400000.5; 0062 %H = 24*(jd - jd0); 0063 %D = jd - 2451545.0; 0064 %D0 = jd0 - 2451545.0; 0065 0066 % now we get the LST: 0067 %GMT = 6.697374558 + 0.06570982441908*D0 + 1.00273790935*H; 0068 %GMT = rem(GMT, 24); 0069 %eps = 23.4393 - 0.0000004*D; 0070 %L = 280.47 + 0.98565*D; 0071 %omega = 125.04 - 0.052954*D; 0072 %deltaPsi = -0.000319*sin(omega) - 0.000024*sin(2*L); 0073 %eqeq = deltaPsi.*cos(eps); 0074 %GAST = GMT + eqeq; 0075 %lst2 = GAST + long/15; 0076 %lst2(lst2<0) = lst2(lst2<0)+24; 0077 %lst = lst2*15; 0078 0079 lst = interp1(d.array.frame.utc, d.antenna0.tracker.lst, utc)*15; % in degrees 0080 0081 % now for hour angle: 0082 %ra = interp1(d.array.frame.utc, d.antenna0.tracker.equat_geoc(:,1), utc); 0083 %ra = ra*15; % in degrees 0084 %dec = interp1(d.array.frame.utc, d.antenna0.tracker.equat_geoc(:,2), utc); % in degrees 0085 %ha = lst - ra; % also in degrees 0086 % 0087 %% convert all to radians: 0088 %HA = ha*pi/180; 0089 %de = dec*pi/180; 0090 %La = lat*pi/180; 0091 % 0092 %[az, el] = hdl2ae(HA,de,La); 0093 %az=deg2rad(azVal); 0094 %el=deg2rad(elVal); 0095 0096 az = azVal*pi/180; 0097 el = elVal*pi/180; 0098 0099 % apply refraction correction. 0100 R = 0.00452.*P./( (273.15+T ).*tan(el))*pi/180; 0101 el = el+R; 0102 0103 az = az*180/pi; 0104 el = el*180/pi; 0105 az(az<0) = az(az<0)+360; 0106 % we need to add the online pointing model applied 0107 model = [d.antenna0.tracker.flexure(1,:), d.antenna0.tracker.tilts(1,:), ... 0108 d.antenna0.tracker.fixedCollimation(1,:), ... 0109 d.antenna0.tracker.encoder_off(1,:)]; 0110 0111 % apply the pointing model 0112 [az, el] = pointing_model(model, az, el); 0113 0114 %daz = azVal-az; 0115 %del= elVal-el; 0116 return;