Changeset 193 for trunk/src/uvmat.m


Ignore:
Timestamp:
Feb 20, 2011, 10:42:19 AM (13 years ago)
Author:
sommeria
Message:

improves the use of get_field, no projection object by default in uvmat( allows usual 1D plots),

various bug repairs, elimination of get_plot_handles.m (not useful)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r192 r193  
    201201function uvmat_OpeningFcn(hObject, eventdata, handles, input )
    202202%------------------------------------------------------------------------
    203 global nb_builtin
    204 
    205 % Choose default command menuline output for uvmat
     203
     204%% Choose default command menuline output for uvmat (standard GUI)
    206205handles.output = hObject;
    207206
    208 % Update handles structure
     207%% Update handles structure (standard GUI)
    209208guidata(hObject, handles);
    210209
    211 % set the position of colorbar and ancillary GUIs:
     210%% set the position of colorbar and ancillary GUIs:
    212211set(hObject,'Units','Normalized')
    213212movegui(hObject,'center')
     
    223222set(handles.axes3,'UserData',AxeData)
    224223
    225 %functions for the mouse and keyboard
     224%% set functions for the mouse and keyboard
    226225set(handles.histo_u,'NextPlot','replacechildren');
    227226set(handles.histo_v,'NextPlot','replacechildren');
     
    232231set(hObject,'DeleteFcn',{@closefcn})%
    233232
    234 %refresh projection plane
    235 UvData.Object{1}.Style='plane';%main plotting plane
     233%% refresh projection plane
     234%UvData.Object{1}.Style='plane';%main plotting plane
    236235UvData.Object{1}.ProjMode='projection';%main plotting plane
    237236if ~isfield(UvData.Object{1},'plotaxes')
    238237    UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
    239238    set(handles.list_object_1,'Value',1);
    240     set(handles.list_object_1,'String',{'1-PLANE'});
     239   % set(handles.list_object_1,'String',{'1-PLANE'});
     240   set(handles.list_object_1,'String',{''});
    241241end
    242242set(handles.Fields,'Value',1)
    243 set(handles.Fields,'string',{''})%TODO:  PUT IN THE GUI
    244 
    245 %TRANSFORM menu: builtin fcts
     243set(handles.Fields,'string',{''})
     244
     245%% TRANSFORM menu: builtin fcts
    246246menu_str={'';'phys';'px';'phys_polar'};
    247 nb_builtin=numel(menu_str); %number of functions
     247UvData.OpenParam.NbBuiltin=numel(menu_str); %number of functions
    248248path_uvmat=fileparts(which('uvmat'));
    249249addpath(fullfile(path_uvmat,'transform_field'))
     
    261261rmpath(fullfile(path_uvmat,'transform_field'))
    262262
    263 %load the list of previously browsed files in menus Open and Open_1
     263%% load the list of previously browsed files in menus Open and Open_1
    264264 dir_perso=prefdir; % path to the directory .matlab for personal data
    265265 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
     
    291291                [path,file]=fileparts(h.transform_fct{ilist});
    292292                addpath(path)
    293 %              if exist(file,'file')
    294293                h_func=str2func(file);
    295294                rmpath(path)
     
    311310set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
    312311set(handles.uvmat,'UserData',UvData)
    313 %set(handles.FixEqual,'Value',1)% by default: axes free to adapt in aspect ratio
    314 %set(handles.FixEqual,'BackgroundColor',[1 1 0])
    315 
    316 %check the path and date of modification of all functions in uvmat
     312
     313%% check the path and date of modification of all functions in uvmat
    317314path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat
    318315[errormsg,date_str]=check_functions;%check the path of the functions called by uvmat.m
    319316date_str=['last modification: ' date_str];
    320 %case of an input argument for uvmat
     317
     318%% case of an input argument for uvmat
    321319testinputfield=0;
    322320inputfile=[];
     
    349347    end
    350348    if ~isempty(inputfile)
     349        %%%%% display the indput field %%%%%%%
    351350        display_file_name(hObject, eventdata, handles,inputfile)
     351        %%%%%%%
    352352        testinputfield=1;
    353353    end
     
    366366   end
    367367end
    368 % UvData.NewSeries=1;
    369 set(handles.uvmat,'UserData',UvData)
     368% set(handles.uvmat,'UserData',UvData)
     369
     370%% plot input field if exists
    370371if testinputfield
    371372    %delete drawn objects
     
    604605        set(handles.list_object_1,'Visible','on')
    605606        set(handles.frame_object,'Visible','on')
    606          % initiate input file:
     607         %%%%%% initiate input file:
    607608        update_rootinfo(hObject,eventdata,handles); 
    608609    otherwise
     
    743744        XmlData.GeometryCalib
    744745        if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y')
    745             'TESTvol'
    746746            set (handles.nb_slice,'String','volume')
    747747        end
     
    872872
    873873if testima
    874 %   set(handles.Fields,'Value',1) % set menu to 'image'
    875 %    set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
    876874elseif isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
    877875   Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ');
     
    901899end 
    902900
    903 % set index navigation options and refresh plots
     901%% set index navigation options and refresh plots
    904902set(handles.RootPath,'BackgroundColor',[1 1 1])
    905903drawnow
     
    923921NomTypeRaw=regexprep(NomType(2:end), '-', '');
    924922if numel(regexp(NomTypeRaw,'\D'))>=1
    925 %     case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab','#A','%01dA','%02dA','%03dA','%04dA'},% two navigation indices
    926923        state_j='on';
    927924        if isequal(nbfield,1)
     
    932929    NomTypeRaw=regexprep(NomType_1(2:end), '-', '');
    933930    if numel(regexp(NomTypeRaw,'\D'))>=1
    934 %     switch NomType_1
    935 %         case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
    936931            state_j='on';
    937932            if isequal(nbfield,1)
     
    954949set(handles.j_text,'Visible',state_j);
    955950
    956 % view the field 
     951%% view the field 
    957952run0_Callback(hObject, eventdata, handles); %view field
    958953mask_test=get(handles.mask_test,'value');
     
    11691164set(handles.FileExt_1,'String',FileExt_1);
    11701165
    1171 % default choice of fields
    1172 if isequal(ext_test,'.image')
    1173 %    set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
    1174 %    set(handles.Fields_1,'Value',2) % set menu to 'image'
    1175 elseif strcmp(FileExt_1,'.nc')||strcmp(FileExt_1,'.cdf')
    1176    Data=nc2struct(fileinput_1,[]);
    1177 %    if isfield(Data,'absolut_time_T0')
    1178 %        set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
    1179 %        set(handles.Fields_1,'Value',4) % set menu to 'velocity'
    1180 %    else   
    1181 %        set(handles.Fields_1,'Value',2) % set menu to 'get_field...'
    1182 %        set(handles.Fields_1,'String',{'';'get_field...'});
    1183 %    end
    1184 end 
     1166% % default choice of fields
     1167% if isequal(ext_test,'.image')
     1168% %    set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
     1169% %    set(handles.Fields_1,'Value',2) % set menu to 'image'
     1170% elseif strcmp(FileExt_1,'.nc')||strcmp(FileExt_1,'.cdf')
     1171%    Data=nc2struct(fileinput_1,[]);
     1172% %    if isfield(Data,'absolut_time_T0')
     1173% %        set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
     1174% %        set(handles.Fields_1,'Value',4) % set menu to 'velocity'
     1175% %    else   
     1176% %        set(handles.Fields_1,'Value',2) % set menu to 'get_field...'
     1177% %        set(handles.Fields_1,'String',{'';'get_field...'});
     1178% %    end
     1179% end 
    11851180set(handles.SubField,'Visible','on')
    11861181set(handles.SubField,'Value',1)
     
    24052400    eval(['nbvec=length(UvData.Field.' XName ');'])%nbre of measurement points (e.g. vectors)
    24062401    test_x=1;%test for unstructured coordinates
    2407 else %structured coordinate
    2408     YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
     2402elseif VarType{imax}.coord(NbDim)>0 %structured coordinate 
    24092403    XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
     2404    if NbDim>1
     2405        YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
     2406    end
    24102407end
    24112408if NbDim==3
     
    24192416    end
    24202417end
     2418if exist('XName','var')
    24212419eval(['XMax=max(UvData.Field.' XName ');'])
    24222420eval(['XMin=min(UvData.Field.' XName ');'])
    2423 eval(['YMax=max(UvData.Field.' YName ');'])
    2424 eval(['YMin=min(UvData.Field.' YName ');'])
     2421UvData.Field.NbDim=NbDim;
     2422UvData.Field.XMax=XMax;
     2423UvData.Field.XMin=XMin;
     2424if NbDim >1
     2425    eval(['YMax=max(UvData.Field.' YName ');'])
     2426    eval(['YMin=min(UvData.Field.' YName ');'])
     2427    UvData.Field.YMax=YMax;
     2428    UvData.Field.YMin=YMin;
     2429end
    24252430eval(['nbvec=length(UvData.Field.' XName ');'])
    24262431if test_x %unstructured coordinates
     
    24342439    VarIndex=CellVarIndex{imax}; % list of variable indices
    24352440    DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
    2436     nbpoints_y=UvData.Field.DimValue(DimIndex(NbDim-1));
    24372441    nbpoints_x=UvData.Field.DimValue(DimIndex(NbDim));
    24382442    DX=(XMax-XMin)/(nbpoints_x-1);
    2439     DY=(YMax-YMin)/(nbpoints_y-1);
     2443    if NbDim >1
     2444        nbpoints_y=UvData.Field.DimValue(DimIndex(NbDim-1));
     2445        DY=(YMax-YMin)/(nbpoints_y-1);
     2446    end
    24402447    if NbDim==3
    24412448        nbpoints_z=UvData.Field.DimValue(DimIndex(1));
     
    24482455    end
    24492456end
    2450 UvData.Field.NbDim=NbDim;
    2451 UvData.Field.XMax=XMax;
    2452 UvData.Field.XMin=XMin;
    2453 UvData.Field.YMax=YMax;
    2454 UvData.Field.YMin=YMin;
    2455 
     2457end
    24562458
    24572459%% 3D case (menuvolume)
     
    25112513else
    25122514    % create a default projection menuplane
    2513     UvData.Object{1}.Style='plane';%main plotting plane
     2515    %UvData.Object{1}.Style='none';%main plotting plane
    25142516    UvData.Object{1}.ProjMode='projection';%main plotting plane
    25152517    UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
    25162518    set(handles.list_object_1,'Value',1);
    2517     set(handles.list_object_1,'String',{'1-PLANE'});
     2519    set(handles.list_object_1,'String',{''});
    25182520end
    25192521if ~isfield(UvData.Object{1},'plotaxes')
     
    25532555        haxes(2)=plot_handles{2}.axes3;
    25542556        PlotParam{2}=read_plot_param(plot_handles{2});%read plotting parameters on the uvmat interface
    2555         keeplim(2)=get(plot_handles{2}.FixedLimits,'Value');
     2557        keeplim(2)=get(plot_handles{2}.FixLimits,'Value');
    25562558        PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
    25572559    end
     
    28292831if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
    28302832    nc=netcdf.open(filename,'NC_WRITE');
    2831     netcdf.reDef(nc)
    2832     netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
     2833    netcdf.reDef(nc);
     2834    netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1);
    28332835    dimid = netcdf.inqDimID(nc,nbname);
    28342836    try
     
    28372839        varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
    28382840    end
    2839     netcdf.endDef(nc)
     2841    netcdf.endDef(nc);
    28402842    netcdf.putVar(nc,varid,UvData.axes3.FF);
    2841     netcdf.close(nc) 
     2843    netcdf.close(nc); 
    28422844else %old netcdf library
    28432845    netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
     
    38193821function transform_fct_Callback(hObject, eventdata, handles)
    38203822%-------------------------------------------------------------
    3821 global nb_builtin
    3822 
    3823 huvmat=get(handles.transform_fct,'parent');
     3823
     3824UvData=get(handles.uvmat,'UserData');
    38243825menu=get(handles.transform_fct,'String');
    38253826ind_coord=get(handles.transform_fct,'Value');
     
    38593860   profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    38603861   if exist(profil_perso,'file')
     3862       nb_builtin=UvData.OpenParam.NbBuiltin;
    38613863       for ilist=nb_builtin+1:numel(list_transform)
    38623864           ff=functions(list_transform{ilist});
     
    38773879set(handles.FixLimits,'Value',0)
    38783880set(handles.FixLimits,'BackgroundColor',[0.7 0.7 0.7])
    3879 
    3880 UvData=get(huvmat,'UserData');
    38813881
    38823882%delete drawn objects
     
    39113911   UvData=rmfield(UvData,'MaskName'); %will impose mask refresh 
    39123912end
    3913 set(huvmat,'UserData',UvData)
     3913set(handles.uvmat,'UserData',UvData)
    39143914run0_Callback(hObject, eventdata, handles)
    39153915
     
    41794179    colcode.colcode2=str2num(get(handles.colcode2,'String'));
    41804180end
    4181 % colcode.option=get(handles.vec_col_bar,'Value');
    41824181colcode.FixedCbounds=0;
    4183 % list_code=get(handles.col_vec,'String');% list menu fields
    4184 % index_code=get(handles.col_vec,'Value');% selected string index
    4185 % colcode.CName= list_code{index_code(1)}; % selected field used for vector color
    41864182colcode.FixedCbounds=1;
    41874183vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*(0.5:width-0.5)/width;%sample of vec_C values from min to max
     
    42034199UvData=get(handles.uvmat,'UserData');
    42044200AxeData=UvData.axes3;
    4205 'TESTupdateplot'
    4206 PlotParam=read_plot_param(handles)
    4207 PlotParam.Vectors
     4201PlotParam=read_plot_param(handles);
    42084202[PP,PlotParamOut]= plot_field(AxeData,haxes,PlotParam);
    4209 'TESTOUT'
    4210 PlotParamOut
    42114203write_plot_param(handles,PlotParamOut); %update the auto plot parameters
    42124204
     
    42144206% --- Executes on button press in grid.
    42154207function grid_Callback(hObject, eventdata, handles)
    4216 
    42174208
    42184209
Note: See TracChangeset for help on using the changeset viewer.