Changeset 1154
- Timestamp:
- Jul 7, 2024, 11:22:00 PM (3 months ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/filter_tps.m
r1152 r1154 6 6 % SubRange(NbCoord,2,NbSubdomain): range (min, max) of the coordinates x and y respectively, for each subdomain 7 7 % NbCentre(NbSubdomain): number of source points for each subdomain 8 % FF: false flags preserved from the input, or equal to 20for vectors excluded by the difference with the smoothed field8 % FF: false flags preserved from the input, or equal to true for vectors excluded by the difference with the smoothed field 9 9 % U_smooth, V_smooth: filtered velocity components at the positions of the initial data 10 10 % Coord_tps(NbCentre,NbCoord,NbSubdomain): positions of the tps centres … … 61 61 62 62 %% smoothing parameter: CHANGED 03 May 2024 TO GET RESULTS INDEPENDENT OF SUBDOMAINSIZE 63 %smoothing=Siz(1)*Siz(2)*FieldSmooth/1000%o ptimum smoothing increase as the area of the subdomain (division by 1000 to reach good values with the default GUI input)63 %smoothing=Siz(1)*Siz(2)*FieldSmooth/1000%old calculation before 03 May < r1129 64 64 NbVecSub=NbVec/NbSubDomain;% refined estimation of the nbre of vectors per subdomain 65 65 smoothing=sqrt(Siz(1)*Siz(2)/NbVecSub)*FieldSmooth;%optimum smoothing increase as the typical mesh size =sqrt(SizX*SizY/NbVecSub)^1/2 66 Threshold=Threshold*Threshold;% take the square of the threshold to work with the modulus squared (not done before r1154) 66 67 67 68 %% default output … … 75 76 V_smooth=zeros(NbVec,1);% smoothed velocity V at the initial positions 76 77 W_smooth=[];%default (2 component case) 77 FF= zeros(NbVec,1);78 FF=false(NbVec,1);%false flag=0 (false) by default 78 79 nb_select=zeros(NbVec,1); 79 80 check_empty=zeros(1,NbSubDomain); … … 88 89 while numel(ind_sel)>numel(ind_sel_previous) 89 90 ind_sel_previous=ind_sel;% record the set of selected vector indices for next iteration 90 ind_sel= find(FF==0 & Coord(:,1)>=SubRange(1,1,isub) & Coord(:,1)<=SubRange(1,2,isub) & Coord(:,2)>=SubRange(2,1,isub) & Coord(:,2)<=SubRange(2,2,isub));% indices of vectors in the subdomain #isub 91 ind_sel= find(~FF & Coord(:,1)>=SubRange(1,1,isub) & Coord(:,1)<=SubRange(1,2,isub) & Coord(:,2)>=SubRange(2,1,isub) & Coord(:,2)<=SubRange(2,2,isub));% indices of vectors in the subdomain #isub 92 %ind_sel= find( Coord(:,1)>=SubRange(1,1,isub) & Coord(:,1)<=SubRange(1,2,isub) & Coord(:,2)>=SubRange(2,1,isub) & Coord(:,2)<=SubRange(2,2,isub));% indices of vectors in the subdomain #isub 91 93 % if no vector in the subdomain #isub, skip the subdomain 92 94 if isempty(ind_sel) … … 97 99 SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4; 98 100 SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4; 99 % subdomain includes enough vectors, perform tps interpolation101 % if subdomain includes enough vectors, perform tps interpolation 100 102 else 101 103 [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel,:),U(ind_sel),smoothing); … … 106 108 ind_ind_sel=1:numel(ind_sel);%default 107 109 if exist('Threshold','var')&&~isempty(Threshold) 108 FF(ind_sel)= 4*(NormDiff>Threshold);%put FF value to 4to identify the criterium of elimmination109 ind_ind_sel=find( FF(ind_sel)==0); % select the indices of remaining vectors in the subset of ind_sel vectors110 FF(ind_sel)=(NormDiff>Threshold);%put FF value to 1 to identify the criterium of elimmination 111 ind_ind_sel=find(~FF(ind_sel)); % select the indices of remaining vectors in the subset of ind_sel vectors 110 112 end 111 113 % if no value exceeds threshold, the result is recorded … … 116 118 y_dist=(Coord(ind_sel,2)-CentreY(isub))/y_width;% relative ydistance to the retangle centre 117 119 weight=cos(x_dist).*cos(y_dist);%weighting fct =1 at the rectangle center and 0 at edge 120 %weight=1;% case for r1129 and before 118 121 U_smooth(ind_sel)=U_smooth(ind_sel)+weight.*U_smooth_sub; 119 122 V_smooth(ind_sel)=V_smooth(ind_sel)+weight.*V_smooth_sub; … … 138 141 y_dist=(Coord(ind_sel(ind_ind_sel),2)-CentreY(isub))/y_width;% relative ydistance to the retangle centre 139 142 weight=cos(x_dist).*cos(y_dist);%weighting fct =1 at the rectangle center and 0 at edge 143 %weight=1; 140 144 U_smooth(ind_sel(ind_ind_sel))=U_smooth(ind_sel(ind_ind_sel))+weight.*U_smooth_sub; 141 145 V_smooth(ind_sel(ind_ind_sel))=V_smooth(ind_sel(ind_ind_sel))+weight.*V_smooth_sub; … … 166 170 U_smooth=U_smooth./nb_select;% take the average at the intersection of several subdomains 167 171 V_smooth=V_smooth./nb_select; 168 U_smooth(FF==4)=U(FF==4);% set to the initial values the eliminated vectors (flagged as false) 169 V_smooth(FF==4)=V(FF==4); 172 173 %eliminate the vectors with diff>threshold not yet eliminated 174 if exist('Threshold','var')&&~isempty(Threshold) 175 UDiff=U_smooth-U;% difference between interpolated U component and initial value 176 VDiff=V_smooth-V;% difference between interpolated V component and initial value 177 NormDiff=UDiff.*UDiff+VDiff.*VDiff;% Square of difference norm 178 FF(NormDiff>Threshold)=true;%put FF value to 1 to identify the criterium of elimmination 179 end 180 181 U_smooth(FF)=U(FF);% set to the initial values the eliminated vectors (flagged as false) 182 V_smooth(FF)=V(FF); 170 183 fill=zeros(NbCoord+1,NbCoord,size(SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage) 171 184 Coord_tps=cat(1,Coord_tps,fill); -
trunk/src/keyboard_callback.m
r1127 r1154 26 26 switch xx 27 27 case {29,28,30,31} %arrows for displacement 28 hhh=get(hObject,'CurrentObject'); 28 29 AxeData=get(cur_axes,'UserData'); 29 30 if isfield(AxeData,'ZoomAxes')&&ishandle(AxeData.ZoomAxes) … … 31 32 axes(cur_axes) 32 33 end 33 if ~isempty(cur_axes) 34 if ~isempty(cur_axes) && ~strcmp(get(hhh,'Type'),'uicontrol') 34 35 xlimit=get(cur_axes,'XLim'); 35 36 ylimit=get(cur_axes,'Ylim'); -
trunk/src/series.m
r1152 r1154 572 572 PairString=get(handles.PairString,'Data'); 573 573 if numel(PairString)>=iview 574 checkpair=strfind(PairString{iview},'j=');575 if checkpair576 j1=str2double( PairString{iview}(4));577 j2=str2double( PairString{iview}(6));578 end574 r=regexp(PairString{iview},'(?<num1>\d+)-(?<num2>\d+)' ,'names'); 575 if ~isempty(r) 576 j1=str2double(r.num1); 577 j2=str2double(r.num2); 578 end 579 579 end 580 580 InputFile=fullfile_uvmat('','',InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,[],j1,j2); … … 1400 1400 errormsg='input field name(s) not defined, select add_field...'; 1401 1401 return 1402 end 1403 [status,result]=system(['svn info ' Param.Action.ActionPath]); 1404 if status==0 1405 t=regexp(result,'R.vision\s*:\s*(?<rev>\d+)','names');%detect 'revision' or 'Revision' in the text 1406 if ~isempty(t) 1407 Param.UvmatRevision=t.rev; %version nbre of the current package 1408 end 1402 1409 end 1403 1410 … … 2305 2312 return 2306 2313 end 2307 [ tild,ActionName,ActionExt]=fileparts(FileName);2314 [~,ActionName,ActionExt]=fileparts(FileName); 2308 2315 2309 2316 % insert the choice in the menu ActionName … … 2397 2404 %% Activate the Action fct to adapt the configuration of the GUI series and bring specific parameters in SeriesData 2398 2405 Param=read_GUI_series(handles); % read the parameters from the GUI series 2399 Param.Action.RUN=0; 2400 Param.SeriesData=SeriesData; 2406 Param.Action.RUN=0;% indicate that we are in the mode of parameter input, not program run 2407 Param.SeriesData=SeriesData;% info stored in 'UserData' of the fig 'series' 2401 2408 ParamOut=h_fun(Param); % run the selected Action function to get the relevant input 2402 2409 … … 2465 2472 ind_var=get(handles.FieldName,'Value'); % indices of previously selected variables 2466 2473 for ilist=1:numel(ind_var) 2467 if isempty(find(strcmp(FieldList{ind_var(ilist)},ListVarName) ))2474 if isempty(find(strcmp(FieldList{ind_var(ilist)},ListVarName), 1)) 2468 2475 FieldList={}; % previous choice not consistent with new input field 2469 2476 set(handles.FieldName,'Value',1) … … 2471 2478 end 2472 2479 end 2473 if ~isempty(FieldList) iview_netcdf2474 if isempty(find(strcmp(get(handles.Coord_x,'String'),ListVarName) ))||...2475 isempty(find(strcmp(get(handles.Coord_y,'String'),ListVarName) ))2480 if ~isempty(FieldList) 2481 if isempty(find(strcmp(get(handles.Coord_x,'String'),ListVarName), 1))||... 2482 isempty(find(strcmp(get(handles.Coord_y,'String'),ListVarName), 1)) 2476 2483 FieldList={}; 2477 2484 set(handles.Coord_x,'String','') … … 2479 2486 end 2480 2487 Coord_z=get(handles.Coord_z,'String'); 2481 if ~isempty(Coord_z) && isempty(find(strcmp(Coord_z,ListVarName) ))REFRESH2488 if ~isempty(Coord_z) && isempty(find(strcmp(Coord_z,ListVarName), 1)) 2482 2489 FieldList={}; 2483 2490 set(handles.Coord_z,'String','') … … 2489 2496 end 2490 2497 set(handles_coord,'Visible','on') 2491 if isempty(find(strcmp('add_field...',FieldList) ))2498 if isempty(find(strcmp('add_field...',FieldList), 1)) 2492 2499 FieldList=[FieldList;{'add_field...'}];%add 'add_field...' to the menu FieldName if it is not already 2493 2500 end … … 2496 2503 set(handles.Field_text_1,'Visible','on') 2497 2504 if CheckPivData_1==0 % not civ input made 2498 FieldList_1={'add_field...'} 2505 FieldList_1={'add_field...'}; 2499 2506 ListVarName=SeriesData.FileInfo{iview_netcdf(2)}.ListVarName; 2500 2507 ind_var=get(handles.FieldName,'Value'); % indices of previously selected variables 2501 2508 for ilist=1:numel(ind_var) 2502 if isempty(find(strcmp(FieldList{ind_var(ilist)},ListVarName) ))2509 if isempty(find(strcmp(FieldList{ind_var(ilist)},ListVarName), 1)) 2503 2510 %FieldList_1={}; % previous choice not consistent with new input field 2504 2511 set(handles.FieldName_1,'Value',1) … … 2507 2514 end 2508 2515 warn_coord=0; 2509 if isempty(find(strcmp(get(handles.Coord_x,'String'),ListVarName) ))||...2510 isempty(find(strcmp(get(handles.Coord_y,'String'),ListVarName) ))2516 if isempty(find(strcmp(get(handles.Coord_x,'String'),ListVarName), 1))||... 2517 isempty(find(strcmp(get(handles.Coord_y,'String'),ListVarName), 1)) 2511 2518 warn_coord=1; 2512 2519 end 2513 if ~isempty(Coord_z) && isempty(find(strcmp(Coord_z,ListVarName) ))2520 if ~isempty(Coord_z) && isempty(find(strcmp(Coord_z,ListVarName), 1)) 2514 2521 FieldList_1={'add_field...'}; 2515 2522 warn_coord=1; … … 2547 2554 %% Check whether alphabetical sorting of input Subdir is allowed by the Action fct (for multiples series entries) 2548 2555 if isfield(ParamOut,'AllowInputSort')&&isequal(ParamOut.AllowInputSort,'on')&& size(Param.InputTable,1)>1 2549 [ tild,iview]=sort(Param.InputTable(:,2)); % subdirectories sorted in alphabetical order2556 [~,iview]=sort(Param.InputTable(:,2)); % subdirectories sorted in alphabetical order 2550 2557 set(handles.InputTable,'Data',Param.InputTable(iview,:)); 2551 2558 MinIndex_i=get(handles.MinIndex_i,'Data'); … … 2632 2639 2633 2640 %% NbSlice visibility 2634 % if isfield(ParamOut,'OutputFileMode')&& strcmp(ParamOut.OutputFileMode,'NbSlice')2635 % ParamOut.NbSlice='on';2636 % end2637 2641 if isfield(ParamOut,'NbSlice') && (strcmp(ParamOut.NbSlice,'on')||isnumeric(ParamOut.NbSlice)) 2638 2642 set(handles.num_NbSlice,'Visible','on') … … 2690 2694 end 2691 2695 set(handles.CheckMask,'Visible',MaskVisible); 2696 set(handles.MaskTable,'Visible',MaskVisible); 2697 2692 2698 %% Setting of expected iteration time 2693 2699 if isfield(ParamOut,'CPUTime') … … 2698 2704 InputTable=get(handles.InputTable,'Data'); 2699 2705 [OutputPath,Device,DeviceExt]=fileparts(InputTable{1,1}); 2700 [ OutputPath,Experiment,ExperimentExt]=fileparts(OutputPath);2706 [~,Experiment,ExperimentExt]=fileparts(OutputPath); 2701 2707 set(handles.Device,'String',[Device DeviceExt]) 2702 2708 set(handles.Device,'Visible','on') … … 2710 2716 2711 2717 %% definition of the subdirectory containing the output files 2712 2713 2718 if ~(isfield(SeriesData,'ActionName') && strcmp(ActionName,SeriesData.ActionName)) 2714 2719 OutputDirExt='.series'; % default … … 2752 2757 set(handles.OutputDirExt,'Visible',OutputDirVisible) 2753 2758 set(handles.OutputSubDir,'Visible',OutputDirVisible) 2754 % set(handles.OutputDir_title,'Visible',OutputDirVisible)2755 2759 SeriesData.ActionName=ActionName; % record ActionName for next use 2756 2760 … … 2776 2780 %% definition of an additional parameter set, determined by an ancillary GUI 2777 2781 if isfield(ParamOut,'ActionInput') 2778 % set(handles.ActionInput,'Visible','on')2779 2782 ParamOut.ActionInput.Program=ActionName; % record the program in ActionInput 2780 2783 SeriesData.ActionInput=ParamOut.ActionInput; 2781 2784 else 2782 % set(handles.ActionInput,'Visible','off')2783 2785 if isfield(SeriesData,'ActionInput') 2784 2786 SeriesData=rmfield(SeriesData,'ActionInput'); -
trunk/src/series/civ_input.m
r1153 r1154 141 141 iview_image=2;%line # for the input images 142 142 otherwise 143 if ~strcmp(FieldType,'image')144 msgbox_uvmat('ERROR','civ_series needs images, scalar fields in netcdf format, or civ data as input')145 return146 end143 % if ~strcmp(FileType,'image') 144 % msgbox_uvmat('ERROR','civ_series needs images, scalar fields in netcdf format, or civ data as input') 145 % return 146 % end 147 147 end 148 148 -
trunk/src/series/civ_series.m
r1153 r1154 127 127 end 128 128 if isfield(Param,'InputTable') 129 [ tild,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);129 [~,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 130 130 iview_A=0;% series index (iview) for the first image series 131 131 iview_B=0;% series index (iview) for the second image series (only non zero for option 'shift' comparing two image series ) … … 195 195 j2_series_Civ2=j2_series_Civ1; 196 196 NomTypeNc='_1'; 197 case 'PIV volume'198 % TODO, TODO199 197 end 200 198 %determine frame indices for input with movie or other multiframe input file … … 252 250 Data.Conventions='uvmat/civdata';% states the conventions used for the description of field variables and attributes 253 251 Data.Program='civ_series'; 252 if isfield(Param,'UvmatRevision') 253 Data.Program=[Data.Program ', uvmat r' Param.UvmatRevision]; 254 end 254 255 Data.CivStage=0;%default 255 256 … … 509 510 % caluclate velocity data (y and v in indices, reverse to y component) 510 511 tstart_civ1=tic; 511 [xtable, ytable, utable, vtable, ctable, F , result_conv, errormsg] = civ (par_civ1);512 [xtable, ytable, utable, vtable, ctable, FF, result_conv, errormsg] = civ (par_civ1); 512 513 if ~isempty(errormsg) 513 514 disp_uvmat('ERROR',errormsg,checkrun) … … 519 520 Data.Civ1_V=reshape(-vtable,[],1); 520 521 Data.Civ1_C=reshape(ctable,[],1); 521 Data.Civ1_FF=reshape(F ,[],1);522 Data.Civ1_FF=reshape(FF,[],1); 522 523 time_civ1=toc(tstart_civ1); 523 524 end … … 601 602 602 603 % perform Patch calculation using the UVMAT fct 'filter_tps' 603 604 604 [Data.Civ1_SubRange,Data.Civ1_NbCentres,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=... 605 605 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); 606 606 Data.Civ1_U_smooth(ind_good)=Ures;% take the interpolated (smoothed) velocity values for good vectors, keep civ1 data for the other 607 607 Data.Civ1_V_smooth(ind_good)=Vres; 608 Data.Civ1_FF(ind_good)=uint8( FFres);608 Data.Civ1_FF(ind_good)=uint8(4*FFres); 609 609 time_patch1=toc(tstart_patch1); 610 610 disp('patch1 performed') … … 770 770 % calculate velocity data (y and v in image indices, reverse to y component) 771 771 772 [xtable, ytable, utable, vtable, ctable, F ,result_conv,errormsg] = civ (par_civ2);772 [xtable, ytable, utable, vtable, ctable, FF,result_conv,errormsg] = civ (par_civ2); 773 773 774 774 list_param=(fieldnames(Param.ActionInput.Civ2))'; … … 810 810 Data.Civ2_V=reshape(-vtable,[],1); 811 811 Data.Civ2_C=reshape(ctable,[],1); 812 Data.Civ2_FF=reshape(F ,[],1);812 Data.Civ2_FF=reshape(FF,[],1); 813 813 disp('civ2 performed') 814 814 time_civ2=toc(tstart_civ2); … … 821 821 return 822 822 end 823 % elseif isfield(Param,'Civ2_X')% use Civ2 data as input in Param (test mode)824 % Data.ListGlobalAttribute={};825 % Data.ListVarName={};826 % Data.VarDimName={};827 % Data.Civ2_X=Param.Civ2_X;828 % Data.Civ2_Y=Param.Civ2_Y;829 % Data.Civ2_U=Param.Civ2_U;830 % Data.Civ2_V=Param.Civ2_V;831 % Data.Civ2_FF=Param.Civ2_FF;832 823 end 833 824 end … … 886 877 Data.Civ2_U_smooth(ind_good)=Ures; 887 878 Data.Civ2_V_smooth(ind_good)=Vres; 888 Data.Civ2_FF(ind_good)= FFres;879 Data.Civ2_FF(ind_good)=uint8(4*FFres); 889 880 Data.CivStage=Data.CivStage+1; 890 881 time_patch2=toc(tstart_patch2); … … 921 912 % OUTPUT: 922 913 % xtable: set of x coordinates 923 % ytable: set of y coordi antes914 % ytable: set of y coordinates 924 915 % utable: set of u displacements (along x) 925 916 % vtable: set of v displacements (along y) … … 1278 1269 % FF=2, for too small correlation 1279 1270 % FF=3, for velocity outside bounds 1280 % FF=4 for exclusion by difference with the smoothed field, not set in this function1271 % FF=4 for exclusion by difference with the smoothed field, set by call to function filter_tps 1281 1272 1282 1273 if isfield (Param,'MinCorr') -
trunk/src/uvmat.m
r1153 r1154 2016 2016 %------------------------------------------------------------------------ 2017 2017 % open the GUI 'series' 2018 function Menu Series_Callback(hObject, eventdata, handles)2018 function MenuRun1_Callback(hObject, eventdata, handles) 2019 2019 %------------------------------------------------------------------------ 2020 2020 Param=read_GUI(handles.uvmat); … … 2023 2023 2024 2024 % -------------------------------------------------------------------- 2025 function Menu PIV_Callback(hObject, eventdata, handles)2025 function MenuRun2_Callback(hObject, eventdata, handles) 2026 2026 Param=read_GUI(handles.uvmat); 2027 2027 Param.HiddenData=get(handles.uvmat,'UserData'); … … 2033 2033 series('ActionName_Callback',hObject,eventdata,hhseries); %file input with xml reading in uvmat, show the image in phys coordinates 2034 2034 2035 % ------------------------------------------------------------------------2036 % -- open the GUI civ.fig for PIV2037 function MenuCIVx_Callback(hObject, eventdata, handles)2038 % ------------------------------------------------------------------------2039 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);2040 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];2041 civ(FileName);% interface de civ(not in the uvmat file)2035 % %------------------------------------------------------------------------ 2036 % % -- open the GUI civ.fig for PIV 2037 % function MenuCIVx_Callback(hObject, eventdata, handles) 2038 % %------------------------------------------------------------------------ 2039 % [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); 2040 % FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; 2041 % civ(FileName);% interface de civ(not in the uvmat file) 2042 2042 2043 2043 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 2603 2603 set(handles.ColorScalar,'String',ColorList) 2604 2604 set(handles.Vectors,'Visible','on') 2605 %set(handles.Coord_x,'Value',1);2606 2605 set(handles.Coord_x,'String','X'); 2607 2606 set(handles.Coord_y,'String','Y'); 2607 set(handles.MenuRun3,'Label','test_filter_tps') 2608 2608 case {'netcdf','mat'} 2609 2609 set(handles_Fields,'Value',1) … … 6108 6108 6109 6109 6110 6111 6110 % -------------------------------------------------------------------- 6112 6111 % --- Executes on button press in CheckTable. … … 6121 6120 6122 6121 6123 6124 6125 6126 6127 6122 % -------------------------------------------------------------------- 6123 function MenuRun3_Callback(hObject, eventdata, handles) 6124 Param=read_GUI(handles.uvmat); 6125 Param.HiddenData=get(handles.uvmat,'UserData'); 6126 hseries=series(Param); 6127 hhseries=guidata(hseries); 6128 ActionMenu=get(hhseries.ActionName,'String'); 6129 index_action=find(strcmp('test_filter_tps',ActionMenu)); 6130 set(hhseries.ActionName,'Value',index_action); 6131 series('ActionName_Callback',hObject,eventdata,hhseries); %file input with xml reading in uvmat, show the image in phys coordinates
Note: See TracChangeset
for help on using the changeset viewer.