Changeset 492


Ignore:
Timestamp:
Jul 15, 2012, 10:30:28 AM (8 years ago)
Author:
sommeria
Message:

civ corrected to deal with windows system
proj_field improved to provject tps fields on lines

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r487 r492  
    2424%TODO: search range
    2525
    26 % Last Modified by GUIDE v2.5 21-Jun-2012 23:37:47
     26% Last Modified by GUIDE v2.5 13-Jul-2012 15:11:00
    2727% Begin initialization code - DO NOT EDIT
    2828gui_Singleton = 1;
     
    533533end
    534534if isempty(time) && (strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
    535     set(handles.ListPairMode,'Value',1);
    536     set(handles.ListPairMode,'String',{'series(Di)'})
     535               set(handles.ListPairMode,'Value',1);
    537536    dt=1/get(MovieObject,'FrameRate');%time interval between successive frames
    538     MaxIndex_i=get(MovieObject,'NumberOfFrames');
    539     time=(dt*(0:MaxIndex_i-1))';%list of image times
     537    if strcmp(NomTypeIma,'*')
     538        set(handles.ListPairMode,'String',{'series(Di)'})
     539        MaxIndex_i=get(MovieObject,'NumberOfFrames');
     540        time=(dt*(0:MaxIndex_i-1))';%list of image times
     541    else
     542        set(handles.ListPairMode,'String',[{'series(Dj)'};{'series(Di)'}])
     543        MaxIndex_i=max(i1_series(i1_series>0));
     544        MaxIndex_j=get(MovieObject,'NumberOfFrames');   
     545        time=ones(MaxIndex_i,1)*(dt*(0:MaxIndex_j-1));%list of image times
     546        enable_j(handles,'on')
     547    end
    540548    TimeUnit='s';
    541549    set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter
     
    614622        set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large
    615623    end
    616 else
     624elseif ~(strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
    617625    set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice
    618626    if strcmp(NomTypeNc,'_1-2_1')
     
    25492557    set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default
    25502558end
    2551 % if strcmp(option,'stereo PIV') && get(handles.CheckPatch1,'Value')
    2552 %     set(handles.CheckStereo,'Visible','on')
    2553 % else
    2554 %     set(handles.CheckStereo,'Visible','off')
    2555 % end
    2556 % if strcmp(option,'stereo PIV') && get(handles.CheckPatch2,'Value')
    2557 %     set(handles.CheckStereo,'Visible','on')
    2558 % else
    2559 %     set(handles.CheckStereo,'Visible','off')
    2560 % end
    25612559ListPairMode_Callback(hObject, eventdata, handles)
    25622560
     
    38553853    end
    38563854    case 'series(Dj)' 
    3857         r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names');
    3858         if ~isempty(r)
     3855%         r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names');
     3856%         if ~isempty(r)
    38593857            NomTypeNc='_1_1-2';
    3860         end
     3858%         end
    38613859   case 'series(Di)'
    38623860        r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names');
     
    43754373                        case {'PCWIN','PCWIN64'}                     
    43764374                            filename=regexprep(filename,'\\','\\\\');% add '\' so that '\' are left as characters
     4375                                    cmd=['civ_matlab(''' regexprep(filename,'(.+)([/\\])(.+$)','$1$20_XML\\$2$3.xml') ''','''...
     4376            filename '.nc'');'];
    43774377                        case {'GLNX86','GLNXA64','MACI64'}
     4378                                    cmd=['civ_matlab(''' regexprep(filename,'(.+)([/\\])(.+$)','$1$20_XML$2$3.xml') ''','''...
     4379            filename '.nc'');'];
    43784380                    end
    4379         cmd=['civ_matlab(''' regexprep(filename,'(.+)([/\\])(.+$)','$1$20_XML$2$3.xml') ''','''...
    4380             filename '.nc'');'];
     4381
     4382       
    43814383    case 'civ_matlab.sh'
    43824384        switch computer
     
    45534555% --- Executes on selection change in RunMode.
    45544556function RunMode_Callback(hObject, eventdata, handles)
     4557
     4558
     4559
     4560function nb_field2_Callback(hObject, eventdata, handles)
     4561% hObject    handle to nb_field2 (see GCBO)
     4562% eventdata  reserved - to be defined in a future version of MATLAB
     4563% handles    structure with handles and user data (see GUIDATA)
     4564
     4565% Hints: get(hObject,'String') returns contents of nb_field2 as text
     4566%        str2double(get(hObject,'String')) returns contents of nb_field2 as a double
     4567
     4568
     4569
     4570function last_j_Callback(hObject, eventdata, handles)
     4571% hObject    handle to last_j (see GCBO)
     4572% eventdata  reserved - to be defined in a future version of MATLAB
     4573% handles    structure with handles and user data (see GUIDATA)
     4574
     4575% Hints: get(hObject,'String') returns contents of last_j as text
     4576%        str2double(get(hObject,'String')) returns contents of last_j as a double
     4577
     4578
     4579
     4580function last_i_Callback(hObject, eventdata, handles)
     4581% hObject    handle to last_i (see GCBO)
     4582% eventdata  reserved - to be defined in a future version of MATLAB
     4583% handles    structure with handles and user data (see GUIDATA)
     4584
     4585% Hints: get(hObject,'String') returns contents of last_i as text
     4586%        str2double(get(hObject,'String')) returns contents of last_i as a double
  • trunk/src/civ_matlab.m

    r466 r492  
    223223    Data.VarAttribute{nbvar+2}.Role='vector_y';
    224224    Data.VarAttribute{nbvar+5}.Role='coord_tps';
    225     Data.VarAttribute{nbvar+6}.Role='vector_x_tps';
    226     Data.VarAttribute{nbvar+7}.Role='vector_y_tps';
     225    Data.VarAttribute{nbvar+6}.Role='vector_x';
     226    Data.VarAttribute{nbvar+7}.Role='vector_y';
    227227    Data.Civ1_U_smooth=zeros(size(Data.Civ1_X));
    228228    Data.Civ1_V_smooth=zeros(size(Data.Civ1_X));
     
    407407    Data.VarAttribute{nbvar+2}.Role='vector_y';
    408408    Data.VarAttribute{nbvar+5}.Role='coord_tps';
    409     Data.VarAttribute{nbvar+6}.Role='vector_x_tps';
    410     Data.VarAttribute{nbvar+7}.Role='vector_y_tps';
     409    Data.VarAttribute{nbvar+6}.Role='vector_x';
     410    Data.VarAttribute{nbvar+7}.Role='vector_y';
    411411    Data.Civ2_U_smooth=zeros(size(Data.Civ2_X));
    412412    Data.Civ2_V_smooth=zeros(size(Data.Civ2_X));
  • trunk/src/proj_field.m

    r491 r492  
    536536%project on a line
    537537% AJOUTER flux,circul,error
     538% OUTPUT:
     539% ProjData: projected field
     540%
    538541function  [ProjData,errormsg] = proj_line(FieldData, ObjectData)
    539542%-----------------------------------------------------------------
     
    547550if isfield(ObjectData,'ProjMode'),ProjMode=ObjectData.ProjMode; end;
    548551% ProjAngle=90; %90 degrees projection by default
    549 % if isfield(FieldData,'ProjAngle'),ProjAngle=ObjectData.ProjAngle; end;
     552
    550553width=0;%default width of the projection band
    551554if isfield(ObjectData,'Range')&&size(ObjectData.Range,2)>=2
     
    569572ListIndex={};
    570573
    571 %angles of the polyline and boundaries of action
     574%% angles of the polyline and boundaries of action
    572575dlinx=diff(ObjectData.Coord(:,1));
    573576dliny=diff(ObjectData.Coord(:,2));
    574 theta=angle(dlinx+i*dliny);%angle of each segment
     577theta=angle(dlinx+1i*dliny);%angle of each segment
    575578theta(siz_line(1))=theta(siz_line(1)-1);
    576579% determine a rectangles at +-width from the line (only used for the ProjMode='projection or 'filter')
     580xsup=zeros(1,siz_line(1)); xinf=zeros(1,siz_line(1)); ysup=zeros(1,siz_line(1)); yinf=zeros(1,siz_line(1));
    577581if isequal(ProjMode,'projection') || isequal(ProjMode,'filter')
    578582    xsup(1)=ObjectData.Coord(1,1)-width*sin(theta(1));
     
    588592end
    589593
    590 %group the variables (fields of 'FieldData') in cells of variables with the same dimensions
     594%% group the variables (fields of 'FieldData') in cells of variables with the same dimensions
    591595[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(FieldData);
    592596if ~isempty(errormsg)
     
    595599end
    596600
    597 % loop on variable cells with the same space dimension
     601%% loop on variable cells with the same space dimension
    598602ProjData.ListVarName={};
    599603ProjData.VarDimName={};
     604testproj=zeros(size(FieldData.ListVarName));
    600605for icell=1:length(CellVarIndex)
    601606    VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list FieldData.ListVarName
     
    605610    end
    606611    testX=~isempty(VarType.coord_x) && ~isempty(VarType.coord_y);% test for unstructured coordinates
     612    test_tps=~isempty(VarType.coord_tps);
    607613    testU=~isempty(VarType.vector_x) && ~isempty(VarType.vector_y);% test for vectors
    608614    testfalse=~isempty(VarType.errorflag);% test for error flag
    609615    testproj(VarIndex)=zeros(size(VarIndex));% test =1 for simply projected variables, default =0
    610616                                             %=0 for vector components, treated separately
    611     testproj(VarType.scalar)=1;
    612     testproj(VarType.image)=1;
    613     testproj(VarType.color)=1;
     617    testproj([VarType.scalar VarType.image VarType.color VarType.vector_x VarType.vector_y])=1;
    614618    VarIndex=VarIndex(find(testproj(VarIndex)));%select only the projected variables
    615     if testU
    616          VarIndex=[VarIndex VarType.vector_x VarType.vector_y];%append u and v at the end of the list of variables
    617     end
     619
    618620    %identify vector components   
    619621    if testU
    620622        UName=FieldData.ListVarName{VarType.vector_x};
    621623        VName=FieldData.ListVarName{VarType.vector_y};
    622         eval(['vector_x=FieldData.' UName ';'])
    623         eval(['vector_y=FieldData.' VName ';'])
     624        vector_x=FieldData.(UName);
     625        vector_y=FieldData.(VName);
    624626    end 
    625627    %identify error flag
    626628    if testfalse
    627629        FFName=FieldData.ListVarName{VarType.errorflag};
    628         eval(['errorflag=FieldData.' FFName ';'])
     630        errorflag=FieldData.(FFName);
    629631    end   
    630632    % check needed object properties for unstructured positions (position given by the variables with role coord_x, coord_y
     
    648650        XName= FieldData.ListVarName{VarType.coord_x};
    649651        YName= FieldData.ListVarName{VarType.coord_y};
    650         eval(['coord_x=FieldData.' XName ';'])   
    651         eval(['coord_y=FieldData.' YName ';'])
     652        coord_x=FieldData.(XName);   
     653        coord_y=FieldData.(YName);
    652654    end   
    653655    %initiate projection
     
    737739        end
    738740        ProjData.X=XLine';
    739         cur_index=1;
    740741        ProjData.ListVarName=[ProjData.ListVarName {XName}];
    741742        ProjData.VarDimName=[ProjData.VarDimName {XName}];
     
    871872                ProjData.VarDimName{end}={AXName,'rgb'};
    872873            end
    873         end     
     874        end
     875    elseif test_tps
     876         if isfield(ObjectData,'DX')&~isempty(ObjectData.DX)
     877                DX=abs(ObjectData.DX);%mesh of interpolation points along the line
     878                Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint);
     879                xreg=cos(theta(ip))*Xproj+ObjectData.Coord(ip,1)
     880                yreg=sin(theta(ip))*Xproj+ObjectData.Coord(ip,2)
     881%                 coord_x_proj=XMin:DX:XMax;
     882%                 coord_y_proj=YMin:DY:YMax;
     883                DataOut=calc_field(FieldData.FieldList,FieldData,cat(3,xreg,yreg));
     884                ProjData.ListVarName=[ProjData.ListVarName DataOut.ListVarName];
     885                ProjData.VarDimName=[ProjData.VarDimName DataOut.VarDimName];
     886                ProjData.VarAttribute=[ProjData.VarAttribute DataOut.VarAttribute];   
     887                DataOut.ListVarName(1)=[];
     888                DataOut.VarDimName(1)=[];
     889                DataOut.VarAttribute(1)=[];
     890                for ilist=2:length(DataOut.ListVarName)% reshape data, excluding coordinates (ilist=1-2), TODO: rationalise
     891                    VarName=DataOut.ListVarName{ilist};
     892                     ProjData.(VarName)=DataOut.(VarName);
     893                end
     894                ProjData.coord_x=Xproj;
     895         end
    874896    end
    875897end
  • trunk/src/read_civdata.m

    r406 r492  
    134134    end
    135135end
    136 if isempty(vel_type)||strcmp(vel_type,'*')
    137     switch CivStage
    138         case {6} %filter2 available
    139             vel_type='civ2';
    140         case {4,5}% civ2 available but not filter2
    141             if testder% derivatives needed
    142                 vel_type='civ1';
    143             else
    144                 vel_type='civ2';
    145             end
    146         case {1,2,3}% civ1 available but not civ2
    147             vel_type='civ1';
    148     end
    149 end
    150136if strcmp(vel_type,'civ2') && testder
    151137    vel_type='filter2';
     
    153139    vel_type='filter1';
    154140end
     141if isempty(vel_type)||strcmp(vel_type,'*')
     142    switch CivStage
     143        case {6} %filter2 available
     144            vel_type='filter2';
     145        case {4,5}% civ2 available but not filter2
     146            if testder% derivatives needed
     147                vel_type='filter1';
     148            else
     149                vel_type='civ2';
     150            end
     151        case 3
     152            vel_type='filter1';
     153        case {1,2}% civ1 available but not filter1
     154            vel_type='civ1';
     155    end
     156end
     157
    155158var={};
    156159switch vel_type
    157160    case 'civ1'
    158         var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbSites';...
    159             'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_F','Civ1_FF',...
    160             'Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps','Civ1_W_tps','Civ1_SubRange','Civ1_NbSites'};
    161         role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','coord_tps','vector_x_tps',...
    162             'vector_y_tps','vector_z_tps','ancillary','ancillary'};
    163         units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel',''};
     161        var={'X','Y','Z','U','V','W','C','F','FF';...
     162            'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_F','Civ1_FF'};
     163        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'};
     164        units={'pixel','pixel','pixel','pixel','pixel','pixel','','',''};
    164165    case 'filter1'
    165166        var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbSites';...
    166167            'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U_smooth','Civ1_V_smooth','Civ1_W','Civ1_C','Civ1_F','Civ1_FF',...
    167168            'Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps','Civ1_W_tps','Civ1_SubRange','Civ1_NbSites'};
    168         role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','coord_tps','vector_x_tps',...
    169             'vector_y_tps','vector_z_tps','ancillary','ancillary'};
     169        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','coord_tps','vector_x',...
     170            'vector_y','vector_z','ancillary','ancillary'};
    170171        units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel',''};
    171172    case 'civ2'
    172         var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbSites';...
    173             'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U','Civ2_V','Civ2_W','Civ2_C','Civ2_F','Civ2_FF',...
    174             'Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps','','Civ2_SubRange','Civ2_NbSites'};
    175         role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','coord_tps','vector_x_tps',...
    176             'vector_y_tps','vector_z_tps','ancillary','ancillary'};
    177         units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel',''};
     173        var={'X','Y','Z','U','V','W','C','F','FF';...
     174            'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U','Civ2_V','Civ2_W','Civ2_C','Civ2_F','Civ2_FF'};
     175        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'};
     176        units={'pixel','pixel','pixel','pixel','pixel','pixel','','',''};
    178177    case 'filter2'
    179178        var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbSites';...
    180179            'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U_smooth','Civ2_V_smooth','Civ2_W','Civ2_C','Civ2_F','Civ2_FF',...
    181180            'Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps','','Civ2_SubRange','Civ2_NbSites'};
    182         role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','coord_tps','vector_x_tps',...
    183             'vector_y_tps','vector_z_tps','ancillary','ancillary'};
     181        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','coord_tps','vector_x',...
     182            'vector_y','vector_z','ancillary','ancillary'};
    184183        units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel',''};
    185184end
Note: See TracChangeset for help on using the changeset viewer.