Changeset 34


Ignore:
Timestamp:
Mar 3, 2010, 11:58:05 PM (14 years ago)
Author:
sommeria
Message:

get_field: list of actions put as functions in subdir get_field (like done for series), store and retrieve the latest opened files.
series: bug repair for action functions
read_get_field: bug repair for the case of vectors with unstructured coordinates

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_field.m

    r17 r34  
    4343% End initialization code - DO NOT EDIT
    4444
    45 
     45%------------------------------------------------------------------------
    4646% --- Executes just before get_field is made visible.
    4747function get_field_OpeningFcn(hObject, eventdata, handles,filename,Field,haxes)
    48 
    49 set(handles.dimensions,'enable','on')% should be put by guide
     48%------------------------------------------------------------------------
     49global nb_builtin
    5050browse_fig(handles.list_fig)
    5151
     
    5555% Update handles structure
    5656guidata(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
     60menu_str={'PLOT';'FFT';'filter_band';'histogram'}; %list of functions included in 'get_field.m'
     61nb_builtin=numel(menu_str)-1;
     62%menu_str(end)=[];%remove from the list the last option 'more...'
     63path_get_field=fileparts(which('get_field'));%path of the function 'get_field'
     64for 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'
     66end
     67dir_perso=prefdir;
     68profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     69if 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
     79end
     80menu_str=[menu_str;{'more...'}];
     81set(handles.ACTION,'String',menu_str)
     82set(handles.ACTION,'UserData',fct_path)% store the list of path in UserData of ACTION 
     83ACTION_Callback(hObject, eventdata, handles)
    6084set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles})%set mouse click action function
    6185if exist('filename','var')& ischar(filename)
     
    6387    inputfile_Callback(hObject, eventdata, handles)
    6488else
    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','')   
     90end
    10691if exist('Field','var') & isstruct(Field)
    10792        Field_input(eventdata,handles,Field)
     
    11297end
    11398
    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%------------------------------------------------------------------------
    116122% --- Outputs from this function are returned to the command line.
    117123function varargout = get_field_OutputFcn(hObject, eventdata, handles)
     124%------------------------------------------------------------------------
    118125varargout{1} = handles.output;
    119126
    120 %-----------------------------------------------------------
     127%------------------------------------------------------------------------
    121128% --- Executes on button press in browse.
    122129function browse_Callback(hObject, eventdata, handles)
    123 
    124 
    125 %---------------------------------------------------------
     130%------------------------------------------------------------------------
     131
     132%------------------------------------------------------------------------
    126133function inputfile_Callback(hObject, eventdata, handles)
     134%------------------------------------------------------------------------
    127135inputfile=get(handles.inputfile,'String');
    128136Field=nc2struct(inputfile,[]);% reads only the lists of fields, dimensions and attributes
     
    131139Field_input(eventdata,handles,Field);
    132140
    133 
    134 %---------------------------------------------------------
     141%------------------------------------------------------------------------
    135142function Field_input(eventdata,handles,Field)
    136 
     143%------------------------------------------------------------------------
    137144if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName)
    138145    Tabcell(:,1)=Field.ListDimName;
     
    203210end
    204211
    205 
    206 %----------------------------------------------------------
     212%------------------------------------------------------------------------
    207213function ordinate_Callback(hObject, eventdata, handles)
     214%------------------------------------------------------------------------
    208215%update_field(hObject, eventdata, handles)
    209216% A REVOIR
     
    236243%update_UserData(handles)
    237244
    238 %----------------------------------------------------------------------
     245%------------------------------------------------------------------------
    239246% --- Executes on selection change in abscissa.
    240247function abscissa_Callback(hObject, eventdata, handles)
     248%------------------------------------------------------------------------
    241249 hselect_field=get(handles.inputfile,'parent');
    242250 Field=get(hselect_field,'UserData');%current input field
     
    379387function update_field(hObject, eventdata, handles,VarName)
    380388% VarName= input variable name for scalar or vector plots
    381 %if ischar(VarName)
    382389hselect_field=get(handles.inputfile,'parent');
    383390Field=get(hselect_field,'UserData');
     
    730737function RUN_Callback(hObject, eventdata, handles)
    731738%---------------------------------------------------------
     739path_get_field=fileparts(which('get_field'));
    732740list=get(handles.ACTION,'String');
    733741index=get(handles.ACTION,'Value');
    734742ACTION=list{index};
    735 hselect_field=get(handles.inputfile,'parent');%handle of the get_field interface
    736 feval(ACTION,hselect_field);
     743list_path=get(handles.ACTION,'UserData');
     744%hselect_field=get(handles.inputfile,'parent');%handle of the get_field interface
     745fct_path=list_path{index}; %path stored for the function ACTION
     746if ~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
     751end
     752% fct_path
     753eval(['h_fun=@' ACTION ';'])
     754if ~isequal(fct_path,path_get_field)
     755        rmpath(fct_path)% add the prescribed path if not the current one   
     756end
     757
     758set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
     759drawnow
     760h_fun(handles.figure1);%handles.figure1 =handles of the GUI get_field
    737761browse_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     return
    747 end
    748 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 else
    754 hfig=str2num(list_fig{val});% chosen figure number from tyhe GUI
    755 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 else
    761     figure(hfig);
    762 end
    763 haxes=findobj(hfig,'Type','axes');
    764 plot_field(SubField,haxes)
    765 end
    766 
    767 
    768 %
    769 % return
    770 %  testuvmat=0;
    771 %     if test_scalar|test_vector
    772 %          [DimVarIndex,CellVarIndex,NbDim]=find_field_indices(SubField);
    773 %          NbDim=max(NbDim);
    774 %          if NbDim==3
    775 %            testuvmat=1; %uvmat interface needed for 3D plots
    776 %          end
    777 %     end
    778 %     if iscell(list_fig)
    779 %         RUN_fig=list_fig{fig_index};
    780 %     else
    781 %         RUN_fig='new fig...';%new plotting axes must be created
    782 %     end
    783 %     if isequal(RUN_fig,'new fig...') &  (test_scalar|test_vector)
    784 %         RUN_fig='uvmat';%use uvmat for a new fig
    785 %     end
    786 %     if testuvmat
    787 %         RUN_fig='uvmat';
    788 %     end
    789 %     if isequal(RUN_fig,'uvmat')
    790 %         
    791 %         huvmat=uvmat(SubField);
    792 %         menu=update_menu(handles.list_fig,'uvmat');%add the selected fct to the menu
    793 %     else
    794 %         test_new=1;
    795 %         if ~isequal(RUN_fig,'new fig...')
    796 %             sep=regexp(RUN_fig,'_')%look for subaxes in a fig
    797 %             if isempty(sep)
    798 %                 axe_index=1;
    799 %             else
    800 %                 axe_index=str2num(RUN_fig(sep+1:end))
    801 %                 RUN_fig=RUN_fig([1:sep-1])             
    802 %             end
    803 %             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 %                     else
    810 %                        iselect(iaxe)=1;
    811 %                     end
    812 %                 end
    813 %                 haxes=haxes(find(iselect));   
    814 %                 if length(haxes)>=axe_index
    815 %                     test_new=0
    816 %                     haxes=haxes(axe_index);
    817 %                     set(haxes,'NextPlot','add')
    818 %                 end
    819 %             end
    820 %         end
    821 %         if test_new
    822 %             hfig=figure;
    823 %             haxes=axes;
    824 %             menu=update_menu(handles.list_fig,num2str(hfig));%add the selected fct to the menu
    825 %         end 
    826 %         RUN_field(SubField,haxes)       
    827 %     end
    828 % end
    829 %
    830 %
    831 %
    832 %
    833 %  w components
    834 % end
    835 %
    836 %
    837 % % select the variable  index (or indices) for z coordinates
    838 % test_grid=0;
    839 % if test_scalar | test_vector
    840 %     nbdim=length(DimIndex);
    841 %     if nbdim > 3
    842 %         warndlg_uvmat('array with more than three dimensions, not supported','ERROR')
    843 %         return
    844 %     else
    845 %         perm_ind=[1:nbdim];
    846 %     end
    847 %     if nbdim==3
    848 %         zstring=get(handles.coord_z_vectors_scalar,'String');
    849 %         zindex=get(handles.coord_z_vectors_scalar,'Value'); %selected indices in the ordinate listbox
    850 %         list_var=zstring(zindex);
    851 %         VarIndex_z=name2index(list_var,Field.ListVarName);%index of the selected variable
    852 %         if isequal(VarIndex.A,VarIndex_z)|isequal(VarIndex.u,VarIndex_z)|isequal(VarIndex.v,VarIndex_z)|isequal(VarIndex.w,VarIndex_z)
    853 %             if zindex ~= 1
    854 %                 set(handles.coord_z_vectors_scalar,'Value',1)%ordinate cannot be the same as scalar or vector components
    855 %                 return
    856 %             end
    857 %         else
    858 %             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 singleton
    863 %             if isequal(DimIndex_z,DimIndex)
    864 %                 VarAttribute{VarIndex_z}.Role='coord_z';%unstructured coordinates
    865 %             elseif length(DimIndex_z)==1
    866 %                 VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z};  %dimension variable
    867 %                 ind_z=find(DimIndex==DimIndex_z(1));
    868 %                 perm_ind(ind_z)=1;
    869 %                 test_grid=1;
    870 %             else
    871 %                 warndlg_uvmat('multiple dimensions for the z coordinate','ERROR')
    872 %                 return
    873 %             end
    874 %         end
    875 % %         if ~isempty(VarIndex_z)
    876 % %             DimIndex_z=Field.VarDimIndex{VarIndex_z};%dimension indices of the variable   
    877 % %             if length(DimIndex_z)==1 & nbdim==3 %dimension variable
    878 % %                 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 % %             end
    883 % %         end
    884 %     end
    885 % end
    886 %
    887 % % select the variable  index (or indices) for ordinate
    888 % ystring=get(handles.ordinate,'String');
    889 % yindex=get(handles.ordinate,'Value'); %selected indices in the ordinate listbox
    890 % 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 components
    894 % else
    895 %     for ivar=1:length(VarIndex.y)
    896 %         VarAttribute{VarIndex.y(ivar)}.Role='coord_y';
    897 %     end
    898 %     VarIndex_tot=[VarIndex_tot VarIndex.y];
    899 % end
    900 % if (test_scalar | test_vector) &  ~isempty(VarIndex.y)
    901 %     DimIndex_y=Field.VarDimIndex{VarIndex.y};%dimension indices of the variable
    902 %     if length(DimIndex_y)==1
    903 %         ind_y=find(DimIndex==DimIndex_y(1));
    904 %         test_grid=1;
    905 %         if nbdim==3
    906 %             VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y};
    907 %             perm_ind(ind_y)=2;
    908 %         elseif nbdim==2
    909 %             VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y};
    910 %              perm_ind(ind_y)=1;
    911 %         end
    912 %     elseif test_grid
    913 %         warndlg_uvmat('the dimension of the y coordinate variable should be 1','ERROR')   
    914 %     end
    915 % end
    916 %
    917 % %select the variable index for the abscissa
    918 % 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_var
    922 % if length(VarIndex.x)==1   
    923 %     DimIndex_x=Field.VarDimIndex{VarIndex.x};
    924 %     DimValue=Field.DimValue(DimIndex_x);
    925 %     ind=find(DimValue==1);         
    926 %     DimIndex_x(ind)=[];%Mremove singleton                     
    927 %     VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x};  %dimension variable           
    928 % %     VarAttribute{VarIndex.x}.Role='coord_x';%default (may be modified)
    929 %     index_detect=find(VarIndex_tot==VarIndex.x);
    930 % else
    931 %     index_detect=[];%coord x variable not already used
    932 % end
    933 % if isempty(index_detect)
    934 %     VarIndex_tot=[VarIndex_tot VarIndex.x];
    935 % else
    936 %     VarIndex.x=[];
    937 %     set(handles.abscissa,'Value',1)%vchosen abscissa already chosen, suppres it as abscissa
    938 % end
    939 %
    940 % if (test_scalar | test_vector) &  ~isempty(VarIndex.x)
    941 %     DimIndex_x=Field.VarDimIndex{VarIndex.x};%dimension indices of the variable
    942 %     if length(DimIndex_x)==1
    943 %         ind_x=find(DimIndex==DimIndex_x(1));
    944 %         if nbdim==3
    945 %             %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x};
    946 %             perm_ind(ind_x)=3;
    947 %         elseif nbdim==2
    948 %             %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x};
    949 %              perm_ind(ind_x)=2;
    950 %         end
    951 %         if isequal(perm_ind,[1:nbdim])
    952 %             test_grid=0;
    953 %         end
    954 %         DimIndex=DimIndex(perm_ind);
    955 %     elseif test_grid
    956 %         warndlg_uvmat('the dimension of the x coordinate variable should be 1','ERROR')   
    957 %     end
    958 %     if isequal(DimIndex_x,DimIndex)
    959 %                 VarAttribute{VarIndex.x}.Role='coord_x';%unstructured coordinates
    960 %     end
    961 % end
    962 %
    963 % %defined the selected sub-field SubField
    964 % 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.u
    970 %     VarAttribute{ivar}.Role='vector_x';
    971 %     if test_grid
    972 %         VarDimIndex{ivar}=DimIndex; %permute dimensions
    973 %     end
    974 % end
    975 % for ivar=VarIndex.v
    976 %     VarAttribute{ivar}.Role='vector_y';
    977 %      if test_grid
    978 %         VarDimIndex{ivar}=DimIndex;%permute dimensions
    979 %     end
    980 % end
    981 % for ivar=VarIndex.A
    982 %     if test_grid
    983 %         VarDimIndex{ivar}=DimIndex;%permute dimensions
    984 %     end
    985 %     if isempty(iuA)
    986 %         VarAttribute{ivar}.Role='scalar';%Role =scalar
    987 %     else
    988 %        VarAttribute=[VarAttribute VarAttribute{ivar}]; %duplicate the attribute for a new variable
    989 %        nbattr=length(VarAttribute);
    990 %        VarAttribute{nbattr}.Role='scalar';
    991 %     end
    992 % end
    993 % 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 SubField
    1000 % for ivar=1:length(VarIndex_tot)
    1001 %     VarName=Field.ListVarName{VarIndex_tot(ivar)};
    1002 %     eval(['SubField.' VarName '=Field.' VarName ';'])
    1003 % end
    1004 % if test_grid
    1005 %     for ivar=1:length(VarIndex.u)
    1006 %          VarName=Field.ListVarName{VarIndex.u(ivar)};
    1007 %         eval(['SubField.' VarName '=permute(SubField.' VarName ',perm_ind);'])
    1008 %     end
    1009 %
    1010 %     for ivar=1:length(VarIndex.v)
    1011 %          VarName=Field.ListVarName{VarIndex.v(ivar)};
    1012 %         eval(['SubField.' VarName '=permute(SubField.' VarName ',perm_ind);'])
    1013 %     end
    1014 %     for ivar=1:length(VarIndex.A)
    1015 %          VarName=Field.ListVarName{VarIndex.A(ivar)};
    1016 %         eval(['SubField.' VarName '=permute(SubField.' VarName ',perm_ind);'])
    1017 %     end   
    1018 % end   
    1019 % if ~isempty(iuA)
    1020 %     VarName= ['A' Field.ListVarName{iuA}]; %create the new variable to distinguish the scaler form the velocity component
    1021 %     SubField.ListVarName=[SubField.ListVarName VarName];
    1022 %     SubField.VarDimIndex=[SubField.VarDimIndex Field.VarDimIndex(iuA)];
    1023 %     eval(['SubField.' VarName '=Field.'  Field.ListVarName{iuA} ';'])
    1024 % end
    1025 % % dimension of SubField
    1026 % if test_scalar|test_vector
    1027 %    % SubField.NbDim=2;
    1028 %     SubField.InputFile=get(handles.inputfile,'String');
    1029 %     SubField.get_field_handle=hselect_field;
    1030 % else
    1031 %     SubField.NbDim=1;
    1032 % end
    1033 %
    1034 % list_fig=get(handles.list_fig,'String');
    1035 % fig_index=get(handles.list_fig,'Value');
    1036 % %ACTION on SubField
    1037 % 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_vector
    1045 %          [DimVarIndex,CellVarIndex,NbDim]=find_field_indices(SubField);
    1046 %          NbDim=max(NbDim);
    1047 %          if NbDim==3
    1048 %            testuvmat=1; %uvmat interface needed for 3D plots
    1049 %          end
    1050 %     end
    1051 %     if iscell(list_fig)
    1052 %         RUN_fig=list_fig{fig_index};
    1053 %     else
    1054 %         RUN_fig='new fig...';%new plotting axes must be created
    1055 %     end
    1056 %     if isequal(RUN_fig,'new fig...') &  (test_scalar|test_vector)
    1057 %         RUN_fig='uvmat';%use uvmat for a new fig
    1058 %     end
    1059 %     if testuvmat
    1060 %         RUN_fig='uvmat';
    1061 %     end
    1062 %     if isequal(RUN_fig,'uvmat')
    1063 %         
    1064 %         huvmat=uvmat(SubField);
    1065 %         menu=update_menu(handles.list_fig,'uvmat');%add the selected fct to the menu
    1066 %     else
    1067 %         test_new=1;
    1068 %         if ~isequal(RUN_fig,'new fig...')
    1069 %             sep=regexp(RUN_fig,'_')%look for subaxes in a fig
    1070 %             if isempty(sep)
    1071 %                 axe_index=1;
    1072 %             else
    1073 %                 axe_index=str2num(RUN_fig(sep+1:end))
    1074 %                 RUN_fig=RUN_fig([1:sep-1])             
    1075 %             end
    1076 %             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 %                     else
    1083 %                        iselect(iaxe)=1;
    1084 %                     end
    1085 %                 end
    1086 %                 haxes=haxes(find(iselect));   
    1087 %                 if length(haxes)>=axe_index
    1088 %                     test_new=0
    1089 %                     haxes=haxes(axe_index);
    1090 %                     set(haxes,'NextPlot','add')
    1091 %                 end
    1092 %             end
    1093 %         end
    1094 %         if test_new
    1095 %             hfig=figure;
    1096 %             haxes=axes;
    1097 %             menu=update_menu(handles.list_fig,num2str(hfig));%add the selected fct to the menu
    1098 %         end 
    1099 %         RUN_field(SubField,haxes)       
    1100 %     end
    1101 % end
    1102 % %Field.VarIndex=VarIndex; %save for use in uvmat
    1103 % % set(hselect_field,'UserData',Field)
    1104762
    1105763
     
    1187845% saveas(2,answer{1})
    1188846 
    1189 %
    1190 % % --- Executes on selection change in spectrum.
    1191 % function Field=FFT(Field)
    1192 % 'TESTFFT'
    1193 % Field
    1194 % nbfield=length(Field.ListVarName);
    1195 % if nbfield==0
    1196 %     warndlg_uvmat('no field selected for FFT','ERROR')
    1197 % elseif nbfield>2
    1198 %     warndlg_uvmat('select only one field for FFT','ERROR')
    1199 % end
    1200 % if nbfield==2
    1201 % % list_fields=get(handles.spectrum,'String');% list menu fields
    1202 % % index_fields=get(handles.spectrum,'Value');% selected string index
    1203 % % fields= list_fields{index_fields(1)}; % selected action
    1204 % % func=eval(fields);
    1205 %     dtmin=min(diff(time));%time step
    1206 %     time1=time(1);timend=time(end);
    1207 %     timeq=[time1:dtmin:timend];%equal time spacing
    1208 %     funcinterp=interp1(time,func,timeq); %interpolated func
    1209 % else
    1210 %     varname=Field.ListVarName{1};
    1211 %     eval(['funcinterp=Field.' varname ';'])
    1212 % end
    1213 % np=length(funcinterp);
    1214 % funcinterp=funcinterp-sum(funcinterp)/np; %substract mean
    1215 % fourier=fft(funcinterp);%take fft (complex)
    1216 % spec=abs(fourier).*abs(fourier);% take sqare of the modulus
    1217 % spec=spec([1:floor(np/2)]);%keep only the first half (the other is symmetric)
    1218 % eval(['Field.' varname '=spec;'])
    1219 % Field
    1220 % % dfreq=1/(time(end)-time(1));%frequency interval
    1221 % % freq=[0:dfreq:(floor(np/2)-1)*dfreq];
    1222 % % figure(1)
    1223 % % hold on
    1224 % % RUN(freq,spec)
    1225 % % xlabel('frequency (Hz)')
    1226 % % ylabel('spectral intensity')
    1227 % % title(['spectrum of' fields]);
    1228 % % grid on
    1229 
    1230 
    1231 
    1232 
    1233847
    1234848%%-------------------------------------------------------
     
    14711085% --- Executes on selection change in ACTION.
    14721086function ACTION_Callback(hObject, eventdata, handles)
     1087global nb_builtin
    14731088list_ACTION=get(handles.ACTION,'String');% list menu fields
    14741089index_ACTION=get(handles.ACTION,'Value');% selected string index
     
    14761091path_get_field=which('get_field');%path to series.m
    14771092list_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
    14921108
    14931109% add a new function to the menu
     
    14981114        browse_name=list_path{end};% initialize browser with  the path of the last introduced function
    14991115    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 %           end
    1509 %     else
    1510 %         path_to_uvmat=which ('uvmat');% check the path of uvmat
    1511 %         pathfct=fileparts(path_to_uvmat);
    1512 %         fct_name=fullfile(pathfct,'USR_FCT');%go to UVMAT/USR_FCT by default
    1513 %     end
    15141116    [FileName, PathName] = uigetfile( ...
    15151117       {'*.m', ' (*.m)';
     
    15201122        return
    15211123    end
    1522     ext_fct=FileName(end-1:end);
     1124    [pp,ACTION,ext_fct]=fileparts(FileName);
    15231125    if ~isequal(ext_fct,'.m')
    15241126        msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
    15251127        return
    15261128    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 
    15291130    % insert the choice in the action menu
    15301131   menu_str=update_menu(handles.ACTION,ACTION);%new action menu in which the new item has been appended if needed
     
    15651166   %check the current path to the selected function
    15661167PathName=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     end
    1574 end
     1168% 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
    15751176set(handles.path_action,'String',PathName); %show the path to the senlected function
    15761177   
     
    18871488set(handles.MenuFile_4,'Label',MenuFile_4)
    18881489set(handles.MenuFile_5,'Label',MenuFile_5)
    1889 
     1490dir_perso=prefdir;
     1491profil_perso=fullfile(dir_perso,'uvmat_perso.mat')
     1492if 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
     1494else
     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
     1503end
    18901504
    18911505% %store input file in personal file uvmat_perso.mat
  • trunk/src/read_get_field.m

    r32 r34  
    3131empty_coord_x=0;
    3232empty_coord_y=0;
    33 dimname_y={};
     33%dimname_y={};
    3434ListVarName={};
    3535VarDimName={};
    3636SubVarAttribute={};
    37 dim_x=0;
    38 dim_y=0;
     37%dim_x=0;
     38%dim_y=0;
    3939dim_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=[];
    4444
    4545%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    5050    val=get(handles.ordinate,'Value');% selection(s) for ordinate
    5151    VarNameCell=inputlist(val); %names of the variable(s) in the list
     52    VarIndex_y=[];
     53    dim_ordinate={};
     54    testpermute=[];
     55    subvarindex=[];
    5256    for ilist=1:length(VarNameCell)
    5357        VarIndex_y(ilist)=name2index(VarNameCell{ilist},Field.ListVarName);%index of the variable in ListVarName
     
    211215        if isempty(VarIndex)% default abscissa = matrix index
    212216%             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;
    214218        else
    215219            dimname_z=Field.VarDimName{VarIndex};
     
    244248%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    245249% vectors
    246 test_vec_x_dimvar=0;%default
    247 test_vec_y_dimvar=0;%default
    248 test_vec_z_dimvar=0;%defaul
     250% test_vec_x_dimvar=0;%default
     251% test_vec_y_dimvar=0;%default
     252% test_vec_z_dimvar=0;%defaul
    249253dimname_vec_x=[];
    250254dimname_vec_y=[];
     
    317321                end
    318322            end
    319             test_vec_x_dimvar=1;
     323%             test_vec_x_dimvar=1;
    320324            SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
    321325        else
     
    350354                end
    351355            end
    352             test_vec_y_dimvar=1;
     356%             test_vec_y_dimvar=1;
    353357            SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
    354358        else
     
    365369        if isempty(VarIndex)% default abscissa = matrix indexTODO like scalar
    366370    %         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;
    368372        else
    369373            dimname_vec_z=Field.VarDimName{VarIndex};
     
    384388                    end
    385389                end
    386                 test_vec_z_dimvar=1;
     390%                 test_vec_z_dimvar=1;
    387391                SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
    388392            else
     
    405409        end
    406410        nbvar=nbvar+1;
    407         w_index=nbvar;
     411%         w_index=nbvar;
    408412        ListVarName{nbvar}=Field.ListVarName{VarIndex};
    409413        VarDimName{nbvar}=dimname_u;
     
    426430        end
    427431        nbvar=nbvar+1;
    428         c_index=nbvar;
     432%         c_index=nbvar;
    429433        ListVarName{nbvar}=Field.ListVarName{VarIndex};
    430434        VarDimName{nbvar}=Field.VarDimName{VarIndex};
     
    528532        if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=field_var_index
    529533            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;
    532536                testold=1;
    533537            end
     
    571575%permute indices if coord_y is not the first matrix index: vector case
    572576if test_vector
    573     VarNameU=Field.ListVarName{VarIndexU};
    574     DimCellU=Field.VarDimName{VarIndexU} % list of dimensions for u component 
     577    VarNameU=Field.ListVarName{VarIndexU}; % name of u component variable
     578    DimCellU=Field.VarDimName{VarIndexU}; % list of dimensions for u component 
    575579    eval(['npxy=size(SubField.' VarNameU ')']) % npxy= dimension values for the u component
    576580    SingleCellU={};
     
    579583        DimCellU=DimCellU(end-numel(npxy)+1:end); %suppress the first singletons) dimensions
    580584    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
    583589    ind_select=find(npxy~=1);%look for non singleton dimensions
    584590    DimCellU=DimCellU(ind_select);
     
    627633        end
    628634    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
    637644    %add default coord_x and/or coord_y if empty
    638645    if empty_coord_vec_x || empty_coord_vec_y
     
    650657        if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=field_var_index
    651658            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;
    654661                testold=1;
    655662            end
     
    711718        eval(['npxy=size(SubField.' VarName ')'])
    712719        if numel(npxy) < numel(DimCell)
    713             DimCell=DimCell(end-numel(npxy)+1:end); %suppress the first singletons) dimensions
    714         end
    715         ind_select=find(npxy~=1) ;%look for non singleton dimensions
    716         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);
    718725        if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=VarIndex_y(1) ...
    719726                             && isfield(Field.VarAttribute{VarIndex_y(1)},'Coord_1')
    720              Coord_1=Field.VarAttribute{VarIndex_y(1)}.Coord_1;%old convention; use of coord_1
     727%              Coord_1=Field.VarAttribute{VarIndex_y(1)}.Coord_1;%old convention; use of coord_1
    721728             eval(['SubField.' coord_x_name '_index=linspace(Coord_1(1),Coord_1(end),npxy(1));'])
    722729        else
  • trunk/src/series.m

    r32 r34  
    135135menu_str={'check_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'};
    136136nb_builtin=numel(menu_str); %number of functions
    137  
    138 %remove from the list the last option 'more...'
    139137[path_series,name,ext]=fileparts(which('series'));
    140 path_series=fullfile(path_series,'/series');%path of the function 'series'
     138path_series=fullfile(path_series,'series');%path of the function 'series'
    141139
    142140for ilist=1:length(menu_str)
    143141    fct_path{ilist,1}=path_series;%paths of the fuctions buil-in in 'series.m'
    144142end
    145 dir_perso=prefdir;
     143% read the list of functions stored in the personal file 'uvmat_perso.mat' in prefdir
     144dir_perso=prefdir;
    146145profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    147146if exist(profil_perso,'file')
  • trunk/src/uvmat.m

    r33 r34  
    325325else
    326326   if ishandle(handles.UVMAT_title)
    327        fid=fopen('revision.log')
     327       fid=fopen('revision.log');
    328328       if fid~=-1
    329329        a=textscan(fid,'%s%s%s',1,'HeaderLines',1,'Delimiter','|');
Note: See TracChangeset for help on using the changeset viewer.