Changeset 238 for trunk


Ignore:
Timestamp:
Apr 18, 2011, 10:42:29 PM (13 years ago)
Author:
sommeria
Message:

various bug corrections

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r236 r238  
    6666filebase=''; % root file name ('filebase'.civ)
    6767ext=[];
    68 testall=0;
     68set(handles.CivAll,'String',{'CivX';'CivAll';'CivUvmat'})
    6969%default input parameters:
    7070num_i1=1; % set of field i numbers
     
    106106end
    107107set(handles.RootName,'String',filebase);
    108 set(handles.ImaDoc,'UserData',testall);
    109108set(handles.ImaDoc,'String',ext)
    110109
     
    113112path_UVMAT=fileparts(path_uvmat); %path to UVMAT
    114113errormsg=[];%default error message
    115 % xmlfile=fullfile(path_UVMAT,'PARAM.xml');
    116 % if ~exist(xmlfile,'file')
    117114xmlfile='PARAM.xml';
    118 % end
    119115if exist(xmlfile,'file')
    120116    try
     
    269265    oldfile=filebase;
    270266end
    271 % testall=get(handles.ImaDoc,'UserData');
    272267ind_opening=1;%default
    273268browse.incr_pair=[0 0]; %default
    274 % if testall
    275 %     menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ...
    276 %         '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'};
    277 % else % menu selecting only .civ or .avi files
    278  menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)';
     269menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)';
    279270       '*.xml',  '.xml files '; ...
    280271        '*.civ',  '.civ files '; ...
     
    285276        '*.nc','.netcdf files'; ...
    286277        '*.*',  'All Files (*.*)'};
    287    % menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ...
    288      %   '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';...
    289     %    '*.*', 'All Files (*.*)'};
    290 % end
    291278[FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile);
    292279fileinput=[PathName FileName];%complete file name
     
    442429end
    443430set(handles.browse_root,'UserData',browse);% store information from browser
    444 % testall=isequal(menu(filtindex,1),{'*.*'});
    445 % set(handles.ImaDoc,'UserData',testall);
    446431
    447432RootName_Callback(hObject, eventdata, handles);
     
    15831568    end
    15841569end
    1585 civAll=isequal(get(handles.CivAll,'Value'),2); % Boolean for new civ programs
    1586 if civAll && isfield(sparam,'CivBin')
     1570
     1571%% choose the civ program
     1572ProgList=get(handles.CivAll,'String');
     1573index=get(handles.CivAll,'Value');
     1574CivX=isequal(ProgList{index},'CivX');
     1575CivAll=isequal(ProgList{index},'CivAll');
     1576CivUvmat=isequal(ProgList{index},'CivUvmat');
     1577%CivAll=isequal(get(handles.CivAll,'Value'),2); % Boolean for new civ programs
     1578if CivAll && isfield(sparam,'CivBin')
    15871579    CivBin=sparam.CivBin;
    15881580    if ~exist(CivBin,'file') || ~isempty(which(CivBin))% if path defined as relative to uvmat
     
    17391731            cmd=[cmd 'umask 002 \n'];%allow writting access to created files for user group
    17401732        end
    1741         if civAll
    1742             civAllxml=xmltree;% xml contents,  all parameters
    1743             civAllCmd='';
    1744             civAllxml=set(civAllxml,1,'name','CivDoc');
     1733        if CivAll
     1734            CivAllxml=xmltree;% xml contents,  all parameters
     1735            CivAllCmd='';
     1736            CivAllxml=set(CivAllxml,1,'name','CivDoc');
    17451737        end
    17461738        [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extention)
     
    18081800            %
    18091801            i_cmd=i_cmd+1;
    1810             if isequal(civAll,0)
     1802            if isequal(CivAll,0)
    18111803                civ1_exe=CIV1_CMD(fullfile(Rootbat,Filebat),'',par_civ1,handles,sparam);%create the parameter file .civ1.cmx and set the execution string civ1_exe
    18121804%                 if(isunix)
     
    18181810                cmd=[cmd civ1_exe '\n'];
    18191811            else
    1820                 civAllCmd=[civAllCmd ' civ1 '];
     1812                CivAllCmd=[CivAllCmd ' civ1 '];
    18211813                str=CIV1_CMD_Unified(fullfile(Rootbat,Filebat),'',par_civ1);
    18221814                fieldnames=fields(str);
    1823                 [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1');
     1815                [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1');
    18241816                for ilist=1:length(fieldnames)
    18251817                    val=eval(['str.' fieldnames{ilist}]);
    18261818                    if ischar(val)
    1827                         [civAllxml,uid_t]=add(civAllxml,uid_civ1,'element',fieldnames{ilist});
    1828                         [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);
     1819                        [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist});
     1820                        [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val);
    18291821                    end
    18301822                end
     
    18441836                maskname=name_generator(maskbase,num1_mask,1,'.png','_i');
    18451837            end
    1846             if isequal(civAll,0)
     1838            if CivX
    18471839                if isunix %unix system
    18481840                cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ...
     
    18561848                end
    18571849                cmd=[cmd cmd_FIX '\n'];
    1858             else
     1850            elseif CivAll
    18591851                fix1.inputFileName=filecell.nc.civ1{ifile,j} ;
    18601852                fix1.fi1=num2str(flagindex1(1));
     
    18641856                fix1.threshV=num2str(thresh_vel1);
    18651857                fieldnames=fields(fix1);
    1866                 [civAllxml,uid_fix1]=add(civAllxml,1,'element','fix1');
     1858                [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1');
    18671859                for ilist=1:length(fieldnames)
    18681860                    val=eval(['fix1.' fieldnames{ilist}]);
    18691861                    if ischar(val)
    1870                         [civAllxml,uid_t]=add(civAllxml,uid_fix1,'element',fieldnames{ilist});
    1871                         [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);
     1862                        [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist});
     1863                        [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val);
    18721864                    end
    18731865                end
    1874                 civAllCmd=[civAllCmd ' fix1 '];
     1866                CivAllCmd=[CivAllCmd ' fix1 '];
    18751867            end
    18761868        end
     
    18781870        %PATCH1
    18791871        if box_test(3)==1
    1880             if isequal(civAll,0)
     1872            if isequal(CivAll,0)
    18811873                cmd_PATCH=PATCH_CMD(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp,sparam.PatchBin);
    18821874                cmd=[cmd cmd_PATCH '\n'];
     
    19121904                patch1.convectFlow='n';
    19131905                fieldnames=fields(patch1);
    1914                 [civAllxml,uid_patch1]=add(civAllxml,1,'element','patch1');
     1906                [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1');
    19151907                for ilist=1:length(fieldnames)
    19161908                    val=eval(['patch1.' fieldnames{ilist}]);
    19171909                    if ischar(val)
    1918                         [civAllxml,uid_t]=add(civAllxml,uid_patch1,'element',fieldnames{ilist});
    1919                         [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);
     1910                        [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist});
     1911                        [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val);
    19201912                    end
    19211913                end
    1922                 civAllCmd=[civAllCmd ' patch1 '];
     1914                CivAllCmd=[CivAllCmd ' patch1 '];
    19231915            end
    19241916        end
     
    19871979            flname=fullfile(Rootbat,Filebat);
    19881980           
    1989             if isequal(civAll,0)
     1981            if isequal(CivAll,0)
    19901982                cmd_CIV2=CIV2_CMD(flname,[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx]
    19911983%                 if(isunix)
     
    19961988%                 end
    19971989            else
    1998                 civAllCmd=[civAllCmd ' civ2 '];
     1990                CivAllCmd=[CivAllCmd ' civ2 '];
    19991991                str=CIV2_CMD_Unified(flname,'',par_civ2);
    20001992                fieldnames=fields(str);
    2001                 [civAllxml,uid_civ2]=add(civAllxml,1,'element','civ2');
     1993                [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2');
    20021994                for ilist=1:length(fieldnames)
    20031995                    val=eval(['str.' fieldnames{ilist}]);
    20041996                    if ischar(val)
    2005                         [civAllxml,uid_t]=add(civAllxml,uid_civ2,'element',fieldnames{ilist});
    2006                         [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);
     1997                        [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist});
     1998                        [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val);
    20071999                    end
    20082000                end
     
    20222014                maskname =name_generator(maskbase,num1_mask,1,'.png','_i');
    20232015            end
    2024             if isequal(civAll,0)
     2016            if isequal(CivAll,0)
    20252017                if isunix
    20262018                cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ...
     
    20422034                fix2.threshV=num2str(thresh_vel2);
    20432035                fieldnames=fields(fix2);
    2044                 [civAllxml,uid_fix2]=add(civAllxml,1,'element','fix2');
     2036                [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2');
    20452037                for ilist=1:length(fieldnames)
    20462038                    val=eval(['fix2.' fieldnames{ilist}]);
    20472039                    if ischar(val)
    2048                         [civAllxml,uid_t]=add(civAllxml,uid_fix2,'element',fieldnames{ilist});
    2049                         [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);
     2040                        [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist});
     2041                        [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val);
    20502042                    end
    20512043                end
    2052                 civAllCmd=[civAllCmd ' fix2 '];
     2044                CivAllCmd=[CivAllCmd ' fix2 '];
    20532045            end
    20542046        end
     
    20562048        %PATCH2
    20572049        if box_test(6)==1
    2058             if isequal(civAll,0)
     2050            if isequal(CivAll,0)
    20592051                cmd_PATCH=PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp,sparam.PatchBin);
    20602052                cmd=[cmd cmd_PATCH '\n'];
     
    20902082                patch2.convectFlow='n';
    20912083                fieldnames=fields(patch2);
    2092                 [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2');
     2084                [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2');
    20932085                for ilist=1:length(fieldnames)
    20942086                    val=eval(['patch2.' fieldnames{ilist}]);
    20952087                    if ischar(val)
    2096                         [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist});
    2097                         [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);
     2088                        [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist});
     2089                        [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val);
    20982090                    end
    20992091                end
    2100                 civAllCmd=[civAllCmd ' patch2 '];
    2101             end
    2102         end
    2103         if isequal(civAll,1)
    2104             save(civAllxml,[flname '.xml']);
    2105             cmd=[cmd sparam.CivBin ' -f ' flname '.xml '  civAllCmd ' >' flname '.log' '\n'];
     2092                CivAllCmd=[CivAllCmd ' patch2 '];
     2093            end
     2094        end
     2095        if CivAll
     2096            save(CivAllxml,[flname '.xml']);
     2097            cmd=[cmd sparam.CivBin ' -f ' flname '.xml '  CivAllCmd ' >' flname '.log' '\n'];
    21062098        end
    21072099        % create the .bat file:
     
    21202112                    eval(  ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]);
    21212113            end
    2122         elseif ~isequal(get(handles.CivAll,'Value'),3)
     2114        elseif ~CivUvmat
    21232115            %% to lauch the jobs locally :
    21242116            if(isunix)
     
    21302122            disp(cmd_str);
    21312123        else       %run PIVlab if selected
    2132             Data=civ_uvmat(par_civ1);
    2133 %             image1=imread(par_civ1.filename_ima_a);
    2134 %             image2=imread(par_civ1.filename_ima_b);     
    2135 %             stepx=str2num(par_civ1.dx);
    2136 %             stepy=str2num(par_civ1.dy);
    2137 %             ibx2=ceil(str2num(par_civ1.ibx)/2);
    2138 %             iby2=ceil(str2num(par_civ1.iby)/2);
    2139 %             isx2=ceil(str2num(par_civ1.isx)/2);
    2140 %             isy2=ceil(str2num(par_civ1.isy)/2);
    2141 %             shiftx=str2num(par_civ1.shiftx);
    2142 %             shifty=str2num(par_civ1.shifty);
    2143 % %             ibx=2*ibx2-1;%ibx and iby odd, reduced by 1 if even
    2144 % %             iby=2*iby2-1;
    2145 %             miniy=max(1+isy2-shifty,1+iby2);
    2146 %             minix=max(1+isx2-shiftx,1+ibx2);
    2147 %             maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2);
    2148 %             maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2);
    2149 %             [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy);
    2150 %             PointCoord(:,1)=reshape(GridX,[],1);
    2151 %             PointCoord(:,2)=reshape(GridY,[],1);
    2152 %             % caluclate velocity data (y and v in indices, reverse to y component)
    2153 %             [xtable ytable utable vtable ctable typevector] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []);
    2154 %                Data.ListGlobalAttribute={'title','Time','Dt'};
    2155 %                Data.title='PIVlab';
    2156 %                Data.Time=str2double(par_civ1.T0);
    2157 %                Data.Dt=str2double(par_civ1.Dt);
    2158 %                Data.ListVarName={'X','Y','U','V','C','FF'};%  cell array containing the names of the fields to record
    2159 %                Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'};
    2160 %                 Data.VarAttribute{1}.Role='coord_x';
    2161 %             Data.VarAttribute{2}.Role='coord_y';
    2162 %             Data.VarAttribute{3}.Role='vector_x';
    2163 %             Data.VarAttribute{4}.Role='vector_y';
    2164 %             Data.VarAttribute{5}.Role='errorflag';
    2165 %             Data.X=reshape(xtable,[],1);
    2166 %             Data.Y=reshape(size(image1,1)-ytable+1,[],1);
    2167 %             Data.U=reshape(utable,[],1);
    2168 %             Data.V=reshape(-vtable,[],1);
    2169 %             Data.C=reshape(ctable,[],1);
    2170 %             Data.FF=reshape(~typevector,[],1);
    2171             errormsg=struct2nc(filecell.nc.civ1{ifile,j},Data);
     2124            if box_test(1)==1
     2125                Param.Civ1=par_civ1;
     2126            end
     2127            if box_test(2)==1
     2128                fix1.WarnFlags=[];
     2129                if get(handles.vec_Fmin2,'Value')
     2130                    fix1.WarnFlags=[fix1.WarnFlags -2];
     2131                end
     2132                if get(handles.vec_F3,'Value')
     2133                    fix1.WarnFlags=[fix1.WarnFlags 3];
     2134                end
     2135                fix1.LowerBoundCorr=thresh_vecC1;
     2136                if get(handles.inf_sup1,'Value')
     2137                    fix1.UppperBoundVel=thresh_vel1;
     2138                else
     2139                     fix1.LowerBoundVel=thresh_vel1;
     2140                end
     2141                Param.Fix1=fix1;
     2142            end
     2143            if box_test(3)==1
     2144                Param.Patch1.Rho=rho_patch1;
     2145                Param.Patch1.Threshold=thresh_patch1;
     2146                Param.Patch1.SubDomain=subdomain_patch1;
     2147            end
     2148            [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j});
    21722149            if isempty(errormsg)
    21732150                display([filecell.nc.civ1{ifile,j} ' written'])
     
    21792156end
    21802157
    2181 if ~batch && ~isequal(get(handles.CivAll,'Value'),3)
     2158if ~batch && ~CivUvmat
    21822159    [Rootbat,Filebat,extbat]=fileparts(filename_bat);
    21832160    filename_superbat=fullfile(Rootbat,'job_list.bat');
     
    40063983end
    40073984par.rho=get(handles.rho,'String');
     3985if isequal(get(handles.rho,'Style'),'popupmenu')
     3986    index=get(handles.rho,'Value');
     3987    par.rho=par.rho{index};
     3988end
    40083989par.dx=get(handles.dx_civ1,'String');
    40093990par.dy=get(handles.dy_civ1,'String');
     
    43014282end
    43024283
    4303 %------------------------------------------------------------------------
    4304 % --- civ using pivlab
    4305 function Data=civ_uvmat(par_civ1)
    4306 %------------------------------------------------------------------------
    4307 image1=imread(par_civ1.filename_ima_a);
    4308 image2=imread(par_civ1.filename_ima_b);
    4309 stepx=str2num(par_civ1.dx);
    4310 stepy=str2num(par_civ1.dy);
    4311 ibx2=ceil(str2num(par_civ1.ibx)/2);
    4312 iby2=ceil(str2num(par_civ1.iby)/2);
    4313 isx2=ceil(str2num(par_civ1.isx)/2);
    4314 isy2=ceil(str2num(par_civ1.isy)/2);
    4315 shiftx=str2num(par_civ1.shiftx);
    4316 shifty=str2num(par_civ1.shifty);
    4317 miniy=max(1+isy2-shifty,1+iby2);
    4318 minix=max(1+isx2-shiftx,1+ibx2);
    4319 maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2);
    4320 maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2);
    4321 [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy);
    4322 PointCoord(:,1)=reshape(GridX,[],1);
    4323 PointCoord(:,2)=reshape(GridY,[],1);
    4324 % caluclate velocity data (y and v in indices, reverse to y component)
    4325 [xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []);
    4326 Data.ListGlobalAttribute=[{'Conventions','Program','CivStage'} {'Time','Dt'}];
    4327 Data.Conventions='uvmat/civdata';
    4328 Data.Program='civ_uvmat';
    4329 Data.CivStage=1;
    4330 % list_param=fieldnames(Param.Civ1);
    4331 % for ilist=1:length(list_param)
    4332 %     eval(['Data.Civ1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';'])
    4333 % end
    4334 Data.Time=str2double(par_civ1.T0);
    4335 Data.Dt=str2double(par_civ1.Dt);
    4336 Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};%  cell array containing the names of the fields to record
    4337 Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'};
    4338 Data.VarAttribute{1}.Role='coord_x';
    4339 Data.VarAttribute{2}.Role='coord_y';
    4340 Data.VarAttribute{3}.Role='vector_x';
    4341 Data.VarAttribute{4}.Role='vector_y';
    4342 Data.VarAttribute{5}.Role='warnflag';
    4343 Data.Civ1_X=reshape(xtable,[],1);
    4344 Data.Civ1_Y=reshape(size(image1,1)-ytable+1,[],1);
    4345 Data.Civ1_U=reshape(utable,[],1);
    4346 Data.Civ1_V=reshape(-vtable,[],1);
    4347 Data.Civ1_C=reshape(ctable,[],1);
    4348 Data.Civ1_F=reshape(F,[],1);
     4284% %------------------------------------------------------------------------
     4285% % --- civ using pivlab
     4286% function Data=civ_uvmat(par_civ1)
     4287% %------------------------------------------------------------------------
     4288% image1=imread(par_civ1.filename_ima_a);
     4289% image2=imread(par_civ1.filename_ima_b);
     4290% stepx=str2num(par_civ1.dx);
     4291% stepy=str2num(par_civ1.dy);
     4292% ibx2=ceil(str2num(par_civ1.ibx)/2);
     4293% iby2=ceil(str2num(par_civ1.iby)/2);
     4294% isx2=ceil(str2num(par_civ1.isx)/2);
     4295% isy2=ceil(str2num(par_civ1.isy)/2);
     4296% shiftx=str2num(par_civ1.shiftx);
     4297% shifty=str2num(par_civ1.shifty);
     4298% miniy=max(1+isy2-shifty,1+iby2);
     4299% minix=max(1+isx2-shiftx,1+ibx2);
     4300% maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2);
     4301% maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2);
     4302% [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy);
     4303% PointCoord(:,1)=reshape(GridX,[],1);
     4304% PointCoord(:,2)=reshape(GridY,[],1);
     4305% % caluclate velocity data (y and v in indices, reverse to y component)
     4306% [xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []);
     4307% Data.ListGlobalAttribute=[{'Conventions','Program','CivStage'} {'Time','Dt'}];
     4308% Data.Conventions='uvmat/civdata';
     4309% Data.Program='civ_uvmat';
     4310% Data.CivStage=1;
     4311% % list_param=fieldnames(Param.Civ1);
     4312% % for ilist=1:length(list_param)
     4313% %     eval(['Data.Civ1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';'])
     4314% % end
     4315% Data.Time=str2double(par_civ1.T0);
     4316% Data.Dt=str2double(par_civ1.Dt);
     4317% Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};%  cell array containing the names of the fields to record
     4318% Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'};
     4319% Data.VarAttribute{1}.Role='coord_x';
     4320% Data.VarAttribute{2}.Role='coord_y';
     4321% Data.VarAttribute{3}.Role='vector_x';
     4322% Data.VarAttribute{4}.Role='vector_y';
     4323% Data.VarAttribute{5}.Role='warnflag';
     4324% Data.Civ1_X=reshape(xtable,[],1);
     4325% Data.Civ1_Y=reshape(size(image1,1)-ytable+1,[],1);
     4326% Data.Civ1_U=reshape(utable,[],1);
     4327% Data.Civ1_V=reshape(-vtable,[],1);
     4328% Data.Civ1_C=reshape(ctable,[],1);
     4329% Data.Civ1_F=reshape(F,[],1);
    43494330
    43504331%------------------------------------------------------------------------
     
    49184899% --- Executes on button press in CivAll.
    49194900function CivAll_Callback(hObject, eventdata, handles)
    4920 if get(handles.CivAll,'Value')==2
    4921     if get(handles.PATCH1,'Value')
    4922         set(handles.thresh_patch1,'Visible','on')
    4923         set(handles.thresh_text1,'Visible','on')
    4924     end
    4925 else
    4926     set(handles.thresh_patch1,'Visible','off')
    4927     set(handles.thresh_text1,'Visible','off')
    4928 end
    4929 
     4901Listprog=get(handles.CivAll,'String');
     4902index=get(handles.CivAll,'Value');
     4903prog=Listprog{index};
     4904switch prog
     4905    case 'CivX'
     4906        set(handles.thresh_patch1,'Visible','off')
     4907        set(handles.thresh_text1,'Visible','off')
     4908        set(handles.rho,'Style','edit')
     4909        set(handles.rho,'String','1')
     4910    case 'CivAll'
     4911        if get(handles.PATCH1,'Value')
     4912            set(handles.thresh_patch1,'Visible','on')
     4913            set(handles.thresh_text1,'Visible','on')
     4914        end
     4915        set(handles.rho,'Style','edit')
     4916        set(handles.rho,'String','1')
     4917    case 'CivUvmat'
     4918        if get(handles.PATCH1,'Value')
     4919            set(handles.thresh_patch1,'Visible','on')
     4920            set(handles.thresh_text1,'Visible','on')
     4921        end
     4922        set(handles.rho,'Style','popupmenu')
     4923        set(handles.rho,'Value',1)
     4924        set(handles.rho,'String',{'1';'2'})
     4925end
     4926
  • trunk/src/geometry_calib.m

    r231 r238  
    458458norm=abs(det(R));
    459459GeometryCalib.CalibrationType='linear';
     460if (a_X1(2)/a_Y1(3))>0
     461    epsilon=1;
    460462GeometryCalib.fx_fy(1)=sqrt((a_X1(2)/a_Y1(3))*norm);
     463else
     464    GeometryCalib.fx_fy(1)=-sqrt((-a_X1(2)/a_Y1(3))*norm);
     465      epsilon=-1;
     466end
    461467GeometryCalib.fx_fy(2)=(a_Y1(3)/a_X1(2))*GeometryCalib.fx_fy(1);
    462468GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
    463469%GeometryCalib.Tx_Ty_Tz=[a_X1(1) a_Y1(1) 1];
    464470GeometryCalib.Tx_Ty_Tz=[a_X1(1)/GeometryCalib.fx_fy(1) a_Y1(1)/GeometryCalib.fx_fy(2) 1];
    465 R(1,:)=R(1,:)/GeometryCalib.fx_fy(1);
     471R(1,:)=epsilon*R(1,:)/GeometryCalib.fx_fy(1);
    466472R(2,:)=R(2,:)/GeometryCalib.fx_fy(2);
    467473R=[R;[0 0]];
    468 GeometryCalib.R=[R [0;0;1]];
    469 GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0];
     474GeometryCalib.R=[R [0;0;-1]];
     475GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0]
    470476%------------------------------------------------------------------------
    471477% determine the tsai parameters for a view normal to the grid plane
  • trunk/src/mouse_down.m

    r231 r238  
    109109                haxes=[];%mouse out of axes
    110110            end
     111            break
     112        elseif isequal(htype,'uicontrol') && isequal(get(hchild(ichild),'Visible'),'on')
     113            msgbox(get(hchild(ichild),'String'),get(hchild(ichild),'Tag'))
     114            break
    111115        end
    112116    end
  • trunk/src/pivlab.m

    r236 r238  
    9090        result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255
    9191        %Find the correlation max, at 255
    92         [y,x] = find(result_conv==255);
    93         if ~isnan(y) & ~isnan(x)
     92        [y,x] = find(result_conv==255,1);
     93        if ~isnan(y) && ~isnan(x)
    9494            try
    9595                if subpixfinder==1
    96                     [vector] = SUBPIXGAUSS (result_conv,x,y);
     96                    [vector,F(ivec)] = SUBPIXGAUSS (result_conv,x,y);
    9797                elseif subpixfinder==2
    98                     [vector] = SUBPIX2DGAUSS (result_conv,x,y);
     98                    [vector,F(ivec)] = SUBPIX2DGAUSS (result_conv,x,y);
    9999                end
    100100                sum_square=sum(sum(image1_crop.*image1_crop));
    101101                ctable(ivec)=corrmax/sum_square;% correlation value
    102                 if vector(1)>shiftx+isx2-ibx2+subpixfinder || vector(2)>shifty+isy2-iby2+subpixfinder
    103                     F(ivec)=-2;%vector reaches the border of the search zone
    104                 end
     102%                 if vector(1)>shiftx+isx2-ibx2+subpixfinder || vector(2)>shifty+isy2-iby2+subpixfinder
     103%                     F(ivec)=-2;%vector reaches the border of the search zone
     104%                 end
    105105            catch ME
    106106                vector=[0 0]; %if something goes wrong with cross correlation.....
     
    125125
    126126
    127 function [vector] = SUBPIXGAUSS (result_conv,x,y)
     127function [vector,F] = SUBPIXGAUSS (result_conv,x,y)
     128vector=[0 0]; %default
     129F=0;
     130[npy,npx]=size(result_conv);
    128131
    129 if size(x,1)>1 %if there are more than 1 peaks just take the first
    130     x=x(1:1);
    131 end
    132 if size(y,1)>1 %if there are more than 1 peaks just take the first
    133     y=y(1:1);
    134 end
    135 if (x <= (size(result_conv,1)-1)) && (y <= (size(result_conv,1)-1)) && (x >= 1) && (y >= 1)
     132% if (x <= (size(result_conv,1)-1)) && (y <= (size(result_conv,1)-1)) && (x >= 1) && (y >= 1)
    136133    %the following 8 lines are copyright (c) 1998, Uri Shavit, Roi Gurka, Alex Liberzon, Technion – Israel Institute of Technology
    137134    %http://urapiv.wordpress.com
    138     f0 = log(result_conv(y,x));
    139     f1 = log(result_conv(y-1,x));
    140     f2 = log(result_conv(y+1,x));
    141     peaky = y+ (f1-f2)/(2*f1-4*f0+2*f2);
    142     f0 = log(result_conv(y,x));
    143     f1 = log(result_conv(y,x-1));
    144     f2 = log(result_conv(y,x+1));
    145     peakx = x+ (f1-f2)/(2*f1-4*f0+2*f2);
    146     [npy,npx]=size(result_conv);
     135    peaky = y;
     136    if y <= npy-1 && y >= 1
     137        f0 = log(result_conv(y,x));
     138        f1 = log(result_conv(y-1,x));
     139        f2 = log(result_conv(y+1,x));
     140        peaky = peaky+ (f1-f2)/(2*f1-4*f0+2*f2);
     141    else
     142        F=-2; % warning flag for vector truncated by the limited search box
     143    end
     144    peakx=x;
     145    if x <= npx-1 && x >= 1
     146        f0 = log(result_conv(y,x));
     147        f1 = log(result_conv(y,x-1));
     148        f2 = log(result_conv(y,x+1));
     149        peakx = peakx+ (f1-f2)/(2*f1-4*f0+2*f2);
     150    else
     151        F=-2; % warning flag for vector truncated by the limited search box
     152    end
    147153    vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1];
    148 else
    149     vector=[NaN NaN];
    150 end
     154% else
     155%     vector=[NaN NaN];
     156% end
    151157
    152 function [vector] = SUBPIX2DGAUSS (result_conv,x,y)
    153 if size(x,1)>1 %if there are more than 1 peaks just take the first
    154     x=x(1:1);
    155 end
    156 if size(y,1)>1 %if there are more than 1 peaks just take the first
    157     y=y(1:1);
    158 end
    159 if (x <= (size(result_conv,1)-1)) && (y <= (size(result_conv,1)-1)) && (x >= 1) && (y >= 1)
     158function [vector,F] = SUBPIX2DGAUSS (result_conv,x,y)
     159vector=[0 0]; %default
     160F=-2;
     161peaky=y;
     162peakx=x;
     163[npy,npx]=size(result_conv);
     164if (x <= npx-1) && (y <= npy-1) && (x >= 1) && (y >= 1)
     165    F=0;
    160166    for i=-1:1
    161167        for j=-1:1
     
    181187    deltax=(c11*c01-2*c10*c02)/(4*c20*c02-c11^2);
    182188    deltay=(c11*c10-2*c01*c20)/(4*c20*c02-c11^2);
    183     peakx=x+deltax;
    184     peaky=y+deltay;
    185    
    186     [npy,npx]=size(result_conv);
    187     vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1];
    188 %     SubpixelX=peakx-(ibx/2)-SubPixOffset;
    189 %     SubpixelY=peaky-(iby/2)-SubPixOffset;
    190 %     vector=[SubpixelX, SubpixelY];
    191 else
    192     vector=[NaN NaN];
     189    if abs(deltax)<1
     190        peakx=x+deltax;
     191    end
     192    if abs(deltay)<1
     193        peaky=y+deltay;
     194    end
    193195end
     196vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1];
  • trunk/src/plot_field.m

    r231 r238  
    900900            if MinA<MaxA
    901901                set(haxes,'CLim',[MinA MaxA])
    902                 %caxis([MinA MaxA])
    903902            else
    904                 set(haxes,'CLim',[MinA MaxA])
    905                 %caxis([MaxA-1 MaxA])
     903                set(haxes,'CLim',[MinA MaxA+1])
    906904            end
    907905            set(hima,'XData',AX);
     
    909907        end
    910908    end
    911 %     if ~isstruct(AxeData)
    912 %         AxeData=[];
    913 %     end
    914909    test_ima=1;
    915910   
  • trunk/src/series.m

    r206 r238  
    122122    FieldCell{1}=param.list_fields{param.index_fields};
    123123end
    124 if isfield(param,'civ1')&& islogical(param.civ1) && isfield(param,'civ2')&& islogical(param.civ2)&...
    125         isfield(param,'interp1')&& islogical(param.interp1)&&isfield(param,'interp2')&& islogical(param.interp2)&...
    126         isfield(param,'filter1')&& islogical(param.filter1)&&isfield(param,'filter2')&& islogical(param.filter2)
    127     set(handles.civ1,'Value',param.civ1);
    128     set(handles.civ2,'Value',param.civ1);
    129     set(handles.interp1,'Value',param.interp1);
    130     set(handles.interp2,'Value',param.interp2);
    131     set(handles.filter1,'Value',param.filter1);
    132     set(handles.filter2,'Value',param.filter2);
    133 end
     124% if isfield(param,'velTypeMenu')&&isfield(param,'velTypeIndex')
     125%     set(handles.VelTypeMenu,'Value',param.VelTypeIndex)
     126%     set(handles.VelTypeMenu,'String',param.VelTypeMenu)
     127% end 
    134128set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles})
    135129NomType_Callback(hObject, eventdata, handles)
  • trunk/src/uvmat.m

    r236 r238  
    24272427   UvData.Field=Field{1};
    24282428end
    2429 
     2429UvData.Field
     2430max(max(UvData.Field.A))
     2431min(min(UvData.Field.A))
    24302432%% get bounds and mesh (needed for mouse action and to open set_object)
    24312433test_x=0;
     
    39273929set(handles.list_object_1,'Value',1)
    39283930set(handles.list_object_1,'String',{''})
    3929 set(handles.list_object_2,'Value',2)
     3931set(handles.list_object_2,'Value',1)
    39303932set(handles.list_object_2,'String',{''})
    39313933list_object_2_Callback(hObject, eventdata, handles)
     
    43064308function list_object_2_Callback(hObject, eventdata, handles)
    43074309%------------------------------------------------------------------------
    4308 list_str=get(handles.list_object_2,'String');
    4309 IndexObj=get(handles.list_object_2,'Value');
     4310list_str=get(handles.list_object_2,'String')
     4311IndexObj=get(handles.list_object_2,'Value')
    43104312if ischar(list_str) || isempty(list_str{IndexObj})% || strcmp(list_str{IndexObj},'...')
    43114313    hview_field=findobj(allchild(0),'Tag','view_field');
     
    47384740    param.index_fields_1=param.index_fields_1-1;
    47394741end
    4740 param.civ1=get(handles.VelType,'Value');
    4741 param.civ2=get(handles.civ2,'Value');
    4742 param.interp1=get(handles.interp1,'Value');
    4743 param.interp2=get(handles.interp2,'Value');
    4744 param.filter1=get(handles.filter1,'Value');
    4745 param.filter2=get(handles.filter2,'Value');
     4742% if isequal(get(handles.VelType,'Visible'),'on')
     4743%     param.VelTypeMenu=get(handles.VelType,'String');
     4744%     param.VelTypeIndex=get(handles.VelType,'Value');
     4745% end
     4746% param.civ1=get(handles.VelType,'Value');
     4747% param.civ2=get(handles.civ2,'Value');
     4748% param.interp1=get(handles.interp1,'Value');
     4749% param.interp2=get(handles.interp2,'Value');
     4750% param.filter1=get(handles.filter1,'Value');
     4751% param.filter2=get(handles.filter2,'Value');
    47464752param.menu_coord_str=get(handles.transform_fct,'String');
    47474753param.menu_coord_val=get(handles.transform_fct,'Value');
Note: See TracChangeset for help on using the changeset viewer.