Home > reduc > newSkyDipMethod2.m

newSkyDipMethod2

PURPOSE ^

by this point, we should have things converted.

SYNOPSIS ^

function [ZenithOpacityMethodTwo] = SkyDipMethod2(dc)

DESCRIPTION ^

 by this point, we should have things converted.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ZenithOpacityMethodTwo] = SkyDipMethod2(dc)
0002 
0003 % by this point, we should have things converted.
0004 %
0005 GainValue = dc.correction.alpha.values(:,9:16);
0006 
0007 
0008 % sometimes gain values incredibly high so those values are set to nans and
0009 % then most recent value taken.
0010 GainValue(abs(GainValue)>2) = nan;
0011 if(size(GainValue,1)>1)
0012   GainValue = nanmean(GainValue);
0013 end
0014 
0015 
0016 Gain1 = mean(abs(GainValue(1:2)));
0017 Gain2 = mean(abs(GainValue(7:8)));
0018 
0019 % Calibrating y axis to read power
0020   
0021 Tamb = (mean(dc.array.weather.airTemperature))+ 273.15;
0022 
0023 Tcmb = 2.725;
0024 
0025 Kb = 1.38*10^(-23);
0026 
0027 Bandwidth = 1;
0028 
0029 % so now for corrected y values (turned from dB into power)
0030 thisY = dc.antenna0.receiver.data(:,[1 6]);
0031 yOne = Kb*Bandwidth*Gain1.*(thisY(:,1));
0032 yTwo = Kb*Bandwidth*Gain2.*(thisY(:,2));
0033 y = [yOne, yTwo];
0034 
0035 
0036 % calculate number of dips
0037 q = length(dc.antenna0.servo.el);
0038 time = dc.antenna0.receiver.utc - dc.antenna0.receiver.utc(1);
0039 time = time.*24;
0040 yy6 = spline(time, dc.antenna0.servo.el,time);
0041 [maxtab] = peakdet(yy6,0.1,time);
0042 Divider = length(maxtab(:,1));
0043     
0044 
0045 if (Divider ~= 0)
0046   NewY = (length(dc.antenna0.servo.el))/Divider;
0047   m = round(NewY);
0048   y = y(1:m, [1 2]);
0049   x = 1./(sind(dc.antenna0.servo.el(1:m)));
0050 
0051 elseif (Divider == 0) 
0052   m = length(y);
0053   y = y(:, [1 2]);
0054   x = 1./(sind(dc.antenna0.servo.el));
0055 end 
0056 
0057 % get rid of our flagged data
0058 flaggedData = isnan(y(:,1)) | isnan(y(:,2));
0059 y(flaggedData,:) = [];
0060 x(flaggedData) = [];
0061 
0062 % next we fit the line on region where uniform slab model is applicable.
0063 GoodX = (x <= 2.0);
0064 
0065 [gradient2 intercept2] = linfit(x(GoodX),y(GoodX, [1 2]));
0066   
0067 finY = y;
0068 finX = x;
0069 
0070 finYR1 = (gradient2(1)*x) + intercept2(1);
0071 finYR2 = (gradient2(2)*x) + intercept2(2);
0072 
0073 
0074 %plot(x,y,'.',x,finYR1,x,finYR2)
0075   
0076 kk = [x(GoodX),y(GoodX,[1])];
0077 ll = [x(GoodX),y(GoodX,[2])];
0078 
0079 hh = kk(:,1);
0080 jj = kk(:,2);
0081 
0082 ff = ll(:,1);
0083 ee = ll(:,2);
0084 
0085 % display ('newSkyDipMethod2:: Channel One gradient and y intercept:')
0086 
0087 p = polyfit(hh,jj,1);
0088 
0089 gradientOne = p(:,1);
0090      
0091 %  display ('newSkyDipMethod2:: Channel Two gradient and y-intercept values:')
0092   
0093 p = polyfit(ff,ee,1);
0094 
0095 gradientTwo = p(:,1);
0096 
0097 %Calculating channel one and six opacity but only using channel one (as six
0098 %to noisy).
0099 
0100 OpacityOne = gradientOne/ (Kb*Bandwidth*Gain1*(Tamb - Tcmb));
0101 OpacityTwo = gradientTwo/ (Kb*Bandwidth*Gain2*(Tamb - Tcmb));
0102 
0103 ZenithOpacityMethodTwo = sqrt((OpacityOne)^2);
0104 
0105 return;
0106 
0107 
0108 
0109   
0110

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