Changeset 581
- Timestamp:
- Mar 12, 2013, 12:52:13 PM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/browse_data.m
r576 r581 22 22 function varargout = browse_data(varargin) 23 23 24 % Last Modified by GUIDE v2.5 15-Feb-2013 19:41:4824 % Last Modified by GUIDE v2.5 07-Mar-2013 18:55:00 25 25 26 26 % Begin initialization code - DO NOT EDIT … … 47 47 function browse_data_OpeningFcn(hObject, eventdata, handles, Campaign) 48 48 %------------------------------------------------------------------------ 49 % Choose default command line output for browse_data 49 50 %% Choose default command line output for browse_data 50 51 handles.output = 'Cancel'; 51 52 52 % Update handles structure53 %% Update handles structure 53 54 guidata(hObject, handles); 54 55 % Determine the position of the dialog - centered on the screen 55 set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) 56 57 %% Determine the position of the dialog - centered on the screen 56 58 FigPos=get(0,'DefaultFigurePosition'); 57 59 OldUnits = get(hObject, 'Units'); … … 95 97 set(handles.OK,'Visible','on') 96 98 set(handles.Cancel,'Visible','on') 97 set(handles. figure,'WindowStyle','modal')% Make% Make the GUI modal99 set(handles.browse_data,'WindowStyle','modal')% Make the GUI modal 98 100 set(hObject,'Visible','on') 99 101 drawnow 100 102 % UIWAIT makes GUI wait for user response (see UIRESUME) 101 uiwait(handles. figure);103 uiwait(handles.browse_data); 102 104 end 103 105 … … 108 110 % Get default command line output from handles structure 109 111 varargout{1} = handles.output; 110 delete(handles. figure)112 delete(handles.browse_data) 111 113 112 114 %------------------------------------------------------------------------ … … 312 314 set(handles.ListExperiments,'Value',1) 313 315 ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories 314 DataviewData=get(handles. figure,'UserData');316 DataviewData=get(handles.browse_data,'UserData'); 315 317 List=DataviewData.List; 316 318 Currentpath=get(handles.SourceDir,'String'); … … 580 582 set(handles.ListExperiments,'Value',1) 581 583 ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories 582 DataviewData=get(handles. figure,'UserData')584 DataviewData=get(handles.browse_data,'UserData') 583 585 List=DataviewData.List; 584 586 Currentpath=get(handles.SourceDir,'String'); … … 654 656 handles.output.Device=Device; 655 657 guidata(hObject, handles);% Update handles structure 656 uiresume(handles. figure);658 uiresume(handles.browse_data); 657 659 drawnow 658 660 return … … 676 678 677 679 %update all the selected xml files 678 DataviewData=get(handles. figure,'UserData');680 DataviewData=get(handles.browse_data,'UserData'); 679 681 % answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' ... 680 682 % DataviewData.GeometryCalib.CalibrationType ' calibration data']) … … 771 773 % handles.output ='OK, Calibration replicated'; 772 774 % guidata(hObject, handles);% Update handles structure 773 % uiresume(handles. figure);775 % uiresume(handles.browse_data); 774 776 775 777 % --- Executes on button press in Cancel. … … 778 780 guidata(hObject, handles); % Update handles structure 779 781 % Use UIRESUME instead of delete because the OutputFcn needs 780 uiresume(handles. figure);781 782 % --- Executes when user attempts to close figure.783 function figure_CloseRequestFcn(hObject, eventdata, handles)784 if isequal(get(handles. figure, 'waitstatus'), 'waiting')782 uiresume(handles.browse_data); 783 784 % --- Executes when user attempts to close browse_data. 785 function browse_data_CloseRequestFcn(hObject, eventdata, handles) 786 if isequal(get(handles.browse_data, 'waitstatus'), 'waiting') 785 787 % The GUI is still in UIWAIT, us UIRESUME 786 uiresume(handles. figure);788 uiresume(handles.browse_data); 787 789 else 788 790 % The GUI is no longer waiting, just close it 789 delete(handles. figure);791 delete(handles.browse_data); 790 792 end 791 793 792 794 % --- Executes on key press over figure1 with no controls selected. 793 function figure_KeyPressFcn(hObject, eventdata, handles)795 function browse_data_KeyPressFcn(hObject, eventdata, handles) 794 796 % Check for "enter" or "escape" 795 797 if isequal(get(hObject,'CurrentKey'),'escape') … … 800 802 guidata(hObject, handles); 801 803 802 uiresume(handles. figure);804 uiresume(handles.browse_data); 803 805 end 804 806 if isequal(get(hObject,'CurrentKey'),'return') 805 uiresume(handles. figure);807 uiresume(handles.browse_data); 806 808 end -
trunk/src/calc_field_tps.m
r575 r581 2 2 %'calc_field_tps': defines fields (velocity, vort, div...) from civ data and calculate them with tps interpolation 3 3 %--------------------------------------------------------------------- 4 % [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbSites,SubRange,FieldVar, Operation,Coord_interp)4 % [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbSites,SubRange,FieldVar,FieldName,Coord_interp) 5 5 % 6 6 % OUTPUT: … … 12 12 % SubRange 13 13 % FieldVar 14 % Operation: cell array representing the list of operations (eg div, rot..)14 % FieldName: cell array representing the list of operations (eg div, rot..) 15 15 % Coord_interp: coordiantes of sites on which the fields need to be calculated 16 16 17 function [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbSites,SubRange,FieldVar, Operation,Coord_interp)17 function [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbSites,SubRange,FieldVar,FieldName,Coord_interp) 18 18 19 19 %list of defined scalars to display in menus (in addition to 'ima_cor'). … … 44 44 check_grid=0; 45 45 check_der=0; 46 for ilist=1:length( Operation)47 OperationType=regexprep(Operation{ilist},'(.+','');48 switch OperationType46 for ilist=1:length(FieldName) 47 FieldNameType=regexprep(FieldName{ilist},'(.+',''); 48 switch FieldNameType 49 49 case 'vec' 50 50 check_grid=1; … … 55 55 case {'U','V','norm'} 56 56 check_grid=1; 57 DataOut.( OperationType)=zeros(nb_sites,1);57 DataOut.(FieldNameType)=zeros(nb_sites,1); 58 58 VarAttribute{1}.Role='scalar'; 59 59 case {'curl','div','strain'} 60 60 check_der=1; 61 DataOut.( OperationType)=zeros(nb_sites,1);61 DataOut.(FieldNameType)=zeros(nb_sites,1); 62 62 VarAttribute{1}.Role='scalar'; 63 63 end … … 79 79 end 80 80 ListVar={}; 81 for ilist=1:length( Operation)81 for ilist=1:length(FieldName) 82 82 var_count=numel(ListVar); 83 switch Operation{ilist}83 switch FieldName{ilist} 84 84 case 'vec(U,V)' 85 85 ListVar=[ListVar {'U', 'V'}]; -
trunk/src/check_files.m
r570 r581 32 32 svn_info.status=[]; 33 33 list_fct={... 34 'xmltree';...%function for editing xml files (toolbox outside uvmat) 34 35 'browse_data';...% function for scanning directories in a project/campaign 35 36 'browse_data.fig';...% GUI corresponding to dataview … … 101 102 'set_object.m';...% edit a projection object 102 103 'set_object.fig';...% interface for set_object 104 'set_subdomains';...% sort a set of points defined by scattered coordinates in subdomains, as needed for tps interpolation 103 105 'stra2num';...% transform letters (a, b, A, B,) or numerical strings ('1','2'..) to the corresponding numbers 104 106 'sub_field';...% combine the two input fields, … … 106 108 'struct2xml';... transform a matlab structure to a xml tree. 107 109 'tps_coeff';...% calculate the thin plate spline (tps) coefficients 110 'tps_coeff_field';...% calculate the thin plate spline (tps) coefficients with subdomains for a field structure 108 111 'tps_eval';... %calculate the thin plate spline (tps) interpolation at a set of points 109 112 'tps_eval_dxy';...% calculate the derivatives of thin plate spline (tps) interpolation at a set of points (limited to the 2D case) -
trunk/src/civ.m
r576 r581 24 24 %TODO: search range 25 25 26 % Last Modified by GUIDE v2.5 24-Jul-2012 13:14:0026 % Last Modified by GUIDE v2.5 09-Mar-2013 22:50:23 27 27 % Begin initialization code - DO NOT EDIT 28 28 gui_Singleton = 1; … … 3705 3705 handle_txtbox=findobj(hchildren,'tag','txt_Mask'); 3706 3706 if isequal(get(hObject,'Value'),0) 3707 set(handles.num_Sub domainSize,'Visible','on')3707 set(handles.num_SubDomainSize,'Visible','on') 3708 3708 set(handles.num_FieldSmooth,'Visible','on') 3709 3709 else 3710 set(handles.num_Sub domainSize,'Visible','off')3710 set(handles.num_SubDomainSize,'Visible','off') 3711 3711 set(handles.num_FieldSmooth,'Visible','off') 3712 3712 end … … 3717 3717 % %------------------------------------------------------------------------ 3718 3718 % if isequal(get(handles.CheckStereo,'Value'),0) 3719 % set(handles.num_ SubdomainSize,'Visible','on')3719 % set(handles.num_subdomainsize,'Visible','on') 3720 3720 % set(handles.num_FieldSmooth,'Visible','on') 3721 3721 % else 3722 % set(handles.num_ SubdomainSize,'Visible','off')3722 % set(handles.num_subdomainsize,'Visible','off') 3723 3723 % set(handles.num_FieldSmooth,'Visible','off') 3724 3724 % end -
trunk/src/civ_matlab.m
r578 r581 165 165 166 166 Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch1_Rho','Patch1_Threshold','Patch1_SubDomain'}]; 167 Data.Patch1_ Rho=Param.Patch1.FieldSmooth;168 Data.Patch1_ Threshold=Param.Patch1.MaxDiff;169 Data.Patch1_SubDomain =Param.Patch1.SubdomainSize;167 Data.Patch1_FieldSmooth=Param.Patch1.FieldSmooth; 168 Data.Patch1_MaxDiff=Param.Patch1.MaxDiff; 169 Data.Patch1_SubDomainSize=Param.Patch1.SubDomainSize; 170 170 nbvar=length(Data.ListVarName); 171 171 Data.ListVarName=[Data.ListVarName {'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbSites','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}]; … … 185 185 end 186 186 [Data.Civ1_SubRange,Data.Civ1_NbSites,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=... 187 filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomain ,Data.Patch1_Rho,Data.Patch1_Threshold);187 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); 188 188 Data.Civ1_U_smooth(ind_good)=Ures; 189 189 Data.Civ1_V_smooth(ind_good)=Vres; … … 373 373 if isfield (Param,'Patch2') 374 374 Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch2_Rho','Patch2_Threshold','Patch2_SubDomain'}]; 375 Data.Patch2_ Rho=Param.Patch2.FieldSmooth;376 Data.Patch2_ Threshold=Param.Patch2.MaxDiff;377 Data.Patch2_SubDomain =Param.Patch2.SubdomainSize;375 Data.Patch2_FieldSmooth=Param.Patch2.FieldSmooth; 376 Data.Patch2_MaxDiff=Param.Patch2.MaxDiff; 377 Data.Patch2_SubDomainSize=Param.Patch2.SubdomainSize; 378 378 nbvar=length(Data.ListVarName); 379 379 Data.ListVarName=[Data.ListVarName {'Civ2_U_smooth','Civ2_V_smooth','Civ2_SubRange','Civ2_NbSites','Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps'}]; … … 394 394 end 395 395 [Data.Civ2_SubRange,Data.Civ2_NbSites,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures, Vres,tild,FFres]=... 396 filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomain ,Data.Patch2_Rho,Data.Patch2_Threshold);396 filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomainSize,Data.Patch2_FieldSmooth,Data.Patch2_MaxDiff); 397 397 Data.Civ2_U_smooth(ind_good)=Ures; 398 398 Data.Civ2_V_smooth(ind_good)=Vres; -
trunk/src/filter_tps.m
r494 r581 1 1 %'filter_tps': find the thin plate spline coefficients for interpolation-smoothing 2 2 %------------------------------------------------------------------------ 3 % [SubRange,Nb Sites,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold)3 % [SubRange,NbCentres,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold) 4 4 % 5 5 % OUTPUT: 6 6 % SubRange(NbCoord,NbSubdomain,2): range (min, max) of the coordiantes x and y respectively, for each subdomain 7 % Nb Sites(NbSubdomain): number of source points for each subdomain7 % NbCentres(NbSubdomain): number of source points for each subdomain 8 8 % FF: false flags 9 9 % U_smooth, V_smooth: filtered velocity components at the positions of the initial data 10 % Coord_tps(Nb Sites,NbCoord,NbSubdomain): positions of the tps centres10 % Coord_tps(NbCentres,NbCoord,NbSubdomain): positions of the tps centres 11 11 % U_tps,V_tps: weight of the tps for each subdomain 12 12 % to get the interpolated field values, use the function calc_field.m … … 19 19 % Subdomain: estimated number of data points in each subdomain 20 20 21 function [SubRange,NbSites,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold) 22 %subdomain decomposition 21 function [SubRange,NbCentres,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold) 22 23 %% adjust subdomain decomposition 23 24 warning off 24 nbvec=size(Coord,1); 25 W_tps=[];%default 26 W_smooth=[]; 25 NbVec=size(Coord,1); 27 26 NbCoord=size(Coord,2); 28 NbSubDomain=nbvec/SubDomain; 29 MinCoord=min(Coord,[],1); 30 MaxCoord=max(Coord,[],1); 27 MinCoord=min(Coord,[],1);%lower coordinate bounds 28 MaxCoord=max(Coord,[],1);%upper coordinate bounds 31 29 Range=MaxCoord-MinCoord; 32 30 AspectRatio=Range(2)/Range(1); 31 NbSubDomain=NbVec/SubDomain; 33 32 NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1); 34 33 NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1); … … 41 40 CentreY=reshape(CentreY,1,[]);% Y positions of subdomain centres 42 41 CentreX=reshape(CentreX,1,[]);% X positions of subdomain centres 43 rho=Siz(1)*Siz(2)*Rho/1000;%optimum rho increase as the area of the subdomain (division by 10^6 to reach good values with the default GUI input) 44 U_tps_sub=zeros(nbvec,NbSubDomain);%default spline 45 V_tps_sub=zeros(nbvec,NbSubDomain);%default spline 46 Indices_tps=zeros(nbvec,NbSubDomain);%default indices 47 U_smooth=zeros(nbvec,1); 48 V_smooth=zeros(nbvec,1); 49 nb_select=zeros(nbvec,1); 50 FF=zeros(nbvec,1); 42 43 %% smoothing parameter 44 rho=Siz(1)*Siz(2)*Rho/1000;%optimum rho increase as the area of the subdomain (division by 1000 to reach good values with the default GUI input) 45 46 %% default output 47 SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the positions of subdomains 48 NbCentres=zeros(NbSubDomain);%number of interpolated values per subdomain, =0 by default 49 Coord_tps=zeros(NbVec,NbCoord,NbSubDomain);% default positions of the tps source= initial positions of the good vectors sorted by subdomain 50 U_tps=zeros(NbVec,NbSubDomain);%default spline 51 V_tps=zeros(NbVec,NbSubDomain);%default spline 52 W_tps=[];%default (2 component case) 53 U_smooth=zeros(NbVec,1); % smoothed velocity U at the initial positions 54 V_smooth=zeros(NbVec,1);% smoothed velocity V at the initial positions 55 W_smooth=[];%default (2 component case) 56 FF=zeros(NbVec,1); 57 nb_select=zeros(NbVec,1); 51 58 check_empty=zeros(1,NbSubDomain); 52 SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the positions of subdomains 53 % SubRangy=zeros(NbSubDomain,2);59 60 %% calculate tps coeff in each subdomain 54 61 for isub=1:NbSubDomain 55 62 SubRange(1,:,isub)=[CentreX(isub)-0.55*Siz(1) CentreX(isub)+0.55*Siz(1)]; … … 57 64 ind_sel_previous=[]; 58 65 ind_sel=0; 59 while numel(ind_sel)>numel(ind_sel_previous) %increase the subdomain during four iterations at most 66 %increase iteratively the subdomain if it contains less than SubDomainNbVec/4 source vectors 67 while numel(ind_sel)>numel(ind_sel_previous) 60 68 ind_sel_previous=ind_sel; 61 69 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)); 62 70 % if no vector in the subdomain, skip the subdomain 63 71 if isempty(ind_sel) 64 check_empty(isub)=1; 72 check_empty(isub)=1; 65 73 U_tps(1,isub)=0;%define U_tps and V_tps by default 66 74 V_tps(1,isub)=0; … … 70 78 SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4; 71 79 SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4; 72 else 80 else 73 81 [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel,:),U(ind_sel),rho); 74 82 [V_smooth_sub,V_tps_sub]=tps_coeff(Coord(ind_sel,:),V(ind_sel),rho); … … 78 86 ind_ind_sel=1:numel(ind_sel);%default 79 87 if exist('Threshold','var') 80 FF(ind_sel)=20*(NormDiff>Threshold);%put FF value to 20 to identify the criterium of elimmination81 ind_ind_sel=find(FF(ind_sel)==0); % select the indices of ind_sel corresponding to the remaining vectors88 FF(ind_sel)=20*(NormDiff>Threshold);%put FF value to 20 to identify the criterium of elimmination 89 ind_ind_sel=find(FF(ind_sel)==0); % select the indices of ind_sel corresponding to the remaining vectors 82 90 end 83 91 % if no value exceeds threshold, the result is recorded … … 85 93 U_smooth(ind_sel)=U_smooth(ind_sel)+U_smooth_sub; 86 94 V_smooth(ind_sel)=V_smooth(ind_sel)+V_smooth_sub; 87 Nb Sites(isub)=numel(ind_sel);88 Coord_tps(1:Nb Sites(isub),:,isub)=Coord(ind_sel,:);89 U_tps(1:Nb Sites(isub)+3,isub)=U_tps_sub;90 V_tps(1:Nb Sites(isub)+3,isub)=V_tps_sub;95 NbCentres(isub)=numel(ind_sel); 96 Coord_tps(1:NbCentres(isub),:,isub)=Coord(ind_sel,:); 97 U_tps(1:NbCentres(isub)+3,isub)=U_tps_sub; 98 V_tps(1:NbCentres(isub)+3,isub)=V_tps_sub; 91 99 nb_select(ind_sel)=nb_select(ind_sel)+1; 92 100 display('good') 93 101 break 94 % if too few selected vectors, increase the subrange for next iteration102 % if too few selected vectors, increase the subrange for next iteration 95 103 elseif numel(ind_ind_sel)<SubDomain/4 && ~isequal( ind_sel,ind_sel_previous); 96 104 SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4; 97 105 SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4; 98 % else interpolation-smoothing is done again with the selected vectors106 % else interpolation-smoothing is done again with the selected vectors 99 107 else 100 108 [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel(ind_ind_sel),:),U(ind_sel(ind_ind_sel)),rho); 101 109 [V_smooth_sub,V_tps_sub]=tps_coeff(Coord(ind_sel(ind_ind_sel),:),V(ind_sel(ind_ind_sel)),rho); 102 110 U_smooth(ind_sel(ind_ind_sel))=U_smooth(ind_sel(ind_ind_sel))+U_smooth_sub; 103 V_smooth(ind_sel(ind_ind_sel))=V_smooth(ind_sel(ind_ind_sel))+V_smooth_sub; 104 Nb Sites(isub)=numel(ind_ind_sel);105 Coord_tps(1:Nb Sites(isub),:,isub)=Coord(ind_sel(ind_ind_sel),:);106 U_tps(1:Nb Sites(isub)+3,isub)=U_tps_sub;107 V_tps(1:Nb Sites(isub)+3,isub)=V_tps_sub;111 V_smooth(ind_sel(ind_ind_sel))=V_smooth(ind_sel(ind_ind_sel))+V_smooth_sub; 112 NbCentres(isub)=numel(ind_ind_sel); 113 Coord_tps(1:NbCentres(isub),:,isub)=Coord(ind_sel(ind_ind_sel),:); 114 U_tps(1:NbCentres(isub)+3,isub)=U_tps_sub; 115 V_tps(1:NbCentres(isub)+3,isub)=V_tps_sub; 108 116 nb_select(ind_sel(ind_ind_sel))=nb_select(ind_sel(ind_ind_sel))+1; 109 117 display('good2') … … 113 121 end 114 122 end 123 124 %% remove empty subdomains 115 125 ind_empty=find(check_empty); 116 %remove empty subdomains117 126 if ~isempty(ind_empty) 118 127 SubRange(:,:,ind_empty)=[]; … … 121 130 V_tps(:,ind_empty)=[]; 122 131 end 123 nb_select(nb_select==0)=1;%ones(size(find(nb_select==0))); 124 U_smooth=U_smooth./nb_select; 132 133 %% final adjustments 134 nb_select(nb_select==0)=1; 135 U_smooth=U_smooth./nb_select;% take the average at the intersection of several subdomains 125 136 V_smooth=V_smooth./nb_select; 126 137 fill=zeros(NbCoord+1,NbCoord,size(SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage) -
trunk/src/find_field_cells.m
r580 r581 1 %'find_field_cells': test field structure for input in proj_field and plot_field 2 % group the variables into 'fields' with common dimensions 1 %'find_field_cells': analyse the field structure for input in uvmat functions, grouping the variables into 'fields' with common coordinates 3 2 %------------------------------------------------------------------------ 4 3 % function [CellInfo,NbDim,errormsg]=find_field_cells(Data) … … 9 8 % .CoordIndex: array of the indices of the variables representing the coordinates (in the order z,y,x) 10 9 % .CoordSize: array of the nbre of values for each coordinate in a grid, nbre of points in the unstructured case 11 % .Nb Site_tps:10 % .NbCentres_tps: 12 11 % .SubRange_tps 13 12 % .VarIndex: arrays of the variable indices in the field cell … … 19 18 % _vector_x,_y,_z: indices of variables giving the vector components x, y, z 20 19 % _warnflag: index of warnflag 21 % . FieldRequest= 'interp_lin', 'interp_tps' indicate whether lin interpolation or derivatives (tps) is needed to calculate the requested field20 % .ProjModeRequest= 'interp_lin', 'interp_tps' indicate whether lin interpolation or derivatives (tps) is needed to calculate the requested field 22 21 % .FieldName = operation to be performed to finalise the field cell after projection 23 22 % .SubCheck=0 /1 indicate that the field must be substracted (second entry in uvmat) … … 61 60 62 61 function [CellInfo,NbDim,errormsg]=find_field_cells(Data) 63 62 CellInfo={}; 64 63 NbDim=0; 65 64 errormsg=''; 66 65 if ~isfield(Data,'ListVarName'), errormsg='the list of variables .ListVarName is missing';return;end 67 66 if ~isfield(Data,'VarDimName'), errormsg='the list of dimensions .VarDimName is missing';return;end 68 nbvar=numel(Data.ListVarName);%number of field variables67 nbvar=numel(Data.ListVarName);%number of variables in the field structure 69 68 if ~isequal(numel(Data.VarDimName),nbvar), errormsg='.ListVarName and .VarDimName have unequal length';return;end 70 69 % check the existence of variable data … … 86 85 % 'ancillary','image','color','discrete','scalar','coord_tps'};% rmq vector_x_tps and vector_y_tps to be replaced by vector_x and vector_y 87 86 Role=num2cell(blanks(nbvar));%initialize a cell array of nbvar blanks 88 FieldRequest=regexprep(Role,' ',''); % fieldRequest set to '' by default87 ProjModeRequest=regexprep(Role,' ',''); % fieldRequest set to '' by default 89 88 FieldName=cell(size(Role)); % fieldRequest set to {} by default 90 89 CheckSub=zeros(size(Role));% =1 for fields to substract … … 95 94 Role{ivar}=Data.VarAttribute{ivar}.Role; 96 95 end 97 if isfield(Data.VarAttribute{ivar},' FieldRequest')98 FieldRequest{ivar}=Data.VarAttribute{ivar}.FieldRequest;96 if isfield(Data.VarAttribute{ivar},'ProjModeRequest') 97 ProjModeRequest{ivar}=Data.VarAttribute{ivar}.ProjModeRequest; 99 98 end 100 99 if isfield(Data.VarAttribute{ivar},'FieldName') … … 162 161 check_coord_tps= strcmp('coord_tps',Role(~check_select)); 163 162 ivar_tps=ivar_remain(check_coord_tps);% variable indices corresponding to tps coordinates 163 164 % loop on the tps coordinate sets 164 165 for icell_tps=1:numel(ivar_tps) 166 check_cell=zeros(1,nbvar);% =1 for the variables selected in the current cell 167 check_cell(ivar_tps(icell_tps))=1;% mark the coordiante variable as selected 165 168 DimCell=Data.VarDimName{ivar_tps(icell_tps)};% dimension names for the current tps coordinate variable 166 169 icell=numel(CellInfo)+icell_tps; % new field cell index 167 170 CellInfo{icell}.CoordIndex=ivar_tps(icell_tps);% index of the tps coordinate variable 168 %CellInfo{icell}.VarIndex_subrange_tps=[];169 %CellInfo{icell}.VarIndex_nbsites_tps=[];170 171 if numel(DimCell)==3 171 172 VarDimName=Data.VarDimName(~check_select); 172 173 for ivardim=1:numel(VarDimName) 173 174 if strcmp(VarDimName{ivardim},DimCell{3}) 174 CellInfo{icell}.Nb Site_tps= ivar_remain(ivardim);175 check_cell(ivar_remain(ivardim))=1;% nbre of sites for each tps subdomain175 CellInfo{icell}.NbCentres_tps= ivar_remain(ivardim);% nbre of sites for each tps subdomain 176 check_cell(ivar_remain(ivardim))=1;% mark the variable as selected 176 177 elseif strcmp(VarDimName{ivardim}{1},DimCell{2}) && strcmp(VarDimName{ivardim}{3},DimCell{3}) 177 CellInfo{icell}.SubRange_tps=ivar_remain(ivardim); 178 check_cell(ivar_remain(ivardim))=1;% subrange definiton for tps179 elseif strcmp(VarDimName{ivardim}{1},DimCell{1}) && strcmp(VarDimName{ivardim}{2},DimCell{3}) 180 check_cell(ivar_remain(ivardim))=1;% variable178 CellInfo{icell}.SubRange_tps=ivar_remain(ivardim);% subrange definiton for tps 179 check_cell(ivar_remain(ivardim))=1;% mark the variable as selected 180 elseif strcmp(VarDimName{ivardim}{1},DimCell{1}) && strcmp(VarDimName{ivardim}{2},DimCell{3})% variable 181 check_cell(ivar_remain(ivardim))=1;% mark the variable as selected 181 182 end 182 183 end … … 222 223 end 223 224 end 224 ListCoordIndex=ListCoordIndex(check_ coord_select);% list of coordinate variable indices225 ListCoordIndex=ListCoordIndex(check_keep);% list of coordinate variable indices 225 226 ListCoordName=ListCoordName(check_keep);% list of coordinate variable names 226 227 ListDimName=ListDimName(check_keep);% list of coordinate dimension names … … 315 316 CellInfo{icell}.(['VarIndex_' Role{ivar}])= ivar; 316 317 end 317 if ~isempty( FieldRequest{ivar})318 CellInfo{icell}. FieldRequest=FieldRequest{ivar};318 if ~isempty(ProjModeRequest{ivar}) 319 CellInfo{icell}.ProjModeRequest=ProjModeRequest{ivar}; 319 320 end 320 321 if ~isempty(FieldName{ivar}) -
trunk/src/get_field.m
r538 r581 1 %'get_field': display variables and attributes from a Netcdf file, and RUNselected fields1 %'get_field': display variables and attributes from a Netcdf file, and OK selected fields 2 2 %------------------------------------------------------------------------ 3 3 %function varargout = get_field(varargin) … … 22 22 function varargout = get_field(varargin) 23 23 24 % Last Modified by GUIDE v2.5 26-Jul-2012 09:11:2324 % Last Modified by GUIDE v2.5 10-Mar-2013 21:19:52 25 25 26 26 % Begin initialization code - DO NOT EDIT 27 gui_Singleton = 0;27 gui_Singleton = 1; 28 28 gui_State = struct('gui_Name', mfilename, ... 29 29 'gui_Singleton', gui_Singleton, ... … … 45 45 %------------------------------------------------------------------------ 46 46 % --- Executes just before get_field is made visible. 47 function get_field_OpeningFcn(hObject, eventdata, handles,filename, multiple)47 function get_field_OpeningFcn(hObject, eventdata, handles,filename,ParamIn) 48 48 %------------------------------------------------------------------------ 49 49 global nb_builtin % nbre of functions to include by default in the menu of functions called by RUN 50 50 51 52 53 51 %% Choose default command line output for get_field 54 handles.output = hObject;52 handles.output = 'Cancel'; 55 53 56 54 %% Update handles structure … … 58 56 set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) 59 57 60 %% prepare the list of RUN fcts and set their paths 61 % functions included by default in 'get_field.m 62 % menu_str={'PLOT';'FFT';'filter_band'}; 63 % nb_builtin=numel(menu_str); 64 % path_uvmat=fileparts(which('uvmat'));%path of the function 'uvmat' 65 % addpath(fullfile(path_uvmat,'get_field')) 66 % testexist=zeros(size(menu_str'));%default 67 % for ilist=1:length(menu_str) 68 % if exist(menu_str{ilist},'file') 69 % fct_handle{ilist,1}=str2func(menu_str{ilist}); 70 % testexist(ilist)=1; 71 % else 72 % fct_handle{ilist,1}=[]; 73 % testexist(ilist)=0; 74 % end 75 % end 76 % rmpath(fullfile(path_uvmat,'get_field')) 77 % dir_perso=prefdir; 78 79 % look for functions previously used (names and paths saved in the personal file uvmat_perso.mat): 80 % profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 81 % if exist(profil_perso,'file') 82 % h=load (profil_perso); 83 % if isfield(h,'get_field_fct') && iscell(h.get_field_fct) 84 % for ilist=1:length(h.get_field_fct) 85 % [path,file]=fileparts(h.get_field_fct{ilist}); 86 % addpath(path) 87 % if exist(file,'file') 88 % h_func=str2func(file); 89 % testexist=[testexist 1]; 90 % else 91 % h_func=[]; 92 % testexist=[testexist 0]; 93 % end 94 % fct_handle=[fct_handle; {h_func}]; %concatene the list of paths 95 % rmpath(path) 96 % menu_str=[menu_str; {file}]; 97 % end 98 % end 99 % end 100 101 % menu_str=menu_str(testexist==1);%=menu_str(testexist~=0) 102 % fct_handle=fct_handle(testexist==1); 103 % menu_str=[menu_str;{'more...'}]; 104 % set(handles.ACTION,'String',menu_str) 105 % set(handles.ACTION,'UserData',fct_handle)% store the list of path in UserData of ACTION 106 % set(handles.path_action,'String',fullfile(path_uvmat,'get_field')) 107 % set(handles.ACTION,'Value',1)% PLOT option selected 108 109 %% settings for 'slave' mode, called by uvamt, or 'master' mode 58 %% settings for 'slave' mode, called by uvmat, or 'master' mode 110 59 if exist('filename','var') && ischar(filename) %transfer input file name in slave mode 111 60 set(handles.inputfile,'String',filename)% prefill the input file name 112 Field=nc2struct(filename,[]);% reads the field structure, without variables61 Field=nc2struct(filename,[]);% reads the field structure, without the variables 113 62 if isfield(Field,'Txt') 114 msgbox_uvmat('ERROR', Field.Txt)63 msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt]) 115 64 else 116 65 set(handles.get_field,'UserData',Field); 117 Field_input(handles,Field); 66 if ~exist('ParamIn','var') 67 ParamIn=[]; 68 end 69 Field_input(handles,Field,ParamIn); 118 70 end 119 71 else %master mode … … 121 73 end 122 74 123 %% load the list of previously browsed files for the upper bar menu Open124 % dir_perso=prefdir;125 % profil_perso=fullfile(dir_perso,'uvmat_perso.mat');%126 % if exist(profil_perso,'file')127 % h=load (profil_perso);128 % if isfield(h,'MenuFile_1')129 % set(handles.MenuFile_1,'Label',h.MenuFile_1);130 % end131 % if isfield(h,'MenuFile_1')132 % set(handles.MenuFile_2,'Label',h.MenuFile_2);133 % end134 % if isfield(h,'MenuFile_1')135 % set(handles.MenuFile_3,'Label',h.MenuFile_3);136 % end137 % if isfield(h,'MenuFile_1')138 % set(handles.MenuFile_4,'Label',h.MenuFile_4);139 % end140 % if isfield(h,'MenuFile_1')141 % set(handles.MenuFile_5,'Label',h.MenuFile_5);142 % end143 % end144 145 75 %% put the GUI on the lower right of the sceen 76 set(hObject,'Unit','pixel') 146 77 pos_view_field=get(hObject,'Position'); 147 78 ScreenSize=get(0,'ScreenSize'); … … 150 81 set(hObject,'Position',pos_view_field) 151 82 152 %% remove already opened get_field GUI with name get_field 153 if ~(exist('multiple','var') && isequal(multiple,1)) %set single occurrence 154 hget_field=findobj(allchild(0),'Name','get_field'); %hget_field(1)= new GUI 155 if length(hget_field)>1 156 delete(hget_field(2)) 157 end 158 else 159 set(hObject,'name','get_field_1') 160 end 161 83 % if ~(exist('multiple','var') && isequal(multiple,1)) %set single occurrence 84 % hget_field=findobj(allchild(0),'Name','get_field'); %hget_field(1)= new GUI 85 % if length(hget_field)>1 86 % delete(hget_field(2)) 87 % end 88 % else 89 % set(hObject,'name','get_field_1') 90 % end 91 set(handles.get_field,'WindowStyle','modal')% Make the GUI modal 92 drawnow 93 uiwait(handles.get_field); 162 94 163 95 %------------------------------------------------------------------------ … … 166 98 %------------------------------------------------------------------------ 167 99 varargout{1} = handles.output; 100 delete(handles.get_field) 168 101 169 102 %------------------------------------------------------------------------ … … 186 119 %------------------------------------------------------------------------ 187 120 % --- update the display when a new field is introduced. 188 function Field_input(handles,Field )121 function Field_input(handles,Field,ParamInput) 189 122 %------------------------------------------------------------------------ 190 123 if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName) … … 203 136 set(handles.variables,'String',[{'*'} Txt]) 204 137 variables_Callback(handles.variables,[], handles) 138 139 if exist('ParamInput','var') 140 fill_GUI(ParamInput,handles); 141 return 142 else 205 143 set(handles.abscissa,'String',[{''} Txt ]) 206 144 set(handles.ordinate,'String',Txt) … … 209 147 set(handles.vector_z,'String',[{''} Txt ]) 210 148 set(handles.vec_color,'String',[{''} Txt ]) 211 set(handles.coord_x_scalar,'String',[{''} Txt ])212 set(handles.coord_y_scalar,'String',[{''} Txt ])213 set(handles.coord_x_vectors,'String',[{''} Txt ])214 set(handles.coord_y_vectors,'String',[{''} Txt ])215 set(handles.coord_z_scalar,'String',[{''} Txt ])216 set(handles.coord_z_vectors,'String',[{''} Txt ])149 % set(handles.XVarName,'String',[{''} Txt ]) 150 % set(handles.ZVarName,'String',[{''} Txt ]) 151 % set(handles.coord_x_vectors,'String',[{''} Txt ]) 152 % set(handles.coord_y_vectors,'String',[{''} Txt ]) 153 % set(handles.YVarName,'String',[{''} Txt ]) 154 % set(handles.TimeVarName,'String',[{''} Txt ]) 217 155 set(handles.scalar,'Value',1) 218 156 219 157 set(handles.scalar,'String', Txt ) 220 158 [CellInfo,NbDim,errormsg]=find_field_cells(Field); 221 % [CellVarIndex,NbDim,CoordType,VarRole,errormsg]=find_field_cells(Field);222 159 if ~isempty(errormsg) 223 160 msgbox_uvmat('ERROR',['get_field / Field_input / find_field_cells: ' errormsg]) 224 161 return 225 162 end 226 % for icell=1:numel(CellInfo)227 % NbDim(icell)=max(NbDim(icell),numel(CellInfo{icell}.VarIndex));228 % end229 163 [maxdim,imax]=max(NbDim); 230 164 165 %% set time mode 166 if maxdim>=4 167 set(handles.SwitchVarIndexTime,'Value',4) 168 else 169 time_index=[]; 170 if isfield(Field,'ListGlobalAttribute') 171 time_index=find(~cellfun('isempty',regexp(Field.ListGlobalAttribute,'Time')));% index of the attributes containing the string 'Time' 172 end 173 if isempty(time_index) 174 set(handles.SwitchVarIndexTime,'Value',1) 175 else 176 set(handles.SwitchVarIndexTime,'Value',2) 177 end 178 end 179 SwitchVarIndexTime_Callback([],[], handles) 180 231 181 if maxdim>=3 232 182 set(handles.vector_z,'Visible','on') 233 183 set(handles.vector_z,'String',[{''} Txt ]) 234 set(handles.coord_z_vectors,'Visible','on') 235 set(handles.coord_z_vectors,'String',[{''} Txt ]) 236 set(handles.coord_z_scalar,'Visible','on') 237 set(handles.coord_z_scalar,'String',[{''} Txt ]) 184 set(handles.ZVarName,'Visible','on') 185 set(handles.SwitchVarIndexZ,'Visible','on') 186 set(handles.Z_title,'Visible','on') 187 % set(handles.TimeVarName,'Visible','on') 188 % set(handles.TimeVarName,'String',[{''} Txt ]) 189 % set(handles.YVarName,'Visible','on') 190 % set(handles.YVarName,'String',[{''} Txt ]) 238 191 else 239 192 set(handles.vector_z,'Visible','off') 240 set(handles.coord_z_vectors,'Visible','off') 241 set(handles.coord_z_scalar,'Visible','off') 193 set(handles.ZVarName,'Visible','off') 194 set(handles.SwitchVarIndexZ,'Visible','off') 195 set(handles.Z_title,'Visible','off') 242 196 end 243 197 if maxdim>=2 … … 248 202 set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1)) 249 203 set(handles.vector_y,'Value',CellInfo{imax}.VarIndex_vector_y(1)) 250 if strcmp(CellInfo{imax}.CoordType,'scattered')251 set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end))252 set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1))253 elseif strcmp(CellInfo{imax}.CoordType,'grid')254 set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end)+1)255 set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1)+1)256 end204 % if strcmp(CellInfo{imax}.CoordType,'scattered') 205 % set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end)) 206 % set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1)) 207 % elseif strcmp(CellInfo{imax}.CoordType,'grid') 208 % set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end)+1) 209 % set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1)+1) 210 % end 257 211 else 258 212 set(handles.CheckScalar,'Value',1) 259 213 set(handles.CheckVector,'Value',0) 260 if isfield(CellInfo{imax},'VarIndex_scalar') 261 set(handles.scalar,'Value',CellInfo{imax}.VarIndex_scalar(1)) 262 set(handles.coord_x_scalar,'Value',CellInfo{imax}.CoordIndex(end)+1) 263 set(handles.coord_y_scalar,'Value',CellInfo{imax}.CoordIndex(end-1)+1) 264 if numel(CellInfo{imax}.CoordIndex)==3 265 set(handles.coord_z_scalar,'Value',CellInfo{imax}.CoordIndex(1)+1) 266 end 267 end 268 end 269 CheckPlot1D_Callback(handles.CheckPlot1D, [], handles) 270 CheckScalar_Callback(handles.CheckScalar, [], handles) 271 CheckVector_Callback(handles.CheckVector, [], handles) 272 end 214 % if isfield(CellInfo{imax},'VarIndex_scalar') 215 % set(handles.scalar,'Value',CellInfo{imax}.VarIndex_scalar(1)) 216 % set(handles.XVarName,'Value',CellInfo{imax}.CoordIndex(end)+1) 217 % set(handles.ZVarName,'Value',CellInfo{imax}.CoordIndex(end-1)+1) 218 % if numel(CellInfo{imax}.CoordIndex)==3 219 % set(handles.YVarName,'Value',CellInfo{imax}.CoordIndex(1)+1) 220 % end 221 % end 222 end 223 else 224 set(handles.CheckPlot1D,'Value',1) 225 set(handles.CheckScalar,'Value',0) 226 set(handles.CheckVector,'Value',0) 227 end 228 end 229 CheckPlot1D_Callback(handles.CheckPlot1D, [], handles) 230 CheckScalar_Callback(handles.CheckScalar, [], handles) 231 CheckVector_Callback(handles.CheckVector, [], handles) 273 232 274 233 %------------------------------------------------------------------------ … … 324 283 % set(handles.variables,'Value',xindex+1)%outline in the list of variables 325 284 % variables_Callback(hObject, eventdata, handles) %display properties of the TimeVariable (dim, attributes) 326 % if ~test_2D & ~test_scalar% look for possible varaibles to RUNin ordinate285 % if ~test_2D & ~test_scalar% look for possible varaibles to OK in ordinate 327 286 % index=Field.VarDimIndex{xindex};%dimension indices of the TimeVariable selected for abscissa 328 287 % VarIndex=[]; … … 330 289 % index_i=Field.VarDimIndex{ilist}; 331 290 % if ~isempty(index_i) 332 % if isequal(index_i(1),index(1))%if the first dimension of the TimeVariable coincide with the selected one, RUNis possible291 % if isequal(index_i(1),index(1))%if the first dimension of the TimeVariable coincide with the selected one, OK is possible 333 292 % VarIndex=[VarIndex ilist]; 334 293 % end … … 378 337 379 338 string_coord=[{''};string(test_coord==1)]; 380 val=get(handles. coord_x_scalar,'Value');339 val=get(handles.XVarName,'Value'); 381 340 if val>numel(string_coord) 382 set(handles. coord_x_scalar,'Value',1)383 end 384 set(handles. coord_x_scalar,'String',string_coord);385 val=get(handles. coord_y_scalar,'Value');341 set(handles.XVarName,'Value',1) 342 end 343 set(handles.XVarName,'String',string_coord); 344 val=get(handles.ZVarName,'Value'); 386 345 if val>numel(string_coord) 387 set(handles. coord_y_scalar,'Value',1)388 end 389 set(handles. coord_y_scalar,'String',string_coord);390 val=get(handles. coord_y_scalar,'Value');346 set(handles.ZVarName,'Value',1) 347 end 348 set(handles.ZVarName,'String',string_coord); 349 val=get(handles.ZVarName,'Value'); 391 350 if val>numel(string_coord) 392 set(handles. coord_y_scalar,'Value',1)393 end 394 set(handles. coord_z_scalar,'String',string_coord);395 396 397 %------------------------------------------------------------------------ 398 % --- Executes on selection change in coord_x_scalar.399 function coord_x_scalar_Callback(hObject, eventdata, handles)400 %------------------------------------------------------------------------ 401 index=get(handles. coord_x_scalar,'Value');402 string=get(handles. coord_x_scalar,'String');351 set(handles.ZVarName,'Value',1) 352 end 353 set(handles.YVarName,'String',string_coord); 354 355 356 %------------------------------------------------------------------------ 357 % --- Executes on selection change in XVarName. 358 function XVarName_Callback(hObject, eventdata, handles) 359 %------------------------------------------------------------------------ 360 index=get(handles.XVarName,'Value'); 361 string=get(handles.XVarName,'String'); 403 362 VarName=string{index}; 404 363 update_field(hObject, eventdata, handles,VarName) 405 364 406 365 %------------------------------------------------------------------------ 407 % --- Executes on selection change in coord_y_scalar.408 function coord_y_scalar_Callback(hObject, eventdata, handles)409 %------------------------------------------------------------------------ 410 index=get(handles. coord_y_scalar,'Value');411 string=get(handles. coord_y_scalar,'String');366 % --- Executes on selection change in ZVarName. 367 function ZVarName_Callback(hObject, eventdata, handles) 368 %------------------------------------------------------------------------ 369 index=get(handles.ZVarName,'Value'); 370 string=get(handles.ZVarName,'String'); 412 371 VarName=string{index}; 413 372 update_field(hObject, eventdata, handles,VarName) 414 373 415 374 %------------------------------------------------------------------------ 416 % --- Executes on selection change in coord_z_scalar.417 function coord_z_scalar_Callback(hObject, eventdata, handles)418 %------------------------------------------------------------------------ 419 index=get(handles. coord_z_scalar,'Value');420 string=get(handles. coord_z_scalar,'String');375 % --- Executes on selection change in YVarName. 376 function YVarName_Callback(hObject, eventdata, handles) 377 %------------------------------------------------------------------------ 378 index=get(handles.YVarName,'Value'); 379 string=get(handles.YVarName,'String'); 421 380 VarName=string{index}; 422 381 update_field(hObject, eventdata, handles,VarName) … … 480 439 end 481 440 set(handles.coord_y_vectors,'String',string_coord); 482 val=get(handles. coord_z_vectors,'Value');441 val=get(handles.TimeVarName,'Value'); 483 442 if val>numel(string_coord) 484 set(handles. coord_z_vectors,'Value',1)485 end 486 set(handles. coord_z_vectors,'String',string_coord);443 set(handles.TimeVarName,'Value',1) 444 end 445 set(handles.TimeVarName,'String',string_coord); 487 446 488 447 update_field(hObject, eventdata, handles,VarName) … … 525 484 526 485 %------------------------------------------------------------------------ 527 % --- Executes on selection change in coord_z_scalar.528 function coord_z_vectors_Callback(hObject, eventdata, handles)529 %------------------------------------------------------------------------ 530 index=get(handles. coord_z_vectors,'Value');531 string=get(handles. coord_z_vectors,'String');486 % --- Executes on selection change in YVarName. 487 function TimeVarName_Callback(hObject, eventdata, handles) 488 %------------------------------------------------------------------------ 489 index=get(handles.TimeVarName,'Value'); 490 string=get(handles.TimeVarName,'String'); 532 491 VarName=string{index}; 533 492 update_field(hObject, eventdata, handles,VarName) … … 689 648 VarIndex.y=name2index(list_var,Field.ListVarName); 690 649 if isequal(VarIndex.A,VarIndex.y) 691 set(handles. coord_y_scalar,'Value',1)650 set(handles.ZVarName,'Value',1) 692 651 elseif isequal(VarIndex.u,VarIndex.y)||isequal(VarIndex.v,VarIndex.y)||isequal(VarIndex.w,VarIndex.y) 693 652 set(handles.coord_y_vectors,'Value',1)%ordinate cannot be the same as scalar or vector components … … 811 770 812 771 %--------------------------------------------------------- 813 % --- Executes on button press in RUN.814 815 function RUN_Callback(hObject, eventdata, handles)772 % --- Executes on button press in OK. 773 774 function OK_Callback(hObject, eventdata, handles) 816 775 %--------------------------------------------------------- 776 777 handles.output=read_GUI(handles.get_field); 778 guidata(hObject, handles);% Update handles structure 779 uiresume(handles.get_field); 780 drawnow 781 return 782 783 %%%% SKIPPED %%%% 817 784 hfield=[]; 818 785 huvmat=findobj(allchild(0),'tag','uvmat'); … … 911 878 if strcmp(list_fig{val},'uvmat') 912 879 set(handles.inputfile,'Enable','off')% desactivate the input file edit box 913 set(handles. RUN,'Visible','off')% RUN button not visible (passive mode, get_field used to define the field for uvamt)880 set(handles.OK,'Visible','off')% RUN button not visible (passive mode, get_field used to define the field for uvamt) 914 881 set(handles.MenuOpen,'Visible','off') 915 882 set(handles.MenuExport,'Visible','off') … … 933 900 % %------------------------------------------------ 934 901 % % --- Executes on button press in Plot_histo. 935 % % RUNglobal histograms902 % %OK global histograms 936 903 % %------------------------------------------------- 937 904 % function RUN_histo_Callback(hObject, eventdata, handles) 938 % % hObject handle to RUN(see GCBO)905 % % hObject handle to OK (see GCBO) 939 906 % % eventdata reserved - to be defined in a future version of MATLAB 940 907 % % handles structure with handles and user data (see GUIDATA) … … 1672 1639 set(handles.TimeIndexValue,'Visible','off') 1673 1640 end 1674 1675 %------------------------------------------------------------------------ 1676 % --- Executes on selection change in TimeDimensionMenu. 1677 function TimeDimensionMenu_Callback(hObject, eventdata, handles) 1678 %------------------------------------------------------------------------ 1679 index=get(handles.TimeDimensionMenu,'Value'); 1680 DimList=get(handles.TimeDimensionMenu,'String'); 1681 DimName=DimList{index}; 1682 Field=get(handles.get_field,'UserData'); 1683 DimIndex=find(strcmp(DimName,Field.ListDimName),1); 1684 ref_index=round(Field.DimValue(DimIndex)/2); 1685 set(handles.TimeIndexValue,'String',num2str(ref_index)) 1686 scalar_Callback(hObject, eventdata, handles) 1687 vector_x_Callback(hObject, eventdata, handles)% update menus of coordinates (remove time) 1688 % look for a corresponding time variable and value 1689 time_test=zeros(size(Field.VarDimName)); 1690 for ilist=1:numel(Field.VarDimName) 1691 if isequal(Field.VarDimName{ilist},{DimName}) 1692 time_test(ilist)=1; 1693 end 1694 end 1695 ListVariable=Field.ListVarName(time_test==1); 1696 set(handles.TimeVariableMenu,'Value',1) 1697 if isempty(ListVariable) 1698 set(handles.TimeVariableMenu,'String',{''}) 1699 set(handles.TimeVarValue,'String','') 1700 else 1701 set(handles.TimeVariableMenu,'String',ListVariable) 1702 TimeVarName=ListVariable{1}; 1703 VarIndex=find(strcmp(TimeVarName,Field.ListVarName),1);%index in the list of variables 1704 inputfile=get(handles.inputfile,'String');% read the input file 1705 SubField=nc2struct(inputfile,{TimeVarName}); 1706 eval(['TimeValue=SubField.' TimeVarName '(ref_index);']) 1707 set(handles.TimeVarValue,'Visible','on') 1708 set(handles.TimeVariableMenu,'Visible','on') 1709 set(handles.TimeVarValue,'String',num2str(TimeValue)) 1710 end 1711 1712 1641 % 1642 % %------------------------------------------------------------------------ 1643 % % --- Executes on selection change in TimeDimensionMenu. 1644 % function TimeDimensionMenu_Callback(hObject, eventdata, handles) 1645 % %------------------------------------------------------------------------ 1646 % index=get(handles.TimeDimensionMenu,'Value'); 1647 % DimList=get(handles.TimeDimensionMenu,'String'); 1648 % DimName=DimList{index}; 1649 % Field=get(handles.get_field,'UserData'); 1650 % DimIndex=find(strcmp(DimName,Field.ListDimName),1); 1651 % ref_index=round(Field.DimValue(DimIndex)/2); 1652 % set(handles.TimeIndexValue,'String',num2str(ref_index)) 1653 % scalar_Callback(hObject, eventdata, handles) 1654 % vector_x_Callback(hObject, eventdata, handles)% update menus of coordinates (remove time) 1655 % % look for a corresponding time variable and value 1656 % time_test=zeros(size(Field.VarDimName)); 1657 % for ilist=1:numel(Field.VarDimName) 1658 % if isequal(Field.VarDimName{ilist},{DimName}) 1659 % time_test(ilist)=1; 1660 % end 1661 % end 1662 % ListVariable=Field.ListVarName(time_test==1); 1663 % set(handles.TimeVariableMenu,'Value',1) 1664 % if isempty(ListVariable) 1665 % set(handles.TimeVariableMenu,'String',{''}) 1666 % set(handles.TimeVarValue,'String','') 1667 % else 1668 % set(handles.TimeVariableMenu,'String',ListVariable) 1669 % TimeVarName=ListVariable{1}; 1670 % VarIndex=find(strcmp(TimeVarName,Field.ListVarName),1);%index in the list of variables 1671 % inputfile=get(handles.inputfile,'String');% read the input file 1672 % SubField=nc2struct(inputfile,{TimeVarName}); 1673 % eval(['TimeValue=SubField.' TimeVarName '(ref_index);']) 1674 % set(handles.TimeVarValue,'Visible','on') 1675 % set(handles.TimeVariableMenu,'Visible','on') 1676 % set(handles.TimeVarValue,'String',num2str(TimeValue)) 1677 % end 1678 % 1679 % 1680 % % % ----------------------------------------------------------------------- 1681 % % % --- Executes on button press in TimeVariable. 1682 % % function TimeVariable_Callback(hObject, eventdata, handles) 1683 % % % ----------------------------------------------------------------------- 1684 % % val=get(handles.TimeVariable,'Value'); 1685 % % if val 1686 % % Field=get(handles.get_field,'UserData'); 1687 % % time_test=zeros(size(Field.VarDimName)); 1688 % % for ilist=1:numel(Field.VarDimName) 1689 % % if isequal(numel(Field.VarDimName{ilist}),1)%select variables with a single dimension 1690 % % time_test(ilist)=1; 1691 % % end 1692 % % end 1693 % % ind_test=find(time_test); 1694 % % if isempty(time_test) 1695 % % set(handles.TimeVariable,'Value',0) 1696 % % set(handles.TimeVariableMenu,'Visible','off') 1697 % % set(handles.TimeVarValue,'Visible','off') 1698 % % else 1699 % % set(handles.TimeVariableMenu,'Visible','on') 1700 % % set(handles.TimeVarValue,'Visible','on') 1701 % % if get(handles.TimeVariableMenu,'Value')>numel(ind_test) 1702 % % set(handles.TimeVariableMenu,'Value',1) 1703 % % end 1704 % % set(handles.TimeVariableMenu,'String',Field.ListVarName(ind_test)) 1705 % % TimeVariableMenu_Callback(hObject, eventdata, handles) 1706 % % set(handles.TimeDimension,'Value',0) %deseselect alternative option sfor time 1707 % % set(handles.TimeAttribute,'Value',0) 1708 % % TimeAttribute_Callback(hObject, eventdata, handles) 1709 % % end 1710 % % else 1711 % % set(handles.TimeVariableMenu,'Visible','off') 1712 % % set(handles.TimeVarValue,'Visible','off') 1713 % % end 1714 % 1713 1715 % % ----------------------------------------------------------------------- 1714 % % --- Executes on button press in TimeVariable.1715 % function TimeVariable _Callback(hObject, eventdata, handles)1716 % % --- Executes on selection change in TimeVariableMenu. 1717 % function TimeVariableMenu_Callback(hObject, eventdata, handles) 1716 1718 % % ----------------------------------------------------------------------- 1717 % val=get(handles.TimeVariable,'Value'); 1718 % if val 1719 % Field=get(handles.get_field,'UserData'); 1720 % time_test=zeros(size(Field.VarDimName)); 1721 % for ilist=1:numel(Field.VarDimName) 1722 % if isequal(numel(Field.VarDimName{ilist}),1)%select variables with a single dimension 1723 % time_test(ilist)=1; 1724 % end 1725 % end 1726 % ind_test=find(time_test); 1727 % if isempty(time_test) 1728 % set(handles.TimeVariable,'Value',0) 1729 % set(handles.TimeVariableMenu,'Visible','off') 1730 % set(handles.TimeVarValue,'Visible','off') 1731 % else 1732 % set(handles.TimeVariableMenu,'Visible','on') 1733 % set(handles.TimeVarValue,'Visible','on') 1734 % if get(handles.TimeVariableMenu,'Value')>numel(ind_test) 1735 % set(handles.TimeVariableMenu,'Value',1) 1736 % end 1737 % set(handles.TimeVariableMenu,'String',Field.ListVarName(ind_test)) 1738 % TimeVariableMenu_Callback(hObject, eventdata, handles) 1739 % set(handles.TimeDimension,'Value',0) %deseselect alternative option sfor time 1740 % set(handles.TimeAttribute,'Value',0) 1741 % TimeAttribute_Callback(hObject, eventdata, handles) 1742 % end 1743 % else 1744 % set(handles.TimeVariableMenu,'Visible','off') 1745 % set(handles.TimeVarValue,'Visible','off') 1719 % ListVar=get(handles.TimeVariableMenu,'String'); 1720 % index=get(handles.TimeVariableMenu,'Value'); 1721 % TimeVariable=ListVar{index};% name of the selected variable 1722 % if isempty(TimeVariable)% case of blank selection 1723 % return 1746 1724 % end 1747 1748 % ----------------------------------------------------------------------- 1749 % --- Executes on selection change in TimeVariableMenu. 1750 function TimeVariableMenu_Callback(hObject, eventdata, handles) 1751 % ----------------------------------------------------------------------- 1752 ListVar=get(handles.TimeVariableMenu,'String'); 1753 index=get(handles.TimeVariableMenu,'Value'); 1754 TimeVariable=ListVar{index};% name of the selected variable 1755 if isempty(TimeVariable)% case of blank selection 1756 return 1757 end 1758 Field=get(handles.get_field,'UserData'); %index of 1759 VarIndex=find(strcmp(TimeVariable,Field.ListVarName),1);%index in the list of variables 1760 DimName=Field.VarDimName{VarIndex}; % dimension corresponding to the variable 1761 set(handles.TimeDimensionMenu,'Value',1) 1762 set(handles.TimeDimensionMenu,'String',DimName) 1763 inputfile=get(handles.inputfile,'String');% read the input file 1764 SubField=nc2struct(inputfile,{TimeVariable}); 1765 eval(['TimeDimension=numel(SubField.' TimeVariable ');']) 1766 ref_index=round(TimeDimension/2); 1767 eval(['TimeValue=SubField.' TimeVariable '(ref_index);']) 1768 set(handles.TimeIndexValue,'String',num2str(ref_index)) 1769 set(handles.TimeVarValue,'String',num2str(TimeValue)) 1770 1771 1772 function TimeValue_Callback(hObject, eventdata, handles) 1773 %TO suppress 1774 1775 % ----------------------------------------------------------------------- 1776 function TimeIndexValue_Callback(hObject, eventdata, handles) 1777 % ----------------------------------------------------------------------- 1778 TimeIndex=str2double(get(handles.TimeIndexValue,'String')); 1779 TimeVarName=Field.ListVarName{time_index}; 1780 set(handles.TimeVariable,'Value',1) 1781 set(handles.TimeName,'String',TimeVarName) 1782 fileinput=get(handles.inputfile,'String'); 1783 SubField=nc2struct(fileinput,{TimeVarName}); 1784 eval(['TimeValue=SubField.' TimeVarName '(ref_index);']); 1785 set(handles.TimeValue,'Visible','on') 1786 set(handles.TimeValue,'String',num2str(TimeValue)) 1787 1788 % ----------------------------------------------------------------------- 1789 function SelectFigure_Callback(hObject, eventdata, handles) 1790 % ----------------------------------------------------------------------- 1791 val=get(handles.SelectFigure,'Value'); 1792 if val 1793 set(handles.list_fig,'Visible','on') 1794 %% look at the existing figures in the work space 1795 browse_fig(handles.list_fig) 1796 else 1797 set(handles.list_fig,'Visible','off') 1798 end 1799 1800 1801 function TimeVarValue_Callback(hObject, eventdata, handles) 1802 1725 % Field=get(handles.get_field,'UserData'); %index of 1726 % VarIndex=find(strcmp(TimeVariable,Field.ListVarName),1);%index in the list of variables 1727 % DimName=Field.VarDimName{VarIndex}; % dimension corresponding to the variable 1728 % set(handles.TimeDimensionMenu,'Value',1) 1729 % set(handles.TimeDimensionMenu,'String',DimName) 1730 % inputfile=get(handles.inputfile,'String');% read the input file 1731 % SubField=nc2struct(inputfile,{TimeVariable}); 1732 % eval(['TimeDimension=numel(SubField.' TimeVariable ');']) 1733 % ref_index=round(TimeDimension/2); 1734 % eval(['TimeValue=SubField.' TimeVariable '(ref_index);']) 1735 % set(handles.TimeIndexValue,'String',num2str(ref_index)) 1736 % set(handles.TimeVarValue,'String',num2str(TimeValue)) 1803 1737 1804 1738 1805 1739 % --- Executes on button press in check_rgb. 1806 1740 function check_rgb_Callback(hObject, eventdata, handles) 1741 1742 1743 % --- Executes when user attempts to close get_field. 1744 function get_field_CloseRequestFcn(hObject, eventdata, handles) 1745 if isequal(get(handles.get_field, 'waitstatus'), 'waiting') 1746 % The GUI is still in UIWAIT, us UIRESUME 1747 uiresume(handles.get_field); 1748 else 1749 % The GUI is no longer waiting, just close it 1750 delete(handles.get_field); 1751 end 1752 1753 1754 1755 1756 1757 % --- Executes on selection change in listbox30. 1758 function listbox30_Callback(hObject, eventdata, handles) 1759 % hObject handle to listbox30 (see GCBO) 1760 % eventdata reserved - to be defined in a future version of MATLAB 1761 % handles structure with handles and user data (see GUIDATA) 1762 1763 % Hints: contents = cellstr(get(hObject,'String')) returns listbox30 contents as cell array 1764 % contents{get(hObject,'Value')} returns selected item from listbox30 1765 1766 1767 % --- Executes on selection change in SwitchVarIndexX. 1768 function SwitchVarIndexX_Callback(hObject, eventdata, handles) 1769 % hObject handle to SwitchVarIndexX (see GCBO) 1770 % eventdata reserved - to be defined in a future version of MATLAB 1771 % handles structure with handles and user data (see GUIDATA) 1772 1773 % Hints: contents = cellstr(get(hObject,'String')) returns SwitchVarIndexX contents as cell array 1774 % contents{get(hObject,'Value')} returns selected item from SwitchVarIndexX 1775 1776 1777 % --- Executes on selection change in SwitchVarIndexTime. 1778 function SwitchVarIndexTime_Callback(hObject, eventdata, handles) 1779 menu=get(handles.SwitchVarIndexTime,'String'); 1780 option=menu{get(handles.SwitchVarIndexTime,'Value')}; 1781 switch option 1782 case 'file index' 1783 set(handles.TimeVarName, 'Visible','off') 1784 case 'attribute' 1785 set(handles.TimeVarName, 'Visible','on') 1786 time_index=[]; 1787 ListAttributes=get(handles.attributes,'String'); 1788 if ~isempty(ListAttributes) 1789 time_index=find(~cellfun('isempty',regexp(ListAttributes,'Time')));% index of the attributes containing the string 'Time' 1790 end 1791 if ~isempty(time_index) 1792 set(handles.TimeVarName,'Value',time_index(1)) 1793 else 1794 set(handles.TimeVarName,'Value',1) 1795 end 1796 set(handles.TimeVarName, 'String',ListAttributes) 1797 case 'variable' 1798 ListDim=get(handles.dimensions,'String'); 1799 Field=get(handles.get_field,'UserData'); 1800 for idim=1:numel(ListDim) 1801 var_count=[]; 1802 for ilist=1:numel(Field.VarDimName) 1803 DimName=Field.VarDimName{ilist}; 1804 if strcmp(DimName,ListDim{idim})||strcmp(DimName,{ListDim{idim}}) %if the variable has a single dim ( 1D array) 1805 var_count=[var_count ilist]; 1806 end 1807 end 1808 if numel(var_count)==1 1809 TimeVarName=[TimeVarName;Field.ListVarName{var_count}]; 1810 end 1811 end 1812 set(handles.TimeVarName, 'Visible','on') 1813 List=get(handles.TimeVarName,'String'); 1814 option=List{get(handles.TimeVarName,'Value')}; 1815 ind=find(strcmp(option,get(handles.dimensions,'String'))); 1816 if isempty(ind) 1817 set(handles.TimeVarName, 'Value',1); 1818 else 1819 set(handles.TimeVarName, 'Value',ind); 1820 end 1821 set(handles.TimeVarName, 'String',TimeVarName) 1822 case 'dim index' 1823 set(handles.TimeVarName, 'Visible','on') 1824 List=get(handles.TimeVarName,'String'); 1825 option=List{get(handles.TimeVarName,'Value')}; 1826 ind=find(strcmp(option,get(handles.dimensions,'String'))); 1827 if isempty(ind) 1828 set(handles.TimeVarName, 'Value',1); 1829 else 1830 set(handles.TimeVarName, 'Value',ind); 1831 end 1832 set(handles.TimeVarName, 'String',get(handles.dimensions,'String')) 1833 end 1834 1835 -
trunk/src/msgbox_uvmat.m
r507 r581 7 7 %INPUT: 8 8 % title: string indicating the type of message box: 9 % title= 'INPUT_TXT','CONFIMATION' ,'ERROR', 'WARNING', 'INPUT_Y-N', default = 'INPUT_TXT' (the title is displayed in the upper bar of the fig).9 % title= 'INPUT_TXT','CONFIMATION' ,'ERROR', 'WARNING', 'INPUT_Y-N','INPUT_MENU' default = 'INPUT_TXT' (the title is displayed in the upper bar of the fig). 10 10 % if title='INPUT_TXT', input data is asked in an edit box 11 11 % if title='CONFIMATION'', 'ERROR', 'WARNING', the figure remains opened until a button 'OK' is pressed … … 37 37 % End initialization code - DO NOT EDIT 38 38 39 %------------------------------------------------------------------------ 39 40 % --- Executes just before msgbox_uvmat is made visible. 40 41 function msgbox_uvmat_OpeningFcn(hObject, eventdata, handles,title,display_str,default_answer,Position) 42 %------------------------------------------------------------------------ 41 43 % This function has no output args, see OutputFcn. 42 44 … … 89 91 testinputstring=1; 90 92 testCancel=1; %no cancel button 93 case 'INPUT_MENU' 94 testinputstring=2; 95 testCancel=1; %no cancel button 91 96 otherwise 92 97 % testinputstring=1; … … 98 103 set(handles.text1, 'String', display_str); 99 104 end 100 % if testinputstring 101 % set(handles.edit_box, 'Visible', 'on'); 102 % else 103 % set(handles.text1, 'Position', [0.15 0.3 0.85 0.7]); 104 % end 105 if testinputstring 106 % set(handles.figure1,'Position',[40,80,20*length(default_answer),50]) 105 106 if testinputstring==1 107 107 set(handles.edit_box, 'Visible', 'on'); 108 108 if ~exist('default_answer','var'); … … 111 111 set(handles.edit_box, 'String', default_answer); 112 112 if exist('Position','var') 113 if iscell(default_answer) 114 widthstring=max(max(cellfun('length',default_answer)),length(display_str)); 115 heightstring=size(default_answer,1);%nbre of expected lines 116 set(handles.edit_box,'Max',2); 117 else 118 widthstring=max(length(default_answer),length(display_str)); 119 heightstring=1; 120 end 121 widthstring=max(widthstring,length(title)+20); 122 boxsize=[10*widthstring 20*heightstring];%size of the display edit box 123 set(handles.edit_box,'Units','pixels') 124 set(handles.edit_box,'FontUnits','pixels') 125 set(handles.edit_box,'FontSize',12) 126 set(handles.edit_box,'Position',[5,34,boxsize(1),boxsize(2)]) 127 FigPos(3)=10+boxsize(1); 128 FigPos(4)=56+boxsize(2); 129 FigPos(2)=Position(2)-FigPos(4)-25; 130 set(handles.figure1,'Position',FigPos) 131 end 132 % set(handles.figure1,'Position',[40,40,20*length(default_answer),50]) 113 if iscell(default_answer) 114 widthstring=max(max(cellfun('length',default_answer)),length(display_str)); 115 heightstring=size(default_answer,1);%nbre of expected lines 116 set(handles.edit_box,'Max',2); 117 else 118 widthstring=max(length(default_answer),length(display_str)); 119 heightstring=1; 120 end 121 widthstring=max(widthstring,length(title)+20); 122 boxsize=[10*widthstring 20*heightstring];%size of the display edit box 123 set(handles.edit_box,'Units','pixels') 124 set(handles.edit_box,'FontUnits','pixels') 125 set(handles.edit_box,'FontSize',12) 126 set(handles.edit_box,'Position',[5,34,boxsize(1),boxsize(2)]) 127 FigPos(3)=10+boxsize(1); 128 FigPos(4)=56+boxsize(2); 129 FigPos(2)=Position(2)-FigPos(4)-25; 130 set(handles.figure1,'Position',FigPos) 131 end 132 elseif testinputstring==2 133 set(handles.edit_box,'style','listbox') 134 set(handles.edit_box, 'Visible', 'on'); 135 set(handles.edit_box,'String', default_answer) 133 136 else 134 137 set(handles.text1, 'Position', [0.15 0.3 0.85 0.7]); … … 189 192 uiwait(handles.figure1); 190 193 191 194 %------------------------------------------------------------------------ 192 195 % --- Outputs from this function are returned to the command line. 193 196 function varargout = msgbox_uvmat_OutputFcn(hObject, eventdata, handles) 197 %------------------------------------------------------------------------ 194 198 195 199 % Get default command line output from handles structure … … 200 204 varargout{1}='No'; 201 205 else 206 if strcmp(get(handles.edit_box,'Style'),'listbox') 207 varargout{1}=get(handles.edit_box,'Value'); 208 else 202 209 varargout{1}=get(handles.edit_box,'String'); 203 if isempty(varargout{1}) || isequal(varargout{1},'') 210 end 211 if isempty(varargout{1}) 204 212 varargout{1}='Yes'; 205 213 end … … 208 216 end 209 217 delete(handles.figure1); 210 218 219 %------------------------------------------------------------------------ 211 220 % --- Executes on button press in OK. 212 221 function OK_Callback(hObject, eventdata, handles) 222 %------------------------------------------------------------------------ 213 223 handles.output = get(hObject,'String'); 214 224 guidata(hObject, handles);% Update handles structure 215 225 uiresume(handles.figure1); 216 226 227 %------------------------------------------------------------------------ 217 228 % --- Executes on button press in No. 218 229 function No_Callback(hObject, eventdata, handles) 230 %------------------------------------------------------------------------ 219 231 handles.output='No'; 220 232 guidata(hObject, handles); 221 233 uiresume(handles.figure1); 222 234 235 %------------------------------------------------------------------------ 223 236 % --- Executes on button press in Cancel. 224 237 function Cancel_Callback(hObject, eventdata, handles) 238 %------------------------------------------------------------------------ 225 239 handles.output = get(hObject,'String'); 226 240 %handles.output = 'Cancel' … … 230 244 uiresume(handles.figure1); 231 245 232 246 %------------------------------------------------------------------------ 233 247 % --- Executes when user attempts to close figure1. 234 248 function figure1_CloseRequestFcn(hObject, eventdata, handles) 249 %------------------------------------------------------------------------ 235 250 if isequal(get(handles.figure1, 'waitstatus'), 'waiting') 236 251 % The GUI is still in UIWAIT, us UIRESUME … … 241 256 end 242 257 258 %------------------------------------------------------------------------ 243 259 % --- Executes on key press over figure1 with no controls selected. 244 260 function figure1_KeyPressFcn(hObject, eventdata, handles) 261 %------------------------------------------------------------------------ 245 262 % Check for "enter" or "escape" 246 263 if isequal(get(hObject,'CurrentKey'),'escape') -
trunk/src/plot_field.m
r569 r581 249 249 function errormsg=plot_text(FieldData,CellInfo,htext) 250 250 %------------------------------------------------------------------- 251 errormsg= [];251 errormsg=''; 252 252 txt_cell={}; 253 253 Data={}; … … 1045 1045 1046 1046 %decimate by a factor 2 in vector mesh(4 in nbre of vectors) 1047 check_decimate=0; 1047 1048 if isfield(PlotParam.Vectors,'CheckDecimate4') && PlotParam.Vectors.CheckDecimate4 1049 check_decimate=1; 1048 1050 diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i) 1049 1051 dy_thresh=max(abs(diffy))/2; … … 1055 1057 nb_sel=length(ind_sel); 1056 1058 ind_sel=ind_sel(1:2:nb_sel);% take half the points on a line 1059 elseif isfield(PlotParam.Vectors,'CheckDecimate16') && PlotParam.Vectors.CheckDecimate16 1060 check_decimate=1; 1061 diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i) 1062 dy_thresh=max(abs(diffy))/2; 1063 ind_jump=find(abs(diffy) > dy_thresh); %indices with diff(vec_Y)> max/2, detect change of line 1064 ind_sel=1:ind_jump(1);%select the first line 1065 for i=2:4:length(ind_jump)-1 1066 ind_sel=[ind_sel (ind_jump(i)+1:ind_jump(i+1))];% select the odd lines 1067 end 1068 nb_sel=length(ind_sel); 1069 ind_sel=ind_sel(1:4:nb_sel);% take half the points on a line 1070 end 1071 if check_decimate 1057 1072 vec_X=vec_X(ind_sel); 1058 1073 vec_Y=vec_Y(ind_sel); -
trunk/src/proj_field.m
r576 r581 142 142 return 143 143 end 144 elseif ~isequal(ObjectData.ProjMode,'interp ')144 elseif ~isequal(ObjectData.ProjMode,'interp_lin') 145 145 errormsg=(['ProjMode option ' ObjectData.ProjMode ' not available in proj_field']); 146 146 return … … 223 223 Var=FieldData.(VarName)(indsel); 224 224 ProjData.(VarName)(ipoint,1)=mean(Var); 225 if isequal(ObjectData.ProjMode,'interp ')225 if isequal(ObjectData.ProjMode,'interp_lin') 226 226 ProjData.(VarName)(ipoint,1)=griddata_uvmat(coord_x(indsel),coord_y(indsel),Var,Xpoint(1),Xpoint(2)); 227 227 end … … 524 524 theta=angle(dlinx+1i*dliny);%angle of each segment 525 525 theta(siz_line(1))=theta(siz_line(1)-1); 526 % determine a rectangles at +-width from the line (only used for the ProjMode='projection or ' filter')526 % determine a rectangles at +-width from the line (only used for the ProjMode='projection or 'interp_tps') 527 527 xsup=zeros(1,siz_line(1)); xinf=zeros(1,siz_line(1)); ysup=zeros(1,siz_line(1)); yinf=zeros(1,siz_line(1)); 528 if isequal(ProjMode,'projection') || isequal(ProjMode,' filter')528 if isequal(ProjMode,'projection') || isequal(ProjMode,'interp_tps') 529 529 xsup(1)=ObjectData.Coord(1,1)-width*sin(theta(1)); 530 530 xinf(1)=ObjectData.Coord(1,1)+width*sin(theta(1)); … … 580 580 % check needed object properties for unstructured positions (position given by the variables with role coord_x, coord_y 581 581 if strcmp(CellInfo{icell}.CoordType,'scattered') 582 if ~isequal(ProjMode,'interp ')582 if ~isequal(ProjMode,'interp_lin') 583 583 if width==0 584 584 errormsg='range of the projection object is missing'; 585 585 return 586 586 else 587 lambda=2/(width*width); %smoothing factor used for filter: weight exp(-2) at distance width from the line587 lambda=2/(width*width); %smoothing factor used for interp_tps: weight exp(-2) at distance width from the line 588 588 end 589 589 end … … 621 621 flagsel=ones(size(coord_x)); 622 622 end 623 if isequal(ProjMode,'projection') | isequal(ProjMode,'filter')623 if isequal(ProjMode,'projection') || isequal(ProjMode,'interp_tps') 624 624 flagsel=flagsel & ((coord_y -yinf(ip))*(xinf(ip+1)-xinf(ip))>(coord_x-xinf(ip))*(yinf(ip+1)-yinf(ip))) ... 625 625 & ((coord_y -ysup(ip))*(xsup(ip+1)-xsup(ip))<(coord_x-xsup(ip))*(ysup(ip+1)-ysup(ip))) ... … … 649 649 end 650 650 end 651 elseif isequal(ProjMode,'interp ') %linear interpolation:651 elseif isequal(ProjMode,'interp_lin') %linear interpolation: 652 652 npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX) 653 653 Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint); … … 659 659 end 660 660 end 661 elseif isequal(ProjMode,' filter') %filtering661 elseif isequal(ProjMode,'interp_tps') %filtering 662 662 npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX) 663 663 Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint); … … 983 983 for icell=1:numel(CellInfo)% TODO: recalculate coordinates here to get the bounds in the rotated coordinates 984 984 ProjMode{icell}=ObjectData.ProjMode; 985 if isfield(CellInfo{icell},' FieldRequest')986 switch CellInfo{icell}. FieldRequest985 if isfield(CellInfo{icell},'ProjModeRequest') 986 switch CellInfo{icell}.ProjModeRequest 987 987 case 'interp_lin' 988 ProjMode{icell}='interp ';988 ProjMode{icell}='interp_lin'; 989 989 case 'interp_tps' 990 ProjMode{icell}=' filter';991 end 992 end 993 if strcmp(ProjMode{icell},'interp ')||strcmp(ProjMode{icell},'filter')990 ProjMode{icell}='interp_tps'; 991 end 992 end 993 if strcmp(ProjMode{icell},'interp_lin')||strcmp(ProjMode{icell},'interp_tps') 994 994 check_grid=1; 995 995 end … … 1043 1043 %% case of input fields with unstructured coordinates 1044 1044 case 'scattered' 1045 if strcmp(ProjMode{icell},' filter')1046 continue %skip for filter(needs tps field cell)1045 if strcmp(ProjMode{icell},'interp_tps') 1046 continue %skip for interp_tps (needs tps field cell) 1047 1047 end 1048 1048 coord_x=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)});% initial x coordinates … … 1148 1148 end 1149 1149 end 1150 case 'interp '%interpolate data on a regular grid1150 case 'interp_lin'%interpolate data on a regular grid 1151 1151 coord_x_proj=XMin:DX:XMax; 1152 1152 coord_y_proj=YMin:DY:YMax; … … 1205 1205 end 1206 1206 1207 %% case of tps interpolation (applies only in filtermode and for spatial derivatives)1207 %% case of tps interpolation (applies only in interp_tps mode and for spatial derivatives) 1208 1208 case 'tps' 1209 if strcmp(ProjMode{icell},' filter')1209 if strcmp(ProjMode{icell},'interp_tps') 1210 1210 Coord=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex}); 1211 Nb Sites=FieldData.(FieldData.ListVarName{CellInfo{icell}.NbSite_tps});1211 NbCentres=FieldData.(FieldData.ListVarName{CellInfo{icell}.NbCentres_tps}); 1212 1212 SubRange=FieldData.(FieldData.ListVarName{CellInfo{icell}.SubRange_tps}); 1213 1213 if isfield(CellInfo{icell},'VarIndex_vector_x_tps')&&isfield(CellInfo{icell},'VarIndex_vector_y_tps') … … 1221 1221 XI=XI+ObjectData.Coord(1,1); 1222 1222 YI=YI+ObjectData.Coord(1,2); 1223 [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord,Nb Sites,SubRange,FieldVar,CellInfo{icell}.FieldName,cat(3,XI,YI));1223 [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord,NbCentres,SubRange,FieldVar,CellInfo{icell}.FieldName,cat(3,XI,YI)); 1224 1224 ListFieldProj=(fieldnames(DataOut))'; 1225 1225 VarDimName=cell(size(ListFieldProj)); … … 1461 1461 YIMA=reshape(round(YIMA),1,npX*npY); 1462 1462 flagin=XIMA>=1 & XIMA<=DimValue(2) & YIMA >=1 & YIMA<=DimValue(1);%flagin=1 inside the original image 1463 if isequal(ProjMode{icell},' filter')1464 npx_ filter=ceil(abs(DX/DAX));1465 npy_ filter=ceil(abs(DY/DAY));1466 M filter=ones(npy_filter,npx_filter)/(npx_filter*npy_filter);1467 test_ filter=1;1463 if isequal(ProjMode{icell},'interp_tps') 1464 npx_interp_tps=ceil(abs(DX/DAX)); 1465 npy_interp_tps=ceil(abs(DY/DAY)); 1466 Minterp_tps=ones(npy_interp_tps,npx_interp_tps)/(npx_interp_tps*npy_interp_tps); 1467 test_interp_tps=1; 1468 1468 else 1469 test_ filter=0;1469 test_interp_tps=0; 1470 1470 end 1471 1471 eval(['ProjData.' AYName '=[coord_y_proj(1) coord_y_proj(end)];']) %record the new (projected ) y coordinates … … 1476 1476 eval(['ProjData.' VarName '=interp2(Coord{2},Coord{1},FieldData.' VarName ',Coord_x,Coord_y'');']) %TO TEST 1477 1477 end 1478 %filter the field (image) if option 'filter' is used1479 % if test_filter1480 % Aclass=class(FieldData.A);1481 % eval(['ProjData.' VarName '=filter2(Mfilter,FieldData.' VarName ',''valid'');'])1482 % if ~isequal(Aclass,'double')1483 % eval(['ProjData.' VarName '=' Aclass '(FieldData.' VarName ');'])%revert to integer values1484 % end1485 % end1486 1478 eval(['vec_A=reshape(FieldData.' VarName ',[],nbcolor);'])%put the original image in line 1487 1479 %ind_in=find(flagin); … … 1525 1517 else 1526 1518 errormsg='projection of structured coordinates on oblique plane not yet implemented'; 1527 %TODO: use interp 31519 %TODO: use interp_lin3 1528 1520 return 1529 1521 end … … 1801 1793 end 1802 1794 end 1803 elseif isequal(ObjectData.ProjMode,'interp ')||isequal(ObjectData.ProjMode,'filter')%interpolate data on a regular grid1795 elseif isequal(ObjectData.ProjMode,'interp_lin')||isequal(ObjectData.ProjMode,'interp_tps')%interpolate data on a regular grid 1804 1796 coord_x_proj=XMin:DX:XMax; 1805 1797 coord_y_proj=YMin:DY:YMax; … … 2074 2066 YIMA=reshape(round(YIMA),1,npX*npY); 2075 2067 flagin=XIMA>=1 & XIMA<=DimValue(2) & YIMA >=1 & YIMA<=DimValue(1);%flagin=1 inside the original image 2076 if isequal(ObjectData.ProjMode,' filter')2077 npx_ filter=ceil(abs(DX/DAX));2078 npy_ filter=ceil(abs(DY/DAY));2079 M filter=ones(npy_filter,npx_filter)/(npx_filter*npy_filter);2080 test_ filter=1;2068 if isequal(ObjectData.ProjMode,'interp_tps') 2069 npx_interp_tps=ceil(abs(DX/DAX)); 2070 npy_interp_tps=ceil(abs(DY/DAY)); 2071 Minterp_tps=ones(npy_interp_tps,npx_interp_tps)/(npx_interp_tps*npy_interp_tps); 2072 test_interp_tps=1; 2081 2073 else 2082 test_ filter=0;2074 test_interp_tps=0; 2083 2075 end 2084 2076 eval(['ProjData.' AYName '=[coord_y_proj(1) coord_y_proj(end)];']) %record the new (projected ) y coordinates … … 2089 2081 eval(['ProjData.' VarName '=interp2(Coord{2},Coord{1},FieldData.' VarName ',Coord_x,Coord_y'');']) %TO TEST 2090 2082 end 2091 %filter the field (image) if option ' filter' is used2092 if test_ filter2083 %filter the field (image) if option 'interp_tps' is used 2084 if test_interp_tps 2093 2085 Aclass=class(FieldData.A); 2094 ProjData.(VarName)= filter2(Mfilter,FieldData.(VarName),'valid');2086 ProjData.(VarName)=interp_tps2(Minterp_tps,FieldData.(VarName),'valid'); 2095 2087 if ~isequal(Aclass,'double') 2096 2088 ProjData.(VarName)=Aclass(FieldData.(VarName));%revert to integer values -
trunk/src/read_civdata.m
r580 r581 62 62 errormsg=''; 63 63 if ischar(FieldNames), FieldNames={FieldNames}; end; 64 FieldRequest='';64 ProjModeRequest=''; 65 65 for ilist=1:length(FieldNames) 66 66 if ~isempty(FieldNames{ilist}) 67 67 switch FieldNames{ilist} 68 68 case{'U','V','norm(U,V)'} 69 FieldRequest='interp_lin';69 ProjModeRequest='interp_lin'; 70 70 case {'curl(U,V)','div(U,V)','strain(U,V)'} 71 FieldRequest='interp_tps';71 ProjModeRequest='interp_tps'; 72 72 end 73 73 end … … 76 76 %% reading data 77 77 Data=nc2struct(filename,'ListGlobalAttribute','CivStage'); 78 [varlist,role,VelTypeOut]=varcivx_generator( FieldRequest,VelType,Data.CivStage);78 [varlist,role,VelTypeOut]=varcivx_generator(ProjModeRequest,VelType,Data.CivStage); 79 79 if isempty(varlist) 80 80 erromsg=['error in read_civdata: unknow velocity type ' VelType]; … … 109 109 Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'Dt','Time'}]; 110 110 ivar_U_tps=[]; 111 ivar_V_tps=[]; 111 112 var_ind=find(vardetect); 112 113 for ivar=1:numel(var_ind) 113 114 Field.VarAttribute{ivar}.Role=role{var_ind(ivar)}; 114 Field.VarAttribute{ivar}.FieldRequest=FieldRequest;115 115 if strcmp(role{var_ind(ivar)},'vector_x') 116 116 Field.VarAttribute{ivar}.FieldName=FieldNames; 117 Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest; 117 118 ivar_U=ivar; 118 119 end 119 120 if strcmp(role{var_ind(ivar)},'vector_x_tps') 120 121 Field.VarAttribute{ivar}.FieldName=FieldNames; 122 Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest; 121 123 ivar_U_tps=ivar; 122 124 end 123 % Field.VarAttribute{ivar}.Unit=units{var_ind(ivar)}; 125 if strcmp(role{var_ind(ivar)},'vector_y') 126 Field.VarAttribute{ivar}.FieldName=FieldNames; 127 Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest; 128 ivar_V=ivar; 129 end 130 if strcmp(role{var_ind(ivar)},'vector_y_tps') 131 Field.VarAttribute{ivar}.FieldName=FieldNames; 132 Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest; 133 ivar_V_tps=ivar; 134 end 124 135 Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel 125 136 end … … 127 138 Field.VarAttribute{ivar_U}.VarIndex_tps=ivar_U_tps; 128 139 end 129 140 if ~isempty(ivar_V_tps) 141 Field.VarAttribute{ivar_V}.VarIndex_tps=ivar_V_tps; 142 end 143 144 %% update list of global attributes 130 145 Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'NbCoord','NbDim','TimeUnit','CoordUnit'}]; 131 % %% update list of global attributes132 146 Field.NbCoord=2; 133 147 Field.NbDim=2; … … 146 160 % if vel_type=[] or'*', a priority choice is done, civ2 considered better than civ1 ) 147 161 148 function [var,role,vel_type_out,errormsg]=varcivx_generator( FieldRequest,vel_type,CivStage)162 function [var,role,vel_type_out,errormsg]=varcivx_generator(ProjModeRequest,vel_type,CivStage) 149 163 150 164 %% default input values … … 154 168 155 169 %% select the priority order for automatic vel_type selection 156 if strcmp(vel_type,'civ2') && strcmp( FieldRequest,'derivatives')170 if strcmp(vel_type,'civ2') && strcmp(ProjModeRequest,'derivatives') 157 171 vel_type='filter2'; 158 elseif strcmp(vel_type,'civ1') && strcmp( FieldRequest,'derivatives')172 elseif strcmp(vel_type,'civ1') && strcmp(ProjModeRequest,'derivatives') 159 173 vel_type='filter1'; 160 174 end … … 164 178 vel_type='filter2'; 165 179 case {4,5}% civ2 available but not filter2 166 if strcmp( FieldRequest,'derivatives')% derivatives needed180 if strcmp(ProjModeRequest,'derivatives')% derivatives needed 167 181 vel_type='filter1'; 168 182 else … … 203 217 % units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel',''}; 204 218 end 205 if ~strcmp( FieldRequest,'interp_tps')219 if ~strcmp(ProjModeRequest,'interp_tps') 206 220 var=var(:,1:9);%suppress tps if not needed 207 221 end -
trunk/src/read_civxdata.m
r579 r581 95 95 Field.VarAttribute{ivar}.FieldName=FieldNames; 96 96 if testinterp 97 Field.VarAttribute{ivar}. FieldRequest='interp_lin';97 Field.VarAttribute{ivar}.ProjModeRequest='interp_lin'; 98 98 end 99 99 end -
trunk/src/set_object.m
r569 r581 249 249 switch Type 250 250 case {'points','line','polyline','plane'} 251 menu_proj={'projection';'interp ';'filter';'none'};251 menu_proj={'projection';'interp_lin';'interp_tps';'none'}; 252 252 case {'polygon','rectangle','ellipse'} 253 253 menu_proj={'inside';'outside';'mask_inside';'mask_outside'}; 254 254 case 'volume' 255 menu_proj={'interp ';'none'};255 menu_proj={'interp_lin';'none'}; 256 256 otherwise 257 menu_proj={'projection';'interp ';'filter';'none'};%default257 menu_proj={'projection';'interp_lin';'interp_tps';'none'};%default 258 258 end 259 259 else … … 288 288 set(handles.num_RangeX_2,'Visible','off') 289 289 set(handles.num_RangeY_1,'Visible','off') 290 if isequal(ProjMode,'interp ')290 if isequal(ProjMode,'interp_lin') 291 291 set(handles.num_RangeY_2,'Visible','off') 292 292 else … … 315 315 % set(handles.YObject,'TooltipString','YObject: set of y coordinates defining the line') 316 316 % set(handles.ZObject,'TooltipString','ZObject: set of z coordinates defining the line') 317 if isequal(ProjMode,'interp ')|| isequal(ProjMode,'filter')317 if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps') 318 318 set(handles.num_DX,'Visible','on') 319 319 set(handles.num_DX,'TooltipString','num_DX: mesh for the interpolated field along the line') … … 338 338 set(handles.num_RangeZ_2,'Visible','on') 339 339 end 340 if isequal(ProjMode,'interp ')|| isequal(ProjMode,'filter')340 if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps') 341 341 set(handles.num_DX,'Visible','on') 342 342 set(handles.num_DY,'Visible','on') … … 345 345 set(handles.num_DY,'Visible','off') 346 346 end 347 if isequal(ProjMode,'interp ')347 if isequal(ProjMode,'interp_lin') 348 348 set(handles.num_DZ,'Visible','on') 349 349 end … … 360 360 set(handles.num_RangeZ_1,'Visible','on') 361 361 set(handles.num_RangeZ_2,'Visible','on') 362 if isequal(ProjMode,'interp ')|| isequal(ProjMode,'filter')362 if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps') 363 363 set(handles.num_DX,'Visible','on') 364 364 set(handles.num_DY,'Visible','on') … … 485 485 PlotType='text'; 486 486 else 487 % create tps coeff if needed for ProjMode ' filter'488 if strcmp(ObjectData.ProjMode,' filter')&&~isfield(UvData.Field,'Coord_tps')487 % create tps coeff if needed for ProjMode 'interp_tps' 488 if strcmp(ObjectData.ProjMode,'interp_tps')&&~isfield(UvData.Field,'Coord_tps') 489 489 UvData.Field=calc_tps(UvData.Field,1); 490 490 end -
trunk/src/sub_field.m
r580 r581 75 75 76 76 %% field request 77 FieldRequest=cell(size(Field.ListVarName));77 ProjModeRequest=cell(size(Field.ListVarName)); 78 78 for ilist=1:numel(Field.VarAttribute) 79 if isfield(Field.VarAttribute{ilist},' FieldRequest')80 FieldRequest{ilist}=Field.VarAttribute{ilist}.FieldRequest;79 if isfield(Field.VarAttribute{ilist},'ProjModeRequest') 80 ProjModeRequest{ilist}=Field.VarAttribute{ilist}.ProjModeRequest; 81 81 end 82 82 end 83 FieldRequest_1=cell(size(Field_1.ListVarName));83 ProjModeRequest_1=cell(size(Field_1.ListVarName)); 84 84 for ilist=1:numel(Field_1.VarAttribute) 85 if isfield(Field_1.VarAttribute{ilist},' FieldRequest')86 FieldRequest_1{ilist}=Field_1.VarAttribute{ilist}.FieldRequest;85 if isfield(Field_1.VarAttribute{ilist},'ProjModeRequest') 86 ProjModeRequest_1{ilist}=Field_1.VarAttribute{ilist}.ProjModeRequest; 87 87 end 88 88 end … … 115 115 VarVal=Field_1.(Field_1.ListVarName{ilist}); 116 116 for i1=1:numel(Field.ListVarName) 117 if (isempty( FieldRequest{i1})&&isempty(FieldRequest_1{ilist})||strcmp(FieldRequest{i1},FieldRequest_1{ilist})) && isequal(Field.(Field.ListVarName{i1}),VarVal)117 if (isempty(ProjModeRequest{i1})&&isempty(ProjModeRequest_1{ilist})||strcmp(ProjModeRequest{i1},ProjModeRequest_1{ilist})) && isequal(Field.(Field.ListVarName{i1}),VarVal) 118 118 ind_remove(ilist)=1; 119 119 NewDim=Field.VarDimName{i1}; -
trunk/src/tps_coeff.m
r434 r581 8 8 % The spatial derivatives are obtained as EMDX*U_tps and EMDY*U_tps, where 9 9 % EMDX and EMDY are obtained from the function tps_eval_dxy. 10 % for big data sets, a splitting in subdomains is needed, see functions 11 % set_subdomains and tps_coeff_field. 12 % 10 13 %------------------------------------------------------------------------ 11 14 % [U_smooth,U_tps]=tps_coeff(ctrs,U,Smoothing) … … 13 16 % OUPUT: 14 17 % U_smooth: values of the quantity U at the N centres after smoothing 15 % U_tps: tps weights of the centres 18 % U_tps: tps weights of the centres and columns of the linear 16 19 17 20 %INPUT: 18 % ctrs: Nx s matrix representing the postions of the N centers, sources of the tps (s=space dimension)21 % ctrs: NxNbDim matrix representing the positions of the N centers, sources of the tps (NbDim=space dimension) 19 22 % U: Nx1 column vector representing the values of the considered scalar measured at the centres ctrs 20 23 % Smoothing: smoothing parameter: the result is smoother for larger Smoothing. 21 24 % 25 %related functions: 26 % tps_eval, tps_eval_dxy 27 % tps_coeff_field, set_subdomains, filter_tps, calc_field 22 28 23 29 function [U_smooth,U_tps]=tps_coeff(ctrs,U,Smoothing) 24 30 %------------------------------------------------------------------------ 25 %Smoothing smoothing parameter 26 % X=reshape(X,[],1); 27 % Y=reshape(Y,[],1); 28 N=size(ctrs,1); 29 % rhs = reshape(U,[],1); 30 U = [U; zeros(3,1)]; 31 % ctrs = [X Y];% coordinates of measurement sites, radial base functions are located at the measurement sites 31 32 N=size(ctrs,1);% nbre of source centres 33 NbDim=size(ctrs,2);% space dimension (2 or 3) 34 U = [U; zeros(NbDim+1,1)]; 32 35 EM = tps_eval(ctrs,ctrs); 33 36 SmoothingMat=Smoothing*eye(N,N);% Smoothing=1/(2*omega) , omega given by fasshauer; 34 SmoothingMat=[SmoothingMat zeros(N, 3)];37 SmoothingMat=[SmoothingMat zeros(N,NbDim+1)]; 35 38 PM=[ones(N,1) ctrs]; 36 IM=[EM+SmoothingMat; [PM' zeros( 3,3)]];39 IM=[EM+SmoothingMat; [PM' zeros(NbDim+1,NbDim+1)]]; 37 40 U_tps=(IM\U); 38 41 U_smooth=EM *U_tps; -
trunk/src/tps_eval.m
r434 r581 16 16 % related functions: 17 17 % tps_coeff, tps_eval_dxy 18 % tps_coeff_field, set_subdomains, filter_tps, calc_field 18 19 19 20 function EM = tps_eval(dsites,ctrs) -
trunk/src/tps_eval_dxy.m
r434 r581 15 15 % related functions: 16 16 % tps_coeff, tps_eval 17 % tps_coeff_field, set_subdomains, filter_tps, calc_field 17 18 18 19 function [DMX,DMY] = tps_eval_dxy(dsites,ctrs) -
trunk/src/uvmat.m
r580 r581 68 68 % --->transform fct<--- transform (e.g. phys.m) and combine input fieldname 69 69 % | 70 % ( calc_tps.m) calculate tps coefficients (for filter projection or spatial derivatives).70 % (tps_coeff_field.m) calculate tps coefficients (for filter projection or spatial derivatives). 71 71 % | 72 72 % UvData.Field-------------->histogram … … 1022 1022 switch FileType 1023 1023 case {'civx','civdata'} 1024 [FieldList,ColorList]=calc_field; 1024 % [FieldList,ColorList]=calc_field; 1025 [FieldList,ColorList]=set_field_list('U','V','C'); 1025 1026 set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data 1026 1027 set(handles_Fields,'Value',2) % set menu to 'velocity … … 2046 2047 if (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx')) 2047 2048 for iobj=1:numel(UvData.Object) 2048 if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,' filter')2049 if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'interp_tps') 2049 2050 check_proj_tps=1; 2050 2051 break … … 2438 2439 2439 2440 %% calculate tps coefficients if needed 2440 UvData.Field= calc_tps(UvData.Field,check_proj_tps);2441 UvData.Field=tps_coeff_field(UvData.Field,check_proj_tps); 2441 2442 2442 2443 %% analyse input field … … 3042 3043 function FieldName_Callback(hObject, eventdata, handles) 3043 3044 %------------------------------------------------------------------------ 3045 UvData=get(handles.uvmat,'UserData'); 3044 3046 list_fields=get(handles.FieldName,'String');% list menu fields 3045 3047 index_fields=get(handles.FieldName,'Value');% selected string index 3046 3048 field= list_fields{index_fields(1)}; % selected string 3049 3050 %% fill the coordinates and variables from selections in get_field 3047 3051 if isequal(field,'get_field...') 3052 if strcmp(get(handles.VelType,'Visible'),'on') 3053 % we use the civ choice as default input 3054 ParamIn.SwitchVarIndexTime='attribute'; 3055 ListVelType=get(handles.VelType,'String'); 3056 VelType=ListVelType{get(handles.VelType,'Value')}; 3057 switch VelType 3058 case 'civ1' 3059 ParamIn.TimeVarName='Civ1_Time'; 3060 ParamIn.vector_x='Civ1_U'; 3061 ParamIn.vector_y='Civ1_V'; 3062 case 'filter1' 3063 ParamIn.TimeVarName='Civ1_Time'; 3064 ParamIn.vector_x='Civ1_U_smooth'; 3065 ParamIn.vector_y='Civ1_V_smooth'; 3066 case 'civ2' 3067 ParamIn.TimeVarName='Civ2_Time'; 3068 ParamIn.vector_x='Civ2_U'; 3069 ParamIn.vector_y='Civ2_V'; 3070 case 'filter2' 3071 ParamIn.TimeVarName='Civ2_Time'; 3072 ParamIn.vector_x='Civ2_U_smooth'; 3073 ParamIn.vector_y='Civ2_V_smooth'; 3074 end 3075 end 3048 3076 set(handles.FixVelType,'visible','off') 3049 set(handles.VelType,' visible','off')3050 set(handles.VelType_1,' visible','off')3077 set(handles.VelType,'Visible','off') 3078 set(handles.VelType_1,'Visible','off') 3051 3079 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 3052 3080 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; 3053 hget_field=findobj(allchild(0),'name','get_field'); 3054 if ~isempty(hget_field) 3055 delete(hget_field) 3056 end 3057 get_field(FileName); 3081 % hget_field=findobj(allchild(0),'name','get_field'); 3082 % if ~isempty(hget_field) 3083 % delete(hget_field) 3084 % end 3085 GetFieldData=get_field(FileName,ParamIn); 3086 FieldList={}; 3087 VecColorList={}; 3088 XName=''; 3089 YName=''; 3090 if GetFieldData.CheckVector 3091 UName=GetFieldData.PanelVectors.vector_x; 3092 VName=GetFieldData.PanelVectors.vector_y; 3093 XName=GetFieldData.PanelVectors.coord_x_vectors; 3094 YName=GetFieldData.PanelVectors.coord_y_vectors; 3095 CName=GetFieldData.PanelVectors.vec_color; 3096 [FieldList,VecColorList]=set_field_list(UName,VName,CName); 3097 % FieldList={['vec(' UName ',' VName ')'];... 3098 % ['norm(' UName ',' VName ')'];... 3099 % ['curl(' UName ',' VName ')'];... 3100 % ['div(' UName ',' VName ')'];... 3101 % ['strain(' UName ',' VName ')']}; 3102 % VecColorList={['norm(' UName ',' VName ')'];... 3103 % UName;... 3104 % VName};... 3105 % if ~isempty(CName) 3106 % VecColorList=[{CName};VecColorList]; 3107 % end 3108 end 3109 if GetFieldData.CheckScalar 3110 AName=GetFieldData.PanelScalar.scalar; 3111 XName=GetFieldData.PanelScalar.coord_x_scalar; 3112 YName=GetFieldData.PanelScalar.coord_y_scalar; 3113 FieldList={AName}; 3114 end 3115 if GetFieldData.CheckPlot1D 3116 XName=GetFieldData.CheckPlot1D.abscissa; 3117 YName=GetFieldData.CheckPlot1D.ordinate; 3118 end 3119 set(handles.Coord_x,'String',{XName}) 3120 set(handles.Coord_y,'String',{YName}) 3121 set(handles.FieldName,'Value',1) 3122 set(handles.FieldName,'String',[FieldList; {'get_field...'}]); 3123 set(handles.ColorScalar,'Value',1) 3124 set(handles.ColorScalar,'String',VecColorList); 3125 UvData.FileType{1}='netcdf'; 3126 set(handles.uvmat,'UserData',UvData) 3127 run0_Callback(hObject, eventdata, handles) 3058 3128 return %no further action 3059 3129 end 3060 3130 3061 UvData=get(handles.uvmat,'UserData'); 3131 3062 3132 3063 3133 %read the rootfile input display … … 3107 3177 indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); 3108 3178 set(handles.FileIndex,'String',indices) 3109 % set(handles.NomType,'String',NomType)3110 3179 3111 3180 %common to Fields_1_Callback … … 3413 3482 % 3414 3483 if isequal(get(handles.edit_vect,'Value'),1) 3415 test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);3416 test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]);3417 if ~ test_civ2 && ~test_civ13484 VelTypeMenu=get(handles.VelType,'String'); 3485 VelType=VelTypeMenu{get(handles.VelType,'Value')}; 3486 if ~strcmp(VelType,'civ2') && ~strcmp(VelType,'civ1') 3418 3487 msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') 3419 3488 end … … 3814 3883 function CheckDecimate4_Callback(hObject, eventdata, handles) 3815 3884 %------------------------------------------------------------------------ 3885 if isequal(get(handles.CheckDecimate4,'Value'),1) 3886 set(handles.CheckDecimate16,'Value',0) 3887 end 3888 update_plot(handles); 3889 3890 %------------------------------------------------------------------------ 3891 % --- Executes on selection change in CheckDecimate16 (nb_vec/16). 3892 function CheckDecimate16_Callback(hObject, eventdata, handles) 3893 %------------------------------------------------------------------------ 3894 if isequal(get(handles.CheckDecimate16,'Value'),1) 3895 set(handles.CheckDecimate4,'Value',0) 3896 end 3816 3897 update_plot(handles); 3817 3898 … … 4341 4422 % -------------------------------------------------------------------- 4342 4423 function MenuExportAxis_Callback(hObject, eventdata, handles) 4343 answer=msgbox_uvmat('CONFIRMATION','select a figure/axis on which the current uvmat plot will be exported') 4344 if strcmp(answer,'Yes') 4345 hchild=get(handles.PlotAxes,'children'); 4346 copyobj(hchild,gca); 4347 end 4424 ListFig=findobj(allchild(0),'Type','figure'); 4425 nb_option=0; 4426 menu={}; 4427 for ilist=1:numel(ListFig) 4428 FigName=get(ListFig(ilist),'name'); 4429 if isempty(FigName) 4430 FigName=['figure ' num2str(ListFig(ilist))]; 4431 end 4432 if ~strcmp(FigName,'uvmat') 4433 ListAxes=findobj(ListFig(ilist),'Type','axes'); 4434 ListTags=get(ListAxes,'Tag'); 4435 if ~isempty(ListTags) && ~isempty(find(~strcmp('Colorbar',ListTags), 1)) 4436 ListAxes=ListAxes(~strcmp('Colorbar',ListTags)); 4437 if numel(ListAxes)==1 4438 nb_option=nb_option+1; 4439 menu{nb_option}=FigName ; 4440 AxesHandle(nb_option)=ListAxes; 4441 else 4442 nb_axis=0; 4443 for iaxes=1:numel(ListAxes) 4444 nb_axis=nb_axis+1; 4445 nb_option=nb_option+1; 4446 menu{nb_option}=[FigName '_' num2str(nb_axis)]; 4447 AxesHandle(nb_option)=ListAxes(nb_axis); 4448 end 4449 end 4450 end 4451 end 4452 end 4453 if isempty(menu) 4454 answer=msgbox_uvmat('INPUT_Y-N','no existing plotting axes available, create new figure?'); 4455 if strcmp(answer,'Yes') 4456 hfig=figure; 4457 copyobj(handles.PlotAxes,hfig); 4458 else 4459 return 4460 end 4461 map=colormap(handles.PlotAxes); 4462 colormap(map);%transmit the current colormap to the zoom fig 4463 colorbar 4464 else 4465 answer=msgbox_uvmat('INPUT_MENU','select a figure/axis on which the current uvmat plot will be exported',menu); 4466 if isempty(answer) 4467 return 4468 else 4469 axes(AxesHandle(answer)) 4470 hold on 4471 hchild=get(handles.PlotAxes,'children'); 4472 copyobj(hchild,gca); 4473 end 4474 end 4475 4348 4476 4349 4477 %------------------------------------------------------------------------ … … 4505 4633 %------------------------------------------------------------------------ 4506 4634 data.Type='volume'; 4507 data.ProjMode='interp ';%default4635 data.ProjMode='interp_lin';%default 4508 4636 data.ProjModeMenu={}; 4509 4637 % set(handles.create,'Visible','on') … … 5019 5147 % --- Executes on button press in CheckColorBar. 5020 5148 function CheckColorBar_Callback(hObject, eventdata, handles) 5149
Note: See TracChangeset
for help on using the changeset viewer.