


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function d = interpRegisterSa(d) only the cryocon and the az/el need to be interpolated Based off the interpRegister(d) for the Northern system Modified: 21-May-2013 (CJC) -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %added provision for NTP timing interpolation from servo to receiver time % added provision to turn off the servoPPS correction to support the new % trimble 1PPS that didn't originally drive both the Roach and the servo 1PPS First we find out if the servo/cryo data are required


0001 function d = interpRegistersSa(d,ntpFlag,servoPPSFlag) 0002 0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0004 % function d = interpRegisterSa(d) 0005 % 0006 % only the cryocon and the az/el need to be interpolated 0007 % Based off the interpRegister(d) for the Northern system 0008 % Modified: 0009 % 21-May-2013 (CJC) -- 0010 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0011 %%added provision for NTP timing interpolation from servo to receiver time 0012 %% added provision to turn off the servoPPS correction to support the new 0013 %% trimble 1PPS that didn't originally drive both the Roach and the servo 1PPS 0014 %First we find out if the servo/cryo data are required 0015 hasRx = 0; 0016 hasCryo = 0; 0017 hasServo= 0; 0018 %display('interpRegistersSa:: interpRegisters'); 0019 if(isfield(d, 'antenna0')) 0020 if(isfield(d.antenna0, 'servo')) 0021 if(isfield(d.antenna0.servo, 'fast_az_pos')) 0022 hasServo = 1; 0023 end 0024 end 0025 0026 if(isfield(d.antenna0, 'thermal')) 0027 if(isfield(d.antenna0.thermal, 'ccTemperatureLoad')) 0028 hasCryo = 1; 0029 end 0030 end 0031 0032 if(isfield(d.antenna0, 'roach1')) 0033 if(isfield(d.antenna0.roach1, 'utc')) 0034 hasRx = 1; 0035 end 0036 end 0037 end 0038 0039 %display('interpRegistersSa:: interpRegisters1'); 0040 hasAny = hasServo + hasRx + hasCryo; 0041 if(hasAny<2) 0042 %display('interpRegistersSa:: Nothing to inpterpolate') 0043 return; 0044 end 0045 0046 if(~hasRx) 0047 display('interpRegistersSa:: Nothing to interpolate') 0048 return; 0049 end 0050 0051 utcLength = length(d.antenna0.roach1.utc); 0052 0053 matchedIndex=find(abs(24*60*60*(d.antenna0.thermal.utc(1)-d.antenna0.servo.utc))<0.1) 0054 0055 %keyboard; 0056 0057 %ntpFlag=1; 0058 if (ntpFlag==1) 0059 d=fitNTPOffsetSouth(d,servoPPSFlag); 0060 utc = d.antenna0.roach1.utc; 0061 % indexing=[1:100:length(d.antenna0.roach1.ntpUSeconds)]; 0062 %% sampleTimes=[0:10000:1e6-10000]; 0063 % ppsOffset=median(d.antenna0.roach1.ntpUSeconds(indexing)); 0064 % utc = d.antenna0.roach1.ntpSeconds+d.antenna0.roach1.ntpUSeconds/1e6-ppsOffset/1e6; %correct the ntpTime for the ppsOffset 0065 else 0066 utc = d.antenna0.roach1.utc; 0067 end 0068 0069 0070 %d.antenna0.servo.utc = d.antenna0.servo.utc + (1/(24*3600))*1e-3*rand(length(d.antenna0.servo.utc),1); 0071 0072 0073 0074 %if(ntpFlag==1) 0075 % indexing=[1:5:length(d.antenna0.servo.ntpSecond)]; 0076 % ppsOffset=median(d.antenna0.servo.ntpUSecond(indexing)); 0077 % d.antenna0.servo.utc = d.antenna0.servo.ntpSecond+d.antenna0.servo.ntpUSecond/1e6-ppsOffset/1e6; %correct the ntpTime for the ppsOffset 0078 %else 0079 %offsetServoTime=+0.00./86400; %%offset time in seconds 0080 %end 0081 0082 0083 % JL JL JL Stronger hack position 0084 %keyboard; 0085 %length(d.antenna0.servo.utc) 0086 %length(unique(d.antenna0.servo.utc)) 0087 %length(utc) 0088 %length(unique(utc)) 0089 0090 if (length(d.antenna0.servo.utc)~=length(unique(d.antenna0.servo.utc))) 0091 disp('interpRegistersSa:: WARN: Times are not all unique in d.antenna0.servo.utc: not attempting to fix, future interpolations may or may not fail'); 0092 0093 % JL This is potential fix assumes all intervals are close to (d.antenna0.servo.utc(2)-d.antenna0.servo.utc(1)) 0094 % JL Leave commented out for the time being 0095 %for i=1:length(d.antenna0.servo.utc) 0096 % d.antenna0.servo.utc(i) = d.antenna0.servo.utc(1) + (i-1)*(d.antenna0.servo.utc(2)-d.antenna0.servo.utc(1)); 0097 %end; 0098 0099 % JL deprecated jitter fix 0100 %d.antenna0.servo.utc = d.antenna0.servo.utc + 1e-5*rand(length(d.antenna0.servo.utc),1); 0101 0102 end; 0103 0104 if (length(utc)~=length(unique(utc))) 0105 disp('interpRegistersSa:: WARN: Times are not all unique in utc'); 0106 disp('interpRegistersSa:: WARN: Times are not all unique in utc: not attempting to fix, future interpolations may or may not fail'); 0107 % JL This is potential fix assumes all intervals are close to utc(2)-utc(1) 0108 % which is currently not the case. 0109 % JL Leave commented out for the time being 0110 % for i=1:length(utc) 0111 % fake(i) = utc(1) + (i-1)*(utc(2)-utc(1)); 0112 % end; 0113 0114 % JL deprecated jitter fix 0115 %disp('interpRegistersSa:: Times are not all unique in utc: adding 10 us jitter:'); 0116 %utc = utc + 1e-5*rand(length(utc),1); % This hack does not work 0117 end; 0118 0119 %size(utc) 0120 %size(d.antenna0.servo.fast_az_pos) 0121 %size(d.antenna0.servo.utc) 0122 0123 servoAz = interp1(d.antenna0.servo.utc,d.antenna0.servo.fast_az_pos,utc); 0124 servoEl = interp1(d.antenna0.servo.utc,d.antenna0.servo.fast_el_pos,utc); 0125 servoAzErr = interp1(d.antenna0.servo.utc,d.antenna0.servo.fast_az_err,utc); 0126 servoElErr = interp1(d.antenna0.servo.utc,d.antenna0.servo.fast_el_err,utc); 0127 0128 %thermalCryo=interp(d.antenna0.thermal.ccTemperatureLoad,20); 0129 thermalCryo=interp1(d.antenna0.servo.utc,d.antenna0.thermal.ccTemperatureLoad,utc); 0130 0131 %timeServo=interp1(d.antenna0.servo.utc-d.antenna0.servo.utc(1),20)+d.antenna0.servo.utc(1);%% double precision not enough for the interpolations 0132 timeServo=interp1(d.antenna0.servo.utc,(d.antenna0.servo.utc-d.antenna0.servo.utc(1)),utc)+d.antenna0.servo.utc(1); 0133 0134 %timeThermal=interp1(d.antenna0.thermal.utc-d.antenna0.thermal.utc(1),20)+d.antenna0.thermal.utc(1);%% double precision not enough for the interpolations 0135 timeThermal=interp1(d.antenna0.servo.utc,(d.antenna0.thermal.utc-d.antenna0.thermal.utc(1)),utc)+d.antenna0.thermal.utc(1); 0136 0137 0138 roachTime=d.antenna0.roach1.utc; 0139 0140 0141 d.antenna0.servo.az = servoAz; 0142 d.antenna0.servo.el = servoEl; 0143 d.antenna0.servo.azerr = servoAzErr; 0144 d.antenna0.servo.elerr = servoElErr; 0145 d.antenna0.servo.utcFast = timeServo; 0146 d.antenna0.thermal.ccTemperatureLoadFast=thermalCryo; 0147 d.antenna0.thermal.utcFast=timeThermal; 0148 0149 0150 0151 return;