- Timestamp:
- Mar 3, 2010, 11:58:05 PM (15 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_field.m
r17 r34 43 43 % End initialization code - DO NOT EDIT 44 44 45 45 %------------------------------------------------------------------------ 46 46 % --- Executes just before get_field is made visible. 47 47 function get_field_OpeningFcn(hObject, eventdata, handles,filename,Field,haxes) 48 49 set(handles.dimensions,'enable','on')% should be put by guide 48 %------------------------------------------------------------------------ 49 global nb_builtin 50 50 browse_fig(handles.list_fig) 51 51 … … 55 55 % Update handles structure 56 56 guidata(hObject, handles); 57 pathuvmat=fileparts(which('uvmat')); 58 addpath(fullfile(pathuvmat,'FIELD_FCT')) 59 set(handles.attributes,'enable','on')% TO BE SET BY GUIDE 57 %pathuvmat=fileparts(which('uvmat')); 58 %addpath(fullfile(pathuvmat,'FIELD_FCT')) 59 %loads the information stored in prefdir to initiate the browser and the list of functions 60 menu_str={'PLOT';'FFT';'filter_band';'histogram'}; %list of functions included in 'get_field.m' 61 nb_builtin=numel(menu_str)-1; 62 %menu_str(end)=[];%remove from the list the last option 'more...' 63 path_get_field=fileparts(which('get_field'));%path of the function 'get_field' 64 for ilist=1:length(menu_str) 65 fct_path{ilist,1}=fullfile(path_get_field,'get_field');%paths of the fuctions buil-in in 'get_field.m' 66 end 67 dir_perso=prefdir; 68 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 69 if exist(profil_perso,'file') 70 % menu={'RUN';'raw2phys';'histogram';'FFT';'peaklocking'}; 71 h=load (profil_perso); 72 if isfield(h,'get_field_fct') && iscell(h.get_field_fct) 73 for ilist=1:length(h.get_field_fct) 74 [path,file]=fileparts(h.get_field_fct{ilist}); 75 fct_path=[fct_path; {path}];%concatene the list of paths 76 menu_str=[menu_str; {file}]; 77 end 78 end 79 end 80 menu_str=[menu_str;{'more...'}]; 81 set(handles.ACTION,'String',menu_str) 82 set(handles.ACTION,'UserData',fct_path)% store the list of path in UserData of ACTION 83 ACTION_Callback(hObject, eventdata, handles) 60 84 set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles})%set mouse click action function 61 85 if exist('filename','var')& ischar(filename) … … 63 87 inputfile_Callback(hObject, eventdata, handles) 64 88 else 65 set(handles.inputfile,'String','') 66 %loads the information stored in prefdir to initiate the browser and the list of functions 67 menu_str={'PLOT'};%list of functions included in 'get_field.m' 68 %menu_str(end)=[];%remove from the list the last option 'more...' 69 path_get_field=which('get_field');%path of the function 'get_field' 70 for ilist=1:length(menu_str) 71 fct_path{ilist,1}=path_get_field;%paths of the fuctions buil-in in 'get_field.m' 72 end 73 dir_perso=prefdir; 74 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 75 if exist(profil_perso,'file') 76 % menu={'RUN';'raw2phys';'histogram';'FFT';'peaklocking'}; 77 h=load (profil_perso); 78 if isfield(h,'get_field_fct') && iscell(h.get_field_fct) 79 for ilist=1:length(h.get_field_fct) 80 [path,file]=fileparts(h.get_field_fct{ilist}); 81 fct_path=[fct_path; {path}];%concatene the list of paths 82 menu_str=[menu_str; {file}]; 83 end 84 85 end 86 end 87 menu_str=[menu_str;{'more...'}]; 88 set(handles.ACTION,'String',menu_str) 89 set(handles.ACTION,'UserData',fct_path)% store the list of path in UserData of ACTION 90 % display the GUI for the default action 'check_files' 91 ACTION_Callback(hObject, eventdata, handles) 92 end 93 % menu=[menu;h.fct_get_field]; 94 % menu=[menu;{'more...'}]; 95 % fct_path=h.fct_path_get_field; 96 % set(handles.ACTION,'String',menu) 97 % set(handles.ACTION,'UserData',fct_path) 98 % for ipath=1:length(fct_path) 99 % if exist(fct_path{ipath},'dir') 100 % addpath(fct_path{ipath}) 101 % end 102 % end 103 % end 104 % end 105 % end 89 set(handles.inputfile,'String','') 90 end 106 91 if exist('Field','var') & isstruct(Field) 107 92 Field_input(eventdata,handles,Field) … … 112 97 end 113 98 114 115 %----------------------------------------------------------- 99 %load the list of previously browsed files in menus Open 100 dir_perso=prefdir; 101 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% 102 if exist(profil_perso,'file') 103 h=load (profil_perso); 104 if isfield(h,'MenuFile_1') 105 set(handles.MenuFile_1,'Label',h.MenuFile_1); 106 end 107 if isfield(h,'MenuFile_1') 108 set(handles.MenuFile_2,'Label',h.MenuFile_2); 109 end 110 if isfield(h,'MenuFile_1') 111 set(handles.MenuFile_3,'Label',h.MenuFile_3); 112 end 113 if isfield(h,'MenuFile_1') 114 set(handles.MenuFile_4,'Label',h.MenuFile_4); 115 end 116 if isfield(h,'MenuFile_1') 117 set(handles.MenuFile_5,'Label',h.MenuFile_5); 118 end 119 end 120 121 %------------------------------------------------------------------------ 116 122 % --- Outputs from this function are returned to the command line. 117 123 function varargout = get_field_OutputFcn(hObject, eventdata, handles) 124 %------------------------------------------------------------------------ 118 125 varargout{1} = handles.output; 119 126 120 %----------------------------------------------------------- 127 %------------------------------------------------------------------------ 121 128 % --- Executes on button press in browse. 122 129 function browse_Callback(hObject, eventdata, handles) 123 124 125 %--------------------------------------------------------- 130 %------------------------------------------------------------------------ 131 132 %------------------------------------------------------------------------ 126 133 function inputfile_Callback(hObject, eventdata, handles) 134 %------------------------------------------------------------------------ 127 135 inputfile=get(handles.inputfile,'String'); 128 136 Field=nc2struct(inputfile,[]);% reads only the lists of fields, dimensions and attributes … … 131 139 Field_input(eventdata,handles,Field); 132 140 133 134 %--------------------------------------------------------- 141 %------------------------------------------------------------------------ 135 142 function Field_input(eventdata,handles,Field) 136 143 %------------------------------------------------------------------------ 137 144 if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName) 138 145 Tabcell(:,1)=Field.ListDimName; … … 203 210 end 204 211 205 206 %---------------------------------------------------------- 212 %------------------------------------------------------------------------ 207 213 function ordinate_Callback(hObject, eventdata, handles) 214 %------------------------------------------------------------------------ 208 215 %update_field(hObject, eventdata, handles) 209 216 % A REVOIR … … 236 243 %update_UserData(handles) 237 244 238 %---------------------------------------------------------------------- 245 %------------------------------------------------------------------------ 239 246 % --- Executes on selection change in abscissa. 240 247 function abscissa_Callback(hObject, eventdata, handles) 248 %------------------------------------------------------------------------ 241 249 hselect_field=get(handles.inputfile,'parent'); 242 250 Field=get(hselect_field,'UserData');%current input field … … 379 387 function update_field(hObject, eventdata, handles,VarName) 380 388 % VarName= input variable name for scalar or vector plots 381 %if ischar(VarName)382 389 hselect_field=get(handles.inputfile,'parent'); 383 390 Field=get(hselect_field,'UserData'); … … 730 737 function RUN_Callback(hObject, eventdata, handles) 731 738 %--------------------------------------------------------- 739 path_get_field=fileparts(which('get_field')); 732 740 list=get(handles.ACTION,'String'); 733 741 index=get(handles.ACTION,'Value'); 734 742 ACTION=list{index}; 735 hselect_field=get(handles.inputfile,'parent');%handle of the get_field interface 736 feval(ACTION,hselect_field); 743 list_path=get(handles.ACTION,'UserData'); 744 %hselect_field=get(handles.inputfile,'parent');%handle of the get_field interface 745 fct_path=list_path{index}; %path stored for the function ACTION 746 if ~isequal(fct_path,path_get_field) 747 % eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION 748 % if ~isequal(spath,fct_path)& exist(fct_path,'dir') 749 addpath(fct_path)% add the prescribed path if not the current one 750 % end 751 end 752 % fct_path 753 eval(['h_fun=@' ACTION ';']) 754 if ~isequal(fct_path,path_get_field) 755 rmpath(fct_path)% add the prescribed path if not the current one 756 end 757 758 set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) 759 drawnow 760 h_fun(handles.figure1);%handles.figure1 =handles of the GUI get_field 737 761 browse_fig(handles.list_fig); %update the list of new existing figures 738 739 %---------------------------------------------------------740 % --- Executes on button press in RUN.741 function PLOT(hget_field)742 %---------------------------------------------------------743 [SubField,errormsg]=read_get_field(hget_field);744 if ~isempty(errormsg)745 msgbox_uvmat('ERROR',['error in get_field/PLOT input:' errormsg])746 return747 end748 handles=guidata(hget_field);749 list_fig=get(handles.list_fig,'String');750 val=get(handles.list_fig,'Value');751 if strcmp(list_fig{val},'uvmat')752 uvmat(SubField)753 else754 hfig=str2num(list_fig{val});% chosen figure number from tyhe GUI755 if isempty(hfig)756 hfig=figure;757 list_fig=[list_fig;num2str(hfig)];758 set(handles.list_fig,'String',list_fig);759 haxes=axes;760 else761 figure(hfig);762 end763 haxes=findobj(hfig,'Type','axes');764 plot_field(SubField,haxes)765 end766 767 768 %769 % return770 % testuvmat=0;771 % if test_scalar|test_vector772 % [DimVarIndex,CellVarIndex,NbDim]=find_field_indices(SubField);773 % NbDim=max(NbDim);774 % if NbDim==3775 % testuvmat=1; %uvmat interface needed for 3D plots776 % end777 % end778 % if iscell(list_fig)779 % RUN_fig=list_fig{fig_index};780 % else781 % RUN_fig='new fig...';%new plotting axes must be created782 % end783 % if isequal(RUN_fig,'new fig...') & (test_scalar|test_vector)784 % RUN_fig='uvmat';%use uvmat for a new fig785 % end786 % if testuvmat787 % RUN_fig='uvmat';788 % end789 % if isequal(RUN_fig,'uvmat')790 %791 % huvmat=uvmat(SubField);792 % menu=update_menu(handles.list_fig,'uvmat');%add the selected fct to the menu793 % else794 % test_new=1;795 % if ~isequal(RUN_fig,'new fig...')796 % sep=regexp(RUN_fig,'_')%look for subaxes in a fig797 % if isempty(sep)798 % axe_index=1;799 % else800 % axe_index=str2num(RUN_fig(sep+1:end))801 % RUN_fig=RUN_fig([1:sep-1])802 % end803 % if ishandle(str2num(RUN_fig))804 % haxes=findobj(str2num(RUN_fig),'Type','axes')805 % for iaxe=1:length(haxes)806 % Tag=get(haxes(iaxe),'Tag');807 % if isequal(Tag,'Colorbar')|isequal(Tag,'legend')808 % iselect(iaxe)=0;809 % else810 % iselect(iaxe)=1;811 % end812 % end813 % haxes=haxes(find(iselect));814 % if length(haxes)>=axe_index815 % test_new=0816 % haxes=haxes(axe_index);817 % set(haxes,'NextPlot','add')818 % end819 % end820 % end821 % if test_new822 % hfig=figure;823 % haxes=axes;824 % menu=update_menu(handles.list_fig,num2str(hfig));%add the selected fct to the menu825 % end826 % RUN_field(SubField,haxes)827 % end828 % end829 %830 %831 %832 %833 % w components834 % end835 %836 %837 % % select the variable index (or indices) for z coordinates838 % test_grid=0;839 % if test_scalar | test_vector840 % nbdim=length(DimIndex);841 % if nbdim > 3842 % warndlg_uvmat('array with more than three dimensions, not supported','ERROR')843 % return844 % else845 % perm_ind=[1:nbdim];846 % end847 % if nbdim==3848 % zstring=get(handles.coord_z_vectors_scalar,'String');849 % zindex=get(handles.coord_z_vectors_scalar,'Value'); %selected indices in the ordinate listbox850 % list_var=zstring(zindex);851 % VarIndex_z=name2index(list_var,Field.ListVarName);%index of the selected variable852 % if isequal(VarIndex.A,VarIndex_z)|isequal(VarIndex.u,VarIndex_z)|isequal(VarIndex.v,VarIndex_z)|isequal(VarIndex.w,VarIndex_z)853 % if zindex ~= 1854 % set(handles.coord_z_vectors_scalar,'Value',1)%ordinate cannot be the same as scalar or vector components855 % return856 % end857 % else858 % VarIndex_tot=[VarIndex_tot VarIndex_z];859 % DimIndex_z=Field.VarDimIndex{VarIndex_z};860 % DimValue=Field.DimValue(DimIndex_z);861 % ind=find(DimValue==1);862 % DimIndex_z(ind)=[];%Mremove singleton863 % if isequal(DimIndex_z,DimIndex)864 % VarAttribute{VarIndex_z}.Role='coord_z';%unstructured coordinates865 % elseif length(DimIndex_z)==1866 % VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z}; %dimension variable867 % ind_z=find(DimIndex==DimIndex_z(1));868 % perm_ind(ind_z)=1;869 % test_grid=1;870 % else871 % warndlg_uvmat('multiple dimensions for the z coordinate','ERROR')872 % return873 % end874 % end875 % % if ~isempty(VarIndex_z)876 % % DimIndex_z=Field.VarDimIndex{VarIndex_z};%dimension indices of the variable877 % % if length(DimIndex_z)==1 & nbdim==3 %dimension variable878 % % VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z};879 % % ind_z=find(DimIndex==DimIndex_z(1));880 % % perm_ind(ind_z)=1;881 % % test_grid=1;882 % % end883 % % end884 % end885 % end886 %887 % % select the variable index (or indices) for ordinate888 % ystring=get(handles.ordinate,'String');889 % yindex=get(handles.ordinate,'Value'); %selected indices in the ordinate listbox890 % list_var=ystring(yindex);891 % VarIndex.y=name2index(list_var,Field.ListVarName);892 % if isequal(VarIndex.A,VarIndex.y)|isequal(VarIndex.u,VarIndex.y)|isequal(VarIndex.v,VarIndex.y)|isequal(VarIndex.w,VarIndex.y)893 % set(handles.ordinate,'Value',1)%ordinate cannot be the same as scalar or vector components894 % else895 % for ivar=1:length(VarIndex.y)896 % VarAttribute{VarIndex.y(ivar)}.Role='coord_y';897 % end898 % VarIndex_tot=[VarIndex_tot VarIndex.y];899 % end900 % if (test_scalar | test_vector) & ~isempty(VarIndex.y)901 % DimIndex_y=Field.VarDimIndex{VarIndex.y};%dimension indices of the variable902 % if length(DimIndex_y)==1903 % ind_y=find(DimIndex==DimIndex_y(1));904 % test_grid=1;905 % if nbdim==3906 % VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y};907 % perm_ind(ind_y)=2;908 % elseif nbdim==2909 % VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y};910 % perm_ind(ind_y)=1;911 % end912 % elseif test_grid913 % warndlg_uvmat('the dimension of the y coordinate variable should be 1','ERROR')914 % end915 % end916 %917 % %select the variable index for the abscissa918 % xstring=get(handles.abscissa,'String');919 % xindex=get(handles.abscissa,'Value');920 % list_var=xstring(xindex);921 % VarIndex.x=name2index(list_var,Field.ListVarName);%var index corresponding to var name list_var922 % if length(VarIndex.x)==1923 % DimIndex_x=Field.VarDimIndex{VarIndex.x};924 % DimValue=Field.DimValue(DimIndex_x);925 % ind=find(DimValue==1);926 % DimIndex_x(ind)=[];%Mremove singleton927 % VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x}; %dimension variable928 % % VarAttribute{VarIndex.x}.Role='coord_x';%default (may be modified)929 % index_detect=find(VarIndex_tot==VarIndex.x);930 % else931 % index_detect=[];%coord x variable not already used932 % end933 % if isempty(index_detect)934 % VarIndex_tot=[VarIndex_tot VarIndex.x];935 % else936 % VarIndex.x=[];937 % set(handles.abscissa,'Value',1)%vchosen abscissa already chosen, suppres it as abscissa938 % end939 %940 % if (test_scalar | test_vector) & ~isempty(VarIndex.x)941 % DimIndex_x=Field.VarDimIndex{VarIndex.x};%dimension indices of the variable942 % if length(DimIndex_x)==1943 % ind_x=find(DimIndex==DimIndex_x(1));944 % if nbdim==3945 % %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x};946 % perm_ind(ind_x)=3;947 % elseif nbdim==2948 % %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x};949 % perm_ind(ind_x)=2;950 % end951 % if isequal(perm_ind,[1:nbdim])952 % test_grid=0;953 % end954 % DimIndex=DimIndex(perm_ind);955 % elseif test_grid956 % warndlg_uvmat('the dimension of the x coordinate variable should be 1','ERROR')957 % end958 % if isequal(DimIndex_x,DimIndex)959 % VarAttribute{VarIndex.x}.Role='coord_x';%unstructured coordinates960 % end961 % end962 %963 % %defined the selected sub-field SubField964 % SubField.ListGlobalAttribute{1}='InputFile';965 % SubField.InputFile=get(handles.inputfile,'String');966 % SubField.ListVarName=Field.ListVarName(VarIndex_tot);967 % VarDimIndex=Field.VarDimIndex;968 %969 % for ivar=VarIndex.u970 % VarAttribute{ivar}.Role='vector_x';971 % if test_grid972 % VarDimIndex{ivar}=DimIndex; %permute dimensions973 % end974 % end975 % for ivar=VarIndex.v976 % VarAttribute{ivar}.Role='vector_y';977 % if test_grid978 % VarDimIndex{ivar}=DimIndex;%permute dimensions979 % end980 % end981 % for ivar=VarIndex.A982 % if test_grid983 % VarDimIndex{ivar}=DimIndex;%permute dimensions984 % end985 % if isempty(iuA)986 % VarAttribute{ivar}.Role='scalar';%Role =scalar987 % else988 % VarAttribute=[VarAttribute VarAttribute{ivar}]; %duplicate the attribute for a new variable989 % nbattr=length(VarAttribute);990 % VarAttribute{nbattr}.Role='scalar';991 % end992 % end993 % SubField.VarDimIndex=VarDimIndex(VarIndex_tot);994 % SubField.VarAttribute=VarAttribute(VarIndex_tot);995 % % Field.SubListVarName=SubField.ListVarName;996 % % Field.SubVarDimIndex=SubField.VarDimIndex;997 % % Field.SubVarAttribute=SubField.VarAttribute;998 % set(hselect_field,'UserData',Field);999 % % copy variables on SubField1000 % for ivar=1:length(VarIndex_tot)1001 % VarName=Field.ListVarName{VarIndex_tot(ivar)};1002 % eval(['SubField.' VarName '=Field.' VarName ';'])1003 % end1004 % if test_grid1005 % for ivar=1:length(VarIndex.u)1006 % VarName=Field.ListVarName{VarIndex.u(ivar)};1007 % eval(['SubField.' VarName '=permute(SubField.' VarName ',perm_ind);'])1008 % end1009 %1010 % for ivar=1:length(VarIndex.v)1011 % VarName=Field.ListVarName{VarIndex.v(ivar)};1012 % eval(['SubField.' VarName '=permute(SubField.' VarName ',perm_ind);'])1013 % end1014 % for ivar=1:length(VarIndex.A)1015 % VarName=Field.ListVarName{VarIndex.A(ivar)};1016 % eval(['SubField.' VarName '=permute(SubField.' VarName ',perm_ind);'])1017 % end1018 % end1019 % if ~isempty(iuA)1020 % VarName= ['A' Field.ListVarName{iuA}]; %create the new variable to distinguish the scaler form the velocity component1021 % SubField.ListVarName=[SubField.ListVarName VarName];1022 % SubField.VarDimIndex=[SubField.VarDimIndex Field.VarDimIndex(iuA)];1023 % eval(['SubField.' VarName '=Field.' Field.ListVarName{iuA} ';'])1024 % end1025 % % dimension of SubField1026 % if test_scalar|test_vector1027 % % SubField.NbDim=2;1028 % SubField.InputFile=get(handles.inputfile,'String');1029 % SubField.get_field_handle=hselect_field;1030 % else1031 % SubField.NbDim=1;1032 % end1033 %1034 % list_fig=get(handles.list_fig,'String');1035 % fig_index=get(handles.list_fig,'Value');1036 % %ACTION on SubField1037 % index=get(handles.ACTION,'Value');1038 1039 %1040 % % if (test_scalar|test_vector)1041 % % RUN_fig='uvmat';1042 % % elseif iscell(list_fig)1043 % testuvmat=0;1044 % if test_scalar|test_vector1045 % [DimVarIndex,CellVarIndex,NbDim]=find_field_indices(SubField);1046 % NbDim=max(NbDim);1047 % if NbDim==31048 % testuvmat=1; %uvmat interface needed for 3D plots1049 % end1050 % end1051 % if iscell(list_fig)1052 % RUN_fig=list_fig{fig_index};1053 % else1054 % RUN_fig='new fig...';%new plotting axes must be created1055 % end1056 % if isequal(RUN_fig,'new fig...') & (test_scalar|test_vector)1057 % RUN_fig='uvmat';%use uvmat for a new fig1058 % end1059 % if testuvmat1060 % RUN_fig='uvmat';1061 % end1062 % if isequal(RUN_fig,'uvmat')1063 %1064 % huvmat=uvmat(SubField);1065 % menu=update_menu(handles.list_fig,'uvmat');%add the selected fct to the menu1066 % else1067 % test_new=1;1068 % if ~isequal(RUN_fig,'new fig...')1069 % sep=regexp(RUN_fig,'_')%look for subaxes in a fig1070 % if isempty(sep)1071 % axe_index=1;1072 % else1073 % axe_index=str2num(RUN_fig(sep+1:end))1074 % RUN_fig=RUN_fig([1:sep-1])1075 % end1076 % if ishandle(str2num(RUN_fig))1077 % haxes=findobj(str2num(RUN_fig),'Type','axes')1078 % for iaxe=1:length(haxes)1079 % Tag=get(haxes(iaxe),'Tag');1080 % if isequal(Tag,'Colorbar')|isequal(Tag,'legend')1081 % iselect(iaxe)=0;1082 % else1083 % iselect(iaxe)=1;1084 % end1085 % end1086 % haxes=haxes(find(iselect));1087 % if length(haxes)>=axe_index1088 % test_new=01089 % haxes=haxes(axe_index);1090 % set(haxes,'NextPlot','add')1091 % end1092 % end1093 % end1094 % if test_new1095 % hfig=figure;1096 % haxes=axes;1097 % menu=update_menu(handles.list_fig,num2str(hfig));%add the selected fct to the menu1098 % end1099 % RUN_field(SubField,haxes)1100 % end1101 % end1102 % %Field.VarIndex=VarIndex; %save for use in uvmat1103 % % set(hselect_field,'UserData',Field)1104 762 1105 763 … … 1187 845 % saveas(2,answer{1}) 1188 846 1189 %1190 % % --- Executes on selection change in spectrum.1191 % function Field=FFT(Field)1192 % 'TESTFFT'1193 % Field1194 % nbfield=length(Field.ListVarName);1195 % if nbfield==01196 % warndlg_uvmat('no field selected for FFT','ERROR')1197 % elseif nbfield>21198 % warndlg_uvmat('select only one field for FFT','ERROR')1199 % end1200 % if nbfield==21201 % % list_fields=get(handles.spectrum,'String');% list menu fields1202 % % index_fields=get(handles.spectrum,'Value');% selected string index1203 % % fields= list_fields{index_fields(1)}; % selected action1204 % % func=eval(fields);1205 % dtmin=min(diff(time));%time step1206 % time1=time(1);timend=time(end);1207 % timeq=[time1:dtmin:timend];%equal time spacing1208 % funcinterp=interp1(time,func,timeq); %interpolated func1209 % else1210 % varname=Field.ListVarName{1};1211 % eval(['funcinterp=Field.' varname ';'])1212 % end1213 % np=length(funcinterp);1214 % funcinterp=funcinterp-sum(funcinterp)/np; %substract mean1215 % fourier=fft(funcinterp);%take fft (complex)1216 % spec=abs(fourier).*abs(fourier);% take sqare of the modulus1217 % spec=spec([1:floor(np/2)]);%keep only the first half (the other is symmetric)1218 % eval(['Field.' varname '=spec;'])1219 % Field1220 % % dfreq=1/(time(end)-time(1));%frequency interval1221 % % freq=[0:dfreq:(floor(np/2)-1)*dfreq];1222 % % figure(1)1223 % % hold on1224 % % RUN(freq,spec)1225 % % xlabel('frequency (Hz)')1226 % % ylabel('spectral intensity')1227 % % title(['spectrum of' fields]);1228 % % grid on1229 1230 1231 1232 1233 847 1234 848 %%------------------------------------------------------- … … 1471 1085 % --- Executes on selection change in ACTION. 1472 1086 function ACTION_Callback(hObject, eventdata, handles) 1087 global nb_builtin 1473 1088 list_ACTION=get(handles.ACTION,'String');% list menu fields 1474 1089 index_ACTION=get(handles.ACTION,'Value');% selected string index … … 1476 1091 path_get_field=which('get_field');%path to series.m 1477 1092 list_path=get(handles.ACTION,'UserData'); 1478 nb_builtin=0; 1479 if iscell(list_path) 1480 for ilist=1:length(list_path) 1481 if isequal(list_path{ilist},path_get_field) 1482 nb_builtin=nb_builtin+1; 1483 else 1484 break 1485 end 1486 end 1487 end 1488 if nb_builtin==0% the path to get_field has been changed, reinitialize 1489 get_field_OpeningFcn(hObject, eventdata, handles) 1490 return 1491 end 1093 1094 % nb_builtin=0; 1095 % if iscell(list_path) 1096 % for ilist=1:length(list_path) 1097 % if isequal(list_path{ilist},path_get_field) 1098 % nb_builtin=nb_builtin+1; 1099 % else 1100 % break 1101 % end 1102 % end 1103 % end 1104 % if nb_builtin==0% the path to get_field has been changed, reinitialize 1105 % get_field_OpeningFcn(hObject, eventdata, handles) 1106 % return 1107 % end 1492 1108 1493 1109 % add a new function to the menu … … 1498 1114 browse_name=list_path{end};% initialize browser with the path of the last introduced function 1499 1115 end 1500 % fct_name='';1501 % dir_perso=prefdir;1502 % profil_perso=fullfile(dir_perso,'uvmat_perso.mat');1503 % display(profil_perso)1504 % if exist(profil_perso,'file')1505 % h=load (profil_perso);1506 % if isfield(h,'get_field_fct')1507 % fct_name=h.get_field_fct;1508 % end1509 % else1510 % path_to_uvmat=which ('uvmat');% check the path of uvmat1511 % pathfct=fileparts(path_to_uvmat);1512 % fct_name=fullfile(pathfct,'USR_FCT');%go to UVMAT/USR_FCT by default1513 % end1514 1116 [FileName, PathName] = uigetfile( ... 1515 1117 {'*.m', ' (*.m)'; … … 1520 1122 return 1521 1123 end 1522 ext_fct=FileName(end-1:end);1124 [pp,ACTION,ext_fct]=fileparts(FileName); 1523 1125 if ~isequal(ext_fct,'.m') 1524 1126 msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); 1525 1127 return 1526 1128 end 1527 ACTION=FileName(1:end-2);% ACTION choice updated by the selected item 1528 1129 % ACTION=FileName(1:end-2);% ACTION choice updated by the selected item 1529 1130 % insert the choice in the action menu 1530 1131 menu_str=update_menu(handles.ACTION,ACTION);%new action menu in which the new item has been appended if needed … … 1565 1166 %check the current path to the selected function 1566 1167 PathName=list_path{index_ACTION};%current recorded path 1567 if ~isequal(path_get_field,PathName)1568 CurrentPath=fileparts(which(ACTION));1569 if ~isequal(CurrentPath,PathName)&&~isequal(CurrentPath,fullfile(PathName,'private'))1570 addpath(PathName)1571 errormsg=check_functions;1572 msgbox_uvmat('CONFIRMATION',[['path ' PathName ' added to the current Matlab pathes'];errormsg])1573 end1574 end1168 % if ~isequal(path_get_field,PathName) 1169 % CurrentPath=fileparts(which(ACTION)); 1170 % if ~isequal(CurrentPath,PathName)%&&~isequal(CurrentPath,fullfile(PathName,'private')) 1171 % addpath(PathName) 1172 % errormsg=check_functions; 1173 % msgbox_uvmat('CONFIRMATION',[['path ' PathName ' added to the current Matlab pathes'];errormsg]) 1174 % end 1175 % end 1575 1176 set(handles.path_action,'String',PathName); %show the path to the senlected function 1576 1177 … … 1887 1488 set(handles.MenuFile_4,'Label',MenuFile_4) 1888 1489 set(handles.MenuFile_5,'Label',MenuFile_5) 1889 1490 dir_perso=prefdir; 1491 profil_perso=fullfile(dir_perso,'uvmat_perso.mat') 1492 if exist(profil_perso,'file') 1493 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat 1494 else 1495 txt=ver; 1496 Release=txt(1).Release; 1497 relnumb=str2double(Release(3:4)); 1498 if relnumb >= 14 1499 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat 1500 else 1501 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat 1502 end 1503 end 1890 1504 1891 1505 % %store input file in personal file uvmat_perso.mat -
trunk/src/read_get_field.m
r32 r34 31 31 empty_coord_x=0; 32 32 empty_coord_y=0; 33 dimname_y={};33 %dimname_y={}; 34 34 ListVarName={}; 35 35 VarDimName={}; 36 36 SubVarAttribute={}; 37 dim_x=0;38 dim_y=0;37 %dim_x=0; 38 %dim_y=0; 39 39 dim_z=0; 40 dim_vec_x=0;41 dim_vec_y=0;42 dim_vec_z=0;43 c_index=[];40 %dim_vec_x=0; 41 %dim_vec_y=0; 42 %dim_vec_z=0; 43 %c_index=[]; 44 44 45 45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 50 50 val=get(handles.ordinate,'Value');% selection(s) for ordinate 51 51 VarNameCell=inputlist(val); %names of the variable(s) in the list 52 VarIndex_y=[]; 53 dim_ordinate={}; 54 testpermute=[]; 55 subvarindex=[]; 52 56 for ilist=1:length(VarNameCell) 53 57 VarIndex_y(ilist)=name2index(VarNameCell{ilist},Field.ListVarName);%index of the variable in ListVarName … … 211 215 if isempty(VarIndex)% default abscissa = matrix index 212 216 % coord_z_name=dimname_A{1};% name of the x coordinate = dimension of the plotted quantity 213 empty_coord_z=1;217 % empty_coord_z=1; 214 218 else 215 219 dimname_z=Field.VarDimName{VarIndex}; … … 244 248 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 245 249 % vectors 246 test_vec_x_dimvar=0;%default247 test_vec_y_dimvar=0;%default248 test_vec_z_dimvar=0;%defaul250 % test_vec_x_dimvar=0;%default 251 % test_vec_y_dimvar=0;%default 252 % test_vec_z_dimvar=0;%defaul 249 253 dimname_vec_x=[]; 250 254 dimname_vec_y=[]; … … 317 321 end 318 322 end 319 test_vec_x_dimvar=1;323 % test_vec_x_dimvar=1; 320 324 SubVarAttribute{nbvar}.Role='dimvar';% dimension variable 321 325 else … … 350 354 end 351 355 end 352 test_vec_y_dimvar=1;356 % test_vec_y_dimvar=1; 353 357 SubVarAttribute{nbvar}.Role='dimvar';% dimension variable 354 358 else … … 365 369 if isempty(VarIndex)% default abscissa = matrix indexTODO like scalar 366 370 % coord_x_name=dimname_u{2};% name of the x coordinate = dimension of the plotted quantity 367 empty_coord_vec_z=1;371 % empty_coord_vec_z=1; 368 372 else 369 373 dimname_vec_z=Field.VarDimName{VarIndex}; … … 384 388 end 385 389 end 386 test_vec_z_dimvar=1;390 % test_vec_z_dimvar=1; 387 391 SubVarAttribute{nbvar}.Role='dimvar';% dimension variable 388 392 else … … 405 409 end 406 410 nbvar=nbvar+1; 407 w_index=nbvar;411 % w_index=nbvar; 408 412 ListVarName{nbvar}=Field.ListVarName{VarIndex}; 409 413 VarDimName{nbvar}=dimname_u; … … 426 430 end 427 431 nbvar=nbvar+1; 428 c_index=nbvar;432 % c_index=nbvar; 429 433 ListVarName{nbvar}=Field.ListVarName{VarIndex}; 430 434 VarDimName{nbvar}=Field.VarDimName{VarIndex}; … … 528 532 if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=field_var_index 529 533 if isfield(Field.VarAttribute{field_var_index},'Coord_2')&& isfield(Field.VarAttribute{field_var_index},'Coord_1') 530 Coord_2=Field.VarAttribute{field_var_index}.Coord_2;531 Coord_1=Field.VarAttribute{field_var_index}.Coord_1;534 % Coord_2=Field.VarAttribute{field_var_index}.Coord_2; 535 % Coord_1=Field.VarAttribute{field_var_index}.Coord_1; 532 536 testold=1; 533 537 end … … 571 575 %permute indices if coord_y is not the first matrix index: vector case 572 576 if test_vector 573 VarNameU=Field.ListVarName{VarIndexU}; 574 DimCellU=Field.VarDimName{VarIndexU} % list of dimensions for u component577 VarNameU=Field.ListVarName{VarIndexU}; % name of u component variable 578 DimCellU=Field.VarDimName{VarIndexU}; % list of dimensions for u component 575 579 eval(['npxy=size(SubField.' VarNameU ')']) % npxy= dimension values for the u component 576 580 SingleCellU={}; … … 579 583 DimCellU=DimCellU(end-numel(npxy)+1:end); %suppress the first singletons) dimensions 580 584 end 581 ind_single=find(npxy==1); 582 SingleCellU=[SingleCellU DimCellU(ind_single)]; 585 ind_single=find(npxy==1);%indices of singleton dimensions 586 if ind_single<=numel(DimCellU) 587 SingleCellU=[SingleCellU DimCellU(ind_single)]; 588 end 583 589 ind_select=find(npxy~=1);%look for non singleton dimensions 584 590 DimCellU=DimCellU(ind_select); … … 627 633 end 628 634 end 629 dimextra=(1:numel(DimCellU)); 630 dimextra(dimU)=[]; %list of unselected dimension indices 631 DimCellU=DimCellU([dimU dimextra]); 632 eval(['SubField.' VarNameU '=permute(squeeze(SubField.' VarNameU '),[dimU dimextra]);']) 633 eval(['SubField.' VarNameV '=permute(squeeze(SubField.' VarNameV '),[dimU dimextra]);']) 634 SubField.VarDimName{VarSubIndexU}=DimCellU; 635 SubField.VarDimName{VarSubIndexV}=DimCellU; 636 635 if numel(DimCellU)>1 636 dimextra=(1:numel(DimCellU)); 637 dimextra(dimU)=[]; %list of unselected dimension indices 638 DimCellU=DimCellU([dimU dimextra]); 639 eval(['SubField.' VarNameU '=permute(squeeze(SubField.' VarNameU '),[dimU dimextra]);']) 640 eval(['SubField.' VarNameV '=permute(squeeze(SubField.' VarNameV '),[dimU dimextra]);']) 641 SubField.VarDimName{VarSubIndexU}=DimCellU; 642 SubField.VarDimName{VarSubIndexV}=DimCellU; 643 end 637 644 %add default coord_x and/or coord_y if empty 638 645 if empty_coord_vec_x || empty_coord_vec_y … … 650 657 if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=field_var_index 651 658 if isfield(Field.VarAttribute{field_var_index},'Coord_2')&& isfield(Field.VarAttribute{field_var_index},'Coord_1') 652 Coord_2=Field.VarAttribute{field_var_index}.Coord_2;653 Coord_1=Field.VarAttribute{field_var_index}.Coord_1;659 % Coord_2=Field.VarAttribute{field_var_index}.Coord_2; 660 % Coord_1=Field.VarAttribute{field_var_index}.Coord_1; 654 661 testold=1; 655 662 end … … 711 718 eval(['npxy=size(SubField.' VarName ')']) 712 719 if numel(npxy) < numel(DimCell) 713 DimCell=DimCell(end-numel(npxy)+1:end); %suppress the first singletons) dimensions714 end 715 ind_select=find(npxy~=1) ;%look for non singleton dimensions716 DimCell=DimCell(ind_select);717 npxy=npxy(ind_select);720 % DimCell=DimCell(end-numel(npxy)+1:end); %suppress the first singletons) dimensions 721 end 722 % ind_select=find(npxy~=1) ;%look for non singleton dimensions 723 % DimCell=DimCell(ind_select); 724 % npxy=npxy(ind_select); 718 725 if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=VarIndex_y(1) ... 719 726 && isfield(Field.VarAttribute{VarIndex_y(1)},'Coord_1') 720 Coord_1=Field.VarAttribute{VarIndex_y(1)}.Coord_1;%old convention; use of coord_1727 % Coord_1=Field.VarAttribute{VarIndex_y(1)}.Coord_1;%old convention; use of coord_1 721 728 eval(['SubField.' coord_x_name '_index=linspace(Coord_1(1),Coord_1(end),npxy(1));']) 722 729 else -
trunk/src/series.m
r32 r34 135 135 menu_str={'check_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'}; 136 136 nb_builtin=numel(menu_str); %number of functions 137 138 %remove from the list the last option 'more...'139 137 [path_series,name,ext]=fileparts(which('series')); 140 path_series=fullfile(path_series,' /series');%path of the function 'series'138 path_series=fullfile(path_series,'series');%path of the function 'series' 141 139 142 140 for ilist=1:length(menu_str) 143 141 fct_path{ilist,1}=path_series;%paths of the fuctions buil-in in 'series.m' 144 142 end 145 dir_perso=prefdir; 143 % read the list of functions stored in the personal file 'uvmat_perso.mat' in prefdir 144 dir_perso=prefdir; 146 145 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 147 146 if exist(profil_perso,'file') -
trunk/src/uvmat.m
r33 r34 325 325 else 326 326 if ishandle(handles.UVMAT_title) 327 fid=fopen('revision.log') 327 fid=fopen('revision.log'); 328 328 if fid~=-1 329 329 a=textscan(fid,'%s%s%s',1,'HeaderLines',1,'Delimiter','|');
Note: See TracChangeset
for help on using the changeset viewer.