0001
0002 function [d,TauAmap, azOffSave, elOffSave,xidx,yidx,LL, RR, L1, L2, QQ, UU, mask,sf] = south_beam_maps_quick(start_date,stop_date,comment)
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 d = read_arcSouth(start_date,stop_date)
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 [d LL RR L1 L2 QQ UU mask] = cbassS2N(d,1);
0051
0052 nchan=4
0053 plot_labels = {'LL','RR','QQ','UU'};
0054 chan_order=[1 6 2 3];
0055
0056
0057
0058
0059 [s e] = findStartStop(d.index.beammap.fast);
0060 dgood = d;
0061 n=0
0062
0063
0064 for m= 1:length(s)
0065 n = n+1;
0066 ind = zeros(size(d.index.beammap.fast));
0067 ind(s(m):e(m)) = 1;
0068 ind = logical(ind);
0069
0070
0071
0072
0073
0074 dcut = framecut(d, ind);
0075
0076 azApp = interp1(dcut.antenna0.tracker.utc, ...
0077 dcut.antenna0.tracker.horiz_topo(:,1), dcut.antenna0.receiver.utc);
0078 azOffSave = (azApp) - dcut.antenna0.servo.apparent(:,1);
0079 azOffSave = -azOffSave;
0080
0081 azOffSave = azOffSave.*cos(dcut.antenna0.servo.el*pi/180);
0082
0083 elApp = interp1(dcut.antenna0.tracker.utc, ...
0084 dcut.antenna0.tracker.horiz_topo(:,2), dcut.antenna0.receiver.utc);
0085 elOffSave = elApp - dcut.antenna0.servo.apparent(:,2);
0086 elOffSave = -elOffSave;
0087
0088
0089 angle = sqrt(elOffSave.^2 + azOffSave.^2);
0090
0091
0092 for chan = chan_order
0093
0094 temp_data = dcut.antenna0.receiver.data(:,chan);
0095 temp_time = dcut.antenna0.receiver.utc;
0096
0097 temp_y = temp_data(angle>2);
0098 temp_x = temp_time(angle>2);
0099
0100
0101
0102
0103
0104
0105
0106
0107 ignore = isnan(temp_y);
0108 p = polyfit(temp_x(~ignore),temp_y(~ignore),1);
0109
0110
0111
0112
0113 all_time = temp_time;
0114 f = polyval(p,all_time);
0115
0116
0117 dcut.antenna0.receiver.data(:,chan) = dcut.antenna0.receiver.data(:,chan) - f;
0118
0119 dgood.antenna0.receiver.data(ind,chan)=dcut.antenna0.receiver.data(:,chan);
0120
0121
0122 clear temp_data temp_time temp_x temp_y p f all_time
0123 end
0124 end
0125
0126
0127 close all
0128 figure(1)
0129 nchan=4
0130 plot_labels={'LL','RR','QQ','UU'}
0131
0132 points = (dgood.index.beammap.fast==1);
0133
0134 for i=1:nchan
0135 if i<7
0136 figure(1)
0137 subplot(2,3,i)
0138
0139 else
0140 figure(2)
0141 nplot=i-6;
0142 subplot(2,2,nplot)
0143
0144 end
0145
0146
0147
0148 plot(dgood.antenna0.receiver.utc(points),dgood.antenna0.receiver.data(points,chan_order(i)))
0149 xlabel(plot_labels{i})
0150 gtitle('Pipeline calibrated and detrended data')
0151 end
0152
0153
0154 d= framecut(dgood,dgood.index.beammap.fast);
0155 azApp = interp1(d.antenna0.tracker.utc, ...
0156 d.antenna0.tracker.horiz_topo(:,1), d.antenna0.roach2.utc);
0157 azOffSave = (azApp - d.antenna0.servo.apparent(:,1));
0158 azOffSave = -wrap180(azOffSave);
0159 azOffSave = azOffSave.*cosd(d.antenna0.servo.el);
0160
0161 elApp = interp1(d.antenna0.tracker.utc, ...
0162 d.antenna0.tracker.horiz_topo(:,2), d.antenna0.roach2.utc);
0163 elOffSave = elApp - d.antenna0.servo.apparent(:,2);
0164 elOffSave = -elOffSave;
0165 d.angle = sqrt(elOffSave.^2 + azOffSave.^2);
0166 d.elOffSave = elOffSave;
0167 d.azOffSave= azOffSave;
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232 disp([ 'Plotting the raster: '] )
0233 azOffRaster=d.azOffSave;
0234 elOffRaster=d.elOffSave;
0235 pixel_size = 0.15;
0236
0237 azmin=-5.0
0238 azmax=5.0
0239 elmin=-5.0
0240 elmax=5.0
0241
0242
0243
0244
0245 colmin = 0
0246 colmax = 1e5
0247
0248 for i=1:4
0249 [TauAmap{i}, xidx, yidx, TauAmapIdx{i}] = bin_quickly2d(azmin, azmax, elmin, elmax, pixel_size,...
0250 azOffRaster, elOffRaster,d.antenna0.receiver.data(:,chan_order(i)));
0251
0252
0253 figure(1)
0254 subplot(2,2,i)
0255
0256 imagesc(fliplr(xidx),fliplr(yidx),TauAmap{i})
0257 colormap('default')
0258 title(plot_labels{i})
0259 axis equal
0260 ylim( [elmin elmax] )
0261 xlim( [azmin azmax] )
0262 colorbar
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272 end
0273
0274
0275 disp( 'Look at cuts through the beam' )
0276
0277 figure(5)
0278 climI = [0 1e5]
0279 colormap('default')
0280 imagesc(TauAmap{1})
0281 title('Please click on the centre of the LL beam pattern')
0282 [usr_TrigAz1 usr_TrigEl1] = ginput(1);
0283 figure(5)
0284 imagesc(TauAmap{2})
0285 title('Please click on the centre of the RR beam pattern')
0286 [usr_TrigAz2 usr_TrigEl2] = ginput(1);
0287 figure(5)
0288 imagesc(TauAmap{3})
0289 title('Please click on the centre of the QQ beam pattern')
0290 [usr_TrigAz3 usr_TrigEl3] = ginput(1);
0291 figure(5)
0292 imagesc(TauAmap{4})
0293 title('Please click on the centre of the UU beam pattern')
0294 [usr_TrigAz4 usr_TrigEl4] = ginput(1);
0295
0296 usr_TrigAz = mean( [usr_TrigAz1 usr_TrigAz2 usr_TrigAz3 usr_TrigAz4] );
0297 usr_TrigEl = mean( [usr_TrigEl1 usr_TrigEl2 usr_TrigEl3 usr_TrigEl4] );
0298
0299 usr_TrigAz = round( usr_TrigAz );
0300 usr_TrigEl = round( usr_TrigEl );
0301
0302
0303 figure(5)
0304 subplot(2,4,1)
0305 plot((TauAmap{1}(usr_TrigEl,:)))
0306 ylabel( 'LL' )
0307 xlabel( 'Azimuth' )
0308 subplot(2,4,5)
0309 plot((TauAmap{1}(:,usr_TrigAz)))
0310 ylabel( 'LL' )
0311 xlabel( 'Elevation' )
0312
0313
0314 subplot(2,4,2)
0315 plot(TauAmap{2}(usr_TrigEl,:))
0316 ylabel( 'RR' )
0317 xlabel( 'Azimuth' )
0318 subplot(2,4,6)
0319 plot(TauAmap{2}(:,usr_TrigAz))
0320 ylabel( 'RR' )
0321 xlabel( 'Elevation' )
0322
0323 subplot(2,4,3)
0324 plot(TauAmap{3}(usr_TrigEl,:))
0325 ylabel( 'QQ' )
0326 xlabel( 'Azimuth' )
0327 subplot(2,4,7)
0328 plot(TauAmap{3}(:,usr_TrigAz))
0329 ylabel( 'QQ' )
0330 xlabel( 'Elevation' )
0331
0332 subplot(2,4,4)
0333 plot(TauAmap{4}(usr_TrigEl,:))
0334 ylabel( 'UU' )
0335 xlabel( 'Azimuth' )
0336 subplot(2,4,8)
0337 plot(TauAmap{4}(:,usr_TrigAz))
0338 ylabel( 'UU' )
0339 xlabel( 'Elevation' )
0340
0341
0342 figure(30)
0343 imagesc(fliplr(xidx),fliplr(yidx),TauAmap{1},[0 300])
0344
0345 xlabel('Az offset, deg');
0346 ylabel('El offset, deg');
0347 title(['Raster of ',num2str(start_date)]);
0348 axis equal
0349
0350 map_name=['MirrorMap_',start_date,'_',comment,'.png'];
0351 print('-f30','-dpng',map_name)
0352
0353 [X,Y]=meshgrid(xidx,yidx);
0354 [sf gof t] = Egauss2D_fit_act(X,Y,TauAmap{1,1});
0355
0356 fwhm_x = 2*sqrt(2*log(2)).*sf.sigma_x
0357 fwhm_y = 2*sqrt(2*log(2)).*sf.sigma_y
0358 amplitude=sf.a1
0359 x0=sf.x0
0360 y0=sf.y0
0361 theta=sf.theta
0362
0363
0364 filename = 'Dish_Focussing.dat';
0365 fid = fopen(filename, 'a+');
0366
0367 data2save={start_date, comment, x0,y0,theta,fwhm_x,fwhm_y};
0368 fprintf( fid,'%s %s %d %d %d %d %d\n', data2save{1,:})
0369
0370 fclose(fid);
0371 end
0372
0373