Changeset 494 for trunk/src/uvmat.m
- Timestamp:
- Jul 19, 2012, 11:50:39 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uvmat.m
r491 r494 859 859 XmlData.Time=[];%default 860 860 XmlData.GeometryCalib=[];%default 861 TimeUnit=[];%default 861 TimeUnit='';%default 862 Time=[]; 862 863 testima=0; %test for image input 863 864 imainfo=[]; … … 870 871 % nbfield_j=1; 871 872 TimeUnit='s'; 872 XmlData.Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)'; 873 if isempty(j1_series); %frame index along i 874 Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)'; 875 else 876 Time=ones(size(i1_series,1),1)*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate); 877 end 873 878 %nbfield=imainfo.NumberOfFrames; 874 879 set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec … … 945 950 end 946 951 end 952 end 953 if ~(isfield(XmlData,'Time')&& ~isempty(XmlData.Time)) 954 XmlData.Time=Time; %time set by video 947 955 end 948 956 … … 1063 1071 if index==2 1064 1072 if get(handles.scan_j,'Value') 1065 scan_option='j'; %keep the scan option for the second fi elseries1073 scan_option='j'; %keep the scan option for the second file series 1066 1074 end 1067 1075 if strcmp(get(handles.j1,'Visible'),'on') … … 1069 1077 end 1070 1078 end 1079 [ref_i,ref_j]=find(i1_series); 1071 1080 if ~isempty(j1_series) 1072 1081 state_j='on'; 1073 if isequal(nbfield,1) &&index==1 1074 scan_option='j'; %scan j index by default if nbfield=1 1075 end 1082 if index==1 1083 if isequal(ref_i,ref_i(1)*ones(size(ref_j)))% if ref_i is always equal to its first vzlue 1084 scan_option='j'; %scan j indext 1085 end 1086 end 1076 1087 end 1077 1088 if isequal(scan_option,'i') 1089 diff_ref_i=diff(ref_i,1); 1090 if isempty(diff_ref_i) 1091 diff_ref_i=1; 1092 end 1093 if isequal (diff_ref_i,diff_ref_i(1)*ones(size(diff_ref_i))) 1094 set(handles.increment_scan,'String',num2str(diff_ref_i(1))) 1095 end 1078 1096 set(handles.scan_i,'Value',1) 1079 1097 scan_i_Callback([],[], handles); 1080 1098 else 1099 diff_ref_j=diff(ref_j); 1100 if isempty(diff_ref_j) 1101 diff_ref_j=1; 1102 end 1103 if isequal (diff_ref_j,diff_ref_j(1)*ones(size(diff_ref_j))) 1104 set(handles.increment_scan,'String',num2str(diff_ref_j(1))) 1105 end 1081 1106 set(handles.scan_j,'Value',1) 1082 1107 scan_j_Callback([],[], handles); … … 1246 1271 option=get(handles.view_xml,'String'); 1247 1272 if isequal(option,'view .xml') 1248 FileXml=[FileBase '.xml']; 1273 FileXml=fullfile(RootPath,[SubDir '.xml']); 1274 if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir 1275 FileXml=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']); 1276 end 1249 1277 heditxml=editxml(FileXml); 1250 1278 end … … 1256 1284 %case of view mask selection 1257 1285 if isequal(get(handles.CheckMask,'Value'),1) 1258 % [FF,RootPath,FileBase]=read_file_boxes(handles);1259 1286 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 1260 1287 FileBase=fullfile(RootPath,RootFile); … … 1270 1297 maskname=maskfiles(ilist).name;% take the first mask file in the list 1271 1298 [tild,tild,tild,tild,tild,tild,tild,MaskExt,Mask_NomType{ilist}]=fileparts_uvmat(maskname); 1272 % [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);1273 1299 [tild,Name]=fileparts(maskname); 1274 1300 Namedouble=double(Name); … … 1955 1981 end 1956 1982 NomType=get(handles.NomType,'String'); 1983 NomType_1=''; 1984 if strcmp(get(handles.NomType_1,'Visible'),'on') 1985 NomType_1=get(handles.NomType_1,'String'); 1986 end 1957 1987 % NomType=get(handles.FileIndex,'UserData'); 1958 1988 %update the z position index … … 2110 2140 ParamOut_1=UvData.ParamOut_1; 2111 2141 else 2142 if isstruct(ParamIn_1) 2112 2143 ParamIn_1.FieldName=FieldName_1; 2113 2144 ParamIn_1.VelType=VelType_1; 2114 2145 ParamIn_1.GUIName='get_field_1'; 2146 end 2115 2147 [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn_1,frame_index_1); 2116 2148 if ~isempty(errormsg) … … 2174 2206 test_veltype_1=1; 2175 2207 set(handles.VelType_1,'Visible','on') 2176 % if ~get(handles.FixVelType,'Value') 2177 menu=set_veltype_display(ParamOut_1.CivStage); 2178 index_menu=strcmp(ParamOut_1.VelType,menu); 2179 set(handles.VelType_1,'Value',1+find(index_menu,1)) 2180 set(handles.VelType_1,'String',[{''};menu]) 2181 % end 2208 menu=set_veltype_display(ParamOut_1.CivStage); 2209 index_menu=strcmp(ParamOut_1.VelType,menu); 2210 set(handles.VelType_1,'Value',1+find(index_menu,1)) 2211 set(handles.VelType_1,'String',[{''};menu]) 2182 2212 end 2183 2213 % update the second field menu: the same quantity 2214 if isstruct(ParamOut_1) 2184 2215 set(handles.Fields_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu 2185 2216 % display the Fields menu from the input file and pick the selected one: 2186 2217 field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); 2187 2218 set(handles.Fields_1,'Value',find(field_index,1)+1) 2188 % % synchronise with the first menu if the first selection is not 'velocity' 2189 % if ~strcmp(ParamOut.FieldName,'velocity') 2190 % field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); 2191 % set(handles.Fields_1,'Value',field_index); %update the field menu 2192 % ParamOut_1.FieldName=ParamOut.FieldName; 2193 % set(handles.Fields_1,'String',ParamOut_1.FieldList) 2194 % end 2219 end 2220 2195 2221 end 2196 2222 if test_veltype||test_veltype_1 … … 2337 2363 Field{1}=transform(Field{1},XmlData); 2338 2364 end 2339 %% update tps in phys coordinates if needed 2340 if (strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))&& strcmp(UvData.FileType{1},'civdata')&&isfield(Field{1},'U')&& isfield(Field{1},'V') 2341 Field{1}.X=Field{1}.X(Field{1}.FF==0); 2342 Field{1}.Y=Field{1}.Y(Field{1}.FF==0); 2343 Field{1}.U=Field{1}.U(Field{1}.FF==0); 2344 Field{1}.V=Field{1}.V(Field{1}.FF==0); 2345 [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps]=filter_tps([Field{1}.X Field{1}.Y],Field{1}.U,Field{1}.V,[],Field{1}.Patch1_SubDomain,0); 2346 end 2347 if numel(Field)==2 && ~test_keepdata_1 && isequal(UvData.FileType{2}(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1) 2348 %update tps in phys coordinates if needed 2349 if (strcmp(VelType_1,'filter1')||strcmp(VelType_1,'filter2'))&& strcmp(UvData.FileType{2},'civdata')&&isfield(Field{2},'U')&& isfield(Field{2},'V') 2350 Field{2}.X=Field{2}.X(Field{2}.FF==0); 2351 Field{2}.Y=Field{1}.Y(Field{2}.FF==0); 2352 Field{2}.U=Field{1}.U(Field{2}.FF==0); 2353 Field{2}.V=Field{1}.V(Field{2}.FF==0); 2354 [Field{2}.SubRange,Field{2}.NbSites,Field{2}.Coord_tps,Field{2}.U_tps,Field{2}.V_tps]=filter_tps([Field{2}.X Field{2}.Y],Field{2}.U,Field{2}.V,[],1500,0); 2365 2366 %% check whether tps is needed, then calculate tps coefficients if needed 2367 check_tps=0; 2368 if strcmp(UvData.FileType{1},'civdata')|| strcmp(UvData.FileType{1},'civx') 2369 switch ParamOut.FieldName 2370 case {'vort','div','strain'} 2371 check_tps=1; 2372 otherwise 2373 check_tps=0; 2374 if isfield(UvData,'Object') 2375 for iobj=1:numel(UvData.Object) 2376 UvData.Object{iobj} 2377 if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'filter') 2378 check_tps=1; 2379 break 2380 end 2381 end 2382 end 2383 end 2384 end 2385 if check_tps 2386 SubDomain=1500; %default, estimated nbre of vectors in a subdomain used for tps 2387 if isfield(Field{1},'SubDomain') 2388 SubDomain=Field{1}.SubDomain;% 2389 end 2390 [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps,tild,U_smooth,V_smooth,W_smooth,FF] =... 2391 filter_tps([Field{1}.X(Field{1}.FF==0) Field{1}.Y(Field{1}.FF==0)],Field{1}.U(Field{1}.FF==0),Field{1}.V(Field{1}.FF==0),[],SubDomain,0); 2392 nbvar=numel(Field{1}.ListVarName); 2393 Field{1}.ListVarName=[Field{1}.ListVarName {'SubRange','NbSites','Coord_tps','U_tps','V_tps'}]; 2394 Field{1}.VarDimName=[Field{1}.VarDimName {{'nb_coord','nb_bounds','nb_subdomain'},{'nb_subdomain'},... 2395 {'nb_tps','nb_coord','nb_subdomain'},{'nb_tps','nb_subdomain'},{'nb_tps','nb_subdomain'}}]; 2396 Field{1}.VarAttribute{nbvar+3}.Role='coord_tps'; 2397 Field{1}.VarAttribute{nbvar+4}.Role='vector_x'; 2398 Field{1}.VarAttribute{nbvar+5}.Role='vector_y'; 2399 if isfield(Field{1},'ListDimName')%cleaning 2400 Field{1}=rmfield(Field{1},'ListDimName'); 2401 end 2402 if isfield(Field{1},'DimValue')%cleaning 2403 Field{1}=rmfield(Field{1},'DimValue'); 2355 2404 end 2356 2405 end … … 3095 3144 [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); 3096 3145 if isequal(field,'image') 3097 SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' 3098 imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); 3146 if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file 3147 imagename=UvData.Field.Civ2_ImageA; 3148 elseif isfield(UvData.Field,'Civ1_ImageA')% 3149 imagename=UvData.Field.Civ1_ImageA; 3150 else 3151 SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' 3152 imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); 3153 end 3099 3154 if ~exist(imagename,'file') 3100 3155 [FileName,PathName] = uigetfile( ... … … 3199 3254 end 3200 3255 case 'image' 3201 % guess the image name corresponding to the current netcdf name (no unique correspondance) 3202 SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.' 3203 imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1); 3256 % get the image name corresponding to the current netcdf name (no unique correspondance) 3257 if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file 3258 imagename=UvData.Field.Civ2_ImageA; 3259 elseif isfield(UvData.Field,'Civ1_ImageA')% 3260 imagename=UvData.Field.Civ1_ImageA; 3261 else 3262 SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.' 3263 imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1); 3264 end 3204 3265 if ~exist(imagename,'file') % browse for images if it is not found 3205 3266 [FileName,PathName] = uigetfile( ...
Note: See TracChangeset
for help on using the changeset viewer.