Changeset 406
- Timestamp:
- May 3, 2012, 7:30:05 PM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/calc_field.m
r405 r406 93 93 %% interpolation with new civ data 94 94 if isfield(DataIn,'SubRange') && isfield(DataIn,'Coord_tps') && (exist('Coord_interp','var') || check_grid ||check_der) 95 96 DataOut.ListGlobalAttribute=DataIn.ListGlobalAttribute; %reproduce global attribute95 %reproduce global attributes 96 DataOut.ListGlobalAttribute=DataIn.ListGlobalAttribute; 97 97 for ilist=1:numel(DataOut.ListGlobalAttribute) 98 98 DataOut.(DataOut.ListGlobalAttribute{ilist})=DataIn.(DataIn.ListGlobalAttribute{ilist}); 99 99 end 100 DataOut.ListVarName={'coord_y','coord_x','FF'}; 101 DataOut.VarDimName{1}='coord_y'; 102 DataOut.VarDimName{2}='coord_x'; 103 XMax=max(max(DataIn.SubRange(1,:,:)));% extrema of the coordinates 104 YMax=max(max(DataIn.SubRange(2,:,:))); 105 XMin=min(min(DataIn.SubRange(1,:,:))); 106 YMin=min(min(DataIn.SubRange(2,:,:))); 100 107 101 %create a default grid if needed 108 102 if ~exist('Coord_interp','var') 103 XMax=max(max(DataIn.SubRange(1,:,:)));% extrema of the coordinates 104 YMax=max(max(DataIn.SubRange(2,:,:))); 105 XMin=min(min(DataIn.SubRange(1,:,:))); 106 YMin=min(min(DataIn.SubRange(2,:,:))); 109 107 if ~isfield(DataIn,'Mesh') 110 108 DataIn.Mesh=sqrt(2*(XMax-XMin)*(YMax-YMin)/numel(DataIn.Coord_tps)); … … 121 119 coord_x=XMin:DataIn.Mesh:XMax; 122 120 coord_y=YMin:DataIn.Mesh:YMax; 121 npx=length(coord_x); 122 npy=length(coord_y); 123 DataOut.coord_x=[XMin XMax]; 124 DataOut.coord_y=[YMin YMax]; 123 125 [XI,YI]=meshgrid(coord_x,coord_y); 124 126 XI=reshape(XI,[],1); … … 126 128 Coord_interp=[XI YI]; 127 129 end 130 131 %initialise output 128 132 nb_sites=size(Coord_interp,1); 129 133 nb_coord=size(Coord_interp,2); 130 %initialise output 134 nbval=zeros(nb_sites,1); 135 NbSubDomain=size(DataIn.SubRange,3); 136 DataOut.ListVarName={'coord_y','coord_x'}; 137 DataOut.VarDimName={{'coord_y'},{'coord_x'}}; 138 DataOut.VarAttribute{1}=[]; 139 DataOut.VarAttribute{2}=[]; 131 140 for ilist=1:length(FieldList) 132 141 switch FieldList{ilist} … … 135 144 DataOut.V=zeros(nb_sites,1); 136 145 otherwise 137 % case{'vort','div','strain'}% case of spatial derivatives138 146 DataOut.(FieldList{ilist})=zeros(nb_sites,1); 139 % otherwise % case of a scalar 140 % check_val=1; 141 % DataOut.(FieldList{ilist})=zeros(size(Coord_interp,1)); 142 end 143 end 144 nbval=zeros(nb_sites,1); 145 NbSubDomain=size(DataIn.SubRange,3); 146 %DataIn.Coord_tps=DataIn.Coord_tps(1:end-3,:,:);% suppress the 3 zeros used to fit with the dimensions of variables 147 end 148 end 149 150 % interpolate data in each subdomain 147 151 for isub=1:NbSubDomain 148 152 nbvec_sub=DataIn.NbSites(isub); … … 159 163 [EMDX,EMDY] = tps_eval_dxy(Coord_interp(ind_sel,:),DataIn.Coord_tps(1:nbvec_sub,:,isub));%kernels for calculating the spatial derivatives from tps 'sources' 160 164 end 165 var_count=0; 161 166 for ilist=1:length(FieldList) 162 167 switch FieldList{ilist} 163 168 case 'velocity' 164 169 ListFields={'U', 'V'}; 165 VarAttributes{ 1}.Role='vector_x';166 VarAttributes{ 2}.Role='vector_y';170 VarAttributes{var_count+1}.Role='vector_x'; 171 VarAttributes{var_count+2}.Role='vector_y'; 167 172 DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub); 168 173 DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub); 169 174 case 'u' 170 ListFields={' U'};171 VarAttributes{ 1}.Role='scalar';172 DataOut. U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);175 ListFields={'u'}; 176 VarAttributes{var_count+1}.Role='scalar'; 177 DataOut.u(ind_sel)=DataOut.u(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub); 173 178 case 'v' 174 ListFields={' V'};175 VarAttributes{ 1}.Role='scalar';176 DataOut. V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);179 ListFields={'v'}; 180 VarAttributes{var_count+1}.Role='scalar'; 181 DataOut.v(ind_sel)=DataOut.v(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub); 177 182 case 'norm_vel' 178 183 ListFields={'norm_vel'}; 179 VarAttributes{ 1}.Role='scalar';184 VarAttributes{var_count+1}.Role='scalar'; 180 185 V=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub); 181 186 V=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub); … … 183 188 case 'vort' 184 189 ListFields={'vort'}; 185 VarAttributes{ 1}.Role='scalar';190 VarAttributes{var_count+1}.Role='scalar'; 186 191 DataOut.vort(ind_sel)=DataOut.vort(ind_sel)+EMDY *DataIn.U_tps(1:nbvec_sub+3,isub)-EMDX *DataIn.V_tps(1:nbvec_sub+3,isub); 187 192 case 'div' 188 193 ListFields={'div'}; 189 VarAttributes{ 1}.Role='scalar';194 VarAttributes{var_count+1}.Role='scalar'; 190 195 DataOut.div(ind_sel)=DataOut.div(ind_sel)+EMDX*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDY *DataIn.V_tps(1:nbvec_sub+3,isub); 191 196 case 'strain' 192 197 ListFields={'strain'}; 193 VarAttributes{ 1}.Role='scalar';198 VarAttributes{var_count+1}.Role='scalar'; 194 199 DataOut.strain(ind_sel)=DataOut.strain(ind_sel)+EMDY*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDX *DataIn.V_tps(1:nbvec_sub+3,isub); 195 200 end 196 end 197 DataOut.FF=nbval==0; %put errorflag to 1 for points outside the interpolation rang 198 nbval(nbval==0)=1; 199 DataOut.ListVarName=[DataOut.ListVarName ListFields]; 200 for ilist=3:numel(DataOut.ListVarName) 201 DataOut.VarDimName{ilist}={'coord_y','coord_x'}; 202 end 203 DataOut.VarAttribute={[],[]}; 204 DataOut.VarAttribute{3}.Role='errorflag'; 205 DataOut.VarAttribute=[DataOut.VarAttribute VarAttributes]; 201 DataOut.FF=nbval==0; %put errorflag to 1 for points outside the interpolation rang 202 nbval(nbval==0)=1; 203 DataOut.ListVarName=[DataOut.ListVarName ListFields {'FF'}]; 204 for ilist=1:numel(ListFields) 205 VarDimName{ilist}={'coord_y','coord_x'}; 206 DataOut.(ListFields{ilist})=reshape(DataOut.(ListFields{ilist}),npy,npx); 207 end 208 DataOut.FF=reshape(DataOut.FF,npy,npx); 209 DataOut.VarDimName=[DataOut.VarDimName VarDimName {{'coord_y','coord_x'}}] ; 210 VarAttributes{length(ListFields)+1}.Role='errorflag'; 211 DataOut.VarAttribute=[DataOut.VarAttribute VarAttributes]; 212 end 206 213 end 207 214 else -
trunk/src/check_field_structure.m
r404 r406 17 17 18 18 function [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data) 19 DataOut=[]; %default 20 errormsg=[]; 19 errormsg=''; 20 ListDimName={}; 21 DimValue=[]; %default 22 VarDimIndex={}; 21 23 if ~isstruct(Data) 22 24 errormsg='input field is not a structure'; -
trunk/src/civ.m
r399 r406 1253 1253 Param.Civ1.ImageWidth=ImageInfo.Width; 1254 1254 Param.Civ1.ImageHeight=ImageInfo.Height; 1255 Param.Civ1.i1=i1_civ1 ;1256 Param.Civ1.i2=i2_civ1 ;1255 Param.Civ1.i1=i1_civ1(ifile,j); 1256 Param.Civ1.i2=i2_civ1(ifile,j); 1257 1257 % read mask parameters 1258 1258 if Param.Civ1.CheckMask % the lines below should be changed with the new gui … … 1431 1431 Param.Civ2.ImageWidth=ImageInfo.Width; 1432 1432 Param.Civ2.ImageHeight=ImageInfo.Height; 1433 Param.Civ2.i1=i1_civ2 ;1434 Param.Civ2.i2=i2_civ2 ;1433 Param.Civ2.i1=i1_civ2(ifile,j); 1434 Param.Civ2.i2=i2_civ2(ifile,j); 1435 1435 switch CivMode 1436 1436 case 'CivX' … … 1586 1586 if isempty(errormsg) 1587 1587 display([filecell.nc.civ1{ifile,j} ' written']) 1588 % else1589 % msgbox_uvmat('ERROR',errormsg)1590 1588 end 1591 1589 end -
trunk/src/civ_matlab.m
r399 r406 58 58 %% Civ1 59 59 if isfield (Param,'Civ1') 60 check_civ1=1;% test for further use of civ1 results60 % check_civ1=1;% test for further use of civ1 results 61 61 % %% prepare images 62 62 par_civ1=Param.Civ1; … … 102 102 list_param=(fieldnames(Param.Civ1))'; 103 103 Civ1_param=list_param;%default 104 %set the values of all the global attributes in list_param 104 105 for ilist=1:length(list_param) 105 106 Civ1_param{ilist}=['Civ1_' list_param{ilist}]; -
trunk/src/read_civdata.m
r404 r406 48 48 49 49 function [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType,CivStage) 50 errormsg=''; 50 51 51 %% default input 52 52 if ~exist('VelType','var') … … 62 62 FieldNames=[]; %default 63 63 end 64 errormsg=''; 64 65 65 66 %% reading data 66 67 [varlist,role,units,VelTypeOut]=varcivx_generator(FieldNames,VelType,CivStage); 67 [Field,vardetect]=nc2struct(filename,varlist);%read the variables in the netcdf file 68 if isempty(varlist) 69 erromsg=['error in read_civdata: unknow velocity type ' VelType]; 70 return 71 else 72 [Field,vardetect]=nc2struct(filename,varlist);%read the variables in the netcdf file 73 end 68 74 if isfield(Field,'Txt') 69 75 errormsg=Field.Txt; … … 106 112 % if vel_type=[] or'*', a priority choice is done, civ2 considered better than civ1 ) 107 113 108 function [var,role,units,vel_type_out ]=varcivx_generator(FieldNames,vel_type,CivStage)114 function [var,role,units,vel_type_out,errormsg]=varcivx_generator(FieldNames,vel_type,CivStage) 109 115 110 116 %% default input values … … 113 119 if ~exist('FieldNames','var'),FieldNames={'ima_cor'};end;%default scalar 114 120 if ischar(FieldNames), FieldNames={FieldNames}; end; 121 errormsg=''; 115 122 116 123 %% select the priority order for automatic vel_type selection … … 127 134 end 128 135 end 129 if isempty(vel_type) 136 if isempty(vel_type)||strcmp(vel_type,'*') 130 137 switch CivStage 131 138 case {6} %filter2 available … … 146 153 vel_type='filter1'; 147 154 end 148 155 var={}; 149 156 switch vel_type 150 157 case 'civ1' -
trunk/src/read_field.m
r405 r406 94 94 ParamOut.CivStage=Field.CivStage; 95 95 end 96 end 97 ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}]; 96 ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}]; 97 end 98 % ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}]; 98 99 if CivStage==0% read the field names on the interface get_field. 99 100 hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI -
trunk/src/uvmat.m
r405 r406 79 79 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%: 80 80 % 81 % fields are opened and visualised by the sub-function refresh_field.m 82 % (called by uvmat_opening, RUN0, runp and runm) 81 % 82 % 1) Input filenames are determined by MenuBrowse (first field), MenuBrowse_1 83 % (second field), or by the stored file names under Browse, or as an input of uvmat. 84 % 2) These functions call 'display_file_name.m' which detects the file series, and fills the file index boxes 85 % 3) Then 'update_rootinfo.m' Updates information about a new field series (indices to scan, timing, calibration from an xml file) 86 % 4) Then fields are opened and visualised by the main sub-function 'refresh_field.m' 83 87 % The function first reads the name of the input file from the edit boxes of the GUI 84 % A second input file can be introduced for file dcomparison88 % A second input file can be introduced for file comparison 85 89 % It then reads the input file(s) with the appropriate function, read for 86 90 % images, read_civxdata.m for CIVx PIV data, nc2struct for other netcdf … … 168 172 %------------------------------------------------------------------------ 169 173 %------------------------------------------------------------------------ 170 % I - MAIN FUNCTION UVMAT174 % I - MAIN FUNCTION uvmat 171 175 %------------------------------------------------------------------------ 172 176 %------------------------------------------------------------------------ … … 343 347 if ~isempty(inputfile) 344 348 %%%%% display the input field %%%%%%% 345 display_file_name(h Object, eventdata, handles,inputfile)349 display_file_name(handles,inputfile) 346 350 %%%%%%% 347 351 testinputfield=1; … … 442 446 443 447 % display the selected field and related information 444 display_file_name( hObject, eventdata,handles,fileinput)448 display_file_name( handles,fileinput) 445 449 446 450 % ----------------------------------------------------------------------- … … 449 453 %------------------------------------------------------------------------ 450 454 fileinput=get(handles.MenuFile_1,'Label'); 451 display_file_name( hObject, eventdata,handles,fileinput)455 display_file_name( handles,fileinput) 452 456 453 457 % ----------------------------------------------------------------------- … … 456 460 %------------------------------------------------------------------------ 457 461 fileinput=get(handles.MenuFile_2,'Label'); 458 display_file_name(h Object, eventdata, handles,fileinput)462 display_file_name(handles,fileinput) 459 463 460 464 % ----------------------------------------------------------------------- … … 463 467 %------------------------------------------------------------------------ 464 468 fileinput=get(handles.MenuFile_3,'Label'); 465 display_file_name(h Object, eventdata, handles,fileinput)469 display_file_name(handles,fileinput) 466 470 467 471 % ----------------------------------------------------------------------- … … 470 474 %------------------------------------------------------------------------ 471 475 fileinput=get(handles.MenuFile_4,'Label'); 472 display_file_name(h Object, eventdata, handles,fileinput)476 display_file_name(handles,fileinput) 473 477 474 478 % ----------------------------------------------------------------------- … … 477 481 %------------------------------------------------------------------------ 478 482 fileinput=get(handles.MenuFile_5,'Label'); 479 display_file_name(h Object, eventdata, handles,fileinput)483 display_file_name(handles,fileinput) 480 484 481 485 %------------------------------------------------------------------------ … … 511 515 % refresh the current displayed field 512 516 set(handles.SubField,'Value',1) 513 display_file_name(h Object,eventdata,handles,fileinput_1,2)517 display_file_name(handles,fileinput_1,2) 514 518 515 519 %update list of recent files in the menubar … … 550 554 fileinput_1=get(handles.MenuFile_1_1,'Label'); 551 555 set(handles.SubField,'Value',1) 552 display_file_name(h Object,eventdata,handles,fileinput_1,2)556 display_file_name(handles,fileinput_1,2) 553 557 554 558 % ----------------------------------------------------------------------- … … 558 562 fileinput_1=get(handles.MenuFile_2_1,'Label'); 559 563 set(handles.SubField,'Value',1) 560 display_file_name(h Object,eventdata,handles,fileinput_1,2)564 display_file_name(handles,fileinput_1,2) 561 565 562 566 % ----------------------------------------------------------------------- … … 566 570 fileinput_1=get(handles.MenuFile_3_1,'Label'); 567 571 set(handles.SubField,'Value',1) 568 display_file_name(h Object,eventdata,handles,fileinput_1,2)572 display_file_name(handles,fileinput_1,2) 569 573 570 574 % ----------------------------------------------------------------------- … … 574 578 fileinput_1=get(handles.MenuFile_4_1,'Label'); 575 579 set(handles.SubField,'Value',1) 576 display_file_name(h Object,eventdata,handles,fileinput_1,2)580 display_file_name(handles,fileinput_1,2) 577 581 578 582 % ----------------------------------------------------------------------- … … 582 586 fileinput_1=get(handles.MenuFile_5_1,'Label'); 583 587 set(handles.SubField,'Value',1) 584 display_file_name(h Object,eventdata,handles,fileinput_1,2)588 display_file_name(handles,fileinput_1,2) 585 589 586 590 %------------------------------------------------------------------------ … … 593 597 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); 594 598 % initiate the input file series and refresh the current field view: 595 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject );599 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,1); 596 600 597 601 %----------------------------------------------------------------------- … … 674 678 %------------------------------------------------------------------------ 675 679 % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput' 676 function display_file_name(h Object, eventdata, handles,fileinput,index)680 function display_file_name(handles,fileinput,index) 677 681 %------------------------------------------------------------------------ 678 682 %% look for the input file existence … … 687 691 drawnow 688 692 689 %% define the relevant handles for the first fiel series (index=1) or the second file series (index=2)693 %% define the relevant handles for the first field series (index=1) or the second file series (index=2) 690 694 if ~exist('index','var') 691 695 index=1; … … 698 702 handles_NomType=handles.NomType; 699 703 handles_FileExt=handles.FileExt; 700 % handles_Fields=handles.Fields;701 704 elseif index==2 702 705 handles_RootPath=handles.RootPath_1; … … 706 709 handles_NomType=handles.NomType_1; 707 710 handles_FileExt=handles.FileExt_1; 708 % handles_Fields=handles.Fields_1;709 711 set(handles.RootPath_1,'Visible','on') 710 712 set(handles.RootFile_1,'Visible','on') … … 782 784 else 783 785 set(handles.SubField,'Value',0) 784 SubField_Callback( hObject, eventdata, handles)786 SubField_Callback([], [], handles) 785 787 end 786 788 end … … 1132 1134 end 1133 1135 1134 %% update list of recent files in the menubar 1136 %% update list of recent files in the menubar and save it for future opening 1135 1137 MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... 1136 1138 {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; … … 2961 2963 end 2962 2964 % display the selected field and related information 2963 display_file_name(h Object, eventdata, handles,imagename)%display the image2965 display_file_name(handles,imagename)%display the image 2964 2966 return 2965 2967 else … … 2973 2975 filename=[PathName FileName]; 2974 2976 % display the selected field and related information 2975 display_file_name( hObject, eventdata,handles,filename)2977 display_file_name( handles,filename) 2976 2978 return 2977 2979 end … … 3068 3070 set(handles.num_Npx,'Visible','on') 3069 3071 set(handles.num_Npy,'Visible','on') 3070 display_file_name(h Object, eventdata, handles,imagename,2)%display the imag3072 display_file_name(handles,imagename,2)%display the imag 3071 3073 end 3072 3074 otherwise … … 4332 4334 if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh) 4333 4335 data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; 4334 data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; 4336 if strcmp(data.Type,'line')||rcmp(data.Type,'polyline') 4337 data.RangeY=UvData.Field.Mesh; 4338 else 4339 data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; 4340 end 4335 4341 data.DX=UvData.Field.Mesh; 4336 4342 data.DY=UvData.Field.Mesh; 4343 4337 4344 % elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image 4338 4345 % np=size(Field.A); -
trunk/src/view_field.m
r405 r406 87 87 set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function 88 88 set(hObject,'WindowButtonUpFcn',{'mouse_up',handles_mouse}) 89 set(hObject,' CloseRequestFcn',{@closefcn})%89 set(hObject,'DeleteFcn',{@closefcn})% 90 90 ViewFieldData.axes3=[];%initiates the record of the current field (will be updated by plot_field) 91 91 set(handles.view_field,'UserData',ViewFieldData);%store the current field
Note: See TracChangeset
for help on using the changeset viewer.