Changeset 415 for trunk/src/uvmat.m


Ignore:
Timestamp:
May 9, 2012, 2:20:26 AM (9 years ago)
Author:
sommeria
Message:

bugs corrected: problems with Dt in read_civxdata and uvmat.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r413 r415  
    20452045        set(handles.num_Npy,'String',num2str(ParamOut.Npy));
    20462046    end
    2047     if isfield(ParamOut,'TimeIndex')
     2047    if isfield(ParamOut,'TimeIndex')% case of time obtained from get_field
    20482048        set(handles.i1,'String',num2str(ParamOut.TimeIndex))
    20492049    end
    20502050    if isfield(ParamOut,'TimeValue')
    2051         Field{1}.Time=ParamOut.TimeValue;
     2051        Field{1}.Time=ParamOut.TimeValue;% case of time obtained from get_field
    20522052    end
    20532053end
     
    22182218end           
    22192219
     2220
     2221
     2222%% display time
     2223testimedoc=0;
     2224TimeUnit='';
     2225if isfield(Field{1},'Time')
     2226    abstime=Field{1}.Time;%time read from the netcdf input file
     2227end
     2228if numel(Field)==2 && isfield(Field{2},'Time')
     2229    abstime_1=Field{2}.Time;%time read from the netcdf input file
     2230end
     2231if isfield(Field{1},'Dt')
     2232    dt=Field{1}.Dt;%dt read from the netcdf input file
     2233    if isfield(Field{1},'TimeUnit')
     2234       TimeUnit=Field{1}.TimeUnit;
     2235    end
     2236elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first
     2237    dt=Field{2}.Dt;%dt read from the netcdf input file
     2238    if isfield(Field{2},'TimeUnit')
     2239       TimeUnit=Field{2}.TimeUnit;
     2240    end
     2241end
     2242% time from xml file overset previous result
     2243if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time')
     2244    if isempty(num_i2)||isnan(num_i2)
     2245        num_i2=num_i1;
     2246    end
     2247    if isempty(num_j1)||isnan(num_j1)
     2248        num_j1=1;
     2249    end
     2250    if isempty(num_j2)||isnan(num_j2)
     2251        num_j2=num_j1;
     2252    end
     2253    siz=size(UvData.XmlData{1}.Time);
     2254    if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
     2255        abstime=(UvData.XmlData{1}.Time(num_i1,num_j1)+UvData.XmlData{1}.Time(num_i2,num_j2))/2;%overset the time read from files
     2256        dt=(UvData.XmlData{1}.Time(num_i2,num_j2)-UvData.XmlData{1}.Time(num_i1,num_j1));
     2257        Field{1}.Dt=dt;
     2258        if isfield(UvData.XmlData{1},'TimeUnit')
     2259            TimeUnit=UvData.XmlData{1}.TimeUnit;
     2260        end
     2261    end
     2262    if numel(UvData.XmlData)==2
     2263        [tild,tild,tild,num_i1,num_i2,num_j1,num_j2]=fileparts_uvmat(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
     2264        if isempty(num_i2)
     2265            num_i2=num_i1;
     2266        end
     2267        if isempty(num_j1)
     2268            num_j1=1;
     2269        end
     2270        if isempty(num_j2)
     2271            num_j2=num_j1;
     2272        end
     2273        siz=size(UvData.XmlData{2}.Time);
     2274        if ~isempty(num_i1) && siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
     2275            abstime_1=(UvData.XmlData{2}.Time(num_i1,num_j1)+UvData.XmlData{2}.Time(num_i2,num_j2))/2;%overset the time read from files
     2276            Field{2}.Dt=(UvData.XmlData{2}.Time(num_i2,num_j2)-UvData.XmlData{2}.Time(num_i1,num_j1));
     2277        end
     2278    end
     2279end
     2280if ~isequal(numel(abstime),1)
     2281    abstime=[];
     2282end
     2283if ~isequal(numel(abstime_1),1)
     2284      abstime_1=[];
     2285end 
     2286set(handles.abs_time,'String',num2str(abstime,4))
     2287set(handles.abs_time_1,'String',num2str(abstime_1,4))
     2288% if testimedoc && isfield(UvData,'dt')
     2289%     dt=UvData.dt;
     2290% end
     2291if isempty(dt)||isequal(dt,0)
     2292    set(handles.Dt_txt,'String','')
     2293else
     2294    if  isempty(TimeUnit)
     2295        set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  10^(-3)'] )
     2296    else
     2297        set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  m' TimeUnit] )
     2298    end
     2299end
     2300
     2301
    22202302%% store the current open names, fields and vel types in uvmat interface
    22212303UvData.filename_1=filename_1;
     
    26422724%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    26432725
    2644 %% display time
    2645 testimedoc=0;
    2646 TimeUnit='';
    2647 if isfield(UvData.Field,'Time')
    2648     abstime=UvData.Field.Time;%time read from the netcdf input file
    2649 end
    2650 if isfield(UvData,'Field_1') && isfield(UvData.Field_1,'Time')
    2651     abstime_1=UvData.Field_1.Time;%time read from the netcdf input file
    2652 end
    2653 if isfield(UvData.Field,'dt')
    2654     dt=UvData.Field.dt;%dt read from the netcdf input file
    2655     if isfield(UvData.Field,'TimeUnit')
    2656        TimeUnit=UvData.Field.TimeUnit;
    2657     end
    2658 elseif isfield(UvData,'Field_1') && isfield(UvData.Field_1,'dt')%dt obtained from the second field if not defined in the first
    2659     dt=UvData.Field_1.dt;%dt read from the netcdf input file
    2660     if isfield(UvData.Field_1,'TimeUnit')
    2661        TimeUnit=UvData.Field_1.TimeUnit;
    2662     end
    2663 end
    2664 % time from xml file overset previous result
    2665 if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time')
    2666     if isempty(num_i2)||isnan(num_i2)
    2667         num_i2=num_i1;
    2668     end
    2669     if isempty(num_j1)||isnan(num_j1)
    2670         num_j1=1;
    2671     end
    2672     if isempty(num_j2)||isnan(num_j2)
    2673         num_j2=num_j1;
    2674     end
    2675     siz=size(UvData.XmlData{1}.Time);
    2676     if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
    2677         abstime=(UvData.XmlData{1}.Time(num_i1,num_j1)+UvData.XmlData{1}.Time(num_i2,num_j2))/2;%overset the time read from files
    2678         dt=(UvData.XmlData{1}.Time(num_i2,num_j2)-UvData.XmlData{1}.Time(num_i1,num_j1));
    2679         testimedoc=1;
    2680         if isfield(UvData.XmlData{1},'TimeUnit')
    2681             TimeUnit=UvData.XmlData{1}.TimeUnit;
    2682         end
    2683     end
    2684     if numel(UvData.XmlData)==2
    2685         [tild,tild,tild,num_i1,num_i2,num_j1,num_j2]=fileparts_uvmat(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
    2686         %  [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
    2687         if isempty(num_i2)
    2688             num_i2=num_i1;
    2689         end
    2690         if isempty(num_j1)
    2691             num_j1=1;
    2692         end
    2693         if isempty(num_j2)
    2694             num_j2=num_j1;
    2695         end
    2696         siz=size(UvData.XmlData{2}.Time);
    2697         if ~isempty(num_i1) && siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
    2698             abstime_1=(UvData.XmlData{2}.Time(num_i1,num_j1)+UvData.XmlData{2}.Time(num_i2,num_j2))/2;%overset the time read from files
    2699         end
    2700     end
    2701 end
    2702 
    2703 if ~isequal(numel(abstime),1)
    2704     abstime=[];
    2705 end
    2706 if ~isequal(numel(abstime_1),1)
    2707       abstime_1=[];
    2708 end 
    2709 set(handles.abs_time,'String',num2str(abstime,4))
    2710 set(handles.abs_time_1,'String',num2str(abstime_1,4))
    2711 if testimedoc && isfield(UvData,'dt')
    2712     dt=UvData.dt;
    2713 end
    2714 if isempty(dt)||isequal(dt,0)
    2715     set(handles.Dt_txt,'String','')
    2716 else
    2717     if  isempty(TimeUnit)
    2718         set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  10^(-3)'] )
    2719     else
    2720         set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  m' TimeUnit] )
    2721     end
    2722 end
     2726
    27232727
    27242728
Note: See TracChangeset for help on using the changeset viewer.