Changeset 871


Ignore:
Timestamp:
Feb 16, 2015, 12:15:23 AM (10 years ago)
Author:
sommeria
Message:

histo improved

Location:
trunk/src
Files:
1 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_field_bounds.m

    r867 r871  
    1 %'find_field_bounds': % find the boounds and typical meshs of coordinates
     1%'find_field_bounds': % find the bounds and typical meshs of coordinates
    22%-----------------------------------------------------------------------
    33%function  FieldOut=find_field_bounds(Field)
     
    99%
    1010%INPUT
    11 % Field
    12 
     11% Field: Matlab structure describing the input field
     12%
    1313%=======================================================================
    1414% Copyright 2008-2014, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France
     
    4141NbDim=max(NbDimArray);% spatial dimension of the input field
    4242imax=find(NbDimArray==NbDim);% indices of field cells to consider
    43 % if isfield(Field,'NbDim')
    44 %     NbDim=double(Field.NbDim);% deal with plane fields containing z coordinates
    45 % end
    4643FieldOut.NbDim=NbDim;
    4744if  NbDim<=1; return; end% stop here for 1D fields
  • trunk/src/get_file_series.m

    r863 r871  
    6060            Param.IndexRange.PairString={Param.IndexRange.PairString};
    6161        end
    62         if ~isempty(Param.IndexRange.PairString{iview,1})
    63         r=regexp(Param.IndexRange.PairString{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');%look for mode=Dj or Di
    64         if isempty(r)
    65             r=regexp(Param.IndexRange.PairString{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');%look for burst pairs
    66         end
     62        if size(Param.IndexRange.PairString,1)>=iview && ~isempty(Param.IndexRange.PairString{iview,1})
     63            r=regexp(Param.IndexRange.PairString{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');%look for mode=Dj or Di
     64            if isempty(r)
     65                r=regexp(Param.IndexRange.PairString{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');%look for burst pairs
     66            end
    6767        end
    6868        % TODO case of free pairs:
     
    7272        r(1).num1='';
    7373        r(1).num2='';
    74         if isfield (Param.IndexRange,'PairString') && strcmp(Param.IndexRange.PairString{iview,1},'j=*-*')
     74        if isfield (Param.IndexRange,'PairString') && size(Param.IndexRange.PairString,1)>=iview &&...
     75                                                           strcmp(Param.IndexRange.PairString{iview,1},'j=*-*')
    7576            r(1).mode='*-*';
    7677        else
  • trunk/src/mouse_up.m

    r809 r871  
    123123    %show object coordinates in the GUI set_object
    124124    if strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')
     125        set(hh_set_object.Coord,'Data',ObjectData.Coord);
    125126        set(hh_set_object.num_RangeX_2,'String',num2str(ObjectData.RangeX,4));
    126127        set(hh_set_object.num_RangeY_2,'String',num2str(ObjectData.RangeY,4));
  • trunk/src/nc2struct.m

    r816 r871  
    233233            end
    234234            try
    235                 if isempty(valuestr)
     235                if ~isempty(valuestr)
    236236                    Data.VarAttribute{ivar}.(attname)=valuestr;
    237237                end
  • trunk/src/plot_field.m

    r869 r871  
    202202    end       
    203203    PlotParamOut.Axes=plot_profile(Data,CellInfo(index_1D),haxes,PlotParamOut.Axes,CheckHold);%
     204    if isfield(PlotParamOut,'Vectors')
     205        PlotParamOut=rmfield(PlotParamOut,'Vectors');
     206    end
     207    if isfield(PlotParamOut,'Scalar')
     208        PlotParamOut=rmfield(PlotParamOut,'Scalar');
     209    end   
    204210    if testzoomaxes
    205211        [zoomaxes,PlotParamOut.Axes]=plot_profile(Data,CellInfo(index_1D),zoomaxes,PlotParamOut.Axes,CheckHold);
     
    216222htext=findobj(hfig,'Tag','TableDisplay');
    217223hchecktable=findobj(hfig,'Tag','CheckTable');
    218 % if isempty(index_2D) && isempty(index_1D)%text display alone
    219 %     htext=findobj(hfig,'Tag','TableDisplay');
    220 % else  %text display added to plot
    221 %     %htext=findobj(hfig,'Tag','text_display');
    222 % end
    223224if ~isempty(htext)&&~isempty(hchecktable)
    224225    if isempty(index_0D)
    225         set(htext,'Data',{})
    226         set(htext,'visible','off')
    227         set(hchecktable,'visible','off')
    228         set(hchecktable,'Value',0)
     226%         set(htext,'Data',{})
     227%         set(htext,'visible','off')
     228%         set(hchecktable,'visible','off')
     229%         set(hchecktable,'Value',0)
    229230    else
    230231        errormsg=plot_text(Data,CellInfo(index_0D),htext);
     
    384385ColorOrder=[1 0 0;0 1 0;0 0 1;0 0.75 0.75;0.75 0 0.75;0.75 0.75 0;0.25 0.25 0.25];
    385386set(hfig,'DefaultAxesColorOrder',ColorOrder)
    386 % if isfield(Coordinates,'NextPlot')
    387 %     set(haxes,'NextPlot',Coordinates.NextPlot)
    388 % end
    389387if CheckHold
    390388    set(haxes,'NextPlot','add')
     
    395393%% prepare the string for plot command
    396394plotstr='hhh=plot(';
    397 % coord_x_index=[];
    398395xtitle='';
    399396ytitle='';
     
    403400MinY_cell=[];
    404401MaxY_cell=[];
     402testplot=ones(size(data.ListVarName));%default test for plotted variables
    405403%loop on input  fields
    406404for icell=1:numel(CellInfo)
    407405    VarIndex=CellInfo{icell}.VarIndex;%  indices of the selected variables in the list data.ListVarName
    408406    coord_x_index=CellInfo{icell}.CoordIndex;
    409     testplot=ones(size(data.ListVarName));%default test for plotted variables
    410407    coord_x_name{icell}=data.ListVarName{coord_x_index};
    411408    coord_x{icell}=data.(data.ListVarName{coord_x_index});%coordinate variable set as coord_x
     
    573570end
    574571
     572%% give statistics for pdf
     573ind_var=find(testplot);
     574if numel(ind_var)==1 && isfield(data,'VarAttribute') && isfield(data.VarAttribute{ind_var},'Role') &&...
     575        strcmp(data.VarAttribute{ind_var}.Role,'histo')
     576    pdf_val=data.(data.ListVarName{ind_var});
     577    x=coord_x{1};
     578    TableData=cell(12,2);
     579    TableData(:,1)={'SampleNbr';'Mean';'RMS';'Skewness';'Kurtosis';...
     580        'Min';'FirstCentile';'FirstDecile';'Median';'LastDecile';'LastCentile';'Max'};
     581    Val=zeros(12,1);
     582    Val(1)=sum(pdf_val);% total sample number
     583    pdf_val=pdf_val/Val(1);% normalised pdf
     584    Val(2)=sum(x.*pdf_val);%Mean
     585    x=x-Val(2); %centered variable
     586    Variance=sum(x.*x.*pdf_val);
     587    Val(3)=sqrt(Variance);
     588    Val(4)=(sum(x.*x.*x.*pdf_val))/(Variance*Val(3));%skewness
     589    Val(5)=(sum(x.*x.*x.*x.*pdf_val))/(Variance*Variance);%kurtosis
     590    Val(6)=min(x);
     591    cumpdf=cumsum(pdf_val);
     592    ind_centile=find(cumpdf>=0.01,1);
     593    Val(7)=x(ind_centile);
     594    ind_decile=find(cumpdf>=0.1,1);
     595    Val(8)=x(ind_decile);
     596    ind_median=find(cumpdf>= 0.5,1);
     597    Val(9)=x(ind_median);
     598    ind_decile=find(cumpdf>=0.9,1);
     599    Val(10)=x(ind_decile);
     600    ind_centile=find(cumpdf>=0.99,1);
     601    Val(11)=x(ind_centile);
     602    Val(12)=max(x);   
     603    TableData(:,2)=mat2cell(Val,ones(12,1),1)
     604    TableData=[TableData(1:5,:);{'   -- centered','stat: --'};TableData(6:12,:)];
     605    htable=findobj(hfig,'Tag','TableDisplay')
     606    set(htable,'Data',TableData)
     607    set(htable,'Visible','on')
     608    drawnow
     609end
     610   
    575611%-------------------------------------------------------------------
    576612function [haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo,haxes,PlotParam)
  • trunk/src/proj_field.m

    r869 r871  
    11%'proj_field': projects the field on a projection object
    22%--------------------------------------------------------------------------
    3 %  function [ProjData,errormsg]=proj_field(FieldData,ObjectData)
     3%  function [ProjData,errormsg]=proj_field(FieldData,ObjectData,VarMesh)
    44%
    55% OUTPUT:
     
    8282%=======================================================================
    8383
    84 function [ProjData,errormsg]=proj_field(FieldData,ObjectData)
     84function [ProjData,errormsg]=proj_field(FieldData,ObjectData,VarMesh)
    8585errormsg='';%default
    8686ProjData=[];
     
    110110    case {'polygon','rectangle','ellipse'}
    111111        if isequal(ObjectData.ProjMode,'inside')||isequal(ObjectData.ProjMode,'outside')
    112             [ProjData,errormsg] = proj_patch(FieldData,ObjectData);
     112            if ~exist('VarMesh','var')
     113                VarMesh=[];
     114            end
     115            [ProjData,errormsg] = proj_patch(FieldData,ObjectData,VarMesh);
    113116        else
    114117            [ProjData,errormsg] = proj_line(FieldData,ObjectData);
     
    342345%-----------------------------------------------------------------
    343346%project in a patch
    344 function  [ProjData,errormsg]=proj_patch(FieldData,ObjectData)%%
     347function  [ProjData,errormsg]=proj_patch(FieldData,ObjectData,VarMesh)%%
    345348%-------------------------------------------------------------------
    346349[ProjData,errormsg]=proj_heading(FieldData,ObjectData);
     
    365368
    366369CoordMesh=zeros(1,numel(FieldData.ListVarName));
     370%VarMesh=nan(1,numel(FieldData.ListVarName));
     371% MinValue=nan(1,numel(FieldData.ListVarName));
     372% MaxValue=nan(1,numel(FieldData.ListVarName));
    367373if isfield (FieldData,'VarAttribute')
    368374    for iattr=1:length(FieldData.VarAttribute)%initialization of variable attribute values
     
    373379            CoordMesh(iattr)=FieldData.VarAttribute{iattr}.CoordMesh;
    374380        end
     381%         if isfield(FieldData.VarAttribute{iattr},'Mesh')
     382%             VarMesh(iattr)=FieldData.VarAttribute{iattr}.Mesh;
     383%         end
     384%         if isfield(FieldData.VarAttribute{iattr},'MinValue')
     385%             VarMesh(iattr)=FieldData.VarAttribute{iattr}.MinValue;
     386%         end
     387%         if isfield(FieldData.VarAttribute{iattr},'MaxValue')
     388%             VarMesh(iattr)=FieldData.VarAttribute{iattr}.MaxValue;
     389%         end
    375390    end
    376391end
     
    496511    end
    497512    indsel=find(testin);
     513    nbvar=0;
     514    VarSize=zeros(size(VarIndex));
    498515    for ivar=VarIndex
    499516        VarName=FieldData.ListVarName{ivar};
    500         ProjData.([VarName 'Mean'])=mean(double(FieldData.(VarName)(indsel,:))); % take the mean in the selected region, for each color component
     517        ProjData.([VarName 'Mean'])=mean(double(FieldData.(VarName)(indsel,:))); % take the mean in the selected region, for each co
    501518        ProjData.([VarName 'Min'])=min(double(FieldData.(VarName)(indsel,:))); % take the min in the selected region , for each color component
    502         ProjData.([VarName 'Max'])=max(double(FieldData.(VarName)(indsel,:))); % take the max in the selected region , for each color component
    503         if isequal(CoordMesh(ivar),0)
    504             [ProjData.([VarName 'Histo']),ProjData.(VarName)]=hist(double(FieldData.(VarName)(indsel,:,:)),100); % default histogram with 100 bins
     519        ProjData.([VarName 'Max'])=max(double(FieldData.(VarName)(indsel,:))); % take the max in the selected region , for each color co
     520        nbvar=nbvar+1;
     521        VarSize(nbvar)=mean((ProjData.([VarName 'Max'])-ProjData.([VarName 'Min']))/100);
     522    end
     523    if  isempty(VarMesh) || isnan(VarMesh) % mesh not specified as input, estimate from the bounds
     524        VarMesh=mean(VarSize);
     525        ord=10^(floor(log10(VarMesh)));%order of magnitude
     526        if VarMesh/ord >=5
     527            VarMesh=5*ord;
     528        elseif VarMesh/ord >=2
     529            VarMesh=2*ord;
    505530        else
    506             ProjData.(VarName)=ProjData.([VarName 'Min'])+CoordMesh(ivar)/2:CoordMesh(ivar):ProjData.([VarName 'Max']); % list of bin values
    507             ProjData.([VarName 'Histo'])=hist(double(FieldData.(VarName)(indsel,:)),ProjData.(VarName)); % histogram at predefined bin positions
    508         end
     531            VarMesh=ord;
     532        end
     533    end
     534    for ivar=VarIndex
     535        VarName=FieldData.ListVarName{ivar};
     536        LowBound=VarMesh*ceil(ProjData.([VarName 'Min'])/VarMesh);
     537        UpperBound=VarMesh*floor(ProjData.([VarName 'Max'])/VarMesh);
     538        ProjData.(VarName)=LowBound:VarMesh:UpperBound; % list of bin values
     539        ProjData.([VarName 'Histo'])=hist(double(FieldData.(VarName)(indsel,:)),ProjData.(VarName)); % histogram at predefined bin positions
    509540        ProjData.ListVarName=[ProjData.ListVarName {VarName} {[VarName 'Histo']} {[VarName 'Mean']} {[VarName 'Min']} {[VarName 'Max']}];
    510541        if test_Amat && testcolor
     
    513544            ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName} {'one'} {'one'} {'one'}];
    514545        end
     546        VarAttribute_var=[];
    515547        if isfield(FieldData,'VarAttribute')&& numel(FieldData.VarAttribute)>=ivar
    516             ProjData.VarAttribute=[ProjData.VarAttribute FieldData.VarAttribute{ivar} {[]} {[]} {[]} {[]}];
    517         end
     548            VarAttribute_var=FieldData.VarAttribute{ivar};
     549        end
     550      %  VarAttribute_var.Role='coord_x';% the variable is now used as an absissa
     551        VarAttribute_histo.Role='histo';
     552        ProjData.VarAttribute=[ProjData.VarAttribute {VarAttribute_var} {VarAttribute_histo} {[]} {[]} {[]}];
    518553    end
    519554end
  • trunk/src/read_civdata.m

    r851 r871  
    151151for ivar=1:numel(var_ind)
    152152    Field.VarAttribute{ivar}.Role=role{var_ind(ivar)};
    153     Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel
     153    %Field.VarAttribute{ivar}.Mesh=0.025;%typical mesh for histograms O.025 pixel (used in series)
    154154    Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
    155155    if strcmp(role{var_ind(ivar)},'vector_x')
  • trunk/src/read_field.m

    r867 r871  
    265265                ParamOut.Npy=npxy(1);
    266266            end
    267             Field.VarAttribute{3}.Mesh=1;
     267%             Field.VarAttribute{3}.Mesh=1;
    268268        else
    269269            Field.NbDim=3;
     
    277277                ParamOut.Npy=npxy(2);
    278278            end
    279             Field.VarAttribute{4}.Mesh=1;
     279%             Field.VarAttribute{4}.Mesh=1;
    280280        end
    281281    else
     
    285285        ParamOut.Npx=npxy(2);% display image size on the interface
    286286        ParamOut.Npy=npxy(1);
    287         Field.VarAttribute{3}.Mesh=1;
     287%         Field.VarAttribute{3}.Mesh=1;
    288288    end
    289289    Field.A=A;
  • trunk/src/series/aver_stat.m

    r869 r871  
    7171    ParamOut.OutputDirExt='.stat';%set the output dir extension
    7272    ParamOut.OutputFileMode='NbSlice';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
    73     % check the existence of the first file in the series
     73     % check for selection of a projection object
     74    hseries=findobj(allchild(0),'Tag','series');% handles of the GUI series
     75    if  ~isfield(Param,'ProjObject')
     76        answer=msgbox_uvmat('INPUT_Y-N','use a projection object?');
     77        if strcmp(answer,'Yes')
     78            hhseries=guidata(hseries);
     79            set(hhseries.CheckObject,'Visible','on')
     80            set(hhseries.CheckObject,'Value',1)
     81            Param.CheckObject=1;
     82            series('CheckObject_Callback',hseries,[],hhseries); %file input with xml reading  in uvmat, show the image in phys coordinates
     83        end
     84    end
     85    % introduce bin size for histograms
     86    if Param.CheckObject
     87        SeriesData=get(hseries,'UserData');
     88        if ismember(SeriesData.ProjObject.ProjMode,{'inside','outside'})
     89            answer=msgbox_uvmat('INPUT_TXT','set bin size for histograms (or keep ''auto'' by default)?','auto');
     90            ParamOut.ActionInput.VarMesh=str2double(answer);
     91        end
     92    end
     93    % check the existence of the first and last file in the series
    7494    first_j=[];
    7595    if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
     
    87107        LastFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
    88108        Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
    89         if ~exist(FirstFileName,'file')
     109        if ~exist(LastFileName,'file')
    90110             msgbox_uvmat('WARNING',['the last input file ' LastFileName ' does not exist'])
    91111        end
     
    170190 % EDIT FROM HERE
    171191
    172 %% check the validity of  input file types
     192%% check the validity of  input file types and set the output file type
    173193if CheckImage{1}
    174194    FileExtOut='.png'; % write result as .png images for image inputs
     
    182202    disp_uvmat('ERROR','input must be two image series or two netcdf file series',checkrun)
    183203    return
     204end
     205if isfield(Param,'ProjObject') && ~strcmp(Param.ProjObject.Type,'plane')
     206      FileExtOut='.nc';% write result as .nc files (even for image input)
    184207end
    185208
     
    212235    end
    213236end
    214 % for i_slice=1:NbSlice
    215 % index_slice=i_slice:NbSlice:nbfield;% select file indices of the slice
    216 nbfiles=0;
    217 % nbmissing=0;
    218 
     237nbfiles=0;%counter of the successfully read files (bad files are skipped)
     238VarMesh=NaN;
     239if isfield(Param,'ProjObject') && ismember(Param.ProjObject.ProjMode,{'inside','outside'})&& isfield(Param.ActionInput,'VarMesh')%case of histograms
     240     VarMesh=Param.ActionInput.VarMesh;
     241end
    219242%%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
    220243for index=1:NbField
     
    243266    if isempty(errormsg)
    244267        Field=Data{1}; % default input field structure
     268        nbfiles=nbfiles+1; %increment the file counter
    245269        %% coordinate transform (or other user defined transform)
    246270        if ~isempty(transform_fct)
     
    265289        end
    266290       
    267         %% calculate tps coefficients if needed
    268         if isfield(Param,'ProjObject')&&isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'interp_tps')
    269             Field=tps_coeff_field(Field,check_proj_tps);
    270         end
    271        
    272         %field projection on an object
     291        %% field projection on an object
    273292        if Param.CheckObject
    274             [Field,errormsg]=proj_field(Field,Param.ProjObject);
     293            if strcmp(Param.ProjObject.ProjMode,'interp_tps')
     294                Field=tps_coeff_field(Field,check_proj_tps);% calculate tps coefficients if needed
     295            end
     296            [Field,errormsg]=proj_field(Field,Param.ProjObject,VarMesh);
    275297            if ~isempty(errormsg)
    276298                disp_uvmat('ERROR',['error in aver_stat/proj_field:' errormsg],checkrun)
     
    278300            end
    279301        end
    280         nbfiles=nbfiles+1;
    281        
     302             
    282303        %%%%%%%%%%%% MAIN RUNNING OPERATIONS  %%%%%%%%%%%%
    283304        if nbfiles==1 %first field
     
    286307                time_1=Field.Time(1);
    287308            end
    288             DataOut=Field;%default
    289             DataOut.Conventions='uvmat'; %suppress Conventions='uvmat/civdata' for civ input files
    290             errorvar=zeros(numel(Field.ListVarName));%index of errorflag associated to each variable
    291             for ivar=1:numel(Field.ListVarName)
    292                 VarName=Field.ListVarName{ivar};
    293                 DataOut.(VarName)=zeros(size(DataOut.(VarName)));% initiate each field to zero
    294                 NbData.(VarName)=zeros(size(DataOut.(VarName)));% initiate the nbre of good data to zero
    295                 for iivar=1:length(Field.VarAttribute)
    296                     if isequal(Field.VarDimName{iivar},Field.VarDimName{ivar})&& isfield(Field.VarAttribute{iivar},'Role')...
    297                             && strcmp(Field.VarAttribute{iivar}.Role,'errorflag')
    298                         errorvar(ivar)=iivar; % index of the errorflag variable corresponding to ivar
     309            DataOut=Field;%outcome reproduces the first (projected) field by default
     310            DataOut.Conventions='uvmat'; %suppress Conventions='uvmat/civdata' for civ input files         
     311            if ismember(Param.ProjObject.ProjMode,{'inside','outside'})%case of histograms
     312                for ivar=1:numel(Field.ListVarName)% list of variable names before projection (histogram)
     313                    VarName=Field.ListVarName{ivar};
     314                    if isfield(Data{1},VarName)
     315                        DataOut.(VarName)=Field.(VarName);
     316                        DataOut.([VarName 'Histo'])=zeros(size(DataOut.(VarName)));
     317                        VarMesh=DataOut.(VarName)(2)-DataOut.(VarName)(1);
    299318                    end
    300319                end
    301             end
    302             DataOut.ListVarName(errorvar(errorvar~=0))=[]; %remove errorflag from result
    303             DataOut.VarDimName(errorvar(errorvar~=0))=[]; %remove errorflag from result
    304             DataOut.VarAttribute(errorvar(errorvar~=0))=[]; %remove errorflag from result
     320                disp(['mesh for histogram = ' num2str(VarMesh)])
     321            else
     322                errorvar=zeros(numel(Field.ListVarName));%index of errorflag associated to each variable
     323                for ivar=1:numel(Field.ListVarName)
     324                    VarName=Field.ListVarName{ivar};
     325                    DataOut.(VarName)=zeros(size(DataOut.(VarName)));% initiate each field to zero
     326                    NbData.(VarName)=zeros(size(DataOut.(VarName)));% initiate the nbre of good data to zero
     327                    for iivar=1:length(Field.VarAttribute)
     328                        if isequal(Field.VarDimName{iivar},Field.VarDimName{ivar})&& isfield(Field.VarAttribute{iivar},'Role')...
     329                                && strcmp(Field.VarAttribute{iivar}.Role,'errorflag')
     330                            errorvar(ivar)=iivar; % index of the errorflag variable corresponding to ivar
     331                        end
     332                    end
     333                end
     334                DataOut.ListVarName(errorvar(errorvar~=0))=[]; %remove errorflag from result
     335                DataOut.VarDimName(errorvar(errorvar~=0))=[]; %remove errorflag from result
     336                DataOut.VarAttribute(errorvar(errorvar~=0))=[]; %remove errorflag from result
     337            end
    305338        end   %current field
    306339        for ivar=1:length(DataOut.ListVarName)
    307             VarName=Field.ListVarName{ivar};
     340            VarName=DataOut.ListVarName{ivar};
    308341            sizmean=size(DataOut.(VarName));
    309342            siz=size(Field.(VarName));
    310             if ~isequal(DataOut.(VarName),0)&& ~isequal(siz,sizmean)
     343            if ismember(Param.ProjObject.ProjMode,{'inside','outside'})
     344                if isfield(Data{1},VarName)
     345                    MaxValue=max(DataOut.(VarName));% current max of histogram absissa
     346                    MinValue=min(DataOut.(VarName));% current min of histogram absissa
     347%                     VarMesh=Field.VarAttribute{ivar}.Mesh;
     348                    MaxIndex=round(MaxValue/VarMesh);
     349                    MinIndex=round(MinValue/VarMesh);
     350                    MaxIndex_new=round(max(Field.(VarName)/VarMesh));% max of the current field
     351                    MinIndex_new=round(min(Field.(VarName)/VarMesh));
     352                    if MaxIndex_new>MaxIndex% the variable max for the current field exceeds the previous one
     353                        DataOut.(VarName)=[DataOut.(VarName) VarMesh*(MaxIndex+1:MaxIndex_new)];% append the new variable values
     354                        DataOut.([VarName 'Histo'])=[DataOut.([VarName 'Histo']) zeros(1,MaxIndex_new-MaxIndex)]; % append the new histo values                   
     355                    end
     356                    if MinIndex_new <= MinIndex-1
     357                        DataOut.(VarName)=[VarMesh*(MinIndex_new:MinIndex-1) DataOut.(VarName)];% insert the new variable values
     358                        DataOut.([VarName 'Histo'])=[zeros(1,MinIndex-MinIndex_new) DataOut.([VarName 'Histo'])];% insert the new histo values
     359                        ind_start=1;
     360                    else
     361                        ind_start=MinIndex_new-MinIndex+1;
     362                    end
     363                    DataOut.([VarName 'Histo'])(ind_start:ind_start+MaxIndex_new-MinIndex_new)=...
     364                        DataOut.([VarName 'Histo'])(ind_start:ind_start+MaxIndex_new-MinIndex_new)+Field.([VarName 'Histo']);   
     365                end
     366            elseif ~isequal(DataOut.(VarName),0)&& ~isequal(siz,sizmean)
    311367                disp_uvmat('ERROR',['unequal size of input field ' VarName ', need to project  on a grid'],checkrun)
    312368                return
     
    328384end
    329385%%%%%%%%%%%%%%%% end loop on field indices %%%%%%%%%%%%%%%%
    330 
    331 for ivar=1:length(Field.ListVarName)
    332     VarName=Field.ListVarName{ivar};
    333     DataOut.(VarName)=DataOut.(VarName)./NbData.(VarName); % normalize the mean
     386if ~ismember(Param.ProjObject.ProjMode,{'inside','outside'})
     387    for ivar=1:length(Field.ListVarName)
     388        VarName=Field.ListVarName{ivar};
     389        DataOut.(VarName)=DataOut.(VarName)./NbData.(VarName); % normalize the mean
     390    end
    334391end
    335392nbmissing=NbField-nbfiles;
    336393if nbmissing~=0
    337     disp_uvmat('WARNING',[num2str(nbmissing) ' input files are missing or skipted'],checkrun)
     394    disp_uvmat('WARNING',[num2str(nbmissing) ' input files are missing or skipped'],checkrun)
    338395end
    339396if isempty(time) % time is read from files
     
    352409%% writing the result file
    353410OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,first_i,last_i,first_j,last_j);
    354 if CheckImage{1} %case of images
     411if strcmp(FileExtOut,'.png') %case of images
    355412    if isequal(FileInfo{1}.BitDepth,16)||(numel(FileInfo)==2 &&isequal(FileInfo{2}.BitDepth,16))
    356413        DataOut.A=uint16(DataOut.A);
     
    361418    end
    362419    disp([OutputFile ' written']);
    363 else %case of netcdf input file , determine global attributes
     420else %case of netcdf file , determine global attributes
    364421    errormsg=struct2nc(OutputFile,DataOut); %save result file
    365422    if isempty(errormsg)
  • trunk/src/series/time_series.m

    r867 r871  
    7373    ParamOut.OutputDirExt='.tseries';%set the output dir extension
    7474    ParamOut.OutputFileMode='NbSlice';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
    75     % check the existence of the first file in the series
    76         first_j=[];
     75    % check for selection of a projection object
     76    hseries=findobj(allchild(0),'Tag','series');% handles of the GUI series
     77    if  ~isfield(Param,'ProjObject')
     78        answer=msgbox_uvmat('INPUT_Y-N','use a projection object for the time_series?');
     79        if strcmp(answer,'Yes')
     80            hhseries=guidata(hseries);
     81            set(hhseries.CheckObject,'Visible','on')
     82            set(hhseries.CheckObject,'Value',1)
     83            series('CheckObject_Callback',hseries,[],hhseries); %file input with xml reading  in uvmat, show the image in phys coordinates
     84        end
     85    end
     86    % introduce bin size for histograms
     87    if Param.CheckObject
     88        SeriesData=get(hseries,'UserData');
     89        if checkhisto
     90             answer=msgbox_uvmat('INPUT_TXT','set bin size for histograms (or keep ''auto'' by default)?','auto');
     91            ParamOut.ActionInput.VarMesh=str2double(answer);
     92        end
     93    end
     94    % check the existence of the first and last file in the series
     95     first_j=[];
    7796    if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
    7897    last_j=[];
     
    85104    if ~exist(FirstFileName,'file')
    86105        msgbox_uvmat('WARNING',['the first input file ' FirstFileName ' does not exist'])
    87     elseif isequal(size(Param.InputTable,1),1) && ~isfield(Param,'ProjObject')
    88         msgbox_uvmat('WARNING','a projection object may be needed to select points for the time_series')
     106    else
     107        [i1,i2,j1,j2] = get_file_index(Param.IndexRange.last_i,last_j,PairString);
     108        LastFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
     109            Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
     110        if ~exist(LastFileName,'file')
     111            msgbox_uvmat('WARNING',['the last input file ' LastFileName ' does not exist'])
     112        end
    89113    end
    90114    return
     
    251275end
    252276
    253 nbmissing=0; %number of undetected files
    254 % for i_slice=1:NbSlice
    255 %index_slice=i_slice:NbSlice:nbfield;% select file indices of the slice
    256 nbfile=0;
     277nbfile=0;% not used , to check
    257278nbmissing=0;
    258 
     279VarMesh=NaN;
     280checkhisto=0;
     281if isfield(Param,'ProjObject') && ismember(Param.ProjObject.ProjMode,{'inside','outside'})
     282    checkhisto=1;
     283    if isfield(Param.ActionInput,'VarMesh')%case of histograms
     284    VarMesh=Param.ActionInput.VarMesh;
     285    end
     286end
    259287%%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
    260288for index=1:nbfield
    261             update_waitbar(WaitbarHandle,index/nbfield)
     289    update_waitbar(WaitbarHandle,index/nbfield)
    262290    if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
    263291        disp('program stopped by user')
     
    304332        end
    305333       
    306         %field projection on an object 
     334        %field projection on an object
    307335        if Param.CheckObject
    308336            % calculate tps coefficients if needed
     
    310338                Field=tps_coeff_field(Field,check_proj_tps);
    311339            end
    312             [Field,errormsg]=proj_field(Field,Param.ProjObject);
     340            [Field,errormsg]=proj_field(Field,Param.ProjObject,VarMesh);
    313341            if ~isempty(errormsg)
    314342                msgbox_uvmat('ERROR',['time_series / proj_field / ' errormsg])
     
    316344            end
    317345        end
    318         nbfile=nbfile+1;
     346%         nbfile=nbfile+1;
    319347       
    320348        % initiate the time series at the first iteration
    321         if nbfile==1
     349        if index==1
    322350            % stop program if the first field reading is in error
    323351            if ~isempty(errormsg)
     
    326354            end
    327355            DataOut=Field;%default
    328 %             DataOut.NbDim=Field.NbDim+1; %add the time dimension for plots
    329356            nbvar=length(Field.ListVarName);
    330357            if nbvar==0
     
    332359                return
    333360            end
    334             testsum=2*ones(1,nbvar);%initiate flag for action on each variable
    335             if isfield(Field,'VarAttribute') % look for coordinate and flag variables
     361            if checkhisto%case of histograms
     362                testsum=zeros(1,nbvar);%initiate flag for action on each variable
     363                for ivar=1:numel(Field.ListVarName)% list of variable names before projection (histogram)
     364                    VarName=Field.ListVarName{ivar};
     365                    if isfield(Data{1},VarName)
     366                        testsum(ivar)=1;
     367                        DataOut.(VarName)=Field.(VarName);
     368                        DataOut.([VarName 'Histo'])=zeros([nbfield numel(DataOut.(VarName))]);
     369                        VarMesh=Field.(VarName)(2)-Field.(VarName)(1);
     370                    end
     371                end
     372                disp(['mesh for histogram = ' num2str(VarMesh)])
     373            else
     374                testsum=2*ones(1,nbvar);%initiate flag for action on each variable
     375                if isfield(Field,'VarAttribute') % look for coordinate and flag variables
     376                    for ivar=1:nbvar
     377                        if length(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'Role')
     378                            var_role=Field.VarAttribute{ivar}.Role;%'role' of the variable
     379                            if isequal(var_role,'errorflag')
     380                                disp_uvmat('ERROR','do not handle error flags in time series',checkrun)
     381                                return
     382                            end
     383                            if isequal(var_role,'warnflag')
     384                                testsum(ivar)=0;  % not recorded variable
     385                                eval(['DataOut=rmfield(DataOut,''' Field.ListVarName{ivar} ''');']);%remove variable
     386                            end
     387                            if strcmp(var_role,'coord_x')||strcmp(var_role,'coord_y')||strcmp(var_role,'coord_z')||strcmp(var_role,'coord')
     388                                testsum(ivar)=1; %constant coordinates, record without time evolution
     389                            end
     390                        end
     391                        % check whether the variable ivar is a dimension variable
     392                        DimCell=Field.VarDimName{ivar};
     393                        if ischar(DimCell)
     394                            DimCell={DimCell};
     395                        end
     396                        if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell{1})%detect dimension variables
     397                            testsum(ivar)=1;
     398                        end
     399                    end
     400                end
    336401                for ivar=1:nbvar
    337                     if length(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'Role')
    338                         var_role=Field.VarAttribute{ivar}.Role;%'role' of the variable
    339                         if isequal(var_role,'errorflag')
    340                             disp_uvmat('ERROR','do not handle error flags in time series',checkrun)
    341                             return
    342                         end
    343                         if isequal(var_role,'warnflag')
    344                             testsum(ivar)=0;  % not recorded variable
    345                             eval(['DataOut=rmfield(DataOut,''' Field.ListVarName{ivar} ''');']);%remove variable
    346                         end
    347                         if strcmp(var_role,'coord_x')||strcmp(var_role,'coord_y')||strcmp(var_role,'coord_z')||strcmp(var_role,'coord')
    348                             testsum(ivar)=1; %constant coordinates, record without time evolution
    349                         end
    350                     end
    351                     % check whether the variable ivar is a dimension variable
    352                     DimCell=Field.VarDimName{ivar};
    353                     if ischar(DimCell)
    354                         DimCell={DimCell};
    355                     end
    356                     if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell{1})%detect dimension variables
    357                         testsum(ivar)=1;
    358                     end
    359                 end
    360             end
    361             for ivar=1:nbvar
    362                 if testsum(ivar)==2
    363                     eval(['DataOut.' Field.ListVarName{ivar} '=[];'])
     402                    if testsum(ivar)==2
     403                        VarName=Field.ListVarName{ivar};
     404                        siz=size(Field.(VarName));
     405                        DataOut.(VarName)=zeros([nbfield siz]);
     406                    end
    364407                end
    365408            end
     
    368411       
    369412        % add data to the current field
    370         for ivar=1:length(Field.ListVarName)
    371             VarName=Field.ListVarName{ivar};
    372             VarVal=Field.(VarName);
    373             if testsum(ivar)==2% test for recorded variable
    374                 if isempty(errormsg)
    375                     if Param.CheckObject && strcmp(Param.ProjObject.ProjMode,'inside')% take the average in the domain for 'inside' projection mode
    376                         if isempty(VarVal)
    377                             disp_uvmat('ERROR',['empty result at frame index ' num2str(i1_series{iview}(index))],checkrun)
    378                             return
    379                         end
    380                         VarVal=mean(VarVal,1);
    381                     end
    382                     VarVal=shiftdim(VarVal,-1); %shift dimension
    383                     DataOut.(VarName)=cat(1,DataOut.(VarName),VarVal);%concanete the current field to the time series
    384                 else
    385                     DataOut.(VarName)=cat(1,DataOut.(VarName),0);% put each variable to 0 in case of input reading error
     413        if checkhisto
     414            for ivar=1:length(Field.ListVarName)
     415                VarName=Field.ListVarName{ivar};
     416                if isfield(Data{1},VarName)
     417                    MaxValue=max(DataOut.(VarName));% current max of histogram absissa
     418                    MinValue=min(DataOut.(VarName));% current min of histogram absissa
     419                    MaxIndex=round(MaxValue/VarMesh);
     420                    MinIndex=round(MinValue/VarMesh);
     421                    MaxIndex_new=round(max(Field.(VarName)/VarMesh));% max of the current field
     422                    MinIndex_new=round(min(Field.(VarName)/VarMesh));
     423                    if MaxIndex_new>MaxIndex% the variable max for the current field exceeds the previous one
     424                        DataOut.(VarName)=[DataOut.(VarName) VarMesh*(MaxIndex+1:MaxIndex_new)];% append the new variable values
     425                        DataOut.([VarName 'Histo'])=[DataOut.([VarName 'Histo']) zeros(nbfield,MaxIndex_new-MaxIndex)]; % append the new histo values
     426                    end
     427                    if MinIndex_new <= MinIndex-1
     428                        DataOut.(VarName)=[VarMesh*(MinIndex_new:MinIndex-1) DataOut.(VarName)];% insert the new variable values
     429                        DataOut.([VarName 'Histo'])=[zeros(nbfield,MinIndex-MinIndex_new) DataOut.([VarName 'Histo'])];% insert the new histo values
     430                        ind_start=1;
     431                    else
     432                        ind_start=MinIndex_new-MinIndex+1;
     433                    end
     434                    DataOut.([VarName 'Histo'])(index,ind_start:ind_start+MaxIndex_new-MinIndex_new)=...
     435                        DataOut.([VarName 'Histo'])(index,ind_start:ind_start+MaxIndex_new-MinIndex_new)+Field.([VarName 'Histo']);
    386436                end
    387             elseif testsum(ivar)==1% variable representing fixed coordinates
    388                 VarInit=DataOut.(VarName);
    389                 if isempty(errormsg) && ~isequal(VarVal,VarInit)
    390                     disp_uvmat('ERROR',['time series requires constant coordinates ' VarName ': use projection mode interp'],checkrun)
    391                     return
     437            end
     438        else
     439            for ivar=1:length(Field.ListVarName)
     440                VarName=Field.ListVarName{ivar};
     441                VarVal=Field.(VarName);
     442                if testsum(ivar)==2% test for recorded variable
     443                    if isempty(errormsg)                     
     444                        VarVal=shiftdim(VarVal,-1); %shift dimension
     445                        DataOut.(VarName)(index,:,:)=VarVal;%concanete the current field to the time series
     446                    end
     447                elseif testsum(ivar)==1% variable representing fixed coordinates
     448                    VarInit=DataOut.(VarName);
     449                    if isempty(errormsg) && ~isequal(VarVal,VarInit)
     450                        disp_uvmat('ERROR',['time series requires constant coordinates ' VarName ': use projection mode interp'],checkrun)
     451                        return
     452                    end
    392453                end
    393454            end
     
    397458        if isempty(time)% time not set by xml filer(s)
    398459            if isfield(Data{1},'Time')
    399                 DataOut.Time(nbfile,1)=Field.Time;
     460                DataOut.Time(index,1)=Field.Time;
    400461            else
    401                 DataOut.Time(nbfile,1)=index;%default
     462                DataOut.Time(index,1)=index;%default
    402463            end
    403464        else % time from ImaDoc prevails  TODO: correct
    404             DataOut.Time(nbfile,1)=time(index);%
     465            DataOut.Time(index,1)=time(index);%
    405466        end
    406467       
     
    411472        end
    412473    end
    413    
    414474end
    415475%%%%%%% END OF LOOP WITHIN A SLICE
     
    456516end
    457517
     518%case of histograms
     519if checkhisto
     520    for ivar=1:numel(Field.ListVarName)
     521        VarName=Field.ListVarName{ivar};
     522        if isfield(Data{1},VarName)
     523            DataOut.ListVarName=[DataOut.ListVarName {[VarName 'Histo']}];
     524            DataOut.VarDimName=[DataOut.VarDimName {{'Time',VarName}}];
     525        end
     526    end
     527end
    458528% display nbmissing
    459529if ~isequal(nbmissing,0)
  • trunk/src/set_object.m

    r864 r871  
    455455%% read the object parameters in the GUI set_object
    456456ObjectData=read_GUI(handles.set_object);%read the parameters defining the object in the GUI set_object
     457if isfield(ObjectData,'CoordLine')% remove CoordLine (not used as object feature)
     458    ObjectData=rmfield(ObjectData,'CoordLine');
     459end
    457460if iscell(ObjectData.Coord)%check for empty line
    458461    ObjectData.Coord=[0 0 0];
     
    650653% ------------------------------------------------------
    651654Object=read_GUI(handles.set_object);
     655if isfield(Object,'CoordLine')% remove CoordLine (not used as object feature)
     656    Object=rmfield(Object,'CoordLine');
     657end
    652658huvmat=findobj('Tag','uvmat');
    653659if isempty(huvmat)
  • trunk/src/transform_field/phys.m

    r866 r871  
    8686        return % transform only fields in pixel coordinates
    8787    end
    88     DataOut=phys_1(DataIn,Calib{1},ZIndex);% transform coordiantes and velocity components
     88    DataOut=phys_1(DataIn,Calib{1},ZIndex);% transform coordinates and velocity components
    8989    %case of images or scalar: in case of two input fields, we need to project the transform  on the same regular grid
    9090    if isfield(DataIn,'A') && isfield(DataIn,'Coord_x') && ~isempty(DataIn.Coord_x) && isfield(DataIn,'Coord_y')&&...
     
    117117    end
    118118    if (isfield(DataIn_1,'CoordUnit')&& strcmp(DataIn_1.CoordUnit,'pixel'))
    119 %         return % transform only fields in pixel coordinates
    120 %     end
    121     DataOut_1=phys_1(DataOut_1,Calib{2},ZIndex);
     119        DataOut_1=phys_1(DataOut_1,Calib{2},ZIndex);
    122120    end
    123121    if isfield(Calib{1},'SliceCoord')
     
    125123            DataOut_1.Txt='different plane positions for the two input fields';
    126124            return
    127         end       
     125        end
    128126        DataOut_1.PlaneCoord=DataOut.PlaneCoord;% same plane position for the two input fields
    129127        if isfield(Calib{1},'SliceAngle')
     
    190188        DataOut.V=(YOut_2-YOut_1)/Dt;
    191189    end
    192 %     if ~strcmp(Calib.CalibrationType,'rescale') && isfield(Data,'X_tps') && isfield(Data,'Y_tps')
    193 %         [DataOut.X_tps,DataOut.Y_tps]=phys_XYZ(Calib,Data.X,Data.Y,ZIndex);
    194 %     end
    195190end
    196191
  • trunk/src/uvmat.m

    r867 r871  
    4444%          .Field: cell array of 1 or 2 structures representing the current  input field(s)
    4545%          .PlotAxes: field structure representing the current field plotted  on the main axes  (used for mouse operations)
    46 %          .HistoAxes: idem for histogram axes
     46%          .HistoAxes: idem for Histogram axes
    4747
    4848% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   DATA FLOW  (for REFRESH_Callback) %%%%%%%%%%%%%%%%%%%%:
     
    6969%                        (tps_coeff_field.m)               calculate tps coefficients (for filter projection or spatial derivatives).
    7070%                            |
    71 %                       UvData.Field-------------->histogram
     71%                       UvData.Field-------------->Histogram
    7272%               _____________|____________
    7373%              |                          |                   
     
    358358%% reset position of text_display and TableDisplay
    359359set(handles.text_display,'Units','pixels')
     360set(handles.TableDisplay,'Units','pixels')
    360361pos_1=get(handles.text_display,'Position');% [lower x lower y width height] for text_display
    361362    pos_1(3)=1.2*ColumnWidth;
     
    363364pos_1(2)=size_fig(4)-pos_InputFile(4)-pos_1(4);             % set text display to the top of the fig
    364365set(handles.text_display,'Position',pos_1)
    365 set(handles.TableDisplay,'Position',pos_1)
     366set(handles.TableDisplay,'Position',[pos_1(1) 10 pos_1(3) 5*pos_1(4)])
    366367% reset position of CheckTable
    367368set(handles.CheckTable,'Units','pixels')
     
    25562557    msgbox_uvmat('ERROR',errormsg);
    25572558end
     2559set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back in red
    25582560
    25592561%------------------------------------------------------------------------
     
    25742576    msgbox_uvmat('ERROR',errormsg);
    25752577end
     2578set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back in red
    25762579
    25772580%------------------------------------------------------------------------
     
    36143617if UvData.Field.NbDim<=1
    36153618    set(handles.Objects,'Visible','off')
     3619    set(handles.CheckFixAspectRatio,'Value',0)
    36163620    [PlotType,PlotParamOut,haxes]=plot_field(UvData.Field,handles.PlotAxes,read_GUI(handles.uvmat));
    36173621    UvData.PlotAxes=UvData.Field; %store data for further plot modifications
     
    36223626        end
    36233627    end
     3628    set(handles.Histogram,'Visible','off')
     3629    set(handles.HistoMenu,'Visible','off')
     3630    set(handles.HistoAxes,'Visible','off')
     3631    hlegend=findobj(handles.uvmat,'Tag','HistoLegend');
     3632    if ~isempty(hlegend)
     3633        delete(hlegend)
     3634    end
     3635    cla(handles.HistoAxes)% clear the curves and legend in histogram axes
    36243636    set(handles.uvmat,'UserData',UvData)
    36253637%% 2D or 3D fieldname are generally projected
     
    36903702        PlotParam{1}.Vectors.ColorCode= {'rgb'};
    36913703    end
    3692     %PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface
    36933704   
    36943705    %% second projection object (view_field display)
     
    36993710            haxes(2)=plot_handles{2}.PlotAxes;
    37003711            PlotParam{2}=read_GUI(view_field_handle);
    3701             %PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
    37023712        end
    37033713    end
    37043714   
    3705     %% loop on the projection objects: one or two
    3706    
     3715    %% loop on the projection objects: one or two
    37073716    for imap=1:numel(IndexObj)
    37083717        iobj=IndexObj(imap);
     
    37583767        set(handles.uvmat,'UserData',UvData)
    37593768        if ~isempty(ObjectData)
    3760             %PlotType='none'; %default
    37613769            if imap==2 && isempty(view_field_handle)
    37623770                view_field(ObjectData)
     
    37723780                        set_object('ProjMode_Callback',hset_object,[],hhset_object);
    37733781                    end
    3774 %                     errormsg=PlotType;
    37753782                    return
    37763783                end
     
    37973804    end
    37983805   
    3799     %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case)
     3806    %% prepare the menus of histograms and plot them (Histogram of the whole volume in 3D case)
    38003807    menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display
    38013808    ind_skip=[];
     
    38033810    Ustring='';
    38043811    Vstring='';
    3805     % suppress axes from the histogram menu
     3812    % suppress axes from the Histogram menu
    38063813    for ivar=1:numel(menu_histo)%l loop on field variables:
    38073814        if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
     
    38383845    test_v=0;
    38393846    if ~isempty(menu_histo)
    3840         set(handles.histo1_menu,'Value',1)
    3841         set(handles.histo1_menu,'String',menu_histo)
    3842         histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram
     3847        set(handles.HistoMenu,'Value',1)
     3848        set(handles.HistoMenu,'String',menu_histo)
     3849        set(handles.Histogram,'Visible','on')
     3850        set(handles.HistoMenu,'Visible','on')
     3851        set(handles.HistoAxes,'Visible','on')
     3852        HistoMenu_Callback(handles.HistoMenu, [], handles)% plot first histogram
    38433853    end
    38443854end
     
    38523862
    38533863%------------------------------------------------------------------------
    3854 function histo1_menu_Callback(hObject, eventdata, handles)
     3864function HistoMenu_Callback(hObject, eventdata, handles)
    38553865%--------------------------------------------
    38563866%% get the current field stored in uvmat user data
     
    38583868Field=UvData.Field;
    38593869
    3860 %% get from the menu 'histo1_menu' the name(s) of the fields to use
    3861 histo_menu=get(handles.histo1_menu,'String');
    3862 histo_value=get(handles.histo1_menu,'Value');
     3870%% get from the menu 'HistoMenu' the name(s) of the fields to use
     3871histo_menu=get(handles.HistoMenu,'String');
     3872histo_value=get(handles.HistoMenu,'Value');
    38633873FieldName=histo_menu{histo_value};
    38643874r=regexp(FieldName,'(?<var1>.*)(?<sep>,)(?<var2>.*)','names');
     
    39023912end
    39033913
    3904 %% calculate and plot histogram
     3914%% calculate and plot Histogram
    39053915if isempty(Field)
    39063916    msgbox_uvmat('ERROR',['empty field ' FieldName])
     
    39353945            Histo.VarAttribute{1}.units=units;
    39363946        end
    3937         Histo.(FieldName)=linspace(Amin,Amax,50); %absissa values for histo
     3947        VarMesh=(Amax-Amin)/100;
     3948        ord=10^(floor(log10(VarMesh)));%order of magnitude
     3949        if VarMesh/ord >=5
     3950            VarMesh=5*ord;
     3951        elseif VarMesh/ord >=2
     3952            VarMesh=2*ord;
     3953        else
     3954            VarMesh=ord;
     3955        end
     3956        Amin=VarMesh*(ceil(Amin/VarMesh));
     3957        Amax=VarMesh*(floor(Amax/VarMesh));
     3958        Histo.(FieldName)=Amin:VarMesh:Amax; %absissa values for histo
    39383959        if isfield(Field,'NbDim') && isequal(Field.NbDim,3)
    39393960            C=reshape(double(FieldHisto),1,[]);% reshape in a vector
     
    39473968        end
    39483969        plot_field(Histo,handles.HistoAxes);
    3949         hlegend=legend;
     3970        hlegend=findobj(handles.uvmat,'Tag','HistoLegend');
     3971        if isempty(hlegend)
     3972            hlegend=legend;
     3973            set(hlegend,'Tag','HistoLegend')
     3974        end
    39503975        if isempty(FieldName_2)
    3951         set(hlegend,'String',FieldName)
     3976            set(hlegend,'String',FieldName)
    39523977        else
    39533978            set(hlegend,'String',{FieldName;FieldName_2})
     
    46774702        data.CoordType=UvData.CoordType;
    46784703    end
    4679     if isfield(UvData.Field,'CoordMesh')&~isempty(UvData.Field.CoordMesh)
     4704    if isfield(UvData.Field,'CoordMesh')&& ~isempty(UvData.Field.CoordMesh)
    46804705        data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
    46814706        data.RangeY=[UvData.Field.YMin UvData.Field.YMax];
    46824707        data.DX=UvData.Field.CoordMesh;
    46834708        data.DY=UvData.Field.CoordMesh;
    4684     elseif isfield(UvData.Field,'Coord_x')&isfield(UvData.Field,'Coord_y')& isfield(UvData.Field,'A')%only image
     4709    elseif isfield(UvData.Field,'Coord_x')&& isfield(UvData.Field,'Coord_y') && isfield(UvData.Field,'A')%only image
    46854710        np=size(UvData.Field.A);
    46864711        meshx=(UvData.Field.Coord_x(end)-UvData.Field.Coord_x(1))/np(2);
     
    56865711    set(handles.PlotAxes,'Visible','on')
    56875712    set(handles.text_display,'Visible','on')
    5688     if isfield(handles,'TableDisplay')
    5689     set(handles.TableDisplay,'Visible','off')
    5690     end
     5713%     if isfield(handles,'TableDisplay')
     5714%     set(handles.TableDisplay,'Visible','off')
     5715%     end
    56915716    Coordinates=PlotParam.Axes;
    56925717    if isfield(Coordinates,'CheckFixAspectRatio')
Note: See TracChangeset for help on using the changeset viewer.