Changeset 411


Ignore:
Timestamp:
May 7, 2012, 3:32:21 PM (13 years ago)
Author:
sommeria
Message:

bugs corrected in uvmat: fixed x/y and calc_field for the new PIV data

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field.m

    r408 r411  
    168168                case 'velocity'
    169169                    ListFields={'U', 'V'};
    170                     VarAttributes{var_count+1}.Role='vector_x';
    171                     VarAttributes{var_count+2}.Role='vector_y';
     170                    VarAttribute{var_count+1}.Role='vector_x';
     171                    VarAttribute{var_count+2}.Role='vector_y';
    172172                    DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
    173173                    DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
    174174                case 'u'
    175175                    ListFields={'u'};
    176                     VarAttributes{var_count+1}.Role='scalar';
     176                    VarAttribute{var_count+1}.Role='scalar';
    177177                    DataOut.u(ind_sel)=DataOut.u(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
    178178                case 'v'
    179179                    ListFields={'v'};
    180                     VarAttributes{var_count+1}.Role='scalar';
     180                    VarAttribute{var_count+1}.Role='scalar';
    181181                    DataOut.v(ind_sel)=DataOut.v(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
    182182                case 'norm_vel'
    183183                    ListFields={'norm_vel'};
    184                     VarAttributes{var_count+1}.Role='scalar';
    185                     V=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
     184                    VarAttribute{var_count+1}.Role='scalar';
     185                    U=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
    186186                    V=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
    187187                    DataOut.norm_vel(ind_sel)=sqrt(U.*U+V.*V);
    188188                case 'vort'
    189189                    ListFields={'vort'};
    190                     VarAttributes{var_count+1}.Role='scalar';
    191                     DataOut.vort(ind_sel)=DataOut.vort(ind_sel)+EMDY *DataIn.U_tps(1:nbvec_sub+3,isub)-EMDX *DataIn.V_tps(1:nbvec_sub+3,isub);
     190                    VarAttribute{var_count+1}.Role='scalar';
     191                    DataOut.vort(ind_sel)=DataOut.vort(ind_sel)-EMDY *DataIn.U_tps(1:nbvec_sub+3,isub)+EMDX *DataIn.V_tps(1:nbvec_sub+3,isub);
    192192                case 'div'
    193193                    ListFields={'div'};
    194                     VarAttributes{var_count+1}.Role='scalar';
     194                    VarAttribute{var_count+1}.Role='scalar';
    195195                    DataOut.div(ind_sel)=DataOut.div(ind_sel)+EMDX*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDY *DataIn.V_tps(1:nbvec_sub+3,isub);
    196196                case 'strain'
    197197                    ListFields={'strain'};
    198                     VarAttributes{var_count+1}.Role='scalar';
     198                    VarAttribute{var_count+1}.Role='scalar';
    199199                    DataOut.strain(ind_sel)=DataOut.strain(ind_sel)+EMDY*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDX *DataIn.V_tps(1:nbvec_sub+3,isub);
    200200            end
    201             DataOut.FF=nbval==0; %put errorflag to 1 for points outside the interpolation rang
    202             nbval(nbval==0)=1;
    203             DataOut.ListVarName=[DataOut.ListVarName ListFields {'FF'}];
    204             for ilist=1:numel(ListFields)
    205                 VarDimName{ilist}={'coord_y','coord_x'};
    206                 DataOut.(ListFields{ilist})=reshape(DataOut.(ListFields{ilist}),npy,npx);
    207             end
    208             DataOut.FF=reshape(DataOut.FF,npy,npx);
    209             DataOut.VarDimName=[DataOut.VarDimName VarDimName {{'coord_y','coord_x'}}] ;
    210             VarAttributes{length(ListFields)+1}.Role='errorflag';
    211             DataOut.VarAttribute=[DataOut.VarAttribute VarAttributes];
    212         end
    213     end
     201        end
     202    end
     203    DataOut.FF=nbval==0; %put errorflag to 1 for points outside the interpolation rang
     204    nbval(nbval==0)=1;
     205    if isempty(find(strcmp('FF',DataOut.ListVarName),1))% if FF is not already listed
     206        DataOut.ListVarName=[DataOut.ListVarName {'FF'}];
     207        DataOut.VarDimName=[DataOut.VarDimName {{'coord_y','coord_x'}}];
     208        DataOut.VarAttribute{length(DataOut.ListVarName)}.Role='errorflag';
     209    end
     210    DataOut.ListVarName=[DataOut.ListVarName ListFields];
     211    for ifield=1:numel(ListFields)
     212        VarDimName{ifield}={'coord_y','coord_x'};
     213        DataOut.(ListFields{ifield})=reshape(DataOut.(ListFields{ifield}),npy,npx);
     214    end
     215    DataOut.FF=reshape(DataOut.FF,npy,npx);
     216    DataOut.VarDimName=[DataOut.VarDimName VarDimName];     
     217    DataOut.VarAttribute=[DataOut.VarAttribute VarAttribute];
    214218else
    215219
  • trunk/src/civ_matlab.m

    r410 r411  
    490490
    491491%% Apply mask
    492     % Convention for mask
     492    % Convention for mask IDEAS TO IMPLEMENT ?
    493493    % mask >200 : velocity calculated
    494494    %  200 >=mask>150;velocity not calculated, interpolation allowed (bad spots)
    495495    % 150>=mask >100: velocity not calculated, nor interpolated
    496     %  100>=mask> 20: velocity not calculated, impermeable (no flux through mask boundaries) TO IMPLEMENT
     496    %  100>=mask> 20: velocity not calculated, impermeable (no flux through mask boundaries)
    497497    %  20>=mask: velocity=0
    498498checkmask=0;
     
    504504   end
    505505  %  check_noflux=(par_civ.Mask<100) ;%TODO: to implement
    506     check_undefined=(par_civ.Mask<200 & par_civ.Mask>=100 );
     506    check_undefined=(par_civ.Mask<200 & par_civ.Mask>=20 );
    507507    par_civ.ImageA(check_undefined)=min(min(par_civ.ImageA));% put image A to zero (i.e. the min image value) in the undefined  area
    508508    par_civ.ImageB(check_undefined)=min(min(par_civ.ImageB));% put image B to zero (i.e. the min image value) in the undefined  area
  • trunk/src/find_field_indices.m

    r404 r411  
    5252function [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data)
    5353CellVarIndex={};
     54
    5455NbDim=[];
    5556VarType=[];
     
    105106    'ancillary','image','color','discrete','scalar','coord_tps'};
    106107NbDim=zeros(size(CellVarIndex));%default
     108if isfield(Data,'VarAttribute');
     109    VarAttribute=Data.VarAttribute;
     110else
     111    VarAttribute={};
     112end
    107113for icell=1:length(CellVarIndex)
    108114    for ilist=1:numel(ListRole)
     
    111117    VarIndex=CellVarIndex{icell};%set of variable indices with the same dim
    112118    DimCell=Data.VarDimName{VarIndex(1)};% list of dimensions for each variable in the cell #icell
    113     if isfield(Data,'VarAttribute');
    114         VarAttribute=Data.VarAttribute;
    115     else
    116         VarAttribute={};
    117     end
    118119    test_2D=0;
    119120    for ivar=VarIndex
     
    181182    VarType{icell}.coord=coord;
    182183    if NbDim(icell)==0 && test_2D %look at attributes Coord_1, coord_2 (obsolete convention)
    183         NbDim(icell)=2;
     184        NbDim(icell)=2;     
    184185    end
    185186    %look for tps data
  • trunk/src/plot_field.m

    r405 r411  
    100100PlotType='text'; %default
    101101PlotParamOut=PlotParam;%default
    102 Coordinates=[];
    103 if isfield(PlotParam,'Coordinates')
    104 Coordinates=PlotParam.Coordinates;
     102if ~isfield(PlotParam,'Coordinates')
     103    PlotParam.Coordinates=[];
    105104end
    106105
     
    193192   
    194193    %% set axes properties
    195     if isfield(Coordinates,'CheckFixLimits') && isequal(Coordinates.CheckFixLimits,1)  %adjust the graph limits
     194    if isfield(PlotParam.Coordinates,'CheckFixLimits') && isequal(PlotParam.Coordinates.CheckFixLimits,1)  %adjust the graph limits
    196195        set(haxes,'XLimMode', 'manual')
    197196        set(haxes,'YLimMode', 'manual')
     
    200199        set(haxes,'YLimMode', 'auto')
    201200    end
    202     if ~isfield(Coordinates,'CheckFixEqual')&& isfield(Data,'CoordUnit')
    203         Coordinates.CheckFixEqual=1;
    204     end
    205     if isfield(Coordinates,'CheckFixEqual') && isequal(Coordinates.CheckFixEqual,1)
     201    if ~isfield(PlotParam.Coordinates,'CheckFixEqual')&& isfield(Data,'CoordUnit')
     202        PlotParam.Coordinates.CheckFixEqual=1;% if CoordUnit is defined, the two coordiantes should be plotted with equal scale by default
     203    end
     204    if isfield(PlotParam.Coordinates,'CheckFixEqual') && isequal(PlotParam.Coordinates.CheckFixEqual,1)
    206205        set(haxes,'DataAspectRatioMode','manual')
    207206        set(haxes,'DataAspectRatio',[1 1 1])
     
    228227        end
    229228    else
    230         Coordinates=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,Coordinates);%
     229        Coordinates=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,PlotParam.Coordinates);%
    231230        if testzoomaxes
    232231            [zoomaxes,Coordinates]=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),zoomaxes,PlotParam.Coordinates);
     
    499498function [haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,PosColorbar)
    500499%-------------------------------------------------------------------
    501 grid(haxes, 'off')
     500
     501grid(haxes, 'off')% remove grid (possibly remaining from other graphs)
    502502%default plotting parameters
    503503PlotType='plane';%default
     
    505505    PlotParam=[];
    506506end
    507 if ~isfield(PlotParam,'Coordinates')
    508     PlotParam.Coordinates=[];
    509 end
     507
    510508if ~isfield(PlotParam,'Scalar')
    511509    PlotParam.Scalar=[];
     
    866864                hima=imagesc(AX,AY,B,[MaxA-1 MaxA]);
    867865            end
    868             set(hima,'Tag','ima','HitTest','off')
     866            % the function imagesc reset the axes 'DataAspectRatioMode'='auto', change if .CheckFixEqual is
     867            % requested:
     868           if isfield(PlotParam.Coordinates,'CheckFixEqual') && isequal(PlotParam.Coordinates.CheckFixEqual,1)
     869                set(haxes,'DataAspectRatioMode','manual')
     870                set(haxes,'DataAspectRatio',[1 1 1])
     871           end
     872            set(hima,'Tag','ima')
     873            set(hima,'HitTest','off')
    869874            set(haxes,'Tag',tag);%preserve the axes tag (removed by image fct !!!)     
    870875            uistack(hima, 'bottom')
  • trunk/src/uvmat.m

    r410 r411  
    24562456%% Plot the projections on the selected  projection objects
    24572457% main projection object (uvmat display)
    2458 list_object=get(handles.ListObject,'String');
     2458list_object=get(handles.ListObject_1,'String');
    24592459if isequal(list_object,{''})%refresh list of objects if the menu is empty
    24602460    UvData.Object={[]};
    2461     set(handles.ListObject,'Value',1)
    2462 end
    2463 IndexObj=get(handles.ListObject,'Value');%selected projection object for main view
     2461    set(handles.ListObject_1,'Value',1)
     2462end
     2463IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view
    24642464if IndexObj(1)> numel(UvData.Object)
    24652465    IndexObj(1)=1;%select the first object if the selected one does not exist
    2466     set(handles.ListObject,'Value',1)
     2466    set(handles.ListObject_1,'Value',1)
     2467end
     2468IndexObj(2)=get(handles.ListObject,'Value');%selected projection object for main view
     2469if isequal(IndexObj(2),IndexObj(1))
     2470    IndexObj(2)=[];
    24672471end
    24682472plot_handles{1}=handles;
     
    27442748% --- Executes on button press in CheckFixEqual.
    27452749function CheckFixEqual_Callback(hObject, eventdata, handles)
    2746 test=get(handles.CheckFixEqual,'Value');
    2747 if test
     2750if get(handles.CheckFixEqual,'Value')
    27482751    set(handles.CheckFixEqual,'BackgroundColor',[1 1 0])
    2749     cla(handles.axes3)
    27502752    update_plot(handles);
    27512753else
    27522754    set(handles.CheckFixEqual,'BackgroundColor',[0.7 0.7 0.7])
    27532755    update_plot(handles);
    2754 %     axis(handles.axes3,'image')
    27552756end
    27562757
     
    34653466
    34663467%delete mask if it is displayed
    3467 if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on
    3468    UvData=rmfield(UvData,'MaskName'); %will impose mask refresh 
    3469 end
     3468% if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on
     3469%    UvData=rmfield(UvData,'MaskName'); %will impose mask refresh 
     3470% end
    34703471set(handles.uvmat,'UserData',UvData)
    34713472run0_Callback(hObject, eventdata, handles)
Note: See TracChangeset for help on using the changeset viewer.