Changeset 494 for trunk/src/uvmat.m


Ignore:
Timestamp:
Jul 19, 2012, 11:50:39 AM (9 years ago)
Author:
sommeria
Message:

various bugs corrected after testing in Windows OS. Introduction
of filter tps

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r491 r494  
    859859XmlData.Time=[];%default
    860860XmlData.GeometryCalib=[];%default
    861 TimeUnit=[];%default
     861TimeUnit='';%default
     862Time=[];
    862863testima=0; %test for image input
    863864imainfo=[];
     
    870871%     nbfield_j=1;
    871872    TimeUnit='s';
    872     XmlData.Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)';
     873    if isempty(j1_series); %frame index along i
     874        Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
     875    else
     876    Time=ones(size(i1_series,1),1)*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
     877    end
    873878    %nbfield=imainfo.NumberOfFrames;
    874879    set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
     
    945950        end
    946951    end
     952end
     953if ~(isfield(XmlData,'Time')&& ~isempty(XmlData.Time))
     954    XmlData.Time=Time; %time set by video
    947955end
    948956
     
    10631071if index==2
    10641072    if get(handles.scan_j,'Value')
    1065         scan_option='j'; %keep the scan option for the second fiel series
     1073        scan_option='j'; %keep the scan option for the second file series
    10661074    end
    10671075    if strcmp(get(handles.j1,'Visible'),'on')
     
    10691077    end
    10701078end
     1079[ref_i,ref_j]=find(i1_series);
    10711080if ~isempty(j1_series)
    10721081        state_j='on';
    1073         if isequal(nbfield,1) &&index==1
    1074             scan_option='j'; %scan j index by default if nbfield=1               
    1075         end
     1082        if index==1
     1083            if isequal(ref_i,ref_i(1)*ones(size(ref_j)))% if ref_i is always equal to its first vzlue
     1084                scan_option='j'; %scan j indext               
     1085            end
     1086        end
    10761087end
    10771088if isequal(scan_option,'i')
     1089    diff_ref_i=diff(ref_i,1);
     1090    if isempty(diff_ref_i)
     1091        diff_ref_i=1;
     1092    end
     1093    if isequal (diff_ref_i,diff_ref_i(1)*ones(size(diff_ref_i)))
     1094        set(handles.increment_scan,'String',num2str(diff_ref_i(1)))
     1095    end
    10781096     set(handles.scan_i,'Value',1)
    10791097     scan_i_Callback([],[], handles);
    10801098else
     1099    diff_ref_j=diff(ref_j);
     1100    if isempty(diff_ref_j)
     1101        diff_ref_j=1;
     1102    end
     1103    if isequal (diff_ref_j,diff_ref_j(1)*ones(size(diff_ref_j)))
     1104        set(handles.increment_scan,'String',num2str(diff_ref_j(1)))
     1105    end
    10811106     set(handles.scan_j,'Value',1)
    10821107     scan_j_Callback([],[], handles);
     
    12461271option=get(handles.view_xml,'String');
    12471272if isequal(option,'view .xml')
    1248     FileXml=[FileBase '.xml'];
     1273    FileXml=fullfile(RootPath,[SubDir '.xml']);
     1274    if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir
     1275        FileXml=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']);
     1276    end
    12491277    heditxml=editxml(FileXml);
    12501278end
     
    12561284%case of view mask selection
    12571285if isequal(get(handles.CheckMask,'Value'),1)
    1258    % [FF,RootPath,FileBase]=read_file_boxes(handles);
    12591286     [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    12601287     FileBase=fullfile(RootPath,RootFile);
     
    12701297            maskname=maskfiles(ilist).name;% take the first mask file in the list
    12711298            [tild,tild,tild,tild,tild,tild,tild,MaskExt,Mask_NomType{ilist}]=fileparts_uvmat(maskname);
    1272 %             [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
    12731299             [tild,Name]=fileparts(maskname);
    12741300            Namedouble=double(Name);
     
    19551981end
    19561982NomType=get(handles.NomType,'String');
     1983NomType_1='';
     1984if strcmp(get(handles.NomType_1,'Visible'),'on')
     1985    NomType_1=get(handles.NomType_1,'String');
     1986end
    19571987% NomType=get(handles.FileIndex,'UserData');
    19581988%update the z position index
     
    21102140        ParamOut_1=UvData.ParamOut_1;
    21112141    else
     2142        if isstruct(ParamIn_1)
    21122143        ParamIn_1.FieldName=FieldName_1;
    21132144        ParamIn_1.VelType=VelType_1;
    21142145        ParamIn_1.GUIName='get_field_1';
     2146        end
    21152147        [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn_1,frame_index_1);
    21162148        if ~isempty(errormsg)
     
    21742206        test_veltype_1=1;
    21752207        set(handles.VelType_1,'Visible','on')
    2176 %         if ~get(handles.FixVelType,'Value')
    2177             menu=set_veltype_display(ParamOut_1.CivStage);
    2178             index_menu=strcmp(ParamOut_1.VelType,menu);
    2179             set(handles.VelType_1,'Value',1+find(index_menu,1))
    2180             set(handles.VelType_1,'String',[{''};menu])
    2181 %         end
     2208        menu=set_veltype_display(ParamOut_1.CivStage);
     2209        index_menu=strcmp(ParamOut_1.VelType,menu);
     2210        set(handles.VelType_1,'Value',1+find(index_menu,1))
     2211        set(handles.VelType_1,'String',[{''};menu])
    21822212    end
    21832213    % update the second field menu: the same quantity
     2214    if isstruct(ParamOut_1)
    21842215    set(handles.Fields_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu
    21852216    % display the Fields menu from the input file and pick the selected one:
    21862217    field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
    21872218    set(handles.Fields_1,'Value',find(field_index,1)+1) 
    2188 %     % synchronise  with the first menu if the first selection is not 'velocity'
    2189 %     if ~strcmp(ParamOut.FieldName,'velocity')
    2190 %         field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
    2191 %         set(handles.Fields_1,'Value',field_index); %update the field menu
    2192 %         ParamOut_1.FieldName=ParamOut.FieldName;
    2193 %         set(handles.Fields_1,'String',ParamOut_1.FieldList)
    2194 %     end
     2219    end
     2220   
    21952221end
    21962222if test_veltype||test_veltype_1
     
    23372363        Field{1}=transform(Field{1},XmlData);
    23382364    end
    2339     %% update tps in phys coordinates if needed
    2340     if (strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))&& strcmp(UvData.FileType{1},'civdata')&&isfield(Field{1},'U')&& isfield(Field{1},'V')
    2341         Field{1}.X=Field{1}.X(Field{1}.FF==0);
    2342         Field{1}.Y=Field{1}.Y(Field{1}.FF==0);
    2343         Field{1}.U=Field{1}.U(Field{1}.FF==0);
    2344         Field{1}.V=Field{1}.V(Field{1}.FF==0);
    2345         [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps]=filter_tps([Field{1}.X Field{1}.Y],Field{1}.U,Field{1}.V,[],Field{1}.Patch1_SubDomain,0);
    2346     end
    2347     if numel(Field)==2 && ~test_keepdata_1 && isequal(UvData.FileType{2}(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1)
    2348         %update tps in phys coordinates if needed
    2349         if (strcmp(VelType_1,'filter1')||strcmp(VelType_1,'filter2'))&& strcmp(UvData.FileType{2},'civdata')&&isfield(Field{2},'U')&& isfield(Field{2},'V')
    2350             Field{2}.X=Field{2}.X(Field{2}.FF==0);
    2351             Field{2}.Y=Field{1}.Y(Field{2}.FF==0);
    2352             Field{2}.U=Field{1}.U(Field{2}.FF==0);
    2353             Field{2}.V=Field{1}.V(Field{2}.FF==0);
    2354             [Field{2}.SubRange,Field{2}.NbSites,Field{2}.Coord_tps,Field{2}.U_tps,Field{2}.V_tps]=filter_tps([Field{2}.X Field{2}.Y],Field{2}.U,Field{2}.V,[],1500,0);
     2365   
     2366    %% check whether tps is needed, then calculate tps coefficients if needed
     2367    check_tps=0;
     2368    if strcmp(UvData.FileType{1},'civdata')|| strcmp(UvData.FileType{1},'civx')
     2369        switch ParamOut.FieldName
     2370            case {'vort','div','strain'}
     2371                check_tps=1;
     2372            otherwise
     2373                check_tps=0;
     2374                if isfield(UvData,'Object')
     2375                for iobj=1:numel(UvData.Object)
     2376                    UvData.Object{iobj}
     2377                    if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'filter')
     2378                        check_tps=1;
     2379                        break
     2380                    end
     2381                end
     2382                end
     2383        end
     2384    end
     2385    if check_tps
     2386        SubDomain=1500; %default, estimated nbre of vectors in a subdomain used for tps
     2387        if isfield(Field{1},'SubDomain')
     2388            SubDomain=Field{1}.SubDomain;%
     2389        end
     2390        [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps,tild,U_smooth,V_smooth,W_smooth,FF] =...
     2391           filter_tps([Field{1}.X(Field{1}.FF==0) Field{1}.Y(Field{1}.FF==0)],Field{1}.U(Field{1}.FF==0),Field{1}.V(Field{1}.FF==0),[],SubDomain,0);
     2392        nbvar=numel(Field{1}.ListVarName);
     2393        Field{1}.ListVarName=[Field{1}.ListVarName {'SubRange','NbSites','Coord_tps','U_tps','V_tps'}];
     2394        Field{1}.VarDimName=[Field{1}.VarDimName {{'nb_coord','nb_bounds','nb_subdomain'},{'nb_subdomain'},...
     2395            {'nb_tps','nb_coord','nb_subdomain'},{'nb_tps','nb_subdomain'},{'nb_tps','nb_subdomain'}}];
     2396        Field{1}.VarAttribute{nbvar+3}.Role='coord_tps';
     2397        Field{1}.VarAttribute{nbvar+4}.Role='vector_x';
     2398        Field{1}.VarAttribute{nbvar+5}.Role='vector_y';
     2399        if isfield(Field{1},'ListDimName')%cleaning
     2400            Field{1}=rmfield(Field{1},'ListDimName');
     2401        end
     2402        if isfield(Field{1},'DimValue')%cleaning
     2403            Field{1}=rmfield(Field{1},'DimValue');
    23552404        end
    23562405    end
     
    30953144[tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]);
    30963145if isequal(field,'image')
    3097     SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
    3098     imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]);
     3146    if  isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file
     3147        imagename=UvData.Field.Civ2_ImageA;
     3148    elseif isfield(UvData.Field,'Civ1_ImageA')%
     3149        imagename=UvData.Field.Civ1_ImageA;
     3150    else
     3151        SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
     3152        imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]);
     3153    end
    30993154    if ~exist(imagename,'file')
    31003155        [FileName,PathName] = uigetfile( ...
     
    31993254        end
    32003255    case 'image'
    3201         % guess the image name corresponding to the current netcdf name (no unique correspondance)
    3202         SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.'
    3203         imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1);
     3256        % get the image name corresponding to the current netcdf name (no unique correspondance)
     3257        if  isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file
     3258            imagename=UvData.Field.Civ2_ImageA;
     3259        elseif isfield(UvData.Field,'Civ1_ImageA')%
     3260            imagename=UvData.Field.Civ1_ImageA;
     3261        else
     3262            SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.'
     3263            imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1);
     3264        end
    32043265        if ~exist(imagename,'file') % browse for images if it is not found
    32053266            [FileName,PathName] = uigetfile( ...
Note: See TracChangeset for help on using the changeset viewer.