Changeset 1077 for trunk


Ignore:
Timestamp:
Mar 20, 2020, 11:29:01 PM (4 years ago)
Author:
sommeria
Message:

various bug repair

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mouse_motion.m

    r1072 r1077  
    231231                    norm_plane(3)=OmAxis(3)*coeff+cos_om;
    232232                    %Z0=norm_plane*Field.ProjObjectCoord'/norm_plane(3);
    233                     pos(3)=-(norm_plane(1)*pos(1)-norm_plane(2)*pos(2))/norm_plane(3);                               
     233                    pos(3)=-(norm_plane(1)*pos(1)+norm_plane(2)*pos(2))/norm_plane(3);                               
    234234                end
    235235                pos=pos+Field.ProjObjectCoord;
  • trunk/src/plot_field.m

    r1071 r1077  
    102102
    103103%% default input and output
    104 if ~exist('PlotParam','var'),PlotParam=[];end;
     104if ~exist('PlotParam','var'),PlotParam=[];end
    105105PlotType='text'; %default
    106106if ~isfield(PlotParam,'Axes')
     
    114114
    115115%% check input structure
    116 % check the cells of fields :
    117 
    118 % if ~isfield(PlotParam,'FieldName')
    119 %     index_0D=[];
    120 %     index_1D=1;
    121 %     index_2D=[];%find 2D fields
    122 %     index_3D=[];
    123 % else
    124116    [CellInfo,NbDimArray,errormsg]=find_field_cells(Data);
    125117    if ~isempty(errormsg)
     
    363355% --- plot 1D fields (usual x,y plots)
    364356%-------------------------------------------------------------------
    365 function PlotParamOut=plot_profile(data,CellInfo,haxes,PlotParam,CheckHold)
     357%INPUT
     358%    Data:   structure describing the field to plot
     359%         (optional) .ListGlobalAttribute: cell listing the names of the global attributes
     360%                    .Att_1,Att_2... : values of the global attributes
     361%         (requested)  .ListVarName: list of variable names to select (cell array of  char strings {'VarName1', 'VarName2',...} )
     362%         (requested)  .VarDimName: list of dimension names for each element of .ListVarName (cell array of string cells)
     363%                      .VarAttribute: cell of attributes for each element of .ListVarName (cell array of structures of the form VarAtt.key=value)
     364%         (requested) .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
     365
     366%            Variable attribute .Role :
     367%    The only variable attribute used for plotting purpose is .Role which can take
     368%    the values:
     369%       Role = 'coord_x' or 'histo' to label the x coordinate
     370%            ='coord_y' or 'discrete' to label the y coordinate, variables labelled as 'discrete'
     371%           will be plotted as isolated points while variables labelled as 'coord_y' will be plotted as continuous lines
     372%    other variables will not be taken into account for plot_profile
     373
     374function PlotParamOut=plot_profile(Data,CellInfo,haxes,PlotParam,CheckHold)
    366375
    367376%% initialization
     
    376385legend_str={};
    377386
    378 %% suppress existing plot if empty data
    379 if isempty(data)
     387%% suppress existing plot if empty Data
     388if isempty(Data)
    380389    hplot=findobj(haxes,'tag','plot_line');
    381390    if ~isempty(hplot)
     
    407416MinY_cell=[];
    408417MaxY_cell=[];
    409 testplot=ones(size(data.ListVarName));%default test for plotted variables
     418testplot=ones(size(Data.ListVarName));%default test for plotted variables
    410419%loop on input  fields
    411420for icell=1:numel(CellInfo)
    412     VarIndex=[CellInfo{icell}.YIndex CellInfo{icell}.YIndex_discrete];%  indices of the selected variables in the list data.ListVarName
     421    VarIndex=[CellInfo{icell}.YIndex CellInfo{icell}.YIndex_discrete];%  indices of the selected variables in the list Data.ListVarName
    413422    coord_x_index=CellInfo{icell}.XIndex;
    414     coord_x_name{icell}=data.ListVarName{coord_x_index};
    415     coord_x{icell}=data.(data.ListVarName{coord_x_index});%coordinate variable set as coord_x
     423    coord_x_name{icell}=Data.ListVarName{coord_x_index};
     424    coord_x{icell}=Data.(Data.ListVarName{coord_x_index});%coordinate variable set as coord_x
    416425    if isempty(find(strcmp(coord_x_name{icell},coord_x_name(1:end-1)), 1)) %xtitle not already selected
    417426        xtitle=[xtitle coord_x_name{icell}];
    418         if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=coord_x_index && isfield(data.VarAttribute{coord_x_index},'units')
    419             xtitle=[xtitle '(' data.VarAttribute{coord_x_index}.units '), '];
     427        if isfield(Data,'VarAttribute')&& numel(Data.VarAttribute)>=coord_x_index && isfield(Data.VarAttribute{coord_x_index},'units')
     428            xtitle=[xtitle '(' Data.VarAttribute{coord_x_index}.units '), '];
    420429        else
    421430            xtitle=[xtitle ', '];
     
    432441            testplot(CellInfo{icell}.VarIndex_warnflag)=0;
    433442        end
    434         if isfield(data,'VarAttribute')
    435             VarAttribute=data.VarAttribute;
     443        if isfield(Data,'VarAttribute')
     444            VarAttribute=Data.VarAttribute;
    436445            for ivar=1:length(VarIndex)
    437446                if length(VarAttribute)>=VarIndex(ivar) && isfield(VarAttribute{VarIndex(ivar)},'long_name')
    438447                    plotname{VarIndex(ivar)}=VarAttribute{VarIndex(ivar)}.long_name;
    439448                else
    440                     plotname{VarIndex(ivar)}=data.ListVarName{VarIndex(ivar)};%name for display in plot A METTRE
     449                    plotname{VarIndex(ivar)}=Data.ListVarName{VarIndex(ivar)};%name for display in plot A METTRE
    441450                end
    442451            end
     
    453462        for ivar=1:length(VarIndex)
    454463            if testplot(VarIndex(ivar))
    455                 VarName=data.ListVarName{VarIndex(ivar)};
     464                VarName=Data.ListVarName{VarIndex(ivar)};
    456465                nbplot=nbplot+1;
    457466                ytitle=[ytitle VarName];
    458                 if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=VarIndex(ivar) && isfield(data.VarAttribute{VarIndex(ivar)},'units')
    459                     ytitle=[ytitle '(' data.VarAttribute{VarIndex(ivar)}.units '), '];
     467                if isfield(Data,'VarAttribute')&& numel(Data.VarAttribute)>=VarIndex(ivar) && isfield(Data.VarAttribute{VarIndex(ivar)},'units')
     468                    ytitle=[ytitle '(' Data.VarAttribute{VarIndex(ivar)}.units '), '];
    460469                else
    461470                    ytitle=[ytitle ', '];
    462471                end
    463                 eval(['data.' VarName '=squeeze(data.' VarName ');'])
    464                 MinY(ivar)=min(min(data.(VarName)));
    465                 MaxY(ivar)=max(max(data.(VarName)));
    466                 plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ','];
    467                 eval(['nbcomponent2=size(data.' VarName ',2);']);
    468                 eval(['nbcomponent1=size(data.' VarName ',1);']);
     472                eval(['Data.' VarName '=squeeze(Data.' VarName ');'])
     473                MinY(ivar)=min(min(Data.(VarName)));
     474                MaxY(ivar)=max(max(Data.(VarName)));
     475                plotstr=[plotstr 'coord_x{' num2str(icell) '},Data.' VarName ',' charplot_0 ','];
     476                eval(['nbcomponent2=size(Data.' VarName ',2);']);
     477                eval(['nbcomponent1=size(Data.' VarName ',1);']);
    469478                if numel(coord_x{icell})==2
    470479                    coord_x{icell}=linspace(coord_x{icell}(1),coord_x{icell}(2),nbcomponent1);
     
    521530    end
    522531    title_str='';
    523     if isfield(data,'filename')
    524        [Path, title_str, ext]=fileparts(data.filename);
     532    if isfield(Data,'filename')
     533       [Path, title_str, ext]=fileparts(Data.filename);
    525534       title_str=[title_str ext];
    526535    end
    527     if isfield(data,'Action')&&isfield(data.Action,'ActionName')
     536    if isfield(Data,'Action')&&isfield(Data.Action,'ActionName')
    528537        if ~isequal(title_str,'')
    529538            title_str=[title_str ', '];
    530539        end
    531         title_str=[title_str data.Action.ActionName];
     540        title_str=[title_str Data.Action.ActionName];
    532541    end
    533542    htitle=title(title_str);
     
    587596    if isfield(CellInfo{icell},'VarIndex_histo')% case of histogram plot
    588597        TextDisplay=1;
    589         VarName=data.ListVarName{CellInfo{icell}.CoordIndex};
    590         pdf_val=data.(data.ListVarName{CellInfo{icell}.VarIndex_histo});
     598        VarName=Data.ListVarName{CellInfo{icell}.CoordIndex};
     599        pdf_val=Data.(Data.ListVarName{CellInfo{icell}.VarIndex_histo});
    591600        x=coord_x{icell};
    592601        if isrow(x)
     
    610619    end
    611620end
    612 if TextDisplay;
     621if TextDisplay
    613622    disp(TableData);
    614623    PlotParamOut.TableDisplay=TableData;
  • trunk/src/proj_field.m

    r1072 r1077  
    719719                    ProjData.VarAttribute{nbvar+ivar}=FieldData.VarAttribute{VarIndex(ivar)};%reproduce var attribute
    720720                    if isfield(ProjData.VarAttribute{nbvar+ivar},'Role')
    721                         if  strcmp(ProjData.VarAttribute{nbvar+ivar}.Role,'vector_x');
     721                        if  strcmp(ProjData.VarAttribute{nbvar+ivar}.Role,'vector_x')
    722722                            ivar_U=nbvar+ivar;
    723                         elseif strcmp(ProjData.VarAttribute{nbvar+ivar}.Role,'vector_y');
     723                        elseif strcmp(ProjData.VarAttribute{nbvar+ivar}.Role,'vector_y')
    724724                            ivar_V=nbvar+ivar;
    725725                        end
    726726                    end
    727                     ProjData.VarAttribute{ivar+nbvar}.Role='discrete';% will promote plots of the profiles with continuoval(['us lines
     727                    ProjData.VarAttribute{ivar+nbvar}.Role='discrete';% will promote plots of the profiles as a  set of individual dots
    728728                end
    729729            elseif isequal(ProjMode,'interp_lin')  %filtering %linear interpolation:
     
    756756                    ProjData.VarDimName=[ProjData.VarDimName {XName}];
    757757                    if isfield(VarAttribute{ivar},'Role')
    758                         if  strcmp(VarAttribute{ivar}.Role,'vector_x');
     758                        if  strcmp(VarAttribute{ivar}.Role,'vector_x')
    759759                            ivar_U=ivar+nbvar;
    760                         elseif strcmp(VarAttribute{ivar}.Role,'vector_y');
     760                        elseif strcmp(VarAttribute{ivar}.Role,'vector_y')
    761761                            ivar_V=ivar+nbvar;
    762762                        end
     
    787787                    ProjData.VarDimName=[ProjData.VarDimName {'X'}];
    788788                    if isfield(VarAttribute{ivar},'Role')
    789                         if  strcmp(VarAttribute{ivar}.Role,'vector_x');
     789                        if  strcmp(VarAttribute{ivar}.Role,'vector_x')
    790790                            ivar_U=ivar+nbvar;
    791                         elseif strcmp(VarAttribute{ivar}.Role,'vector_y');
     791                        elseif strcmp(VarAttribute{ivar}.Role,'vector_y')
    792792                            ivar_V=ivar+nbvar;
    793793                        end
     
    813813                AY=FieldData.(AYName);% set of y positions
    814814                AZ=FieldData.(AZName);% set of z positions
    815                  AName=FieldData.ListVarName{VarIndex(1)};
     815                AName=FieldData.ListVarName{VarIndex(1)};
    816816                npxy=size(FieldData.(AName));
    817817                npz=npxy(1);
     
    820820                AXI=linspace(AX(1),AX(end), npx);%set of  x  positions for the interpolated input data
    821821                AYI=linspace(AY(1),AY(end), npy);%set of  x  positions for the interpolated input data
    822                  AZI=linspace(AZ(1),AZ(end), npy);%set of  x  positions for the interpolated input data
     822                AZI=linspace(AZ(1),AZ(end), npy);%set of  x  positions for the interpolated input data
    823823                for ivar=VarIndex
    824824                    VarName=FieldData.ListVarName{ivar};
    825825                    FieldData.(VarName)=interp3(FieldData.(AXName),FieldData.(AYName),FieldData.(AZName),FieldData.(VarName),AXI,AYI,AZI);
    826 
    827 %                     vec_A=reshape(squeeze(FieldData.(FieldData.ListVarName{ivar})),npx*npy,nbcolor); %put the original image in colum
    828 %                     if nbcolor==1
    829 %                         vec_B(ind_in)=vec_A(ICOMB);
    830 %                         vec_B(ind_out)=zeros(size(ind_out));
    831 %                         A_out=reshape(vec_B,npY,npX);
    832 %                         ProjData.(FieldData.ListVarName{ivar}) =sum(A_out,1)/npY;
    833 %                     elseif nbcolor==3
    834 %                         vec_B(ind_in,1:3)=vec_A(ICOMB,:);
    835 %                         vec_B(ind_out,1)=zeros(size(ind_out));
    836 %                         vec_B(ind_out,2)=zeros(size(ind_out));
    837 %                         vec_B(ind_out,3)=zeros(size(ind_out));
    838 %                         A_out=reshape(vec_B,npY,npX,nbcolor);
    839 %                         ProjData.(FieldData.ListVarName{ivar})=squeeze(sum(A_out,1)/npY);
    840 %                     end
     826                   
     827                    %                     vec_A=reshape(squeeze(FieldData.(FieldData.ListVarName{ivar})),npx*npy,nbcolor); %put the original image in colum
     828                    %                     if nbcolor==1
     829                    %                         vec_B(ind_in)=vec_A(ICOMB);
     830                    %                         vec_B(ind_out)=zeros(size(ind_out));
     831                    %                         A_out=reshape(vec_B,npY,npX);
     832                    %                         ProjData.(FieldData.ListVarName{ivar}) =sum(A_out,1)/npY;
     833                    %                     elseif nbcolor==3
     834                    %                         vec_B(ind_in,1:3)=vec_A(ICOMB,:);
     835                    %                         vec_B(ind_out,1)=zeros(size(ind_out));
     836                    %                         vec_B(ind_out,2)=zeros(size(ind_out));
     837                    %                         vec_B(ind_out,3)=zeros(size(ind_out));
     838                    %                         A_out=reshape(vec_B,npY,npX,nbcolor);
     839                    %                         ProjData.(FieldData.ListVarName{ivar})=squeeze(sum(A_out,1)/npY);
     840                    %                     end
    841841                    ProjData.ListVarName=[ProjData.ListVarName FieldData.ListVarName{ivar}];
    842842                    ProjData.VarDimName=[ProjData.VarDimName {AXName}];%to generalize with the initial name of the x coordinate
     
    941941                    ProjData.ListVarName=[ProjData.ListVarName FieldData.ListVarName{ivar}];
    942942                    ProjData.VarDimName=[ProjData.VarDimName {AXName}];%to generalize with the initial name of the x coordinate
    943                     nbvar=nbvar+1;
    944                     ProjData.VarAttribute{nbvar}.Role='coord_y';% for plot with continuous line
    945                 end
     943                    nbvar_proj=numel(ProjData.ListVarName);
     944                    if isfield(FieldData.VarAttribute{ivar},'Role')
     945                        if  strcmp(FieldData.VarAttribute{ivar}.Role,'vector_x')
     946                            ivar_U=nbvar_proj;
     947                        elseif strcmp(FieldData.VarAttribute{ivar}.Role,'vector_y')
     948                            ivar_V=nbvar_proj;
     949                        end
     950                    end
     951                    if isequal(ProjMode,'projection')
     952                        ProjData.VarAttribute{nbvar_proj}.Role='discrete';
     953                    else
     954                        ProjData.VarAttribute{nbvar_proj}.Role='coord_y';
     955                    end
     956                end
     957               
    946958                if nbcolor==3
    947959                    ProjData.VarDimName{end}={AXName,'rgb'};
     
    950962           
    951963    end
    952 if ~isempty(ivar_U) && ~isempty(ivar_V)
    953     vector_x =ProjData.(ProjData.ListVarName{ivar_U});
    954     ProjData.(ProjData.ListVarName{ivar_U}) =cos(theta)*vector_x+sin(theta)*ProjData.(ProjData.ListVarName{ivar_V});
    955     ProjData.(ProjData.ListVarName{ivar_V}) =-sin(theta)*vector_x+cos(theta)*ProjData.(ProjData.ListVarName{ivar_V});
    956 end
     964    % for vector fields, take the components longitudinal and tranverse to the projection line
     965    if ~isempty(ivar_U) && ~isempty(ivar_V)
     966        vector_x =ProjData.(ProjData.ListVarName{ivar_U});
     967        ProjData.(ProjData.ListVarName{ivar_U}) =cos(theta)*vector_x+sin(theta)*ProjData.(ProjData.ListVarName{ivar_V});
     968        ProjData.(ProjData.ListVarName{ivar_V}) =-sin(theta)*vector_x+cos(theta)*ProjData.(ProjData.ListVarName{ivar_V});
     969    end
    957970end
    958971
     
    11751188        AYName='coord_y';
    11761189        AXName='coord_x';
    1177         if strcmp(ObjectData.ProjMode,'projection')||strcmp(ObjectData.Type,'plane')
     1190        if strcmp(ObjectData.ProjMode,'projection')%||strcmp(ObjectData.Type,'plane')
    11781191            ProjData.coord_y=[FieldData.YMin FieldData.YMax];%note that if projection is done on a grid, the Min and Max along each direction must have been defined
    11791192            ProjData.coord_x=[FieldData.XMin FieldData.XMax];
  • trunk/src/series/turb_stat.m

    r1071 r1077  
    194194DataOut.Curl2Mean=0;
    195195DataOut.Div2Mean=0;
     196DataOut.KEflux=0;
    196197U2Mean=0;
    197198V2Mean=0;
     
    231232    DataOut.UMean=DataOut.UMean+Field.U; %increment the sum
    232233    DataOut.VMean=DataOut.VMean+Field.V; %increment the sum
     234   
    233235    U2Mean=U2Mean+(Field.U).*(Field.U); %increment the U squared sum
    234236    V2Mean=V2Mean+(Field.V).*(Field.V); %increment the V squared sum
  • trunk/src/transform_field/ima2concentration.m

    r1075 r1077  
    3232cpath=which('uvmat');
    3333addpath(fullfile(fileparts(cpath),'transform_field'))% define path for phys_polar.m
     34
     35%% rescale the image
     36[nby,nbx]=size(DataIn.A);
     37x=linspace(DataIn.Coord_x(1),DataIn.Coord_x(2),nbx)-nbx/2;
     38y=linspace(DataIn.Coord_y(1),DataIn.Coord_y(2),nby)-nby/2;
     39[X,Y]=meshgrid(x,y);
     40coeff_quad=0.15*4/(nbx*nbx);% image luminosity reduced by 10% at the edge
     41DataIn.A=double(DataIn.A).*(1+coeff_quad*(X.*X+Y.*Y));
    3442
    3543%% Transform images to polar coordinates with origin at the light source position
  • trunk/src/uvmat.m

    r1076 r1077  
    14151415end
    14161416
    1417 prompt = {'offset luminosity value in the absence of illumination';'smoothing width for the reference line (in pixels)'};
     1417prompt = {'offset luminosity value in the absence of illumination';'smoothing width for the reference line (in pixels)';...
     1418    'LIF Temperature Coeff1';'LIF Temperature Coeff2';'LIF Temperature Coeff3'};
    14181419    dlg_title = 'set the parameters for LIF';
    1419     num_lines= 2;
    1420     def     = { num2str(BlackOffset);num2str(RefLineWidth)};
     1420    num_lines= 5;
     1421    def     = { num2str(BlackOffset);num2str(RefLineWidth);'0';'0';'0'};
    14211422    answer = inputdlg(prompt,dlg_title,num_lines,def);
    14221423if isempty(answer)
     
    14251426    XmlData.LIFCalib.BlackOffset=str2double(answer{1}) ;% image value for black background, to be determined by taking images with a cover on the objective lens
    14261427    XmlData.LIFCalib.RefLineWidth=str2double(answer{2}) ;% smoothing width used for the reference line
     1428    XmlData.LIFCalib.TLIFCoeff=[str2double(answer{3}) str2double(answer{4}) str2double(answer{5})];
    14271429end
    14281430
     
    14431445XmlData.LIFCalib.Ray2Coord=LineData{2}.Coord;
    14441446XmlData.LIFCalib.RefLineCoord=LineData{3}.Coord;
     1447
     1448%% rescale the image
     1449[nby,nbx]=size(UvData.Field.A);
     1450x=linspace(UvData.Field.Coord_x(1),UvData.Field.Coord_x(2),nbx)-nbx/2;
     1451y=linspace(UvData.Field.Coord_y(1),UvData.Field.Coord_y(2),nby)-nby/2;
     1452[X,Y]=meshgrid(x,y);
     1453coeff_quad=0.15*4/(nbx*nbx);% image luminosity reduced by 10% at the edge
     1454UvData.Field.A=double(UvData.Field.A).*(1+coeff_quad*(X.*X+Y.*Y));
    14451455
    14461456%% display the current image in polar axes with origin at the  illumination source
Note: See TracChangeset for help on using the changeset viewer.