0001 function TauARaster_quick2(nchan,plot_labels,save_path,source_name,start_date,IntensityType,calmat)
0002
0003
0004 [home,installeddir] = where_am_i();
0005 maindir= [home,'/',installeddir,'/',save_path,'/'];
0006 filename = ([maindir,start_date,'_',source_name,'_',IntensityType]);
0007 load([filename,'_dgood.mat'])
0008
0009 load([filename,'_PA_IQUV.mat']);
0010
0011 [antenna_no antenna_name] = identifyTelescope(dgood);
0012 telescope_constants
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 n=0
0026 cell_size=0.1
0027 clims{1} = [-1 1]*620;
0028 clims{2} = [-0.1 0.1]*620;
0029 clims{3} = [-0.1 0.1]*620;
0030 clims{4} = [-1 1]*620;
0031
0032 [s e] = findStartStop(dgood.index.radio_point_scan.fast);
0033
0034
0035 azOffSaveP = zeros(size(dgood.antenna0.receiver.data(:,1)));
0036 elOffSaveP = zeros(size(dgood.antenna0.receiver.data(:,1)));
0037 dataP = zeros(size(dgood.antenna0.receiver.data(:,1)));
0038 AZ= zeros(size(dgood.antenna0.receiver.data(:,1)));
0039 EL= zeros(size(dgood.antenna0.receiver.data(:,1)));
0040 DEC= zeros(size(dgood.antenna0.receiver.data(:,1)));
0041 RA = zeros(size(dgood.antenna0.receiver.data(:,1)));
0042 points = zeros(size(dgood.antenna0.receiver.data(:,1)));
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 dgood.azApp = interp1(dgood.antenna0.tracker.utc,dgood.antenna0.tracker.horiz_topo(:,1), dgood.antenna0.receiver.utc);
0054 dgood.azOffSave = dgood.azApp - dgood.antenna0.servo.apparent(:,1);
0055 dgood.azOffSave = -dgood.azOffSave;
0056 dgood.azOffSave = dgood.azOffSave.*cos(dgood.antenna0.servo.el*pi/180);
0057
0058
0059
0060 dgood.elApp = interp1(dgood.antenna0.tracker.utc,dgood.antenna0.tracker.horiz_topo(:,2), dgood.antenna0.receiver.utc);
0061 dgood.elOffSave = dgood.elApp - dgood.antenna0.servo.apparent(:,2);
0062 dgood.elOffSave = -dgood.elOffSave;
0063 angle = sqrt(dgood.elOffSave.^2 + dgood.azOffSave.^2);
0064
0065
0066 for m=good_rasters;
0067 ind = zeros(size(dgood.index.radio_point_scan.fast));
0068 ind(s(m)+1000:e(m)) = 1;
0069 ind = logical(ind);
0070 dcut = framecut(dgood, ind);
0071
0072
0073
0074 azOffSaveP(ind)=dcut.azOffSave - gfit{m,1}.x0*cell_size;
0075 elOffSaveP(ind)=dcut.elOffSave - gfit{m,1}.y0*cell_size;
0076 dataP(ind,1:nchan)=dcut.antenna0.receiver.data(:,1:nchan);
0077 timeP(ind) = dcut.antenna0.receiver.utc;
0078 AZ(ind) = deg2rad(dcut.antenna0.servo.apparent(:,1));
0079 EL(ind) = deg2rad(dcut.antenna0.servo.apparent(:,2));
0080
0081
0082
0083 dcut=calcRADECcurrent(dcut);
0084 DEC(ind) = (dcut.antenna0.servo.equa(:,2));
0085 RA(ind) = (dcut.antenna0.servo.equa(:,1));
0086
0087 points(ind)=1;
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109 end
0110
0111 points = logical(points);
0112 clear dcut
0113 clear dgood ind
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128 close all
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141 close all
0142
0143
0144
0145
0146 if(exist('calmat'))
0147 calmat
0148
0149 calmat1=calmat(:,[1,3,5]);
0150 calmat2=calmat(:,[2,4,6]);
0151
0152 invcalmat1 = inv(calmat1);
0153 invcalmat2 = inv(calmat2);
0154
0155
0156
0157
0158 for i=1:length(dataP(:,1));
0159 dataP(i,[1,2,3])=dataP(i,[1,2,3])*invcalmat1;
0160 dataP(i,[8,4,5])=dataP(i,[8,4,5])*invcalmat2;
0161 end
0162 end
0163
0164
0165
0166 if(nchan==9)
0167
0168 dataP(:,9) = (dataP(:,1)-dataP(:,8))/2 ;
0169 meanQ = (dataP(:,2)+dataP(:,4))/2;
0170 meanU = (dataP(:,3)+dataP(:,5))/2;
0171 meanI = (dataP(:,1)+dataP(:,8))/2;
0172 dataP(:,10) = meanI;
0173 dataP(:,11) = meanQ;
0174 dataP(:,12) = meanU;
0175 dataP(:,13) = sqrt(dataP(:,2).^2 + dataP(:,3).^2);
0176 dataP(:,14) = sqrt(dataP(:,4).^2 + dataP(:,5).^2);
0177 dataP(:,15) = sqrt(meanU.^2 + meanQ.^2);
0178 labels=plot_labels;
0179 labels(10:18) = {'I','Q','U','P1 (timestream)','P2 (timestream)','P (timestream)','P1 (from Q1,U1 maps)','P2 (from Q2,U2 maps)','P (from Q,U maps)'},
0180 chanstoplot=[1,2,3,13,8,4,5,14,10,11,12,15];
0181 plotnums = [1,2,3,4 ,6,7,8,9 ,11,12,13,14];
0182 chanstofit=[1,8];
0183 else
0184 disp(['Need to fix this for CBASS-S'])
0185 end
0186 clear meanI meanQ meanU
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198 close all
0199 figure
0200
0201 num=0
0202 for (chan=chanstoplot);
0203 num=num+1;
0204 plotnum=plotnums(num);
0205 subplot(3,5,plotnum);
0206 xp=azOffSaveP(points);
0207 yp=elOffSaveP(points);
0208 data=dataP(points,chan);
0209 a = (isnan(xp) | isnan(yp));
0210 [x y z h] = gridcbass2(xp,yp,data,0.05,2,1,1);
0211
0212 clear xp yp
0213
0214 xx{chan}=x;
0215 yy{chan}=y;
0216 zz{chan}=z;
0217 clear x y z;
0218
0219 zz{chan}(zz{chan}==0)=NaN;
0220 bb{chan}=inpaint_nans(zz{chan},1);
0221
0222 imagesc(bb{chan});
0223 colorbar;
0224 xlabel(labels{chan});
0225 axis equal
0226 end
0227 plotnum=5;
0228 matnum=15;
0229 for chan=[2,4,11];
0230 matnum=matnum+1;
0231 bb{matnum}=(sqrt(bb{chan}.^2 +bb{chan+1}.^2));
0232 subplot(3,5,plotnum);
0233 imagesc(bb{matnum});
0234 colorbar;
0235 xlabel(labels{matnum});
0236 axis equal;
0237 plotnum=plotnum+5;
0238 if(exist('calmat'));
0239 gtitle(['Calibrated, NO PA rotation, binned maps -', source_name,'_',IntensityType])
0240 print('-f1','-dpng',[maindir,'CALMAT_noPArot_binned_map_',source_name,'_',IntensityType,'_',start_date,'.png'])
0241 else
0242 gtitle(['Un-calibrated, NO PA rotation, binned maps -', source_name,'_',IntensityType])
0243 print('-f1','-dpng',[maindir,'Uncal_noPArot_binned_map_',source_name,'_',IntensityType,'_',start_date,'.png'])
0244 end
0245
0246 end
0247
0248
0249
0250
0251
0252
0253
0254 pnum=0;
0255
0256 for chan=chanstofit;
0257 pnum=pnum+1;
0258
0259 XII=xx{1};
0260
0261 YII=yy{1};
0262 ZII=bb{chan};
0263
0264
0265 [sf gof t] = gauss2D_fit_act(XII,YII,ZII);
0266 big_gfit{chan} = sf;
0267 x_off = big_gfit{chan}.x0;
0268 y_off = big_gfit{chan}.y0;
0269 XII = XII-x_off;
0270 YII = YII-y_off;
0271
0272 angle = sqrt(XII.^2 + YII.^2);
0273 ang=reshape(angle,1,81*81);
0274 zinew = reshape(bb{chan},1,81*81);
0275
0276 extrap_max =1;
0277 figure;
0278
0279
0280
0281
0282 x = ang;
0283 y = zinew./extrap_max;
0284
0285 topEdge = 5;
0286 botEdge = 0;
0287
0288 binWidth = 0.05;
0289 numBins = topEdge/binWidth;
0290
0291 binEdges = linspace(botEdge, topEdge, numBins+1);
0292 [h,whichBin] = histc(x, binEdges);
0293
0294 for i = 1:numBins
0295 flagBinMembers = (whichBin == i);
0296 binMembers = y(flagBinMembers);
0297 binMean(i) = nanmean(binMembers);
0298 binStd(i) = nanstd(binMembers);
0299 xbinMembers = x(flagBinMembers);
0300 xbinMean(i) = nanmean(xbinMembers);
0301 end
0302
0303
0304 if(chan==1)
0305 Ibeam_max = max(binMean);
0306 end
0307 binCentres = binEdges +(binWidth)/2;
0308
0309
0310
0311
0312
0313
0314
0315 figure(19)
0316 subplot(1,2,pnum);
0317 n_cuts = 2;
0318 object='TauA';
0319 fit_lim = 0.8;
0320 [mean_power_ZP mean_power_P sim_beam sim_data sim_angles phi vals_sim FWHM_sim sim_fit_angles simfile] = read_sim_beam_freq(n_cuts, fit_lim,object);
0321
0322
0323 plot(xbinMean,binMean./Ibeam_max);
0324
0325 if(chan==1)
0326 errorbar(xbinMean,binMean./Ibeam_max,binStd(1:end)./Ibeam_max);
0327 hold all;
0328 plot(sim_beam(:,1),sim_beam(:,2)/max(sim_beam(:,2)));
0329 end
0330 grid on;
0331 xlim([0 4]);
0332
0333
0334
0335
0336
0337
0338 legend(labels{chan})
0339 end
0340
0341 ylim([0 max(binMean./Ibeam_max)*1.2]);
0342
0343
0344 if(exist('calmat'))
0345 gtitle(['Calibrated,azimuthally binned beam profile (I) - ', source_name,'_',IntensityType]);
0346
0347 print('-f19','-dpng',[maindir,'CALMAT_AzimuthalBeam_',source_name,'_',IntensityType,'_',start_date,'.png'])
0348 else
0349 gtitle(['Un-calibrated,azimuthally binned beam profile (I) - ', source_name,'_',IntensityType]);
0350 print('-f19','-dpng',[maindir,'AzimuthalBeam_',source_name,'_',IntensityType,'_',start_date,'.png'])
0351 end
0352 close all
0353
0354
0355
0356
0357
0358
0359
0360
0361 I= dataP(points,10);
0362 Q= dataP(points,11);
0363 U= dataP(points,12);
0364 V= dataP(points,9);
0365 P= dataP(points,15);
0366 time_cut = timeP(points);
0367
0368
0369
0370
0371
0372
0373
0374
0375 DEC= DEC(points);
0376 RA = RA(points);
0377
0378
0379
0380
0381 LAT_D = antenna_latitude(antenna_no)
0382 LON_D = antenna_longitude(antenna_no)
0383
0384 LAT = deg2rad(LAT_D);
0385 LON = deg2rad(LON_D);
0386 JD = mjd2jd(time_cut);
0387 LST=lst(JD,deg2rad(LON_D),'m');
0388
0389
0390 clear dataP timeP xx yy bb zz;
0391 clear mean_power_ZP mean_power_P sim_beam sim_data sim_angles phi vals_sim FWHM_sim sim_fit_angles simfile;
0392 clear JD;
0393
0394 cwd = pwd;
0395 cd(tempdir);
0396 pack
0397 cd(cwd)
0398
0399 whos
0400 [PA]=parallactic_angle(((RA)),((DEC)),(LST),(LAT));
0401 PA_D = rad2deg(PA);
0402
0403
0404
0405
0406
0407 Qc = Q.*cos(2*PA) - U.*sin(2*PA) ;
0408 Uc = U.*cos(2*PA) + Q.*sin(2*PA) ;
0409 Pc = sqrt(Qc.^2 + Uc.^2);
0410
0411
0412 scrsz = get(0,'ScreenSize');
0413
0414
0415 close all
0416 figure(22)
0417
0418 ax(1)=subplot(3,2,1);
0419 h(1)=plot(time_cut,I,'r');
0420 xlabel('I')
0421 if(~exist('calmat'))
0422 ylim([0 2])
0423 end
0424
0425 ax(4)= subplot(3,2,2);
0426 h(4)=plot(time_cut,V,'k');
0427 xlabel('V ')
0428
0429
0430 ax(2)=subplot(3,2,3);
0431 h(2)=plot(time_cut,Q,'g');
0432 xlabel('Q - no PA correction')
0433 if(~exist('calmat'))
0434 ylim([-0.1 0.1])
0435 end
0436
0437 ax(3)=subplot(3,2,4);
0438 h(3)=plot(time_cut,U,'b');
0439 xlabel('U - no PA correction')
0440 if(~exist('calmat'))
0441 ylim([-0.1 0.1])
0442 end
0443
0444 ax(5)= subplot(3,2,5);
0445 h(5)=plot(time_cut,P,'k');
0446 xlabel('P - no PA correction');
0447 if(~exist('calmat'))
0448 ylim([0 0.1])
0449 end
0450
0451 ax(6)=subplot(3,2,6);
0452 h(6)=plot(time_cut,PA_D);
0453 xlabel('Parallactic angle.deg')
0454
0455 linkaxes(ax,'x');
0456
0457 if(exist('calmat'))
0458 gtitle('Calibrated - no PA rotation')
0459 print('-f22','-dpng',[maindir,'CALMAT_IQUV_1_',source_name,'_',IntensityType,'_',start_date,'.png'])
0460 else
0461 gtitle('No calibration - no PA rotation')
0462 print('-f22','-dpng',[maindir,'IQUV_1_',source_name,'_',IntensityType,'_',start_date,'.png'])
0463 end
0464
0465
0466 figure(23)
0467 ax(1)=subplot(3,2,1);
0468 h(1)=plot(time_cut,I,'r');
0469 xlabel('I')
0470 if(~exist('calmat'))
0471 ylim([0 2])
0472 end
0473
0474 ax(4)= subplot(3,2,2);
0475 h(4)=plot(time_cut,V,'k');
0476 xlabel('V ')
0477
0478 ax(2)=subplot(3,2,2);
0479 h(2)=plot(time_cut,Qc,'g');
0480 xlabel('Q')
0481 if(~exist('calmat'))
0482 ylim([-0.1 0.1])
0483 end
0484
0485 ax(3)=subplot(3,2,3);
0486 h(3)=plot(time_cut,Uc,'b');
0487 xlabel('U')
0488 if(~exist('calmat'))
0489 ylim([-0.1 0.1])
0490 end
0491
0492 ax(4)= subplot(3,2,4);
0493 h(4)=plot(time_cut,Pc,'k');
0494 xlabel('P')
0495 if(~exist('calmat'))
0496 ylim([0 0.1])
0497 end
0498
0499 ax(5)=subplot(3,2,5);
0500 h(5)=plot(time_cut,PA_D);
0501 xlabel('Parallactic angle, deg')
0502 linkaxes(ax,'x');
0503
0504 if(exist('calmat'))
0505 gtitle('Calibrated - PA rotated')
0506 print('-f23','-dpng',[maindir,'CALMAT_IQUV_2_',source_name,'_',IntensityType,'_',start_date,'.png'])
0507 else
0508 gtitle('No calibration - PA rotated')
0509 print('-f23','-dpng',[maindir,'IQUV_2_',source_name,'_',IntensityType,'_',start_date,'.png'])
0510 end
0511
0512
0513
0514 close all
0515
0516 datac = [I Qc Uc V Pc];
0517 labels_small={'I','Q','U','V','P timestream','P maps'};
0518 for (chan=1:5)
0519 subplot(2,3,chan);
0520 xp=azOffSaveP(points);
0521 yp=elOffSaveP(points);
0522 data = datac(:,chan);
0523 clear datac;
0524 a = (isnan(xp) | isnan(yp));
0525 [x y z h] = gridcbass2(xp,yp,data,0.1,2,1,1);
0526
0527
0528
0529
0530
0531
0532
0533
0534 xx{chan}=x;
0535 yy{chan}=y;
0536 zz{chan}=z;
0537 clear x y z;
0538
0539 zz{chan}(zz{chan}==0)=NaN;
0540 bb{chan}=inpaint_nans(zz{chan},1);
0541
0542 imagesc(bb{chan});
0543 xlabel(labels_small{chan});
0544 colorbar;
0545 axis equal
0546
0547 end
0548
0549
0550 bb{6}=(sqrt(bb{2}.^2 +bb{3}.^2)) ;
0551 chan=6;
0552 subplot(2,3,chan);
0553 imagesc(bb{chan});
0554 colorbar;
0555 xlabel(labels_small{chan});
0556 axis equal;
0557
0558 if(exist('calmat'))
0559 gtitle(['Calibrated and PA rotated binned maps - ', source_name,'_',IntensityType]);
0560 print('-f1','-dpng',[maindir,'CALMAT_Binned_PArotated_map_',source_name,'_',IntensityType,'_',start_date,'.png'])
0561 else
0562 gtitle(['Un-calibrated but PA rotated binned maps - ', source_name,'_',IntensityType]);
0563 print('-f1','-dpng',[maindir,'Binned_PArotated_map_',source_name,'_',IntensityType,'_',start_date,'.png'])
0564 end
0565 close all
0566
0567
0568 ZI_Q = bb{2};
0569 ZI_U = bb{3};
0570 ZI_P = bb{5};
0571
0572 figure(100)
0573 Chi = 0.5*atan(ZI_U./ZI_Q);
0574 [u,v] = pol2cart(Chi,ZI_P);
0575
0576
0577
0578 contour(ZI_P);
0579 hold on
0580 quiver(u,v);
0581
0582
0583 if(exist('calmat'))
0584 gtitle(['Calibrated and PA rotated Polarization map - ', source_name,'_',IntensityType]);
0585 print('-f100','-dpng',[maindir,'CALMAT_Binned_PArotated_Polmap_',source_name,'_',IntensityType,'_',start_date,'.png'])
0586 else
0587 gtitle(['Un-calibrated but PA rotated Polarization map - ', source_name,'_',IntensityType]);
0588 print('-f100','-dpng',[maindir,'Binned_PArotated_Polmap_',source_name,'_',IntensityType,'_',start_date,'.png'])
0589 end
0590
0591
0592
0593
0594
0595
0596
0597
0598
0599
0600
0601
0602
0603
0604
0605
0606
0607
0608
0609
0610
0611
0612
0613
0614
0615
0616
0617
0618
0619
0620
0621
0622
0623
0624
0625
0626
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637
0638
0639
0640