Home > cbassSouthFunctions > ACTFunctions > Load_Sky_Balance > load_sky_balance.m

load_sky_balance

PURPOSE ^

Script to plot load/sky balance vs frequency for CBASS-S data

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 Script to plot load/sky balance vs frequency for CBASS-S data

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Script to plot load/sky balance vs frequency for CBASS-S data
0002 
0003 %/elephant/cbass_analysisSa/CbassSouthTest/Commissioning/HartRAOData
0004 
0005 %% Import Tsys data from text file.
0006 % Script for importing data from the following text file:
0007 %
0008 %    /elephant/act/CBASS/cbass_analysis/cbass_s_matlab_scripts/Load_Sky_Balance/be_tsys_23apr.txt
0009 %
0010 % To extend the code to different selected data or a different text file,
0011 % generate a function instead of a script.
0012 
0013 % Auto-generated by MATLAB on 2013/05/31 17:15:04
0014 
0015 %% Initialize variables.
0016 filename = '/elephant/act/CBASS/cbass_analysis/cbass_s_matlab_scripts/Load_Sky_Balance/be_tsys_23apr.txt';
0017 delimiter = ' ';
0018 
0019 %% Format string for each line of text:
0020 %   column1: double (%f)
0021 %    column2: double (%f)
0022 %   column3: double (%f)
0023 %    column4: double (%f)
0024 %   column5: double (%f)
0025 % For more information, see the TEXTSCAN documentation.
0026 formatSpec = '%f%f%f%f%f%[^\n\r]';
0027 
0028 %% Open the text file.
0029 fileID = fopen(filename,'r');
0030 
0031 %% Read columns of data according to format string.
0032 % This call is based on the structure of the file used to generate this
0033 % code. If an error occurs for a different file, try regenerating the code
0034 % from the Import Tool.
0035 dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'MultipleDelimsAsOne', true,  'ReturnOnError', false);
0036 
0037 %% Close the text file.
0038 fclose(fileID);
0039 
0040 %% Post processing for unimportable data.
0041 % No unimportable data rules were applied during the import, so no post
0042 % processing code is included. To generate code which works for
0043 % unimportable data, select unimportable cells in a file and regenerate the
0044 % script.
0045 
0046 %% Allocate imported array to column variable names
0047 Frequency = dataArray{:, 1};
0048 Tsys(1,:) = dataArray{:, 2};
0049 Tsys(2,:) = dataArray{:, 3};
0050 Tsys(3,:) = dataArray{:, 4};
0051 Tsys(4,:) = dataArray{:, 5};
0052 
0053 %% Clear temporary variables
0054 clearvars filename delimiter formatSpec fileID dataArray ans;
0055 %% Load in some data and get best estimate of when each channel balances the load
0056 %
0057 d = read_arcSouth('30-Apr-2013:03:16:52  ','     30-Apr-2013:03:36:44')
0058 %d = read_arcSouth('30-Aug-2013:00:50:03 ','     30-Aug-2013:01:22:15 ')
0059 % LL
0060 LL = [d.antenna0.roach1.LL,d.antenna0.roach2.LL];
0061 
0062 LL_load = [d.antenna0.roach1.load2,d.antenna0.roach2.load2];
0063 
0064 for freq_chan = 1:128
0065     best = (abs(LL(:,freq_chan)-LL_load(:,freq_chan))<3000); % just find data when difference between them is 3000 (ie. small - units are of order 1e4)
0066     balance_LL(2,freq_chan) = nanmean(d.antenna0.thermal.ccTemperatureLoadFast(best));
0067     balance_LL(1,freq_chan)= freq_chan;
0068 end
0069 
0070 % Zero data where there was no balance (will be Nan in balance_LL)
0071 nans=isnan(balance_LL(2,:));
0072 balance_LL(2,nans)=0;
0073 plot(balance_LL(1,:),balance_LL(2,:),'.')
0074 
0075 % Now weight the data by the 1/Tsys^2
0076 
0077 weights = 1./(Tsys(1,:)).^2; % Tsys should roughly be same in file above - calculated for each of channel 1,2,3,4 in power mode
0078 
0079 %weights(nans)=0; % remove data where Tsys estimated as nan
0080 sum_of_weights_r1 = sum(weights(1:64));
0081 sum_of_weights_r2 = sum(weights(65:128));
0082 %LL = [d.antenna0.roach1.LL,d.antenna0.roach2.LL];
0083 %weighted_LL= zeros(size(LL));
0084 
0085 
0086 for freq_chan= 1:64
0087     weighted_LL_r1(:,freq_chan) =  (weights(freq_chan).*LL(:,freq_chan));
0088     %weighted_load(:,freq_chan)= LL_load(:,freq_chan)./sum_of_weights;
0089 end
0090 for freq_chan= 65:128
0091     weighted_LL_r2(:,freq_chan) =  (weights(freq_chan).*LL(:,freq_chan));
0092     %weighted_load(:,freq_chan)= LL_load(:,freq_chan)./sum_of_weights;
0093 end
0094 LL_weighted_freq_r1 = sum(weighted_LL_r1,2)./sum_of_weights_r1;
0095 LL_freq_r1= mean(LL,2);
0096 LL_weighted_freq_r2 = sum(weighted_LL_r2,2)./sum_of_weights_r2;
0097 LL_r1= LL(:,1:64);
0098 LL_r2 = LL(:,65:128);
0099 LL_r1_freq= mean(LL_r1,2);
0100 LL_r2_freq= mean(LL_r2,2);
0101 
0102 LL_load_r1 = LL_load(:,1:64);
0103 LL_load_r2 = LL_load(:,65:128);
0104 LL_load_r1_freq = mean(LL_load_r1,2);
0105 LL_load_r2_freq = mean(LL_load_r2,2);
0106 
0107 
0108 figure(1)
0109 plot(LL_r1_freq)
0110 hold all
0111 plot(LL_load_r1_freq)
0112 plot(LL_weighted_freq_r1)
0113 title('LL Roach 1')
0114 
0115 
0116 
0117 figure(2)
0118 plot(LL_r2_freq)
0119 hold all
0120 plot(LL_load_r2_freq)
0121 plot(LL_weighted_freq_r2)
0122 title('LL Roach 2')
0123 
0124 figure(1)
0125 plot(LL_r1_freq)
0126 hold all
0127 plot(LL_load_r1_freq)
0128 plot(LL_weighted_freq_r1)
0129 title('LL Roach 1')
0130 
0131 
0132 figure(1)
0133 plot(LL_r1_freq)
0134 hold all
0135 plot(LL_load_r1_freq)
0136 plot(LL_weighted_freq_r1)
0137 title('LL Roach 1')
0138 
0139 
0140 figure(3)
0141 plot(balance_LL(2,1:64),Tsys(1,1:64),'.')
0142 title('Balance vs Tsys, Roach 1')
0143 xlabel('Balance point, K')
0144 ylabel('Tsys, K')
0145 ylim([0 100])
0146 grid on
0147 
0148 figure(4)
0149 plot(balance_LL(2,65:128),Tsys(1,65:128),'.')
0150 title('Balance vs Tsys, Roach 2')
0151 xlabel('Balance point, K')
0152 ylabel('Tsys, K')
0153 grid on
0154 ylim([0 100])
0155 
0156 figure(5)
0157 plot(balance_LL(2,1:64),weights(1,1:64),'.')
0158 title('Balance vs Weighting, Roach 1')
0159 xlabel('Balance point, K')
0160 ylabel('weighting')
0161 grid on
0162 
0163

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