Changeset 615 for trunk/src/uvmat.m


Ignore:
Timestamp:
Apr 23, 2013, 4:22:08 PM (12 years ago)
Author:
sommeria
Message:

a few bugs repaired

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r611 r615  
    850850TimeUnit='';%default
    851851Time=[];
    852 % testima=0; %test for image input
    853852imainfo=[];
    854853ColorType='falsecolor'; %default
    855 % hhh=[];
    856854UvData.MovieObject{index}=VideoObject;
    857855if ~isempty(VideoObject)
    858856    imainfo=get(VideoObject);
    859 %     testima=1;
    860857    TimeUnit='s';
    861858    if isempty(j1_series); %frame index along i
    862         Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
     859        Time=zeros(imainfo.NumberOfFrames+1,2);
     860        Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
    863861    else
    864         Time=ones(size(i1_series,1),1)*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
     862        Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
    865863    end
    866864    set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
     
    20302028
    20312029%% initialisation
    2032 abstime=[];
    2033 abstime_1=[];
    2034 dt=[];
    20352030if ~exist('Field','var')
    20362031    Field={};
     
    23502345
    23512346%% display time
    2352 testimedoc=0;
     2347abstime=[];%default inputs
     2348abstime_1=[];
     2349dt=[];
    23532350TimeUnit='';
    2354 if isfield(Field{1},'Time')
    2355     abstime=Field{1}.Time;%time read from the netcdf input file
    2356 end
    2357 if numel(Field)==2 && isfield(Field{2},'Time')
    2358     abstime_1=Field{2}.Time;%time read from the netcdf input file
    2359 end
    2360 if isfield(Field{1},'Dt')
    2361     dt=Field{1}.Dt;%dt read from the netcdf input file
    2362     if isfield(Field{1},'TimeUnit')
    2363        TimeUnit=Field{1}.TimeUnit;
    2364     end
    2365 elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first
    2366     dt=Field{2}.Dt;%dt read from the netcdf input file
    2367     if isfield(Field{2},'TimeUnit')
    2368        TimeUnit=Field{2}.TimeUnit;
    2369     end
    2370 end
    2371 % time from xml file overset previous result
     2351% time from xml file or video movie
    23722352if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time')
    23732353    if isempty(num_i2)||isnan(num_i2)
     
    23812361    end
    23822362    siz=size(UvData.XmlData{1}.Time);
    2383     if ~isempty(num_i1)&& ~isempty(num_i2) && num_i1>=0 &&siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
     2363    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)
    23842364        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
    23852365        dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1));
     
    24002380        end
    24012381        siz=size(UvData.XmlData{2}.Time);
    2402         if ~isempty(i1_1) && siz(1)>=max(i1_1,i2_1) && siz(2)>=max(j1_1,j2_1)
    2403             abstime_1=(UvData.XmlData{2}.Time(i1_1,j1_1)+UvData.XmlData{2}.Time(i2_1,j2_1))/2;%overset the time read from files
    2404             Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1,j2_1)-UvData.XmlData{2}.Time(i1_1,j1_1));
    2405         end
    2406     end
    2407 end
    2408 if ~isequal(numel(abstime),1)
    2409     abstime=[];
    2410 end
    2411 if ~isequal(numel(abstime_1),1)
    2412       abstime_1=[];
    2413 end 
     2382        if ~isempty(i1_1) && siz(1)>=max(i1_1+1,i2_1+1) && siz(2)>=max(j1_1+1,j2_1+1)
     2383            abstime_1=(UvData.XmlData{2}.Time(i1_1+1,j1_1+1)+UvData.XmlData{2}.Time(i2_1+1,j2_1+1))/2;%overset the time read from files
     2384            Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1+1,j2_1+1)-UvData.XmlData{2}.Time(i1_1+1,j1_1+1));
     2385        end
     2386    end
     2387end
     2388% if isfield(Field{1},'Time')
     2389%     abstime=Field{1}.Time;%time read from the netcdf input file
     2390% end
     2391% if numel(Field)==2 && isfield(Field{2},'Time')
     2392%     abstime_1=Field{2}.Time;%time read from the netcdf input file
     2393% end
     2394
     2395% look for timing in the input file if not defined in a xml file or movie
     2396if isempty(abstime)
     2397if isfield(Field{1},'Dt')
     2398    dt=Field{1}.Dt;%dt read from the netcdf input file
     2399    if isfield(Field{1},'TimeUnit')
     2400       TimeUnit=Field{1}.TimeUnit;
     2401    end
     2402elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first
     2403    dt=Field{2}.Dt;%dt read from the netcdf input file
     2404    if isfield(Field{2},'TimeUnit')
     2405       TimeUnit=Field{2}.TimeUnit;
     2406    end
     2407end
     2408end
     2409% if ~isequal(numel(abstime),1)
     2410%     abstime=[];
     2411% end
     2412% if ~isequal(numel(abstime_1),1)
     2413%       abstime_1=[];
     2414% end 
    24142415set(handles.abs_time,'String',num2str(abstime,5))
    24152416set(handles.abs_time_1,'String',num2str(abstime_1,5))
Note: See TracChangeset for help on using the changeset viewer.