Changeset 580


Ignore:
Timestamp:
Mar 7, 2013, 1:47:51 PM (12 years ago)
Author:
sommeria
Message:

bugs corrected for combining fields

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field.m

    r575 r580  
    1 %'calc_field': defines fields (velocity, vort, div...) from civx data (old conventions) and calculate them.
     1%'calc_field': defines fields (velocity, vort, div...) OBSOLETE: fusionner
     2%avec calc_field_interp et calc_field_tps
    23%---------------------------------------------------------------------
    34% [DataOut,errormsg]=calc_field(FieldList,DataIn,Coord_interp)
     
    4445    'U';... %u velocity component
    4546    'V';... %v velocity component
    46     'w';... %w velocity component
    47     'w_normal';... %w velocity component normal to the plane
     47    'W';... %w velocity component
     48    'W_normal';... %w velocity component normal to the plane
    4849    'error'}; %error associated to a vector (for stereo or patch)
    4950ColorList={'C';...%image correlation corresponding to a vel vector
  • trunk/src/find_field_cells.m

    r576 r580  
    205205VarDimName=Data.VarDimName(~check_select);%dimensions of remaining variables
    206206check_coord_select= cellfun(@numel,VarDimName)==1|cellfun(@ischar,VarDimName)==1;% find remaining variables with a single dimension
    207 check_coord(~check_select)=check_coord_select;
    208 ListCoordIndex=ivar_remain(check_coord);% indices of remaining variables with a single dimension
    209 ListCoordName=Data.ListVarName(ListCoordIndex);% corresponding names of remaining variables with a single dimension
    210 ListDimName=Data.VarDimName(ListCoordIndex);% dimension names of remaining variables with a single dimension
     207%check_coord(~check_select)=check_coord_select;
     208ListCoordIndex=ivar_remain(check_coord_select);% indices of remaining variables with a single dimension
     209ListCoordName=ListVarName(check_coord_select);% corresponding names of remaining variables with a single dimension
     210ListDimName=VarDimName(check_coord_select);% dimension names of remaining variables with a single dimension
    211211
    212212%remove redondant variables -> keep only one variable per dimension
     
    222222    end
    223223end
    224 ListCoordIndex=ListCoordIndex(check_keep);% list of coordinate variable indices
     224ListCoordIndex=ListCoordIndex(check_coord_select);% list of coordinate variable indices
    225225ListCoordName=ListCoordName(check_keep);% list of coordinate variable names
    226226ListDimName=ListDimName(check_keep);% list of coordinate dimension names
  • trunk/src/read_civdata.m

    r576 r580  
    22%------------------------------------------------------------------
    33%
    4 % function [Field,VelTypeOut]=read_civxdata(filename,FieldNames,VelType)
     4% function [Field,VelTypeOut]=read_civdata(filename,FieldNames,VelType)
    55%
    66% OUTPUT:
     
    2626%                    .FF: error flag, =0 for good vectors
    2727%                     .C: scalar associated with velocity (used for vector colors)
    28 %                    .DijU; matrix of spatial derivatives (DijU(1,1,:)=DUDX,
    29 %                        DijU(1,2,:)=DUDY, Dij(2,1,:)=DVDX, DijU(2,2,:)=DVDY
    3028%
    3129% VelTypeOut: velocity type corresponding to the selected field: ='civ1','interp1','interp2','civ2'....
  • trunk/src/read_field.m

    r576 r580  
    77% ParamOut: structure representing parameters:
    88%        .FieldName; field name
    9 %        .FieldList: menu of possible fields
    109%        .VelType
    1110%        .CivStage: stage of civx processing (=0, not Civx, =1 (civ1), =2  (fix1)....     
     
    131130if ~isempty(A)
    132131    if isstruct(ParamOut)
    133     ParamOut.FieldName='image';
    134     ParamOut.FieldList={'image'};
     132        ParamOut.FieldName='image';
    135133    end
    136134    Npz=1;%default
    137135    npxy=size(A);
    138 %     Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
    139 %     Rangy=[npxy(1)-0.5 0.5]; %
     136    %     Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
     137    %     Rangy=[npxy(1)-0.5 0.5]; %
    140138    Field.NbDim=2;%default
    141139    Field.AName='image';
     
    147145            Field.AX=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
    148146            if isstruct(ParamOut)
    149             ParamOut.Npx=npxy(2);% display image size on the interface
    150             ParamOut.Npy=npxy(1);
     147                ParamOut.Npx=npxy(2);% display image size on the interface
     148                ParamOut.Npy=npxy(1);
    151149            end
    152150            Field.VarAttribute{3}.Mesh=1;
     
    159157            Field.AX=[0.5 npxy(3)-0.5]; % coordinates of the first and last pixel centers
    160158            if isstruct(ParamOut)
    161             ParamOut.Npx=npxy(3);% display image size on the interface
    162             ParamOut.Npy=npxy(2);
    163              end
     159                ParamOut.Npx=npxy(3);% display image size on the interface
     160                ParamOut.Npy=npxy(2);
     161            end
    164162            Field.VarAttribute{4}.Mesh=1;
    165163        end
  • trunk/src/sub_field.m

    r548 r580  
    105105end
    106106
    107 %look for coordinates common to Field in Field_1
     107%% look for coordinates common to Field in Field_1
    108108ind_remove=zeros(size(Field_1.ListVarName));
    109109for ilist=1:numel(Field_1.ListVarName)
     
    121121                   NewDim={NewDim};
    122122               end
    123                Field_1.VarDimName=regexprep_r(Field_1.VarDimName,OldDim{1},NewDim{1});
     123               Field_1.VarDimName=regexprep_r(Field_1.VarDimName,['^' OldDim{1} '$'],NewDim{1});
    124124            end
    125125        end
     
    130130Field_1.VarAttribute(find(ind_remove))=[];
    131131
    132 %append the other variables of the second field, modifying their name if needed
     132%% append the other variables of the second field, modifying their name if needed
    133133for ilist=1:numel(Field_1.ListVarName)
    134134    VarName=Field_1.ListVarName{ilist};
     
    138138    else  % variable name exists in Field     
    139139            VarNameNew=[VarName '_1'];   
     140            if isfield(Field_1.VarAttribute{ilist},'FieldName')
     141                Field_1.VarAttribute{ilist}.FieldName=regexprep_r(Field_1.VarAttribute{ilist}.FieldName,VarName,VarNameNew);
     142            end
    140143    end
    141144        SubData.ListVarName=[SubData.ListVarName {VarNameNew}];
     
    146149end
    147150
    148 %append the other variables of the second field, modifying their name if needed
    149 
    150151%% substrat fields when possible
    151152%[CellVarIndex,NbDim,CellVarType,errormsg]=find_field_cells(SubData);
    152 [CellInfo,NbDim,errormsg]=find_field_cells(SubData)
     153[CellInfo,NbDim,errormsg]=find_field_cells(SubData);
    153154ind_remove=zeros(size(SubData.ListVarName));
    154155ivar=[];
     
    179180SubData.VarDimName(find(ind_remove))=[];
    180181SubData.VarAttribute(find(ind_remove))=[];
     182%end
    181183
    182 function OutputCell=regexprep_r(InputCell,dimname,dimname_new)
     184function OutputCell=regexprep_r(InputCell,search_string,new_string)
    183185for icell=1:numel(InputCell)
    184     OutputCell{icell}=regexprep(InputCell{icell},['^' dimname '$'],dimname_new);
     186    OutputCell{icell}=regexprep(InputCell{icell},search_string,new_string);
    185187end
    186188       
  • trunk/src/uvmat.m

    r579 r580  
    10251025        set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
    10261026        set(handles_Fields,'Value',2) % set menu to 'velocity
     1027        if index==1
     1028            set(handles.FieldName_1,'Value',1);
     1029            set(handles.FieldName_1,'String',[{''};{'image'};FieldList;{'get_field...'}]);%standard menu for civx data reproduced for the second field
     1030        end
    10271031        set(handles.ColorScalar,'Value',1)
    10281032        set(handles.ColorScalar,'String',ColorList)
     
    21382142        return
    21392143    end
    2140     Name=FileName_1;
     2144   % Name=FileName_1;
    21412145    switch UvData.FileType{2}
    21422146        case {'civx','civdata','netcdf'};
     
    21882192    test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
    21892193    if ~isequal(NomType_1,'*')&& isfield(UvData,'FileName_1')
    2190            test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ;%&& strcmp(FieldName_1,UvData.FieldName_1);
     2194           test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ;
    21912195    end
    21922196    if test_keepdata_1
     
    21992203        ParamIn_1.GUIName='get_field_1';
    22002204        end 
    2201         [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn_1,frame_index_1);
     2205        [Field{2},ParamOut_1,errormsg] = read_field(FileName_1,UvData.FileType{2},ParamIn_1,frame_index_1);
    22022206        if ~isempty(errormsg)
    22032207            errormsg=['error in reading ' FieldName_1 ' in ' FileName_1 ': ' errormsg];
     
    22562260test_veltype_1=0;
    22572261if isempty(FileName_1)
    2258 %     set(handles.FieldName_1,'Value',1); %update the field menu
    2259 %     if isstruct(ParamOut)
    2260 %     set(handles.FieldName_1,'String',[{''};ParamOut.FieldList]); %update the field menu
    2261 %     end
     2262    %     set(handles.FieldName_1,'Value',1); %update the field menu
     2263    %     if isstruct(ParamOut)
     2264    %     set(handles.FieldName_1,'String',[{''};ParamOut.FieldList]); %update the field menu
     2265    %     end
    22622266elseif ~test_keepdata_1
    22632267    if (~strcmp(UvData.FileType{2},'netcdf')&&~strcmp(UvData.FileType{2},'civdata')&&~strcmp(UvData.FileType{2},'civx'))|| isequal(FieldName_1,'get_field...')
     
    22732277    % update the second field menu: the same quantity
    22742278    if isstruct(ParamOut_1)
    2275     set(handles.FieldName_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu
    2276     % display the FieldName menu from the input file and pick the selected one:
    2277     field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
    2278     set(handles.FieldName_1,'Value',find(field_index,1)+1) 
    2279     end
    2280    
     2279%        set(handles.FieldName_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu
     2280        % display the FieldName menu from the input file and pick the selected one:
     2281        FieldList=get(handles.FieldName_1,'String');
     2282        field_index=strcmp(ParamOut_1.FieldName,FieldList);
     2283        if ~isempty(field_index)
     2284            set(handles.FieldName_1,'Value',find(field_index,1))
     2285        end
     2286    end
    22812287end
    22822288if test_veltype||test_veltype_1
    2283      set(handles.FixVelType,'Visible','on')
     2289    set(handles.FixVelType,'Visible','on')
    22842290else
    2285      set(handles.FixVelType,'Visible','off')
     2291    set(handles.FixVelType,'Visible','off')
    22862292end
    22872293
     
    29632969    set(handles.VelType_1,'Value',1);%set to blank state
    29642970    set(handles.num_Opacity,'String','')% desactivate opacity setting
     2971    FieldList=get(handles.FieldName,'String');
     2972    if numel(FieldList)>1   % if a choice of fields exists
     2973        set(handles.FieldName_1,'Value',1)% set second field choice to blank
     2974        set(handles.FieldName_1,'String',[{''};FieldList])% reproduce the menu FieldName plus a blank option
     2975    else
     2976        set(handles.FieldName_1,'String',{''})% set second field choice to blank
     2977    end
    29652978    if ~strcmp(get(handles.VelType,'Visible'),'on')
    29662979        set(handles.VelType_1,'Visible','off')
     
    31943207        end
    31953208    otherwise
    3196         if check_new
    3197             UvData.FileType{2}=UvData.FileType{1};
     3209        check_refresh=1;
     3210        if check_new% if a second field was not previously entered, we just read another field in the first input file
    31983211            set(handles.FileIndex_1,'String',get(handles.FileIndex,'String'))
    31993212            set(handles.FileExt_1,'String',get(handles.FileExt,'String'))
     3213           
     3214            UvData.FileType{2}=UvData.FileType{1};
     3215            UvData.XmlData{2}= UvData.XmlData{1};
     3216            transform=get(handles.path_transform,'UserData');
     3217             if (~isa(transform,'function_handle')||nargin(transform)<3)
     3218                set(handles.uvmat,'UserData',UvData)
     3219                set(handles.transform_fct,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields
     3220                transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot
     3221                 check_refresh=0;
     3222             end             
    32003223        end
    32013224        if ~isequal(field,'image')
     
    32053228        end
    32063229        set(handles.uvmat,'UserData',UvData)
    3207         if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
     3230 
     3231        if check_refresh && ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
    32083232            run0_Callback(hObject, eventdata, handles)
    32093233        end
     
    32803304        FileName_1='';% we plot the first input field without the second field
    32813305        set(handles.SubField,'Value',0)
    3282         SubField_Callback(hObject, eventdata, handles)% activate SubField_Callback and refresh current display, removing the second field
     3306        SubField_Callback(hObject, eventdata, handles)% activate SubField_Callback and refresh current plot, removing the second field
    32833307elseif get(handles.SubField,'Value')% if subfield is already 'on'
    32843308     FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];% name of the second input file
    3285      check_refresh=1;%will refresh the current display
     3309     check_refresh=1;%will refresh the current plot
    32863310else% we introduce the same file (with a different field) for the second series
    32873311     FileName_1=FileName;% we compare two fields in the same file
     
    32913315     transform=get(handles.path_transform,'UserData');
    32923316     if (~isa(transform,'function_handle')||nargin(transform)<3)
    3293         set(handles.transform_fct,'value',2); % set transform to sub_field if the current fct doe not accept two input fields
    3294         transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current display
     3317        set(handles.uvmat,'UserData',UvData)
     3318        set(handles.transform_fct,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields
     3319        transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot
    32953320     else
    32963321         check_refresh=1;
     
    32983323end
    32993324
    3300 % refresh the current display if it has not been done previously
     3325% refresh the current plot if it has not been done previously
    33013326if check_refresh
    33023327    UvData.FileName_1='';% desactivate the use of a constant second file
     
    33213346end
    33223347
    3323 %-----------------------------------------------
     3348
     3349%-----------------------------------------------------------------------
    33243350% --- reset civ buttons
    33253351function reset_vel_type(handles_civ0,handle1)
     3352%-----------------------------------------------------------------------
    33263353for ibutton=1:length(handles_civ0)
    33273354    set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
     
    33323359end
    33333360
    3334 %-------------------------------------------------------
     3361%-----------------------------------------------------------------------
    33353362% --- Executes on button press in MENUVOLUME.
    3336 %-------------------------------------------------------
    33373363function VOLUME_Callback(hObject, eventdata, handles)
     3364%-----------------------------------------------------------------------
    33383365%errordlg('command VOL not implemented yet')
    33393366if ishandle(handles.UVMAT_title)
Note: See TracChangeset for help on using the changeset viewer.