Home > reduc > plotting > plot_sourcesAll.m

plot_sourcesAll

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function [sources] = plot_sourcesAll(d,withfig,root_name)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Function to plot data and identify which sources have been observed
 Particularly useful for seeing what calibrator sources were looked at- 
 This version is based on plot_sources (by ACT) ans instead of a single
 channel plots all 6 channels together with titles on the plots. It also
 returns a handle to the axes used so that the axis limits can be set.
 This is done as follows:
 ylim(ax(1),[22 30]); sets the ylimits for the first plot (I1)
 xlim(ax(2),[22 30]); sets the ylimits for the second plot (Q1)
 Note that to get this working I needed to adapt the subplot.m function to
 space out the plots a bit more- this will be stored as subplot2.m
 Have now remove subplot2.m as it seemed to crash MACS and will work on a
 better implementation of spacing the title.
 act - 16/7/2010
 CJC - 30/9/2010
 CJC - 2/11/2010
 act - 7/11/2010  -> add option to write to file & adapted layout 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [sources] =  plot_sourcesAll(d,withfig,root_name)
0002 
0003 
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 % Function to plot data and identify which sources have been observed
0006 % Particularly useful for seeing what calibrator sources were looked at-
0007 % This version is based on plot_sources (by ACT) ans instead of a single
0008 % channel plots all 6 channels together with titles on the plots. It also
0009 % returns a handle to the axes used so that the axis limits can be set.
0010 % This is done as follows:
0011 % ylim(ax(1),[22 30]); sets the ylimits for the first plot (I1)
0012 % xlim(ax(2),[22 30]); sets the ylimits for the second plot (Q1)
0013 % Note that to get this working I needed to adapt the subplot.m function to
0014 % space out the plots a bit more- this will be stored as subplot2.m
0015 % Have now remove subplot2.m as it seemed to crash MACS and will work on a
0016 % better implementation of spacing the title.
0017 % act - 16/7/2010
0018 % CJC - 30/9/2010
0019 % CJC - 2/11/2010
0020 % act - 7/11/2010  -> add option to write to file & adapted layout
0021 %
0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0023 
0024 
0025 
0026 % To plot the source data and name it - names of sources are stored in
0027 %     d.antenna0.tracker.source
0028 % The associated times of these frames is in:
0029 %    d.antenna0.tracker.utc
0030 
0031 % First check to see if we want to display the figure or save to file
0032 if (withfig == 1)
0033     h = figure('visible','off');
0034 else
0035     figure
0036 end
0037 
0038 
0039 %First find sources observed
0040 
0041 %figure
0042 titlename{1}='I1';
0043 titlename{2}='Q1';
0044 titlename{3}='-U1';
0045 titlename{4}='Q2';
0046 titlename{5}='U2';
0047 titlename{6}='I2';
0048 %hold
0049 for k=1:6
0050 
0051 sources = unique(d.antenna0.tracker.source);
0052 channel=k;
0053 
0054 if (k==1)
0055     ax(k) = subplot(18,1,1:4);
0056 else
0057     ax(k) = subplot(18,1,2*k+1:2*k+2);
0058 end
0059 
0060 %ax(2) = subplot(6,1,3:4);
0061 for i = 1:length(sources);
0062 
0063     test = strcmp(sources(i),d.antenna0.tracker.source);
0064     
0065     % Grab the data for this source and plot it
0066     
0067     testData = framecut(d,test);
0068          
0069     hh(i)=plot(ax(k),86400*(testData.antenna0.receiver.utc-d.antenna0.receiver.utc(1)),testData.antenna0.receiver.data(:,channel),'p');
0070    % hold
0071  %   h(2*i)=plot(ax(2),86400*(testData.antenna0.receiver.utc-d.antenna0.receiver.utc(1)),testData.antenna0.receiver.data(:,2),'p');
0072    % hold(ax(2))
0073     hold all
0074     clear test
0075     clear testData;
0076     
0077 end
0078 
0079 
0080 % Now add places where there is skydips and noise cal
0081 % First we see if there's any skydip data
0082 
0083 j=i+1;
0084 
0085 
0086 if(length(find(d.index.skydip.fast))==0)
0087   display('no sky dips in your data');
0088 else
0089     skydip = framecut(d,d.index.skydip.fast);
0090     hh(j) = plot(ax(k),86400*(skydip.antenna0.receiver.utc-d.antenna0.receiver.utc(1)),skydip.antenna0.receiver.data(:,channel),'kp');
0091     set(gca,'xtick',[]);
0092     hold all
0093     %h(j) = plot(ax(2),86400*(skydip.antenna0.receiver.utc-d.antenna0.receiver.utc(1)),skydip.antenna0.receiver.data(:,channel),'kp');
0094 
0095     clear skydip;
0096     sources(j) = cellstr('skydip')';
0097     j = j+1;
0098 end
0099 
0100 %Next look for noise source data
0101 
0102 if(length(find(d.index.noise.fast))==0)
0103   display('no noise source events in your data');
0104 else
0105   noise = framecut(d,d.index.noise.fast);
0106     hh(j) = plot(ax(k),86400*(noise.antenna0.receiver.utc-d.antenna0.receiver.utc(1)),noise.antenna0.receiver.data(:,channel), ...
0107      'mo', ...
0108         'LineWidth',2,...
0109         'MarkerEdgeColor','m',...
0110         'MarkerFaceColor',[.49 1 .63],...
0111         'MarkerSize',8);
0112     set(gca,'xtick',[]);
0113    % h(j) = plot(ax(2),86400*(noise.antenna0.receiver.utc-d.antenna0.receiver.utc(1)),noise.antenna0.receiver.data(:,channel), ...
0114    %  'mo', ...
0115    %     'LineWidth',2,...
0116    %     'MarkerEdgeColor','m',...
0117    %     'MarkerFaceColor',[.49 1 .63],...
0118    %     'MarkerSize',8);
0119     clear noise;
0120     sources(j) = cellstr('noise');
0121     j = j+1;
0122 end
0123 
0124 
0125 % Update legend names
0126 if k==1
0127     legend(hh,sources(1:length(sources)),'Location','NorthOutside','Orientation','horizontal' );
0128 end
0129 %xlabel('UTC');
0130 %ylabel('Nominal units');
0131 ylabel(titlename{k},'Rotation', 0.0);
0132 %title(['Channel ', num2str(channel) ,' raw data  ', titlename{k}]);
0133 
0134 end
0135 
0136 
0137 
0138 
0139 % Also plot the azimuth and elevation tied to the same x -axis
0140 
0141 ax(7) = subplot(18,1,15:16);
0142 
0143 plot(ax(7),86400*(d.antenna0.receiver.utc-d.antenna0.receiver.utc(1)), d.antenna0.servo.el);
0144 set(gca,'xtick',[])
0145 ylabel({'El      ';'deg    '},'Rotation', 0.0);
0146 
0147 ax(8) = subplot(18,1,17:18);
0148 
0149 plot(ax(8),86400*(d.antenna0.receiver.utc-d.antenna0.receiver.utc(1)), d.antenna0.servo.az);
0150 set(gca,'xtick',[])
0151 ylabel({'Az   ';'deg   '},'Rotation', 0.0);
0152 xlabel('Elapsed Time [s]')
0153 set(gca,'xtickMode', 'auto')
0154 linkaxes(ax,'x');
0155 
0156 if (withfig ==1)
0157 
0158     saveas(h,[root_name,'sources.png'],'png');
0159 end
0160 sources
0161 %ylim(ax(1),[22 30]);
0162 %ylim(ax(2),[-5 -1]);
0163 %ylim(ax(3),[8 12]);
0164 %ylim(ax(4),[-5 -1]);
0165 %ylim(ax(5),[-13 -9]);
0166 %ylim(ax(6),[2 10]);

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