Changeset 1180 for trunk/src/uvmat.m
- Timestamp:
- Mar 27, 2025, 5:59:21 PM (3 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uvmat.m
r1179 r1180 517 517 end 518 518 end 519 520 521 522 % -----------------------------------------------------------------------523 % --- Executes on the menu Open/Browse campaign...524 % --- search the file inside a campaign, using the GUI browse_data525 % -----------------------------------------------------------------------526 function MenuBrowseCampaign_Callback(hObject, eventdata, handles)527 % set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0])528 % drawnow529 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);530 DataSeries=fullfile(RootPath,SubDir);531 if isempty(DataSeries) %loads the previously stored file name and set it as default in the file_input box532 DataSeries=get(handles.RootPath,'UserData');533 end534 OutPut=browse_data(DataSeries,'on');% open the GUI browse_data to get select a campaign dir, experiment and device535 if ~isfield(OutPut,'Campaign')536 return537 end538 DataSeries=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});539 fileinput=uigetfile_uvmat('pick an input file',DataSeries);540 hh=dir(fileinput);541 if numel(hh)>1542 msgbox_uvmat('ERROR','invalid input, probably a broken link');543 return544 end545 546 %% update the list of campaigns in the menubar547 MenuCampaign=[{get(handles.MenuCampaign_1,'Label')};{get(handles.MenuCampaign_2,'Label')};...548 {get(handles.MenuCampaign_3,'Label')};{get(handles.MenuCampaign_4,'Label')};{get(handles.MenuCampaign_5,'Label')}];549 check_dir=isempty(find(strcmp(DataSeries,MenuCampaign)));550 if check_dir %insert the new campaign in the list if it is not found551 MenuCampaign(end)=[]; %suppress the last item552 MenuCampaign=[{DataSeries};MenuCampaign];%insert the new campaign553 for ilist=1:numel(MenuCampaign)554 set(handles.(['MenuCampaign_' num2str(ilist)]),'Label',MenuCampaign{ilist})555 end556 % save the list for future opening:557 dir_perso=prefdir;558 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');559 if exist(profil_perso,'file')560 save (profil_perso,'MenuCampaign','RootPath','-append'); %store the file names for future opening of uvmat561 else562 save (profil_perso,'MenuCampaign','RootPath','-V6'); %store the file names for future opening of uvmat563 end564 end565 566 %% display the selected field and related information567 %display_file_name( handles,fullfile(DirName,FileName))568 display_file_name( handles,fileinput)569 set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])570 571 % -----------------------------------------------------------------------572 % --- Open again as second field the file whose name has been recorded in MenuFile_1573 % -----------------------------------------------------------------------574 function MenuCampaign_Callback(hObject, eventdata, handles)575 576 set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0])577 OutPut=browse_data(get(hObject,'Label'),'on');% open the GUI browse_data to get select a campaign dir, experiment and device578 if isfield(OutPut,'Campaign')579 fileinput=uigetfile_uvmat('pick an input file',fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1}));580 hh=dir(fileinput);581 if numel(hh)>1582 msgbox_uvmat('ERROR','invalid input, probably a broken link');583 else584 display_file_name(handles,fileinput)585 end586 end587 set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])588 589 519 590 520 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 1169 1099 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1170 1100 %------------------------------------------------------------------------ 1101 function MenuRuler_Callback(hObject, eventdata, handles) 1102 %------------------------------------------------------------------------ 1103 if strcmp(get(handles.MenuRuler,'checked'),'on') 1104 set(handles.MenuRuler,'checked','off')%desactivate if activated 1105 else 1106 set(handles.MenuRuler,'checked','on')%activate if selected 1107 set(handles.CheckZoom,'Value',0) 1108 CheckZoom_Callback(handles.uvmat, [], handles) 1109 UvData=get(handles.uvmat,'UserData'); 1110 UvData.MouseAction='ruler'; 1111 set(handles.uvmat,'UserData',UvData); 1112 end 1113 1114 %------------------------------------------------------------------------ 1171 1115 function MenuCalib_Callback(hObject, eventdata, handles) 1172 1116 %------------------------------------------------------------------------ … … 1995 1939 set_grid(FileName,UvData.Field);% call the set_object interface 1996 1940 1997 1998 %------------------------------------------------------------------------ 1999 function MenuRuler_Callback(hObject, eventdata, handles) 2000 %------------------------------------------------------------------------ 2001 if strcmp(get(handles.MenuRuler,'checked'),'on') 2002 set(handles.MenuRuler,'checked','off')%desactivate if activated 2003 else 2004 set(handles.MenuRuler,'checked','on')%activate if selected 2005 set(handles.CheckZoom,'Value',0) 2006 CheckZoom_Callback(handles.uvmat, [], handles) 2007 UvData=get(handles.uvmat,'UserData'); 2008 UvData.MouseAction='ruler'; 2009 set(handles.uvmat,'UserData',UvData); 1941 %------------------------------------------------------------------------ 1942 %-- introduce a section FileSeries in the xml file ImaDoc to virtually relabel frames 1943 % -------------------------------------------------------------------- 1944 function MenuRelabelFrames_Callback(hObject, eventdata, handles) 1945 1946 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); 1947 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; 1948 CheckAbort=false; 1949 if strcmp(get(handles.MenuRelabelFrames,'checked'),'off')% if the option is selected 1950 if strcmp(FileExt,'.tif') && ~isempty(regexp(RootFile,'^im', 'once'))% case of PCO images, document <FileSeries> in the xml file 1951 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; 1952 FileInfo=get_file_info(FileName); 1953 XmlFile=fullfile(RootPath,[SubDir '.xml']); 1954 [XmlData,errormsg]=imadoc2struct(XmlFile); 1955 if ~isempty(errormsg) 1956 disp(['a file ' XmlFile ' is needed to document the timing']) 1957 CheckAbort=true; 1958 elseif ~isfield(XmlData,'FileSeries')% fill the FleSeries if does not exist 1959 FileSeries.Convention='PCO'; 1960 FileSeries.FileName{1,1}='im.tif'; 1961 FileSeries.FileName{2,1}='im@0001.tif'; 1962 FileSeries.NbFramePerFile=FileInfo.NumberOfFrames; 1963 [checkupdate,xmlfile,errormsg]=update_imadoc(RootPath,SubDir,'FileSeries',FileSeries); 1964 if isempty(errormsg) 1965 disp([xmlfile 'updated with FileSeries']) 1966 else 1967 disp(errormsg) 1968 CheckAbort=true; 1969 end 1970 end 1971 end 1972 if ~CheckAbort 1973 set(handles.MenuRelabelFrames,'checked','on') 1974 end 1975 else 1976 set(handles.MenuRelabelFrames,'checked','off')%if the option was chcked, uncheck it 1977 end 1978 if ~CheckAbort 1979 errormsg=display_file_name(handles,FileName,1); 1980 if ~isempty(errormsg) 1981 disp(errormsg) 1982 end 2010 1983 end 2011 1984 … … 2015 1988 2016 1989 %------------------------------------------------------------------------ 2017 % open the GUI 'series' 1990 % open the GUI 'series' with the current file series as input 2018 1991 function MenuRun1_Callback(hObject, eventdata, handles) 2019 1992 %------------------------------------------------------------------------ 2020 1993 MenuRun(hObject,handles); 2021 1994 2022 1995 %------------------------------------------------------------------------ 1996 % open the GUI 'series' with the current file series as input 2023 1997 % -------------------------------------------------------------------- 2024 1998 function MenuRun2_Callback(hObject, eventdata, handles) 2025 1999 MenuRun(hObject,handles); 2026 % Param=read_GUI(handles.uvmat); 2027 % Param.HiddenData=get(handles.uvmat,'UserData'); 2028 % hseries=series(Param); 2029 % hhseries=guidata(hseries); 2030 % ActionMenu=get(hhseries.ActionName,'String'); 2031 % index_action=find(strcmp('civ_series',ActionMenu)); 2032 % set(hhseries.ActionName,'Value',index_action); 2033 % series('ActionName_Callback',hObject,eventdata,hhseries); %file input with xml reading in uvmat, show the image in phys coordinates 2034 2000 2001 %------------------------------------------------------------------------ 2002 % open the GUI 'series' with the current file series as input 2035 2003 % -------------------------------------------------------------------- 2036 2004 function MenuRun3_Callback(hObject, eventdata, handles) 2037 2005 MenuRun(hObject,handles); 2038 % Param=read_GUI(handles.uvmat); 2039 % Param.HiddenData=get(handles.uvmat,'UserData'); 2040 % hseries=series(Param); 2041 % hhseries=guidata(hseries); 2042 % ActionMenu=get(hhseries.ActionName,'String'); 2043 % index_action=find(strcmp('test_filter_tps',ActionMenu)); 2044 % set(hhseries.ActionName,'Value',index_action); 2045 % series('ActionName_Callback',hObject,eventdata,hhseries); %file input with xml reading in uvmat, show the image in phys coordinates 2046 2006 2007 %------------------------------------------------------------------------ 2008 % open the GUI 'series' with the current file series as input 2009 % -------------------------------------------------------------------- 2047 2010 function MenuRun(hObject,handles) 2048 2011 Param=read_GUI(handles.uvmat); … … 2311 2274 elseif isfield(FileInfo,'VolumeScan') 2312 2275 Mask.VolumeScan=FileInfo.VolumeScan; 2313 end2314 set(handles.CheckMask,'UserData', Mask)2276 end 2277 set(handles.CheckMask,'UserData', Mask) 2315 2278 else 2316 2279 set(handles.CheckMask,'Value',0) 2317 2280 CheckMask_Callback(handles.CheckMask, [], handles) 2318 end2281 end 2319 2282 else %read the current field index to synchronise with the first series 2320 2283 i1_s=str2double(get(handles.i1,'String')); … … 2419 2382 set(handles.FixVelType,'Value',0); %desactivate fixed veltype by default 2420 2383 2421 %% look for the xml file and read it2422 XmlFileName=find_imadoc(RootPath,SubDir); 2384 %% look for the ImaDoc xml file and read it 2385 XmlFileName=find_imadoc(RootPath,SubDir);% search the appropriate ImaDoc xml file 2423 2386 [~,XmlName]=fileparts(XmlFileName); 2424 2387 warntext='';%default warning message 2425 2388 NbSlice=1;%default 2426 %CheckImaDoc=false;2427 2389 TimeUnit='';%default 2428 2390 TimeName='';%default 2429 CheckIndexing=false;%default2430 2391 XmlData=[]; 2431 if isempty(XmlFileName) 2392 if isempty(XmlFileName) %no ImaDoc xml file detected 2432 2393 set(handles.view_xml,'Visible','off') 2433 2394 else … … 2441 2402 end 2442 2403 if ~isempty(XmlData) 2443 %CheckImaDoc=true;2444 2404 if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit) 2445 2405 TimeUnit=XmlData.TimeUnit; 2446 2406 end 2447 2407 if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) 2448 TimeName='xml';% 2449 if XmlData.Time(1,:)==XmlData.Time(2,:)% case starting with index 1 2450 sizDti=size(XmlData.Time,1)-1;%size of the time vector explicitly defined in the xml file 2451 ind_start=1; 2452 else 2453 sizDti=size(XmlData.Time,1);% case starting with index 0 2454 ind_start=0; 2455 end 2456 if isfield(XmlData,'FileSeries') 2457 if strcmp(XmlName,SubDir)% frame indexing documented from the xml file (case PCO) 2458 CheckIndexing=true; 2459 else 2460 XmlData=rmfield(XmlData,'FileSeries');%desactivate file indexing option for derived file series 2461 end 2408 TimeName='xml';%Time possibly documented by the xml file (but priority to the opened file if available) 2409 % if XmlData.Time(1,:)==XmlData.Time(2,:)% case starting with index 1 2410 % sizDti=size(XmlData.Time,1)-1;%size of the time vector explicitly defined in the xml file 2411 % ind_start=1; 2412 % else 2413 % sizDti=size(XmlData.Time,1);% case starting with index 0 2414 % ind_start=0; 2415 % end 2416 if isfield(XmlData,'FileSeries')&& ~strcmp(XmlName,SubDir) 2417 XmlData=rmfield(XmlData,'FileSeries');%desactivate file indexing option for derived file series (e.g. images.png) 2462 2418 end 2463 2419 end … … 2470 2426 end 2471 2427 end 2428 XmlData.FileInfo=FileInfo; 2472 2429 2473 2430 %% get the file series 2474 2431 MovieObject=[]; 2475 if strcmp(TimeName,'xml') && strcmp(XmlName,SubDir)% get the image series info from the xml file 2476 [nbfield,nbfield_j]=size(XmlData.Time); 2477 nbfield=nbfield-1; %remove the possible index 0 2478 nbfield_j=nbfield_j-1; %remove the possible index 0 2432 if strcmp(get(handles.MenuRelabelFrames,'checked'),'on') && isfield(XmlData,'FileSeries') && isfield(XmlData.FileSeries,'FileName') 2433 CheckIndexing=true; 2434 NomType='*'; 2435 i1_series=[]; 2436 i2_series=[]; 2437 j1_series=[]; 2438 j2_series=[]; 2439 nbfield=[]; 2440 nbfield_j=[]; 2441 2442 % if iscell(XmlData.FileSeries.FileName) 2443 % [RootPath,SubDir,RootFile,i1,i2,j1,j2,Ext,NomType]=fileparts_uvmat(XmlData.FileSeries.FileName{1}); 2444 % else 2445 % [RootPath,SubDir,RootFile,i1,i2,j1,j2,Ext,NomType]=fileparts_uvmat(XmlData.FileSeries.FileName); 2446 % end 2447 if strcmp(TimeName,'xml') %&& CheckIndexing% get the image series info from the xml file 2448 [nbfield,nbfield_j]=size(XmlData.Time); 2449 nbfield=nbfield-1; %remove the possible index 0 2450 nbfield_j=nbfield_j-1; %remove the possible index 0 2479 2451 i1_series=zeros(nbfield,nbfield_j,1); 2480 i1_series(:,:,1)=(1:nbfield)'*ones(1,nbfield_j); 2481 i2_series=i1_series; 2482 if nbfield_j==1 2483 j1_series=[]; 2484 else 2485 j1_series(:,:,1)=ones(nbfield,1)*(1:nbfield_j); 2486 end 2487 j2_series=j1_series; 2488 else % scan the input folder to get the list of existing files 2489 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1,i2,j1,j2]=... 2452 i1_series(:,:,1)=(1:nbfield)'*ones(1,nbfield_j); 2453 i2_series=i1_series; 2454 if nbfield_j==1 2455 j1_series=[]; 2456 else 2457 j1_series(:,:,1)=ones(nbfield,1)*(1:nbfield_j); 2458 end 2459 j2_series=j1_series; 2460 end 2461 set(handles.i1,'String','1') 2462 set(handles.j1,'String','1') 2463 else % scan the input folder to get the list of existing files and NomType 2464 CheckIndexing=false; 2465 [~,~,~,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject]=... 2490 2466 find_file_series(fullfile(RootPath,SubDir),FileName); 2491 2467 nbfield=max(max(max(i2_series)));% total number of fields (i index) … … 2497 2473 nbfield_j=max(max(max(j1_series))); 2498 2474 end 2499 if input_line==1 2475 if ~isempty(j1_series)&& ~strcmp(NomType,'*')% the j index is used to label the frame in multimage series 2476 set(handles.j1,'String','1') 2477 end 2478 end 2479 if input_line==1 2500 2480 set(handles.NomType,'String',NomType) 2501 2502 2503 2504 end 2505 if CheckIndexing 2506 i1=str2double(get(handles.FileIndex,'String')); 2507 if isnan(i1) 2508 i1=1; 2509 else 2510 i1=(i1-XmlData.FileSeries.FirstFileIndex)*XmlData.FileSeries.NbFramePerFile+1;%frame index deduced from input file index 2511 end 2512 if strcmp(TimeName,'xml')% indices i and j 2513 j1=mod(i1-1,nbfield_j)+1;2514 i1=floor((i1-1)/nbfield_j)+1; 2515 set(handles.j1,'String',num2str(j1)) 2516 end 2517 set(handles.i1,'String',num2str(i1)) 2518 end2481 else 2482 set(handles.NomType_1,'String',NomType) 2483 end 2484 % if CheckIndexing 2485 % % i1=str2double(get(handles.FileIndex,'String')); 2486 % % if isnan(i1) 2487 % % i1=1; 2488 % % else 2489 % % i1=(i1-XmlData.FileSeries.FirstFileIndex)*XmlData.FileSeries.NbFramePerFile+1;%frame index deduced from input file index 2490 % % end 2491 % % if strcmp(TimeName,'xml')% indices i and j 2492 % % j1=mod(i1-1,nbfield_j)+1; 2493 % % i1=floor((i1-1)/nbfield_j)+1; 2494 % % set(handles.j1,'String',num2str(j1)) 2495 % % end 2496 % % set(handles.i1,'String',num2str(i1)) 2497 % 2498 % end 2519 2499 2520 2500 … … 2534 2514 %% read timing and total frame number from the current file (e.g. movie files) 2535 2515 ColorType='falsecolor'; %default 2536 if isfield(FileInfo,'FrameRate')% frame rate given in the file (case of video data)2516 if ~CheckIndexing && isfield(FileInfo,'FrameRate')% frame rate given in the file (case of video data) 2537 2517 TimeUnit='s'; 2538 2518 if isempty(j1_series) %frame index along i … … 2562 2542 %% read parameters (time, geometric calibration..) from a documentation file (.xml advised) 2563 2543 %XmlData.GeometryCalib=[];%default 2564 if input_line==12565 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);2566 else2567 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);2568 end2544 % if input_line==1 2545 % [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 2546 % else 2547 % [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); 2548 % end 2569 2549 2570 2550 %% Define timing … … 2629 2609 set(handles.TransformName,'Value',3); % phys transform by default if fixedLimits is off 2630 2610 end 2631 if isfield(XmlData .Slice,'SliceCoord')2611 if isfield(XmlData,'Slice') && isfield(XmlData.Slice,'SliceCoord') 2632 2612 siz=size(XmlData.Slice.SliceCoord); 2633 2613 if siz(1)>1 … … 3262 3242 set(handles.CheckFixPair,'Value',0) 3263 3243 end 3264 CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&& isempty(j2));3244 %CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&& isempty(j2)); 3265 3245 3266 3246 % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected) … … 3441 3421 if strcmp(NomType,'level') 3442 3422 indices=num2str(i1); 3443 elseif isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'FileSeries')3423 elseif strcmp(get(handles.MenuRelabelFrames,'Checked'),'on') && isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'FileSeries') 3444 3424 NbField_j_cell=get(handles.MaxIndex_j,'String'); 3445 3425 NbField_j=str2double(NbField_j_cell{1}); 3446 [RootFile,indices,FrameIndex]=index2filename(UvData.XmlData{1}.FileSeries,i1,j1,NbField_j); 3426 [RootFile,FrameIndex]=index2filename(UvData.XmlData{1}.FileSeries,i1,j1,NbField_j); 3427 [~,RootFile]=fileparts(RootFile);%suppress the file extension 3447 3428 set(handles.RootFile,'String',RootFile) 3429 indices=''; 3448 3430 else 3449 3431 indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); … … 3651 3633 return 3652 3634 end 3653 [F NameMulti,FileIndexString,frame_index]=index2filename(UvData.XmlData{1}.FileSeries,num_i1,num_j1,NbField_j);3654 FileName=fullfile(RootName, [FNameMulti FileIndexString Ext]);3635 [FileName,frame_index]=index2filename(UvData.XmlData{1}.FileSeries,num_i1,num_j1,NbField_j); 3636 FileName=fullfile(RootName,FileName); 3655 3637 end 3656 3638 switch UvData.FileInfo{1}.FieldType … … 3871 3853 set(handles.VelType_1,'String',[{''};menu]) 3872 3854 else 3873 3855 set(handles.VelType_1,'Visible','off') 3874 3856 end 3875 3857 % update the second field menu: the same quantity … … 3894 3876 end 3895 3877 3896 %% display time value of the current fi le3878 %% display time value of the current field 3897 3879 abstime=[];%default inputs 3898 3880 dt=[]; … … 3903 3885 TimeName=get(handles.TimeName,'String'); 3904 3886 3905 % time from xml file or video movie 3906 if strcmp(TimeName,'xml')||strcmp(TimeName,'video') 3907 if isempty(num_i2)||isnan(num_i2) 3908 num_i2=num_i1; 3909 end 3910 if isempty(num_j1)||isnan(num_j1) 3911 num_j1=1; 3912 end 3913 if isempty(num_j2)||isnan(num_j2) 3914 num_j2=num_j1; 3915 end 3916 siz=size(UvData.XmlData{1}.Time); 3917 if ~isempty(num_i1)&& ~isempty(num_i2) && num_i1>=0 &&siz(1)>=max(num_i1+1,num_i2+1) && siz(2)>=max(num_j1+1,num_j2+1) 3918 abstime=(UvData.XmlData{1}.Time(num_i1+1,num_j1+1)+UvData.XmlData{1}.Time(num_i2+1,num_j2+1))/2;%overset the time read from files 3919 dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1)); 3920 Field{1}.Dt=dt; 3921 if isfield(UvData.XmlData{1},'TimeUnit') 3922 TimeUnit=UvData.XmlData{1}.TimeUnit; 3923 end 3924 end 3925 end 3926 3927 % time in the input file, not defined in a xml file or movie 3928 if isempty(abstime) 3929 if (strcmp(TimeName,'civdata')||strcmp(TimeName,'civx')||strcmp(TimeName,'timestamp'))&&isfield(Field{1},'Time') 3930 abstime=Field{1}.Time; 3931 elseif ~isempty(regexp(TimeName,'^att:', 'once')) 3932 abstime=Field{1}.(TimeName(5:end));%the time is an attribute selected by get_file 3933 if isfield(Field{1},[TimeName(5:end) 'Unit']) 3934 TimeUnit=Field{1}.([TimeName(5:end) 'Unit']); 3887 switch TimeName 3888 case 'xml' % time from ImaDoc xml file 3889 if isempty(num_i2)||isnan(num_i2) 3890 num_i2=num_i1; 3891 end 3892 if isempty(num_j1)||isnan(num_j1) 3893 num_j1=1; 3894 end 3895 if isempty(num_j2)||isnan(num_j2) 3896 num_j2=num_j1; 3897 end 3898 siz=size(UvData.XmlData{1}.Time); 3899 if ~isempty(num_i1)&& ~isempty(num_i2) && num_i1>=0 &&siz(1)>=max(num_i1+1,num_i2+1) && siz(2)>=max(num_j1+1,num_j2+1) 3900 abstime=(UvData.XmlData{1}.Time(num_i1+1,num_j1+1)+UvData.XmlData{1}.Time(num_i2+1,num_j2+1))/2;%overset the time read from files 3901 dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1)); 3902 Field{1}.Dt=dt; 3903 if isfield(UvData.XmlData{1},'TimeUnit') 3904 TimeUnit=UvData.XmlData{1}.TimeUnit; 3905 end 3906 end 3907 3908 case 'video'% time obtained from the frame rate in video file 3909 if isempty(num_i2)% single video record with frame index num_i1 3910 abstime=num_i1/UvData.XmlData{1}.FileInfo.FrameRate; 3935 3911 else 3936 TimeUnit=''; 3937 end 3938 elseif ~isempty(regexp(TimeName,'^var:', 'once')) 3939 abstime=Field{1}.(TimeName(5:end));%the time is a variale selected by get_file 3940 % TODO: look for time unit attribute 3941 elseif ~isempty(regexp(TimeName,'^dim:')) 3942 abstime=str2double(get(handles.i1,'String')); 3943 TimeUnit='index'; 3944 end 3945 if isfield(Field{1},'Dt') 3946 dt=Field{1}.Dt;%dt read from the netcdf input file 3947 elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first 3948 dt=Field{2}.Dt;%dt read from the netcdf input file 3949 end 3912 abstime=num_i2/UvData.XmlData{1}.FileInfo.FrameRate;% set of video records with frame index num_i2 3913 end 3914 TimeUnit='s'; 3915 3916 otherwise % time sought in the input file 3917 if (strcmp(TimeName,'civdata')||strcmp(TimeName,'civx')||strcmp(TimeName,'timestamp'))&&isfield(Field{1},'Time') 3918 abstime=Field{1}.Time; 3919 elseif ~isempty(regexp(TimeName,'^att:', 'once')) 3920 abstime=Field{1}.(TimeName(5:end));%the time is an attribute selected by get_file 3921 if isfield(Field{1},[TimeName(5:end) 'Unit']) 3922 TimeUnit=Field{1}.([TimeName(5:end) 'Unit']); 3923 else 3924 TimeUnit=''; 3925 end 3926 elseif ~isempty(regexp(TimeName,'^var:', 'once')) 3927 abstime=Field{1}.(TimeName(5:end));%the time is a variale selected by get_file 3928 % TODO: look for time unit attribute 3929 elseif ~isempty(regexp(TimeName,'^dim:', 'once')) 3930 abstime=str2double(get(handles.i1,'String')); 3931 TimeUnit='index'; 3932 end 3933 if isfield(Field{1},'Dt') 3934 dt=Field{1}.Dt;%dt read from the netcdf input file 3935 elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first 3936 dt=Field{2}.Dt;%dt read from the netcdf input file 3937 end 3950 3938 end 3951 3939 set(handles.TimeValue,'String',num2str(abstime)) … … 6249 6237 6250 6238 6239 6240
Note: See TracChangeset
for help on using the changeset viewer.