Changeset 775
- Timestamp:
- May 16, 2014, 8:40:58 AM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_field.m
r771 r775 66 66 67 67 %% enter input data 68 if ischar(filename) % input file name68 if ischar(filename) % input file name 69 69 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 71 else 72 msgbox_uvmat('ERROR','get_field requires a file name as input')% display error message for input file reading 73 return 74 end 75 if ~isempty(errormsg) 76 msgbox_uvmat('ERROR',['get_field/nc2struct/' errormsg])% display error message for input file reading 77 return 78 end 79 if ~isfield(Field,'ListVarName') 80 msgbox_uvmat('ERROR',['no variable found in ' filename])% display error message for input file reading 81 return 73 82 end 74 83 if ~exist('ParamIn','var') 75 84 ParamIn=[]; 76 end77 if isfield(Field,'Txt')78 msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])% display error message for input file reading79 return80 end81 if ~isfield(Field,'ListVarName')82 return83 85 end 84 86 -
trunk/src/series.m
r773 r775 243 243 if isfield(Param,'InputFile') 244 244 245 InputTable={};246 245 %% fill the list of file series 247 SeriesData=Param.HiddenData;248 246 InputTable=[{Param.InputFile.RootPath},{Param.InputFile.SubDir},{Param.InputFile.RootFile},{Param.InputFile.NomType},{Param.InputFile.FileExt}]; 249 TimeTable=[{ []},{[]},{[]},{[]}];247 TimeTable=[{Param.InputFile.TimeName},{[]},{[]},{[]},{[]}]; 250 248 if isfield(Param.InputFile,'RootPath_1') 251 249 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},{[]},{[]},{[]},{[]}]]; 253 251 end 254 252 set(handles.InputTable,'Data',InputTable) … … 654 652 InputTable={'','','','',''}; 655 653 InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; 656 set(handles.TimeTable,'Data',[{ []},{[]},{[]},{[]}])654 set(handles.TimeTable,'Data',[{''},{[]},{[]},{[]},{[]}]) 657 655 set(handles.MinIndex_i,'Data',[]) 658 656 set(handles.MaxIndex_i,'Data',[]) … … 855 853 end 856 854 857 %% default time unit855 %% default time settings 858 856 TimeUnit=''; 859 857 % read value set by the first series for the append mode (iwiew >1) … … 861 859 TimeUnit=get(handles.TimeUnit,'String'); 862 860 end 863 Time Source='';861 TimeName=''; 864 862 Time=[];%default 863 TimeMin=[]; 864 TimeFirst=[]; 865 TimeLast=[]; 866 TimeMax=[]; 865 867 866 868 %% read image documentation file if found … … 875 877 % read time if available 876 878 if isfield(XmlData,'Time') 877 Time=XmlData.Time;878 Time Source='xml';879 Time=XmlData.Time; 880 TimeName='xml'; 879 881 end 880 882 if isfield(XmlData,'Camera') … … 908 910 end 909 911 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) 913 if ~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'; 922 end 923 924 925 %% determine the min and max times: case of Netcdf files will be treated later in FieldName_Callback 926 if ~isempty(TimeName) 927 TimeMin=Time(MinIndex_i+1,MinIndex_j+1); 931 928 if size(Time)>=[first_i+1 first_j+1] 932 Time Table{iview,2}=Time(first_i+1,first_j+1);929 TimeFirst=Time(first_i+1,first_j+1); 933 930 end 934 931 if size(Time)>=[last_i+1 last_j+1] 935 Time Table{iview,3}=Time(last_i+1,last_j+1);932 TimeLast=Time(last_i+1,last_j+1); 936 933 end 937 934 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 937 end 938 939 %% update the time table 940 TimeTable=get(handles.TimeTable,'Data'); 941 TimeTable{iview,1}=TimeName; 942 TimeTable{iview,2}=TimeMin; 943 TimeTable{iview,3}=TimeFirst; 944 TimeTable{iview,4}=TimeLast; 945 TimeTable{iview,5}=TimeMax; 946 set(handles.TimeTable,'Data',TimeTable) 942 947 943 948 %% update the series info in 'UserData' … … 949 954 SeriesData.FileInfo{iview}=FileInfo; 950 955 SeriesData.Time{iview}=Time; 951 if ~isempty(TimeSource)952 SeriesData.TimeSource=TimeSource;953 end956 % if ~isempty(TimeName) 957 % SeriesData.TimeSource=TimeSource; 958 % end 954 959 if check_calib 955 960 SeriesData.GeometryCalib{iview}=XmlData.GeometryCalib; … … 964 969 if CheckPair% if pairs need to be display for line iview 965 970 [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); 967 972 PairString{iview,1}=Menu{1}; 968 973 else … … 1112 1117 1113 1118 %------------------------------------------------------------------------ 1114 function displ_pair=update_listpair(i1_series,i2_series,j1_series,j2_series,mode,time,TimeUnit,ref_i,ref_j )1119 function displ_pair=update_listpair(i1_series,i2_series,j1_series,j2_series,mode,time,TimeUnit,ref_i,ref_j,TimeName,InputTable,FileInfo) 1115 1120 %------------------------------------------------------------------------ 1116 1121 displ_pair={}; … … 1179 1184 if numel(j1_series(j1_series==pair1))>0 && numel(j2_series(j2_series==pair2))>0 1180 1185 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]; 1183 1189 displ_pair=[displ_pair;{pair_string}]; 1184 1190 end … … 1242 1248 [i1_2,i2_2,j1_2,j2_2] = get_file_index(ref_i_2,ref_j_2,PairString); 1243 1249 TimeTable=get(handles.TimeTable,'Data'); 1244 1250 %%%%%% 1251 %TODO: read time in netcdf file, see ActionName_Callback 1252 %%%%%%% 1245 1253 %Pairs=get(handles.PairString,'Data'); 1246 1254 for iview=1:size(TimeTable,1) … … 1248 1256 break 1249 1257 end 1250 TimeTable{iview,2}=[];1251 1258 TimeTable{iview,3}=[]; 1259 TimeTable{iview,4}=[]; 1252 1260 if size(SeriesData.Time{iview},1)>=i2_2+1 && (isempty(ref_j_1)||size(SeriesData.Time{iview},2)>=j2_2+1) 1253 1261 if isempty(ref_j_1) … … 1258 1266 time_last=(SeriesData.Time{iview}(i1_2+1,j1_2+1)+SeriesData.Time{iview}(i2_2+1,j2_1+1))/2; 1259 1267 end 1260 TimeTable{iview, 2}=time_first; %TODO: take into account pairs1261 TimeTable{iview, 3}=time_last; %TODO: take into account pairs1268 TimeTable{iview,3}=time_first; %TODO: take into account pairs 1269 TimeTable{iview,4}=time_last; %TODO: take into account pairs 1262 1270 end 1263 1271 end … … 1975 1983 iview_netcdf=find(strcmp('netcdf',SeriesData.FileType)|strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType));% all nc files, icluding civ 1976 1984 FieldList=get(handles.FieldName,'String');% previous list as default 1985 if ~iscell(FieldList),FieldList={FieldList};end 1977 1986 FieldList_1=get(handles.FieldName_1,'String');% previous list as default 1987 if ~iscell(FieldList_1),FieldList_1={FieldList_1};end 1978 1988 CheckList=0;% indicate whether FieldName has been updated 1979 1989 CheckList_1=1;% indicate whether FieldName_1 has been updated … … 2250 2260 field=field_str{field_index(1)}; 2251 2261 if 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 2252 2265 hget_field=findobj(allchild(0),'name','get_field'); 2253 2266 if ~isempty(hget_field) … … 2255 2268 end 2256 2269 Param=read_GUI(handles.series); 2257 Param.InputTable=Param.InputTable(1,:);2270 InputTable=Param.InputTable(iview,:); 2258 2271 % 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 2263 2279 PairString=''; 2264 if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString ; end2280 if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString{iview}; end 2265 2281 [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); 2268 2284 if exist(FirstFileName,'file') 2269 2285 ParamIn.Title='get_field: pick input variables and coordinates for series processing'; … … 2302 2318 YName=GetFieldData.Coordinates.Coord_y; 2303 2319 TimeNameStr=GetFieldData.Time.SwitchVarIndexTime; 2320 % get the time info 2321 TimeTable=get(handles.TimeTable,'Data'); 2304 2322 switch TimeNameStr 2305 2323 case 'file index' 2306 set(handles.TimeName,'String','');2324 TimeName=''; 2307 2325 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 2309 2332 case 'variable' 2310 2333 set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName]) … … 2314 2337 ParamIn.TimeVarName=GetFieldData.Time.TimeName; 2315 2338 case 'matrix_index' 2316 set(handles.TimeName,'String',['dim:' GetFieldData.Time.TimeName]);2339 TimeName=['dim:' GetFieldData.Time.TimeName]; 2317 2340 set(handles.NomType,'String','*') 2318 2341 set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) … … 2320 2343 ParamIn.TimeDimName=GetFieldData.Time.TimeName; 2321 2344 end 2345 TimeTable{iview,1}=TimeName; 2346 set(handles.TimeTable,'Data',TimeTable); 2322 2347 end 2323 2348 set(handles.Coord_x,'String',XName) 2324 2349 set(handles.Coord_y,'String',YName) 2350 end 2351 end 2352 2353 function [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); 2355 FileName=fullfile_uvmat(InputTable{1},InputTable{2},InputTable{3},InputTable{5},InputTable{4},i1,i2,j1,j2); 2356 Data=nc2struct(FileName,[]); 2357 TimeValue=[]; 2358 DtValue=[]; 2359 if 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 2367 else 2368 if ~isempty(TimeName) 2369 TimeValue=Data.(TimeName); 2370 end 2371 if exist('DtName','var') && isfield(Data,DtName) 2372 DtValue=Data.(DtName); 2325 2373 end 2326 2374 end … … 2660 2708 function MenuHelp_Callback(hObject, eventdata, handles) 2661 2709 %------------------------------------------------------------------- 2662 web('http://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/wiki/UvmatHelp#Series') 2710 2711 2663 2712 % path_to_uvmat=which ('uvmat');% check the path of uvmat 2664 2713 % pathelp=fileparts(path_to_uvmat); … … 2896 2945 set(handles.TimeTable,'Unit','normalized') 2897 2946 % ColumnWidth=get(handles.TimeTable,'ColumnWidth'); 2898 ColumnWidth=num2cell(floor([0.2 5 0.25 0.25 0.25]*(Pos(3)-20)));2947 ColumnWidth=num2cell(floor([0.2 0.2 0.2 0.2 0.2]*(Pos(3)-20))); 2899 2948 set(handles.TimeTable,'ColumnWidth',ColumnWidth) 2900 2949 … … 3188 3237 [ModeMenu,ModeValue]=update_mode(SeriesData.i1_series{iview},SeriesData.i2_series{iview},SeriesData.j2_series{iview}); 3189 3238 displ_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}); 3191 3240 % first raw of the GUI 3192 3241 uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.88 0.5 0.1],'BackgroundColor',BackgroundColor,... … … 3266 3315 3267 3316 %% 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 );3317 Menu=update_listpair(i1_series,i2_series,j1_series,j2_series,mode,SeriesData.Time{iview},TimeUnit,ref_i,ref_j,FileInfo); 3269 3318 hlist_pairs=findobj(get(hObject,'parent'),'Tag','ListPair'); 3270 3319 set(hlist_pairs,'Value',1)% set the first choice by default in ListPair … … 3304 3353 3305 3354 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 MATLAB3310 % handles structure with handles and user data (see GUIDATA)3311 3312 % Hints: get(hObject,'String') returns contents of Coord_z as text3313 % str2double(get(hObject,'String')) returns contents of Coord_z as a double3314 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 needed3320 % % 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 % end3326 % %% enable other menus and uicontrols3327 % 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 red3335 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 selecteds3340 % handles structure with handles and user data (see GUIDATA)3341 3342
Note: See TracChangeset
for help on using the changeset viewer.