- Timestamp:
- Jan 27, 2015, 9:21:37 AM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mouse_motion.m
r858 r859 73 73 test_piv=1; 74 74 end 75 76 75 %find the current axe 'CurrentAxes' and display the current mouse position or uicontrol tag 77 76 text_displ_1=''; … … 126 125 end 127 126 end 128 FigData=get(hCurrentFig,'UserData'); 129 tagaxes=get(CurrentAxes,'tag'); 127 FigData=get(hCurrentFig,'UserData'); % user data of the current figure 128 tagaxes=get(CurrentAxes,'tag'); % tag name of the current axes, for instance PlotAxes 130 129 if isfield(FigData,tagaxes) 131 Field=FigData.(tagaxes); 130 Field=FigData.(tagaxes); % the current field is sought as substructure of FigData with key tagaxes 132 131 if isfield(Field,'ListVarName') 133 132 [CellInfo,NbDimArray]=find_field_cells(Field);%analyse the physical fields contained in Field … … 227 226 pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis; 228 227 end 229 % pos=pos+[Field.ProjObjectCoord 0];230 228 pos=pos+Field.ProjObjectCoord; 231 229 text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)]; 232 230 end 233 % if ~isempty(z)234 % text_displ_1=[text_displ_1 ' z=' num2str(z,4)];235 % end236 231 % case of PIV correlation display 237 232 if test_piv … … 260 255 yround=Field.Y(ind_pt); 261 256 262 % mark the correlation box with a rectangle 257 % mark the correlation box with a rectangle in view_field 263 258 ibx2=floor((par_civ.CorrBoxSize(1)-1)/2); 264 259 iby2=floor((par_civ.CorrBoxSize(2)-1)/2); -
trunk/src/series/civ_input.m
r858 r859 1149 1149 %------------------------------------------------------------------------ 1150 1150 1151 % --- Executes on button press in CheckDeformation. 1152 function CheckDeformation_Callback(hObject, eventdata, handles) 1153 set(handles.configSource,'String','NEW') 1154 set(handles.OK,'BackgroundColor',[1 0 1]) 1155 1151 1156 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1152 1157 % Callbacks in the uipanel Fix1 … … 1886 1891 Param.Action.RUN=1; 1887 1892 Param.ActionInput=read_GUI(handles.civ_input); 1893 if isfield(Param,'OutputSubDir') 1888 1894 Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series 1889 Param.ActionInput.Civ2.SmoothParam=0;% launch Civ2 with no data point (to get the image names for A and B) 1895 end 1896 Param.ActionInput.Civ2.CorrSmooth=0;% launch Civ2 with no data point (to get the image names for A and B) 1890 1897 set(handles.Civ1,'BackgroundColor',[1 1 0]) 1898 set(handles.Fix1,'BackgroundColor',[1 1 0]) 1899 set(handles.Patch1,'BackgroundColor',[1 1 0]) 1891 1900 [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results 1892 1901 … … 1916 1925 hhview_field=guihandles(hview_field);% 1917 1926 set(hview_field,'CurrentAxes',hhview_field.PlotAxes) 1918 %ViewData=get(hview_field,'UserData');1927 ViewData=get(hview_field,'UserData'); % get the currently plotted field (the image A) 1919 1928 % store info in the UserData of view-field 1920 1929 ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field … … 1922 1931 ViewData.PlotAxes.X=Data.Civ2_X'; 1923 1932 ViewData.PlotAxes.Y=Data.Civ2_Y'; 1924 ViewData.PlotAxes.ShiftX=Data.Civ2_U'; 1933 ViewData.PlotAxes.ShiftX=Data.Civ2_U';% shift at each point (from patch1) estimated by running civ2 1925 1934 ViewData.PlotAxes.ShiftY=Data.Civ2_V'; 1926 1935 ViewData.PlotAxes.Civ1_SubRange=Data.Civ1_SubRange; … … 1932 1941 ViewData.PlotAxes.Civ2_Dt=Data.Civ2_Dt; 1933 1942 set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field 1943 bckcolor=get(handles.civ_input,'Color'); 1944 set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calmculation is finished 1945 set(handles.Fix1,'BackgroundColor',bckcolor) 1946 set(handles.Patch1,'BackgroundColor',bckcolor) 1947 drawnow 1934 1948 1935 1949 %% look for a current figure for image correlation display … … 2245 2259 % --- Executes on button press in TestPatch2. 2246 2260 function TestPatch2_Callback(hObject, eventdata, handles) 2261 2262 2263 -
trunk/src/series/civ_series.m
r858 r859 20 20 % Param.OutputSubDir: sets the folder name of output file(s, 21 21 % if absent no file is produced, result in the output structure Data (test mode) 22 % Param.ActionInput: substructure with the parameters provided by the GUI civ_input 22 % Param.ActionInput: substructure with the parameters provided by the GUI civ_input 23 23 % .Civ1: parameters for civ1 24 24 % .Fix1: parameters for fix1 25 % .Patch1: 25 % .Patch1: 26 26 % .Civ2: for civ2 27 % .Fix2: 27 % .Fix2: 28 28 % .Patch2: 29 29 … … 32 32 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 33 33 % This is part of the toolbox UVMAT. 34 % 34 % 35 35 % UVMAT is free software; you can redistribute it and/or modify 36 36 % it under the terms of the GNU General Public License as published by 37 37 % the Free Software Foundation; either version 2 of the License, or 38 38 % (at your option) any later version. 39 % 39 % 40 40 % UVMAT is distributed in the hope that it will be useful, 41 41 % but WITHOUT ANY WARRANTY; without even the implied warranty of … … 48 48 49 49 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName or InputTable refreshed 50 if isstruct(Param) && isequal(Param.Action.RUN,0)% function activated from the GUI series but not RUN 50 if isstruct(Param) && isequal(Param.Action.RUN,0)% function activated from the GUI series but not RUN 51 51 path_series=fileparts(which('series')); 52 52 addpath(fullfile(path_series,'series')) … … 82 82 %% test input 83 83 if ~isfield(Param,'ActionInput') 84 85 84 disp_uvmat('ERROR','no parameter set for PIV',checkrun) 85 return 86 86 end 87 87 iview_A=0;%default values … … 105 105 if isfield(Param,'InputTable') 106 106 [tild,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 107 % iview_nc=0;% series index (iview) for an input nc file (for civ2 or patch2)108 107 iview_A=0;% series index (iview) for the first image series 109 108 iview_B=0;% series index (iview) for the second image series (only non zero for option 'shift' comparing two image series ) … … 158 157 end 159 158 end 160 % i1_series_Civ1=i1_series_Civ1(~check_bounds);161 % i2_series_Civ1=i2_series_Civ1(~check_bounds);162 % j1_series_Civ1=j1_series_Civ1(~check_bounds);163 % j2_series_Civ1=j2_series_Civ1(~check_bounds);164 159 case 'displacement' 165 160 i1_series_Civ1=Param.ActionInput.OriginIndex*ones(size(i1_series{1})); … … 271 266 OutputDir=''; 272 267 if CheckOutputFile 273 OutputDir=[Param.OutputSubDir Param.OutputDirExt];268 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 274 269 end 275 270 end … … 280 275 Data.Program='civ_series'; 281 276 Data.CivStage=0;%default 282 maskname='';%default283 277 check_civx=0;%default 284 278 … … 440 434 [xtable, ytable, utable, vtable, ctable, F, result_conv, errormsg] = civ (par_civ1); 441 435 if ~isempty(errormsg) 442 436 disp_uvmat('ERROR',errormsg,checkrun) 443 437 return 444 438 end … … 468 462 if exist('ncfile','var') 469 463 CivFile=ncfile; 470 % elseif isfield(Param.Patch1,'CivFile')471 % CivFile=Param.Patch1.CivFile;472 % end473 464 [Data,tild,tild,errormsg]=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0'); %look for the constant 'absolut_time_T0' to detect old civx data format 474 465 if ~isempty(errormsg) … … 476 467 return 477 468 end 478 if ~isempty(Data.absolut_time_T0')%read civx file 479 check_civx=1;% test for old civx data format 480 [Data,vardetect,ichoice]=nc2struct(CivFile);%read the variables in the netcdf file 481 else 482 [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file 483 end 469 [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file 484 470 elseif isfield(Param,'Civ1_X') 485 471 Data.ListGlobalAttribute={}; … … 490 476 Data.Civ1_U=Param.Civ1_U; 491 477 Data.Civ1_V=Param.Civ1_V; 492 Data.Civ1_FF=Param.Civ1_FF; 478 Data.Civ1_FF=Param.Civ1_FF; 493 479 end 494 480 end … … 502 488 Data=rmfield(Data,Data.ListGlobalAttribute{Fix1_attr(ilist)}); 503 489 end 504 end 490 end 505 491 list_param=fieldnames(Param.ActionInput.Fix1)'; 506 492 Fix1_param=regexprep(list_param,'^.+','Fix1_$0');% insert 'Fix1_' before each string in ListFixParam 507 %indicate the values of all the global attributes in the output data 493 %indicate the values of all the global attributes in the output data 508 494 for ilist=1:length(list_param) 509 495 Data.(Fix1_param{ilist})=Param.ActionInput.Fix1.(list_param{ilist}); 510 496 end 511 497 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Fix1_param]; 512 % 513 % for ilist=1:length(ListFixParam) 514 % ParamName=ListFixParam{ilist}; 515 % ListName=['Fix1_' ParamName]; 516 % eval(['Data.ListGlobalAttribute=[Data.ListGlobalAttribute ''' ParamName '''];']) 517 % eval(['Data.' ListName '=Param.ActionInput.Fix1.' ParamName ';']) 518 % end 519 if check_civx 520 if ~isfield(Data,'fix') 521 Data.ListGlobalAttribute=[Data.ListGlobalAttribute 'fix']; 522 Data.fix=1; 523 Data.ListVarName=[Data.ListVarName {'vec_FixFlag'}]; 524 Data.VarDimName=[Data.VarDimName {'nb_vectors'}]; 525 end 526 Data.vec_FixFlag=fix(Param.ActionInput.Fix1,Data.vec_F,Data.vec_C,Data.vec_U,Data.vec_V,Data.vec_X,Data.vec_Y); 527 else 528 Data.ListVarName=[Data.ListVarName {'Civ1_FF'}]; 529 Data.VarDimName=[Data.VarDimName {'nb_vec_1'}]; 530 nbvar=length(Data.ListVarName); 531 Data.VarAttribute{nbvar}.Role='errorflag'; 532 Data.Civ1_FF=fix(Param.ActionInput.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V); 533 Data.CivStage=2; 534 end 498 Data.ListVarName=[Data.ListVarName {'Civ1_FF'}]; 499 Data.VarDimName=[Data.VarDimName {'nb_vec_1'}]; 500 nbvar=length(Data.ListVarName); 501 Data.VarAttribute{nbvar}.Role='errorflag'; 502 Data.Civ1_FF=fix(Param.ActionInput.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V); 503 Data.CivStage=2; 535 504 end 536 505 %% Patch1 … … 570 539 end 571 540 572 % perform Patch calculation using the UVMAT fct 'filter_tps'541 % perform Patch calculation using the UVMAT fct 'filter_tps' 573 542 [Data.Civ1_SubRange,Data.Civ1_NbCentres,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=... 574 543 filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomainSize,Data.Patch1_FieldSmooth,Data.Patch1_MaxDiff); … … 647 616 U_tps=Data.Civ2_U_tps; 648 617 V_tps=Data.Civ2_V_tps; 649 CivStage=Data.CivStage; 618 CivStage=Data.CivStage;%store the current CivStage 650 619 Civ1_Dt=Data.Civ2_Dt; 651 620 Data=[];%reinitialise the result structure Data … … 653 622 Data.Conventions='uvmat/civdata';% states the conventions used for the description of field variables and attributes 654 623 Data.Program='civ_series'; 655 Data.CivStage=CivStage ;624 Data.CivStage=CivStage+1;%update the current civStage after reinitialisation of Data 656 625 Data.ListVarName={}; 657 626 Data.VarDimName={}; … … 663 632 V_tps=Data.Civ1_V_tps; 664 633 Civ1_Dt=Data.Civ1_Dt; 634 Data.CivStage=4; 665 635 end 666 636 else … … 672 642 Civ1_Dt=par_civ2.Civ1_Dt; 673 643 Civ2_Dt=par_civ2.Civ1_Dt; 674 675 644 Data.ListVarName={}; 645 Data.VarDimName={}; 676 646 end 677 647 Shiftx=zeros(size(par_civ2.Grid,1),1);% shift expected from civ1 data … … 683 653 ind_sel=find(par_civ2.Grid(:,1)>=SubRange(1,1,isub) & par_civ2.Grid(:,1)<=SubRange(1,2,isub) &... 684 654 par_civ2.Grid(:,2)>=SubRange(2,1,isub) & par_civ2.Grid(:,2)<=SubRange(2,2,isub)); 685 epoints = par_civ2.Grid(ind_sel,:);% coordinates of interpolation sites 686 ctrs=Coord_tps(1:nbvec_sub,:,isub) ;%(=initial points) ctrs 687 nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for each interpolation point (in case of subdomain overlap) 688 EM = tps_eval(epoints,ctrs); 689 Shiftx(ind_sel)=Shiftx(ind_sel)+EM*U_tps(1:nbvec_sub+3,isub); 690 Shifty(ind_sel)=Shifty(ind_sel)+EM*V_tps(1:nbvec_sub+3,isub); 691 if par_civ2.CheckDeformation 692 [EMDX,EMDY] = tps_eval_dxy(epoints,ctrs);%2D matrix of distances between extrapolation points epoints and spline centres (=site points) ctrs 693 DUDX(ind_sel)=DUDX(ind_sel)+EMDX*U_tps(1:nbvec_sub+3,isub); 694 DUDY(ind_sel)=DUDY(ind_sel)+EMDY*U_tps(1:nbvec_sub+3,isub); 695 DVDX(ind_sel)=DVDX(ind_sel)+EMDX*V_tps(1:nbvec_sub+3,isub); 696 DVDY(ind_sel)=DVDY(ind_sel)+EMDY*V_tps(1:nbvec_sub+3,isub); 655 if ~isempty(ind_sel) 656 epoints = par_civ2.Grid(ind_sel,:);% coordinates of interpolation sites 657 ctrs=Coord_tps(1:nbvec_sub,:,isub) ;%(=initial points) ctrs 658 nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for each interpolation point (in case of subdomain overlap) 659 EM = tps_eval(epoints,ctrs); 660 Shiftx(ind_sel)=Shiftx(ind_sel)+EM*U_tps(1:nbvec_sub+3,isub); 661 Shifty(ind_sel)=Shifty(ind_sel)+EM*V_tps(1:nbvec_sub+3,isub); 662 if par_civ2.CheckDeformation 663 [EMDX,EMDY] = tps_eval_dxy(epoints,ctrs);%2D matrix of distances between extrapolation points epoints and spline centres (=site points) ctrs 664 DUDX(ind_sel)=DUDX(ind_sel)+EMDX*U_tps(1:nbvec_sub+3,isub); 665 DUDY(ind_sel)=DUDY(ind_sel)+EMDY*U_tps(1:nbvec_sub+3,isub); 666 DVDX(ind_sel)=DVDX(ind_sel)+EMDX*V_tps(1:nbvec_sub+3,isub); 667 DVDY(ind_sel)=DVDY(ind_sel)+EMDY*V_tps(1:nbvec_sub+3,isub); 668 end 697 669 end 698 670 end … … 726 698 par_civ2.DVDY=DVDY./nbval; 727 699 end 728 par_civ2700 729 701 % calculate velocity data (y and v in indices, reverse to y component) 730 702 [xtable, ytable, utable, vtable, ctable, F,result_conv,errormsg] = civ (par_civ2); 731 703 732 704 list_param=(fieldnames(Param.ActionInput.Civ2))'; 705 list_param(strcmp('TestCiv2',list_param))=[];% remove the parameter TestCiv2 from the list 733 706 Civ2_param=regexprep(list_param,'^.+','Civ2_$0');% insert 'Civ2_' before each string in list_param 734 707 Civ2_param=[{'Civ2_ImageA','Civ2_ImageB','Civ2_Time','Civ2_Dt'} Civ2_param]; %insert the names of the two input images 735 708 %indicate the values of all the global attributes in the output data 736 709 if exist('ImageName_A','var') 737 Data.Civ2_ImageA=ImageName_A;738 Data.Civ2_ImageB=ImageName_B;739 Data.Civ2_Time=(time(i2+1,j2+1)+time(i1+1,j1+1))/2;740 Data.Civ2_Dt=Civ2_Dt;710 Data.Civ2_ImageA=ImageName_A; 711 Data.Civ2_ImageB=ImageName_B; 712 Data.Civ2_Time=(time(i2+1,j2+1)+time(i1+1,j1+1))/2; 713 Data.Civ2_Dt=Civ2_Dt; 741 714 end 742 715 % Data.Civ2_Time=1; … … 748 721 749 722 nbvar=numel(Data.ListVarName); 750 Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_F','Civ2_C'}];% cell array containing the names of the fields to record 751 Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2'}]; 752 Data.VarAttribute{nbvar+1}.Role='coord_x'; 753 Data.VarAttribute{nbvar+2}.Role='coord_y'; 754 Data.VarAttribute{nbvar+3}.Role='vector_x'; 755 Data.VarAttribute{nbvar+4}.Role='vector_y'; 756 Data.VarAttribute{nbvar+5}.Role='warnflag'; 723 % define the Civ2 variable (if Civ2 data are not replaced from previous calculation) 724 if isempty(find(strcmp('Civ2_X',Data.ListVarName),1)) 725 Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_F','Civ2_C'}];% cell array containing the names of the fields to record 726 Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2'}]; 727 Data.VarAttribute{nbvar+1}.Role='coord_x'; 728 Data.VarAttribute{nbvar+2}.Role='coord_y'; 729 Data.VarAttribute{nbvar+3}.Role='vector_x'; 730 Data.VarAttribute{nbvar+4}.Role='vector_y'; 731 Data.VarAttribute{nbvar+5}.Role='warnflag'; 732 end 757 733 Data.Civ2_X=reshape(xtable,[],1); 758 734 Data.Civ2_Y=reshape(size(par_civ2.ImageA,1)-ytable+1,[],1); … … 761 737 Data.Civ2_C=reshape(ctable,[],1); 762 738 Data.Civ2_F=reshape(F,[],1); 763 Data.CivStage=Data.CivStage+1;764 739 end 765 740 … … 768 743 list_param=fieldnames(Param.ActionInput.Fix2)'; 769 744 Fix2_param=regexprep(list_param,'^.+','Fix2_$0');% insert 'Fix1_' before each string in ListFixParam 770 %indicate the values of all the global attributes in the output data 745 %indicate the values of all the global attributes in the output data 771 746 for ilist=1:length(list_param) 772 747 Data.(Fix2_param{ilist})=Param.ActionInput.Fix2.(list_param{ilist}); 773 748 end 774 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Fix2_param]; 775 % 776 % ListFixParam=fieldnames(Param.ActionInput.Fix2);777 % for ilist=1:length(ListFixParam)778 % ParamName=ListFixParam{ilist};779 % ListName=['Fix2_' ParamName];780 % eval(['Data.ListGlobalAttribute=[Data.ListGlobalAttribute ''' ParamName '''];'])781 % eval(['Data.' ListName '=Param.ActionInput.Fix2.' ParamName ';'])782 % end749 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Fix2_param]; 750 % 751 % ListFixParam=fieldnames(Param.ActionInput.Fix2); 752 % for ilist=1:length(ListFixParam) 753 % ParamName=ListFixParam{ilist}; 754 % ListName=['Fix2_' ParamName]; 755 % eval(['Data.ListGlobalAttribute=[Data.ListGlobalAttribute ''' ParamName '''];']) 756 % eval(['Data.' ListName '=Param.ActionInput.Fix2.' ParamName ';']) 757 % end 783 758 if check_civx 784 759 if ~isfield(Data,'fix2') … … 802 777 %% Patch2 803 778 if isfield (Param.ActionInput,'Patch2') 804 list_param=fieldnames(Param.ActionInput.Patch2)'; 779 list_param=fieldnames(Param.ActionInput.Patch2)'; 780 list_param(strcmp('TestPatch2',list_param))=[];% remove the parameter TestCiv1 from the list 805 781 Patch2_param=regexprep(list_param,'^.+','Patch2_$0');% insert 'Fix1_' before each string in ListFixParam 806 %indicate the values of all the global attributes in the output data 782 %indicate the values of all the global attributes in the output data 807 783 for ilist=1:length(list_param) 808 784 Data.(Patch2_param{ilist})=Param.ActionInput.Patch2.(list_param{ilist}); … … 811 787 812 788 813 % Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch2_FieldSmooth','Patch2_MaxDiff','Patch2_SubDomainSize'}];814 % Data.Patch2_FieldSmooth=Param.ActionInput.Patch2.FieldSmooth;815 % Data.Patch2_MaxDiff=Param.ActionInput.Patch2.MaxDiff;816 % Data.Patch2_SubDomainSize=Param.ActionInput.Patch2.SubDomainSize;789 % Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch2_FieldSmooth','Patch2_MaxDiff','Patch2_SubDomainSize'}]; 790 % Data.Patch2_FieldSmooth=Param.ActionInput.Patch2.FieldSmooth; 791 % Data.Patch2_MaxDiff=Param.ActionInput.Patch2.MaxDiff; 792 % Data.Patch2_SubDomainSize=Param.ActionInput.Patch2.SubDomainSize; 817 793 nbvar=length(Data.ListVarName); 818 794 Data.ListVarName=[Data.ListVarName {'Civ2_U_smooth','Civ2_V_smooth','Civ2_SubRange','Civ2_NbCentres','Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps'}]; … … 841 817 842 818 %% write result in a netcdf file if requested 843 if CheckOutputFile 819 if CheckOutputFile 844 820 errormsg=struct2nc(ncfile,Data); 845 821 if isempty(errormsg) … … 886 862 887 863 %% prepare measurement grid 888 if isfield(par_civ,'Grid')% grid points set as input 864 if isfield(par_civ,'Grid')% grid points set as input 889 865 if ischar(par_civ.Grid)%read the grid file if the input is a file name 890 866 par_civ.Grid=dlmread(par_civ.Grid); … … 903 879 nbvec=size(par_civ.Grid,1); 904 880 905 %% prepare correlation and search boxes 881 %% prepare correlation and search boxes 906 882 ibx2=ceil(par_civ.CorrBoxSize(1)/2); 907 883 iby2=ceil(par_civ.CorrBoxSize(2)/2); … … 924 900 result_conv=[]; 925 901 errormsg=''; 926 902 927 903 %% prepare mask 928 904 if isfield(par_civ,'Mask') && ~isempty(par_civ.Mask) … … 964 940 965 941 %% Apply mask 966 967 968 969 970 % 100>=mask> 20: velocity not calculated, impermeable (no flux through mask boundaries) 971 942 % Convention for mask IDEAS TO IMPLEMENT ? 943 % mask >200 : velocity calculated 944 % 200 >=mask>150;velocity not calculated, interpolation allowed (bad spots) 945 % 150>=mask >100: velocity not calculated, nor interpolated 946 % 100>=mask> 20: velocity not calculated, impermeable (no flux through mask boundaries) 947 % 20>=mask: velocity=0 972 948 checkmask=0; 973 949 MinA=min(min(par_civ.ImageA)); 974 950 MinB=min(min(par_civ.ImageB)); 975 951 if isfield(par_civ,'Mask') && ~isempty(par_civ.Mask) 976 checkmask=1;977 if ~isequal(size(par_civ.Mask),[npy_ima npx_ima])952 checkmask=1; 953 if ~isequal(size(par_civ.Mask),[npy_ima npx_ima]) 978 954 errormsg='mask must be an image with the same size as the images'; 979 955 return 980 end981 % check_noflux=(par_civ.Mask<100) ;%TODO: to implement956 end 957 % check_noflux=(par_civ.Mask<100) ;%TODO: to implement 982 958 check_undefined=(par_civ.Mask<200 & par_civ.Mask>=20 ); 983 959 par_civ.ImageA(check_undefined)=MinA;% put image A to zero (i.e. the min image value) in the undefined area … … 1007 983 check1_y=subrange1_y>=1 & subrange1_y<=par_civ.ImageHeight; 1008 984 check2_x=subrange2_x>=1 & subrange2_x<=par_civ.ImageWidth;% check which points in the subimage 2 are contained in the initial image 2 1009 check2_y=subrange2_y>=1 & subrange2_y<=par_civ.ImageHeight; 985 check2_y=subrange2_y>=1 & subrange2_y<=par_civ.ImageHeight; 1010 986 image1_crop(check1_y,check1_x)=par_civ.ImageA(subrange1_y(check1_y),subrange1_x(check1_x));%extract a subimage (correlation box) from image A 1011 987 image2_crop(check2_y,check2_x)=par_civ.ImageB(subrange2_y(check2_y),subrange2_x(check2_x));%extract a larger subimage (search box) from image B … … 1031 1007 YIant=YI-par_civ.DVDX(ivec)*XI-par_civ.DVDY(ivec)*YI+ceil(size(image1_crop,1)/2); 1032 1008 image1_crop=interp2(image1_crop,XIant,YIant); 1009 image1_crop(isnan(image1_crop))=0; 1033 1010 xi=(1:mesh:size(image2_crop,2)); 1034 1011 yi=(1:mesh:size(image2_crop,1))'; 1035 1012 image2_crop=interp2(image2_crop,xi,yi); 1013 image2_crop(isnan(image2_crop))=0; 1014 %% 1036 1015 end 1037 1016 sum_square=sum(sum(image1_crop.*image1_crop)); … … 1066 1045 else 1067 1046 F(ivec)=3; 1047 [y,x] 1068 1048 end 1069 1049 end … … 1133 1113 c11=(1/4)*sum(sum(c11)); 1134 1114 c20=(1/6)*sum(sum(c20)); 1135 c02=(1/6)*sum(sum(c02)); 1115 c02=(1/6)*sum(sum(c02)); 1136 1116 deltax=(c11*c01-2*c10*c02)/(4*c20*c02-c11^2); 1137 1117 deltay=(c11*c10-2*c01*c20)/(4*c20*c02-c11^2); … … 1151 1131 %filename: name of the netcdf file (used as input and output) 1152 1132 %field: structure specifying the names of the fields to fix (depending on civ1 or civ2) 1153 1154 1155 1156 %flagindex: flag specifying which values of vec_f are removed: 1157 1158 1159 1133 %.vel_type='civ1' or 'civ2'; 1134 %.nb=name of the dimension common to the field to fix ('nb_vectors' for civ1); 1135 %.fixflag=name of fix flag variable ('vec_FixFlag' for civ1) 1136 %flagindex: flag specifying which values of vec_f are removed: 1137 % if flagindex(1)=1: vec_f=-2 vectors are removed 1138 % if flagindex(2)=1: vec_f=3 vectors are removed 1139 % if flagindex(3)=1: vec_f=2 vectors are removed (if iter=1) or vec_f=4 vectors are removed (if iter=2) 1160 1140 %iter=1 for civ1 fields and iter=2 for civ2 fields 1161 1141 %thresh_vecC: threshold in the image correlation vec_C … … 1220 1200 if ~isempty(r) 1221 1201 NomTypeNc='_1_1-2'; 1222 end 1202 end 1223 1203 end 1224 1204 end … … 1226 1206 display('wrong pair mode input option') 1227 1207 else 1228 ind1=stra2num(r.num1);1229 ind2=stra2num(r.num2);1208 ind1=stra2num(r.num1); 1209 ind2=stra2num(r.num2); 1230 1210 end 1231 1211 end
Note: See TracChangeset
for help on using the changeset viewer.