function [fighandle]=gdat_plot(gdat_data,varargin); % % choices from doplot in gdat_data.gdat_params.doplot: % doplot = 0: no plot % = 1: new figure created % = -1: add to current figure (with hold all) % > 1: create new figure with this number, adding clf % <-1: add to figure number abs(doplot) (with hold all) % if ~isfield(gdat_data.gdat_params,'doplot') || gdat_data.gdat_params.doplot ==0 return end if prod(isfield(gdat_data,{'data','t'})) && ~isempty(gdat_data.data) && ~isempty(gdat_data.t) fighandle = get(0,'CurrentFigure'); if gdat_data.gdat_params.doplot == 1 fighandle = figure; elseif gdat_data.gdat_params.doplot > 1 fighandle = figure(gdat_data.gdat_params.doplot); clf; elseif gdat_data.gdat_params.doplot == -1 hold all elseif gdat_data.gdat_params.doplot < -1 fighandle = figure(abs(gdat_data.gdat_params.doplot)); hold all end if strcmp(gdat_data.gdat_request,'eqdsk') % special case, plot contours of first equil endstr = ''; if iscell(gdat_data.eqdsk); endstr = '{1}'; end eval(['contour(gdat_data.eqdsk' endstr '.rmesh,gdat_data.eqdsk' endstr '.zmesh,gdat_data.eqdsk' endstr '.psi'',100);']) hold on eval(['plot(gdat_data.eqdsk' endstr '.rplas,gdat_data.eqdsk' endstr '.zplas,''k'');']) eval(['plot(gdat_data.eqdsk' endstr '.rlim,gdat_data.eqdsk' endstr '.zlim,''k'');']) axis equal; title(eval(['gdat_data.eqdsk' endstr '.stitle'])); elseif any(find(size(gdat_data.data)==length(gdat_data.t))) plot(gdat_data.t,gdat_data.data); title([gdat_data.gdat_params.machine ' #' num2str(gdat_data.shot)]); if isfield(gdat_data,'mapping_for') xlabel(['time [' gdat_data.dimunits{gdat_data.mapping_for.(gdat_data.gdat_params.machine).gdat_timedim} ']']); else xlabel(['time']); end ylabel_eff = gdat_data.label; if iscell(gdat_data.label) && length(gdat_data.label)>=2; ylabel_eff = gdat_data.label{2}; end if ~isempty(gdat_data.units) ylabel([ylabel_eff '[' gdat_data.units ']']); else ylabel(ylabel_eff); end zoom on; end else disp('cannot plot gdat_data, has empty data or t field') end