Changeset 874 for trunk/src/plot_field.m


Ignore:
Timestamp:
Feb 19, 2015, 2:17:59 AM (9 years ago)
Author:
sommeria
Message:

merge_proj corrected + various bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plot_field.m

    r873 r874  
    201201        CheckHold= PlotParam.CheckHold;
    202202    end       
    203     PlotParamOut.Axes=plot_profile(Data,CellInfo(index_1D),haxes,PlotParamOut.Axes,CheckHold);%
     203    PlotParamOut=plot_profile(Data,CellInfo(index_1D),haxes,PlotParamOut,CheckHold);%
    204204    if isempty(index_2D)
    205205        if isfield(PlotParamOut,'Vectors')
     
    224224if ~(isfield(PlotParamOut,'Axes')&&isfield(PlotParamOut.Axes,'TextDisplay')&&(PlotParamOut.Axes.TextDisplay)) % if text is not already given as statistics
    225225    htext=findobj(hfig,'Tag','TableDisplay');
    226     hchecktable=findobj(hfig,'Tag','CheckTable');
    227     if ~isempty(htext)&&~isempty(hchecktable)
     226%     hchecktable=findobj(hfig,'Tag','CheckTable');
     227    if ~isempty(htext)%&&~isempty(hchecktable)
    228228        if isempty(index_0D)
    229229            %         set(htext,'Data',{})
     
    234234            errormsg=plot_text(Data,CellInfo(index_0D),htext);
    235235            set(htext,'visible','on')
    236             set(hchecktable,'visible','on')
    237             set(hchecktable,'Value',1)
     236%             set(hchecktable,'visible','on')
     237%             set(hchecktable,'Value',1)
    238238        end
    239239        set(hfig,'Unit','pixels');
     
    261261%% update the parameters stored in AxeData
    262262if ishandle(haxes)&&( ~isempty(index_2D)|| ~isempty(index_1D))
    263 %     AxeData=[];
    264263    if isfield(PlotParamOut,'MinX')
    265264        AxeData.RangeX=[PlotParamOut.MinX PlotParamOut.MaxX];
     
    362361% --- plot 1D fields (usual x,y plots)
    363362%-------------------------------------------------------------------
    364 function CoordinatesOut=plot_profile(data,CellInfo,haxes,Coordinates,CheckHold)
     363function PlotParamOut=plot_profile(data,CellInfo,haxes,PlotParam,CheckHold)
    365364
    366365%% initialization
    367 if ~exist('Coordinates','var')
     366if ~(exist('PlotParam','var')&&~isempty(PlotParam.Axes))
    368367    Coordinates=[];
    369 end
    370 CoordinatesOut=Coordinates; %default
     368    PlotParamOut.Axes=Coordinates;
     369else
     370    Coordinates=PlotParam.Axes;
     371    PlotParamOut=PlotParam;
     372end
    371373hfig=get(haxes,'parent');
    372374legend_str={};
     
    545547    if ~isempty(MinX)
    546548        if check_lim
    547             CoordinatesOut.MinX=min(min(MinX),CoordinatesOut.MinX);
    548             CoordinatesOut.MaxX=max(max(MaxX),CoordinatesOut.MaxX);
    549         else
    550             CoordinatesOut.MinX=min(MinX);
    551             CoordinatesOut.MaxX=max(MaxX);
     549            Coordinates.MinX=min(min(MinX),Coordinates.MinX);
     550            Coordinates.MaxX=max(max(MaxX),Coordinates.MaxX);
     551        else
     552            Coordinates.MinX=min(MinX);
     553            Coordinates.MaxX=max(MaxX);
    552554        end
    553555    end
    554556    if ~isempty(MinY_cell)
    555557        if check_lim
    556             CoordinatesOut.MinY=min(min(MinY_cell),CoordinatesOut.MinY);
    557             CoordinatesOut.MaxY=max(max(MaxY_cell),CoordinatesOut.MaxY);
    558         else
    559             CoordinatesOut.MinY=min(MinY_cell);
    560             CoordinatesOut.MaxY=max(MaxY_cell);
     558            Coordinates.MinY=min(min(MinY_cell),Coordinates.MinY);
     559            Coordinates.MaxY=max(max(MaxY_cell),Coordinates.MaxY);
     560        else
     561            Coordinates.MinY=min(MinY_cell);
     562            Coordinates.MaxY=max(MaxY_cell);
    561563        end
    562564    end
     
    570572    set(haxes,'DataAspectRatioMode','auto')%automatic aspect ratio
    571573    AspectRatio=get(haxes,'DataAspectRatio');
    572     CoordinatesOut.AspectRatio=AspectRatio(1)/AspectRatio(2);
    573 end
     574    Coordinates.AspectRatio=AspectRatio(1)/AspectRatio(2);
     575end
     576PlotParamOut.Axes= Coordinates;
    574577
    575578%% give statistics for pdf
     
    577580TableData={'Variable';'SampleNbr';'bin size';'Mean';'RMS';'Skewness';'Kurtosis';'    centered ';...
    578581    'Min';'FirstCentile';'FirstDecile';'Median';'LastDecile';'LastCentile';'Max'};
    579 CoordinatesOut.TextDisplay=0;
     582%PlotParamOut.TableDisplay={};
     583TextDisplay=0;
    580584for icell=1:numel(CellInfo)
    581585    if isfield(CellInfo{icell},'VarIndex_histo')
    582586        check_stat=1;
    583         CoordinatesOut.TextDisplay=1;
     587        TextDisplay=1;
    584588        VarName=data.ListVarName{CellInfo{icell}.CoordIndex};
    585589        pdf_val=data.(data.ListVarName{CellInfo{icell}.VarIndex_histo});
     
    597601        Val(5)=(sum(x.*x.*x.*pdf_val))/(Variance*Val(4));%skewness
    598602        Val(6)=(sum(x.*x.*x.*x.*pdf_val))/(Variance*Variance);%kurtosis
    599         cumpdf=cumsum(pdf_val);
     603        cumpdf=cumsum(pdf_val);% sum of pdf
    600604        ind_centile=find(cumpdf>=0.01,1);% first index with cumsum >=0.01
    601         Val(8)=(cumpdf(ind_centile)-0.01)*x(ind_centile-1)+(0.01-cumpdf(ind_centile-1))*x(ind_centile);
    602         Val(8)=Val(8)/(cumpdf(ind_centile)-cumpdf(ind_centile-1));%linear interpolation near ind_centile
     605        Val(8)=x(ind_centile)+Val(2)/2;%
     606        if ind_centile>1
     607            Val(8)=(cumpdf(ind_centile)-0.01)*x(ind_centile-1)+(0.01-cumpdf(ind_centile-1))*x(ind_centile);
     608            Val(8)=Val(8)/(cumpdf(ind_centile)-cumpdf(ind_centile-1))+Val(2)/2;%linear interpolation near ind_centile
     609        end
    603610        ind_decile=find(cumpdf>=0.1,1);
    604         Val(9)=(cumpdf(ind_decile)-0.1)*x(ind_decile-1)+(0.1-cumpdf(ind_decile-1))*x(ind_decile);
    605         Val(9)=Val(9)/(cumpdf(ind_decile)-cumpdf(ind_decile-1));%linear interpolation near ind_decile;
     611        if ind_decile>1
     612            Val(9)=x(ind_decile)+Val(2)/2;%
     613            Val(9)=(cumpdf(ind_decile)-0.1)*x(ind_decile-1)+(0.1-cumpdf(ind_decile-1))*x(ind_decile);
     614            Val(9)=Val(9)/(cumpdf(ind_decile)-cumpdf(ind_decile-1))+Val(2)/2;%linear interpolation near ind_decile;
     615        end
    606616        ind_median=find(cumpdf>= 0.5,1);
    607617        Val(10)=(cumpdf(ind_median)-0.5)*x(ind_median-1)+(0.5-cumpdf(ind_median-1))*x(ind_median);
    608         Val(10)=Val(10)/(cumpdf(ind_median)-cumpdf(ind_median-1));%linear interpolation near ind_median;
     618        Val(10)=Val(10)/(cumpdf(ind_median)-cumpdf(ind_median-1))+Val(2)/2;%linear interpolation near ind_median;
    609619        %     Val(9)=x(ind_median);
    610620        ind_decile=find(cumpdf>=0.9,1);
    611621        Val(11)=(cumpdf(ind_decile)-0.9)*x(ind_decile-1)+(0.9-cumpdf(ind_decile-1))*x(ind_decile);
    612         Val(11)=Val(11)/(cumpdf(ind_decile)-cumpdf(ind_decile-1));%linear interpolation near ind_median;
     622        Val(11)=Val(11)/(cumpdf(ind_decile)-cumpdf(ind_decile-1))+Val(2)/2;%linear interpolation near ind_median;
    613623        ind_centile=find(cumpdf>=0.99,1);
    614624        Val(12)=(cumpdf(ind_centile)-0.99)*x(ind_centile-1)+(0.99-cumpdf(ind_centile-1))*x(ind_centile);
    615         Val(12)=Val(12)/(cumpdf(ind_centile)-cumpdf(ind_centile-1));%linear interpolation near ind_centile;
    616         Val(13)=max(x);
     625        Val(12)=Val(12)/(cumpdf(ind_centile)-cumpdf(ind_centile-1))+Val(2)/2;%linear interpolation near ind_centile;
    617626        Column=mat2cell(Val,ones(13,1),1);
    618627        Column=[{VarName};Column(1:6);{'stat: --'};Column(7:13)];
     
    620629    end
    621630end
    622 if CoordinatesOut.TextDisplay;
     631if TextDisplay;
    623632    disp(TableData);
    624     htable=findobj(hfig,'Tag','TableDisplay');
    625     set(htable,'Data',TableData)
    626     set(htable,'Visible','on')
    627     drawnow
     633    PlotParamOut.TableDisplay=TableData;
     634   % PlotParamOut.CheckTable=1;
     635%     htable=findobj(hfig,'Tag','TableDisplay');
     636%     set(htable,'Data',TableData)
     637%     set(htable,'Visible','on')
     638%     drawnow
     639else
     640    if isfield(PlotParamOut,'TableDisplay')
     641        PlotParamOut=rmfield(PlotParamOut,'TableDisplay');
     642    end
    628643end
    629644   
Note: See TracChangeset for help on using the changeset viewer.