0001 function [noiseVals, noiseInterp, noiseInterpErr] = getNoiseDiodeTemps(d)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 if(nargin<2)
0017 primCal = [1,2,8];
0018
0019 end
0020
0021 filename = 'constants/noise_diode_values_ptcross.txt';
0022
0023
0024
0025
0026
0027 tnoise = load(filename);
0028
0029
0030 indmethod = tnoise(:,11) == 1;
0031 tnoise = tnoise(indmethod,:);
0032 tnoise(:,11) = [];
0033
0034
0035
0036 tDate = tnoise(:,1);
0037
0038 [tDateChron, sortOrder] = sort(tDate);
0039 tChron = tnoise(sortOrder,:);
0040
0041
0042 tDate = tDateChron;
0043 tnoise = tChron;
0044
0045
0046 reps = find(diff(tDate)==0);
0047 tDate(reps,:) = [];
0048 tnoise(reps,:) = [];
0049
0050
0051 sources = tnoise(:,2);
0052 times = tDate;
0053 noiseVals = tnoise(:,5:10);
0054 tnd = noiseVals(:,1:2);
0055 tndErr = noiseVals(:, 3:4);
0056 flags = noiseVals(:,5:6) | isnan(tnd);
0057
0058
0059
0060
0061 indPrim1 = find(sources == primCal(1));
0062 indPrim2 = find(sources == primCal(2));
0063 indPrim3 = find(sources == primCal(3));
0064 indPrim = cat(1, indPrim1, indPrim2, indPrim3);
0065 sources = sources(indPrim);
0066 times =times(indPrim);
0067 noiseVals = noiseVals(indPrim, 1:6);
0068 tnd = tnd(indPrim, 1:2);
0069 tndErr = tndErr(indPrim, 1:2);
0070 flags =flags(indPrim, 1:2);
0071
0072
0073 if(isstruct(d))
0074 ind = times > d.array.frame.utc(1) - 2/24 & times < ...
0075 last(d.array.frame.utc) + 2/24;
0076 finc= find(ind);
0077
0078 hr = 73;
0079 while(isempty(finc))
0080
0081
0082 ind = times > d.array.frame.utc(1) - hr/24 & times < ...
0083 last(d.array.frame.utc) + hr/24;
0084 finc = find(ind);
0085 hr = hr+1;
0086 end
0087 eval(sprintf('display(''getNoiseDiodeTemps:: Nearest noise diode is within %d hours of track'')', (hr-1)));
0088 else
0089 ind = times > d(1) - 2/24 & times < ...
0090 last(d) + 2/24;
0091 finc= find(ind);
0092
0093 hr = 73;
0094 while(isempty(finc))
0095
0096
0097 ind = times > d(1) - hr/24 & times < ...
0098 last(d) + hr/24;
0099 finc = find(ind);
0100 hr = hr+1;
0101 end
0102 eval(sprintf('display(''getNoiseDiodeTemps:: Nearest noise diode is within %d hours of track'')', (hr-1)));
0103 if ( (hr-1) > 23)
0104 disp('getNoiseDiodeTemps:: WARN - Nearest noise diode event is greater than 24 hours away from track')
0105 end
0106 end
0107
0108
0109
0110 if(~isempty(finc))
0111 tnd.time = times(finc);
0112 tnd.source = sources(finc);
0113 tnd.elev = tnoise(finc,3);
0114 tnd.pa = tnoise(finc,4);
0115 tnd.Tnd = noiseVals(finc,1:2);
0116 tnd.TndErr = tndErr(finc, 1:2);
0117 tnd.flags = flags(finc, 1:2);
0118 else
0119 error('getNoiseDiodeTemps:: You have no noise diode info in your archive');
0120 end
0121
0122
0123
0124 acceptable1 = find(tnd.flags(:,1) == 0);
0125 acceptable2 = find(tnd.flags(:,2) == 0);
0126 using1 = tnd.Tnd(acceptable1, 1);
0127 using2 = tnd.Tnd(acceptable2, 2);
0128 usingErr1 = tnd.TndErr(acceptable1, 1);
0129 usingErr2 = tnd.TndErr(acceptable2, 2);
0130
0131 [wmean1 error_wm1] = weighted_mean(using1,usingErr1);
0132 [wmean2 error_wm2] = weighted_mean(using2,usingErr2);
0133 if(isnan(wmean1))
0134 wmean1 = 3;
0135 error_wm1 = inf;
0136 end
0137 if(isnan(wmean2))
0138 wmean2 = 3;
0139 error_wm2 = inf;
0140 end
0141
0142
0143
0144 if(isstruct(d))
0145 noiseInterp(:,1) = repmat(wmean1, length(d.antenna0.receiver.utc), 1);
0146 noiseInterpErr(:,1) = repmat(error_wm1, length(d.antenna0.receiver.utc), 1);
0147 noiseInterp(:,2) = repmat(wmean2, length(d.antenna0.receiver.utc), 1);
0148 noiseInterpErr(:,2) = repmat(error_wm2, length(d.antenna0.receiver.utc), 1);
0149 else
0150 noiseInterp = [wmean1 wmean2];
0151 noiseInterpErr = [error_wm1 error_wm2];
0152 end
0153
0154
0155 noiseVals = tnd;
0156
0157 timeM = mean(tnd.time);
0158
0159
0160
0161
0162
0163
0164
0165 return;
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186