Changeset 775


Ignore:
Timestamp:
May 16, 2014, 8:40:58 AM (11 years ago)
Author:
sommeria
Message:

different bug corrections in series (time display for netcdf files)

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_field.m

    r771 r775  
    6666
    6767%% enter input data
    68 if ischar(filename)% input file name
     68if ischar(filename) % input file name
    6969    set(handles.inputfile,'String',filename)% fill the input file name
    70     Field=nc2struct(filename,[]);% reads the  field structure, without the variables
    71 else
    72     'bad input to get_field'
     70    [Field,tild,tild,errormsg]=nc2struct(filename,[]);% reads the  field structure, without the variables
     71else
     72    msgbox_uvmat('ERROR','get_field requires a file name as input')% display error message for input file reading
     73    return
     74end
     75if ~isempty(errormsg)
     76    msgbox_uvmat('ERROR',['get_field/nc2struct/' errormsg])% display error message for input file reading
     77    return
     78end
     79if ~isfield(Field,'ListVarName')
     80    msgbox_uvmat('ERROR',['no variable found in ' filename])% display error message for input file reading
     81    return
    7382end
    7483if ~exist('ParamIn','var')
    7584    ParamIn=[];
    76 end
    77 if isfield(Field,'Txt')
    78     msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])% display error message for input file reading
    79     return
    80 end
    81 if ~isfield(Field,'ListVarName')
    82     return
    8385end
    8486
  • trunk/src/series.m

    r773 r775  
    243243if isfield(Param,'InputFile')
    244244   
    245     InputTable={};
    246245    %% fill the list of file series
    247     SeriesData=Param.HiddenData;
    248246    InputTable=[{Param.InputFile.RootPath},{Param.InputFile.SubDir},{Param.InputFile.RootFile},{Param.InputFile.NomType},{Param.InputFile.FileExt}];
    249     TimeTable=[{[]},{[]},{[]},{[]}];
     247    TimeTable=[{Param.InputFile.TimeName},{[]},{[]},{[]},{[]}];
    250248    if isfield(Param.InputFile,'RootPath_1')
    251249        InputTable=[InputTable;[{Param.InputFile.RootPath_1},{Param.InputFile.SubDir_1},{Param.InputFile.RootFile_1},{Param.InputFile.NomType_1},{Param.InputFile.FileExt_1}]];
    252         TimeTable=[TimeTable; [{[]},{[]},{[]},{[]}]];
     250        TimeTable=[TimeTable; [{Param.InputFile.TimeName_1},{[]},{[]},{[]},{[]}]];
    253251    end
    254252    set(handles.InputTable,'Data',InputTable)
     
    654652    InputTable={'','','','',''};
    655653    InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
    656     set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}])
     654    set(handles.TimeTable,'Data',[{''},{[]},{[]},{[]},{[]}])
    657655    set(handles.MinIndex_i,'Data',[])
    658656    set(handles.MaxIndex_i,'Data',[])
     
    855853end
    856854
    857 %% default time unit
     855%% default time settings
    858856TimeUnit='';
    859857% read  value set by the first series for the append mode (iwiew >1)
     
    861859    TimeUnit=get(handles.TimeUnit,'String');
    862860end
    863 TimeSource='';
     861TimeName='';
    864862Time=[];%default
     863TimeMin=[];
     864TimeFirst=[];
     865TimeLast=[];
     866TimeMax=[];
    865867
    866868%%  read image documentation file if found
     
    875877    % read time if available
    876878    if isfield(XmlData,'Time')
    877         Time=XmlData.Time;
    878         TimeSource='xml';
     879         Time=XmlData.Time;
     880        TimeName='xml';
    879881    end
    880882    if isfield(XmlData,'Camera')
     
    908910end
    909911
    910 %% read timing and total frame number from the current file (movie files) if not already set by the xml file (prioritary)
    911 InputTable=get(handles.InputTable,'Data');
    912 
    913 % case of movies
    914 if isempty(Time)
    915     if ~isempty(VideoObject)
    916         imainfo=get(VideoObject);
    917         if isempty(j1_series); %frame index along i
    918             Time=zeros(imainfo.NumberOfFrames+1,2);
    919             Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
    920         else
    921             Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
    922         end
    923         TimeSource='video';
    924     end
    925 end
    926 
    927 %% update time table
    928 if ~isempty(Time)
    929     TimeTable=get(handles.TimeTable,'Data');
    930     TimeTable{iview,1}=Time(MinIndex_i+1,MinIndex_j+1);
     912%% read timing  from the current file (prioritary)
     913if ~isempty(VideoObject)% case of movies
     914    imainfo=get(VideoObject);
     915    if isempty(j1_series); %frame index along i
     916        Time=zeros(imainfo.NumberOfFrames+1,2);
     917        Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
     918    else
     919        Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
     920    end
     921    TimeName='video';
     922end
     923
     924
     925%% determine the min and max times: case of Netcdf files will be treated later in FieldName_Callback
     926if ~isempty(TimeName)
     927    TimeMin=Time(MinIndex_i+1,MinIndex_j+1);
    931928    if size(Time)>=[first_i+1 first_j+1]
    932         TimeTable{iview,2}=Time(first_i+1,first_j+1);
     929        TimeFirst=Time(first_i+1,first_j+1);
    933930    end
    934931    if size(Time)>=[last_i+1 last_j+1]
    935         TimeTable{iview,3}=Time(last_i+1,last_j+1);
     932        TimeLast=Time(last_i+1,last_j+1);
    936933    end
    937934    if size(Time)>=[MaxIndex_i+1 MaxIndex_j+1];
    938         TimeTable{iview,4}=Time(MaxIndex_i+1,MaxIndex_j+1);
    939     end
    940     set(handles.TimeTable,'Data',TimeTable)
    941 end
     935        TimeMax=Time(MaxIndex_i+1,MaxIndex_j+1);
     936    end
     937end
     938
     939%% update the time table
     940TimeTable=get(handles.TimeTable,'Data');
     941TimeTable{iview,1}=TimeName;
     942TimeTable{iview,2}=TimeMin;
     943TimeTable{iview,3}=TimeFirst;
     944TimeTable{iview,4}=TimeLast;
     945TimeTable{iview,5}=TimeMax;
     946set(handles.TimeTable,'Data',TimeTable)
    942947
    943948%% update the series info in 'UserData'
     
    949954SeriesData.FileInfo{iview}=FileInfo;
    950955SeriesData.Time{iview}=Time;
    951 if ~isempty(TimeSource)
    952     SeriesData.TimeSource=TimeSource;
    953 end
     956% if ~isempty(TimeName)
     957%     SeriesData.TimeSource=TimeSource;
     958% end
    954959if check_calib
    955960    SeriesData.GeometryCalib{iview}=XmlData.GeometryCalib;
     
    964969if CheckPair% if pairs need to be display for line iview
    965970    [ModeMenu,ModeValue]=update_mode(i1_series,i2_series,j2_series);
    966     Menu=update_listpair(i1_series,i2_series,j1_series,j2_series,ModeMenu{ModeValue},Time,TimeUnit,ref_i,ref_j);
     971    Menu=update_listpair(i1_series,i2_series,j1_series,j2_series,ModeMenu{ModeValue},Time,TimeUnit,ref_i,ref_j,TimeName,InputTable(iview,:),FileInfo);
    967972    PairString{iview,1}=Menu{1};
    968973else
     
    11121117
    11131118%------------------------------------------------------------------------
    1114 function displ_pair=update_listpair(i1_series,i2_series,j1_series,j2_series,mode,time,TimeUnit,ref_i,ref_j)
     1119function displ_pair=update_listpair(i1_series,i2_series,j1_series,j2_series,mode,time,TimeUnit,ref_i,ref_j,TimeName,InputTable,FileInfo)
    11151120%------------------------------------------------------------------------
    11161121displ_pair={};
     
    11791184                if numel(j1_series(j1_series==pair1))>0 && numel(j2_series(j2_series==pair2))>0
    11801185                    pair_string=['j= ' num2str(pair1) '-' num2str(pair2)];
    1181                     Dt=time(ref_i,pair2+1)-time(ref_i,pair1+1);
    1182                     pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit];
     1186                    [TimeValue,DtValue]=get_time(ref_i,[],pair_string,InputTable,FileInfo,TimeName,'Dt');
     1187                    %Dt=time(ref_i,pair2+1)-time(ref_i,pair1+1);
     1188                    pair_string=[pair_string ', Dt=' num2str(DtValue) ' ' dtunit];
    11831189                    displ_pair=[displ_pair;{pair_string}];
    11841190                end
     
    12421248[i1_2,i2_2,j1_2,j2_2] = get_file_index(ref_i_2,ref_j_2,PairString);
    12431249TimeTable=get(handles.TimeTable,'Data');
    1244 
     1250%%%%%%
     1251%TODO: read time in netcdf file, see ActionName_Callback
     1252%%%%%%%
    12451253%Pairs=get(handles.PairString,'Data');
    12461254for iview=1:size(TimeTable,1)
     
    12481256        break
    12491257    end
    1250     TimeTable{iview,2}=[];
    12511258    TimeTable{iview,3}=[];
     1259    TimeTable{iview,4}=[];
    12521260    if size(SeriesData.Time{iview},1)>=i2_2+1 && (isempty(ref_j_1)||size(SeriesData.Time{iview},2)>=j2_2+1)
    12531261        if isempty(ref_j_1)
     
    12581266            time_last=(SeriesData.Time{iview}(i1_2+1,j1_2+1)+SeriesData.Time{iview}(i2_2+1,j2_1+1))/2;
    12591267        end
    1260         TimeTable{iview,2}=time_first; %TODO: take into account pairs
    1261         TimeTable{iview,3}=time_last; %TODO: take into account pairs
     1268        TimeTable{iview,3}=time_first; %TODO: take into account pairs
     1269        TimeTable{iview,4}=time_last; %TODO: take into account pairs
    12621270    end
    12631271end
     
    19751983iview_netcdf=find(strcmp('netcdf',SeriesData.FileType)|strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType));% all nc files, icluding civ
    19761984FieldList=get(handles.FieldName,'String');% previous list as default
     1985if ~iscell(FieldList),FieldList={FieldList};end
    19771986FieldList_1=get(handles.FieldName_1,'String');% previous list as default
     1987if ~iscell(FieldList_1),FieldList_1={FieldList_1};end
    19781988CheckList=0;% indicate whether FieldName has been updated
    19791989CheckList_1=1;% indicate whether FieldName_1 has been updated
     
    22502260field=field_str{field_index(1)};
    22512261if isequal(field,'get_field...')
     2262    SeriesData=get(handles.series,'UserData');
     2263    % input line for which the field choice is relevant
     2264    iview=find(strcmp('netcdf',SeriesData.FileType)|strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType));% all nc files, icluding civ
    22522265    hget_field=findobj(allchild(0),'name','get_field');
    22532266    if ~isempty(hget_field)
     
    22552268    end
    22562269    Param=read_GUI(handles.series);
    2257     Param.InputTable=Param.InputTable(1,:);
     2270    InputTable=Param.InputTable(iview,:);
    22582271    % check the existence of the first file in the series
    2259     first_j=[];
    2260     if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
    2261     last_j=[];
    2262     if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end
     2272    first_j=[];last_j=[];MinIndex_j=1;MaxIndex_j=1;%default setting for index j
     2273    if isfield(Param.IndexRange,'first_j');% if index j is used
     2274        first_j=Param.IndexRange.first_j;
     2275        last_j=Param.IndexRange.last_j;
     2276        MinIndex_j=Param.IndexRange.MinIndex_j(iview);
     2277        MaxIndex_j=Param.IndexRange.MaxIndex_j(iview);
     2278    end
    22632279    PairString='';
    2264     if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
     2280    if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString{iview}; end
    22652281    [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
    2266     FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
    2267         Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
     2282    FirstFileName=fullfile_uvmat(InputTable{1},InputTable{2},InputTable{3},...
     2283        InputTable{5},InputTable{4},i1,i2,j1,j2);
    22682284    if exist(FirstFileName,'file')
    22692285        ParamIn.Title='get_field: pick input variables and coordinates for series processing';
     
    23022318            YName=GetFieldData.Coordinates.Coord_y;
    23032319            TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
     2320            % get the time info                     
     2321            TimeTable=get(handles.TimeTable,'Data');
    23042322            switch TimeNameStr
    23052323                case 'file index'
    2306                     set(handles.TimeName,'String','');
     2324                    TimeName='';
    23072325                case 'attribute'
    2308                     set(handles.TimeName,'String',['att:' GetFieldData.Time.TimeName]);
     2326                    TimeName=['att:' GetFieldData.Time.TimeName];
     2327                    % update the time table
     2328                    TimeTable{iview,2}=get_time(Param.IndexRange.MinIndex_i(iview),MinIndex_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName);  % Min time     
     2329                    TimeTable{iview,3}=get_time(Param.IndexRange.first_i,first_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName);  % first time             
     2330                    TimeTable{iview,4}=get_time(Param.IndexRange.last_i,last_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName);  % last time                     
     2331                    TimeTable{iview,5}=get_time(Param.IndexRange.MaxIndex_i(iview),MaxIndex_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName);  % Max time
    23092332                case 'variable'
    23102333                    set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName])
     
    23142337                    ParamIn.TimeVarName=GetFieldData.Time.TimeName;
    23152338                case 'matrix_index'
    2316                     set(handles.TimeName,'String',['dim:' GetFieldData.Time.TimeName]);
     2339                    TimeName=['dim:' GetFieldData.Time.TimeName];
    23172340                    set(handles.NomType,'String','*')
    23182341                    set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])
     
    23202343                    ParamIn.TimeDimName=GetFieldData.Time.TimeName;
    23212344            end
     2345            TimeTable{iview,1}=TimeName;
     2346            set(handles.TimeTable,'Data',TimeTable);
    23222347        end
    23232348        set(handles.Coord_x,'String',XName)
    23242349        set(handles.Coord_y,'String',YName)
     2350    end
     2351end
     2352
     2353function [TimeValue,DtValue]=get_time(ref_i,ref_j,PairString,InputTable,FileInfo,TimeName,DtName)
     2354[i1,i2,j1,j2] = get_file_index(ref_i,ref_j,PairString);
     2355FileName=fullfile_uvmat(InputTable{1},InputTable{2},InputTable{3},InputTable{5},InputTable{4},i1,i2,j1,j2);
     2356Data=nc2struct(FileName,[]);
     2357TimeValue=[];
     2358DtValue=[];
     2359if isequal(FileInfo.FileType,'civdata')
     2360    if ismember(TimeName,{'civ1','filter1'})
     2361        TimeValue=Data.Civ1_Time;
     2362        DtValue=Data.Civ1_Dt;
     2363    else
     2364        TimeValue=Data.Civ2_Time;
     2365        DtValue=Data.Civ2_Dt;
     2366    end
     2367else
     2368    if ~isempty(TimeName)
     2369        TimeValue=Data.(TimeName);
     2370    end
     2371    if exist('DtName','var') && isfield(Data,DtName)
     2372        DtValue=Data.(DtName);
    23252373    end
    23262374end
     
    26602708function MenuHelp_Callback(hObject, eventdata, handles)
    26612709%-------------------------------------------------------------------
    2662 web('http://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/wiki/UvmatHelp#Series')
     2710
     2711
    26632712% path_to_uvmat=which ('uvmat');% check the path of uvmat
    26642713% pathelp=fileparts(path_to_uvmat);
     
    28962945set(handles.TimeTable,'Unit','normalized')
    28972946% ColumnWidth=get(handles.TimeTable,'ColumnWidth');
    2898 ColumnWidth=num2cell(floor([0.25 0.25 0.25 0.25]*(Pos(3)-20)));
     2947ColumnWidth=num2cell(floor([0.2 0.2 0.2 0.2 0.2]*(Pos(3)-20)));
    28992948set(handles.TimeTable,'ColumnWidth',ColumnWidth)
    29002949
     
    31883237[ModeMenu,ModeValue]=update_mode(SeriesData.i1_series{iview},SeriesData.i2_series{iview},SeriesData.j2_series{iview});
    31893238displ_pair=update_listpair(SeriesData.i1_series{iview},SeriesData.i2_series{iview},SeriesData.j1_series{iview},SeriesData.j2_series{iview},ModeMenu{ModeValue},...
    3190                                                      SeriesData.Time{iview},TimeUnit,SeriesData.ref_i,SeriesData.ref_j);
     3239                                                     SeriesData.Time{iview},TimeUnit,SeriesData.ref_i,SeriesData.ref_j,SeriesData.FileInfo{iview});
    31913240% first raw of the GUI
    31923241uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.88 0.5 0.1],'BackgroundColor',BackgroundColor,...
     
    32663315
    32673316%% update the menu ListPair
    3268 Menu=update_listpair(i1_series,i2_series,j1_series,j2_series,mode,SeriesData.Time{iview},TimeUnit,ref_i,ref_j);
     3317Menu=update_listpair(i1_series,i2_series,j1_series,j2_series,mode,SeriesData.Time{iview},TimeUnit,ref_i,ref_j,FileInfo);
    32693318hlist_pairs=findobj(get(hObject,'parent'),'Tag','ListPair');
    32703319set(hlist_pairs,'Value',1)% set the first choice by default in ListPair
     
    33043353
    33053354
    3306 
    3307 function Coord_z_Callback(hObject, eventdata, handles)
    3308 % hObject    handle to Coord_z (see GCBO)
    3309 % eventdata  reserved - to be defined in a future version of MATLAB
    3310 % handles    structure with handles and user data (see GUIDATA)
    3311 
    3312 % Hints: get(hObject,'String') returns contents of Coord_z as text
    3313 %        str2double(get(hObject,'String')) returns contents of Coord_z as a double
    3314 
    3315 
    3316 
    3317 % % --- Executes on key press with focus on InputTable and none of its controls.
    3318 % function InputTable_KeyPressFcn(hObject, eventdata, handles)
    3319 % set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed
    3320 % % set(handles.REFRESH_title,'Visible','on')
    3321 % iview=eventdata.Indices(1);
    3322 % view_set=get(handles.REFRESH,'UserData');
    3323 % if isempty(find(view_set==iview))
    3324 %     set(handles.REFRESH,'UserData',[view_set iview])
    3325 % end
    3326 % %% enable other menus and uicontrols
    3327 % set(handles.MenuOpenCampaign,'Enable','on')
    3328 % set(handles.MenuCampaign_1,'Enable','on')
    3329 % set(handles.MenuCampaign_2,'Enable','on')
    3330 % set(handles.MenuCampaign_3,'Enable','on')
    3331 % set(handles.MenuCampaign_4,'Enable','on')
    3332 % set(handles.MenuCampaign_5,'Enable','on')
    3333 % set(handles.RUN, 'Enable','On')
    3334 % set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red
    3335 
    3336 
    3337 % hObject    handle to InputTable (see GCBO)
    3338 % eventdata  structure with the following fields (see UITABLE)
    3339 %       Indices: row and column indices of the cell(s) currently selecteds
    3340 % handles    structure with handles and user data (see GUIDATA)
    3341 
    3342 
Note: See TracChangeset for help on using the changeset viewer.