% gfd_run_plot % plots variables versus distance for a flight-level run % calls gfd_flightlevel_set_variables.m % based on airplotyy (Ian Renfrew 1997), clamp_aws_plot, and dplot2 (Dave Sproson) %---------------------------------------------- % *** set up and load data set %---------------------------------------------- idata = 268; data_name = 'B268'; if (idata == 268) filea = 'C:\data\gfd\FAAM\B268\B268_flightlevel_1hz_v1.mat'; fileb = 'C:\data\gfd\FAAM\B268\B268_flightlevel_diagnostics_1hz_v1.mat'; dirp = 'C:\data\gfd\B268_RTJ\flightlevel_pics'; tleg = [13 46 15; 13 57 00;]; leg_name = ' low-level leg 1'; tleg = [13 57 00; 14 07 00;]; leg_name = ' low-level leg 2'; tleg = [14 07 00; 14 17 00;]; leg_name = ' low-level leg 3'; end; cd(dirp) disp(['loading ' filea]); load(filea); disp(['loading ' fileb]); load(fileb); %-------------------------------------------------------------- % set up x-axis as distance along leg (Note: this can be flipped *** % Could also use x = time(e1); x1_label='time (s)'; % Note: at present same x for all panels %-------------------------------------------------------------- time_leg = [tleg(1,1)*3600+tleg(1,2)*60+tleg(1,3) tleg(2,1)*3600+tleg(2,2)*60+tleg(2,3)]; % Convert to seconds e1 = find(time_leg(1)<=time & time<=time_leg(2)); % find indices for leg1 hhmm_start = [num2str(hh(e1(1))) ':' num2str(mi(e1(1)))]; if (mi(e1(1))<10) hhmm_start = [num2str(hh(e1(1))) ':0' num2str(mi(e1(1)))]; end; hhmm_end = [num2str(hh(e1(length(e1)))) ':' num2str(mi(e1(length(e1))))]; if (mi(e1(length(e1)))<10) hhmm_end = [num2str(hh(e1(length(e1)))) ':0' num2str(mi(e1(length(e1))))]; end; dist = gc_dist(lon(e1), lat(e1)); xd = dist; %xd = max(dist)-dist; disp('distance flipped for plotting'); %***change x_lim = [min(xd) max(xd)]; x.data = xd; x.label ='distance (km)'; x.lim = x_lim; %----------------------------------------------------------------- % *** Set number of panels to plot: npanels % *** Set number of lines to plot in each panel: nlines % *** Set number of axes for each panel: naxes % *** Set plotting variables for each line: i % NOTE: nlines must be equal to length(i) %------------------------------------------------------------------ npanels = 4; for j=1:npanels if (j==1) nlines=2; naxes=1; i=[70 71]; end; if (j==2) nlines=2; naxes=2; i=[33 16]; end; if (j==3) nlines=2; naxes=2; i=[20 21]; end; if (j==4) nlines=1; naxes=1; i=[24]; end; if ((naxes==2)&(nlines ~=2)) disp('Problem in gfd_run_plot: nlines not equal to 2'); end; if (nlines ~= length(i)) disp('Problem in gfd_run_plot: nlines not equal to no. of variables set'); end; %------------------------------------------------------------- % loop over nlines to plot in each panel (max of 3) % put variable details into a structure y(k) %------------------------------------------------------------- for k = 1:nlines gfd_flightlevel_set_variables; % *** Define plotting variables here y(k).data = yd(e1); y(k).label = y_label; y(k).label2 = y_label2; y(k).lim = y_lim; y(k).tick = y_tick; end; %----------------------------------------------------------- % plot with single axes: axes limits should be the same for each line %------------------------------------------------------------ pstyle = char('b-','r-','g-'); % plotline style if (naxes==1) for k = 1:nlines subplot(npanels,1,j), plot(x.data, y(k).data, pstyle(k,:)); hold on; end; hold off; h = gca; grid on; set(h, 'xlim', x.lim) set(h, 'ylim', y(k).lim) set(h, 'ytick', [y(k).lim(1): y(k).tick: y(k).lim(2)]) xlabel(x.label) ylabel(y(k).label) if (nlines == 2) legend(y(1).label2, y(2).label2) elseif (nlines ==3) legend(y(1).label2, y(2).label2, y(3).label2) end; %----------------------------------------------------------- % plot with double axes %------------------------------------------------------------ elseif (naxes==2) subplot(npanels,1,j), [AX, H1, H2]= plotyy(x.data, y(1).data, x.data, y(2).data); h=AX(1); % first axes grid on; set(h, 'xlim', x.lim) set(h, 'ylim', y(1).lim) set(h, 'ytick', [y(1).lim(1): y(1).tick: y(1).lim(2)]) xlabel(x.label) ylabel(y(1).label) axes(AX(2)); % second axes h=AX(2); set(h, 'xtick', []) set(h,'YAxisLocation','Right'); set(h,'tickdir','out') set(h, 'xlim', x.lim) set(h, 'ylim', y(2).lim) set(h, 'ytick', [y(2).lim(1): y(2).tick: y(2).lim(2)]) ylabel(y(2).label) end if (j==1) title([data_name leg_name ' - ' hhmm_start ' to ' hhmm_end]); end; end % j loop over no. of panels orient tall