Changeset 421 for trunk/src/uvmat.m


Ignore:
Timestamp:
May 14, 2012, 7:03:14 AM (9 years ago)
Author:
sommeria
Message:

bugs corrections and improvements following tutorial presentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r415 r421  
    411411[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    412412oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    413 % oldfile=read_file_box,es(handles);
    414413if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
    415414         dir_perso=prefdir;
     
    422421         end
    423422end
    424 [FileName, PathName] = uigetfile( ...
    425        {'*.xml;*.xls;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol;*.nc;*.cmx;*.fig;*.log;*.dat;*.bat;', ' (*.xml,*.xls,*.civ,*.jpg ,*.png, .tif, *.avi,*.vol,*.nc,*.cmx,*.fig,*.log,*.dat,*.bat)';
    426        '*.xml',  '.xml files '; ...
    427         '*.xls',  '.xls files '; ...
    428         '*.civ',  '.civ files '; ...
    429         '*.jpg',' jpeg image files'; ...
    430         '*.png','.png image files'; ...
    431         '*.tif','.tif image files'; ...
    432         '*.avi;*.AVI','.avi movie files'; ...
    433         '*.vol','.volume images (png)'; ...
    434         '*.nc','.netcdf files'; ...
    435         '*.cdf','.netcdf files'; ...
    436         '*.cmx','.cmx text files ';...
    437         '*.fig','.fig files (matlab fig)';...
    438         '*.log','.log text files ';...
    439         '*.dat','.dat text files ';...
    440         '*.bat','.bat system command text files';...
    441         '*.*',  'All Files (*.*)'}, ...
    442         'Pick a file',oldfile);
     423% [FileName, PathName] = uigetfile( ...
     424%        {'*.xml;*.xls;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol;*.nc;*.cmx;*.fig;*.log;*.dat;*.bat;', ' (*.xml,*.xls,*.civ,*.jpg ,*.png, .tif, *.avi,*.vol,*.nc,*.cmx,*.fig,*.log,*.dat,*.bat)';
     425%        '*.xml',  '.xml files '; ...
     426%         '*.xls',  '.xls files '; ...
     427%         '*.civ',  '.civ files '; ...
     428%         '*.jpg',' jpeg image files'; ...
     429%         '*.png','.png image files'; ...
     430%         '*.tif','.tif image files'; ...
     431%         '*.avi;*.AVI','.avi movie files'; ...
     432%         '*.vol','.volume images (png)'; ...
     433%         '*.nc','.netcdf files'; ...
     434%         '*.cdf','.netcdf files'; ...
     435%         '*.cmx','.cmx text files ';...
     436%         '*.fig','.fig files (matlab fig)';...
     437%         '*.log','.log text files ';...
     438%         '*.dat','.dat text files ';...
     439%         '*.bat','.bat system command text files';...
     440%         '*.*',  'All Files (*.*)'}, ...
     441%         'Pick a file',oldfile);
     442
     443[FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',oldfile);
    443444fileinput=[PathName FileName];%complete file name
    444445sizf=size(fileinput);
     
    488489function MenuBrowse_1_Callback(hObject, eventdata, handles)
    489490%------------------------------------------------------------------------
    490 % huvmat=get(handles.run0,'parent');
    491 UvData=get(handles.uvmat,'UserData');
    492 
    493491RootPath=get(handles.RootPath,'String');
    494 [FileName, PathName, filterindex] = uigetfile( ...
    495        {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
    496        '*.xml',  '.xml files '; ...
    497         '*.xls',  '.xls files '; ...
    498         '*.civ',  '.civ files '; ...
    499         '*.jpg','.jpg image files'; ...
    500         '*.png','.png image files'; ...
    501         '*.avi;*.AVI','.avi movie files'; ...
    502         '*.nc','.netcdf files'; ...
    503         '*.cdf','.netcdf files'; ...
    504         '*.cmx','.cmx text files';...
    505         '*.cmx2','.cmx2 text files';...
    506         '*.fig','.fig files (matlab fig)';...
    507         '*.log','.log text files ';...
    508         '*.dat','.dat text files ';...
    509         '*.*',  'All Files (*.*)'}, ...
    510         'Pick a second file for comparison',RootPath);
     492% [FileName, PathName, filterindex] = uigetfile( ...
     493%        {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
     494%        '*.xml',  '.xml files '; ...
     495%         '*.xls',  '.xls files '; ...
     496%         '*.civ',  '.civ files '; ...
     497%         '*.jpg','.jpg image files'; ...
     498%         '*.png','.png image files'; ...
     499%         '*.avi;*.AVI','.avi movie files'; ...
     500%         '*.nc','.netcdf files'; ...
     501%         '*.cdf','.netcdf files'; ...
     502%         '*.cmx','.cmx text files';...
     503%         '*.cmx2','.cmx2 text files';...
     504%         '*.fig','.fig files (matlab fig)';...
     505%         '*.log','.log text files ';...
     506%         '*.dat','.dat text files ';...
     507%         '*.*',  'All Files (*.*)'}, ...
     508%         'Pick a second file for comparison',RootPath);
     509[FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',RootPath);
    511510fileinput_1=[PathName FileName];%complete file name
    512511sizf=size(fileinput_1);
     
    19971996
    19981997%% read the first input field if a filename has been introduced
     1998ParamIn.ColorVar='';%default variable name for vector color
    19991999if ~isempty(filename)
    20002000    ObjectName=filename;
     
    23502350
    23512351%% calculate scalar
    2352 if (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))%&&~strcmp(ParamOut.FieldName,'velocity')&& ~strcmp(ParamOut.FieldName,'get_field...');% ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
     2352if ~strcmp(ParamOut.FieldName,'get_field...')&& (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))%&&~strcmp(ParamOut.FieldName,'velocity')&& ~strcmp(ParamOut.FieldName,'get_field...');% ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
    23532353    Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1});
    23542354end
    2355 if numel(Field)==2 && ~test_keepdata_1 && (strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{2},'civx'))  &&~strcmp(ParamOut_1.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...')
     2355if numel(Field)==2 && ~strcmp(ParamOut_1.FieldName,'get_field...')&& ~test_keepdata_1 && (strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{2},'civx'))  &&~strcmp(ParamOut_1.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...')
    23562356     Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2});
    23572357end
     
    23862386    return
    23872387end
    2388 [NbDim,imax]=max(NbDim);
     2388[NbDim,imax]=max(NbDim);% spatial dimension of the input field
    23892389if isfield(UvData.Field,'NbDim')
    23902390    NbDim=UvData.Field.NbDim;% deal with plane fields containing z coordinates
    23912391end
     2392XName=''; %default
     2393YName='';
    23922394if ~isempty(VarType{imax}.coord_x)  && ~isempty(VarType{imax}.coord_y)    %unstructured coordinates
    23932395    XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
    23942396    YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
    2395     eval(['nbvec=length(UvData.Field.' XName ');'])%nbre of measurement points (e.g. vectors)
     2397    nbvec=length(UvData.Field.(XName));%nbre of measurement points (e.g. vectors)
    23962398    test_x=1;%test for unstructured coordinates
    23972399    if ~isempty(VarType{imax}.coord_z)
     
    24022404elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 %structured coordinate
    24032405    XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
    2404     if NbDim>1
     2406    if NbDim> 1 && VarType{imax}.coord(NbDim-1)>0
    24052407        YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
    24062408    end
     2409    VarIndex=CellVarIndex{imax}; % list of variable indices
     2410DimIndex=VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
     2411nbpoints_x=DimValue(DimIndex(NbDim));
     2412XMax=nbpoints_x;%default
     2413XMin=1;%default
    24072414end
    24082415if NbDim==3
     
    24202427    end
    24212428end
    2422 if exist('XName','var')
    2423     eval(['XMax=max(max(UvData.Field.' XName '));'])
    2424     eval(['XMin=min(min(UvData.Field.' XName '));'])
     2429
     2430if ~isempty (XName)
     2431    XMax=max(max(UvData.Field.(XName)));
     2432    XMin=min(min(UvData.Field.(XName)));
    24252433    UvData.Field.NbDim=NbDim;
    24262434    UvData.Field.XMax=XMax;
    24272435    UvData.Field.XMin=XMin;
    2428     if NbDim >1
    2429         eval(['YMax=max(max(UvData.Field.' YName '));'])
    2430         eval(['YMin=min(min(UvData.Field.' YName '));'])
     2436    if NbDim >1&& ~isempty(YName)
     2437        YMax=max(max(UvData.Field.(YName)));
     2438        YMin=min(min(UvData.Field.(YName)));
    24312439        UvData.Field.YMax=YMax;
    2432         UvData.Field.YMin=YMin;
    2433     end
    2434     eval(['nbvec=length(UvData.Field.' XName ');'])
     2440        UvData.Field.YMin=YMin; 
     2441    end
     2442    nbvec=length(UvData.Field.(XName));
    24352443    if test_x %unstructured coordinates
    24362444        if test_z
     
    24402448            UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D
    24412449        end
     2450    end
     2451end
     2452if ~test_x
     2453    %         VarIndex=CellVarIndex{imax}; % list of variable indices
     2454    %         DimIndex=VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
     2455    %         nbpoints_x=DimValue(DimIndex(NbDim));
     2456    DX=(XMax-XMin)/(nbpoints_x-1);
     2457    if NbDim >1
     2458        nbpoints_y=DimValue(DimIndex(NbDim-1));
     2459        if isempty(YName)% if the y coordinate is not expressed, it is taken as the matrix index
     2460            DY=1;
     2461            UvData.Field.YMax=nbpoints_y;
     2462            UvData.Field.YMin=1;
     2463        else
     2464            DY=(YMax-YMin)/(nbpoints_y-1);
     2465        end
     2466    end
     2467    if NbDim==3
     2468        nbpoints_z=DimValue(DimIndex(1));
     2469        DZ=(ZMax-ZMin)/(nbpoints_z-1);
     2470        UvData.Field.Mesh=(DX*DY*DZ)^(1/3);
     2471        UvData.Field.ZMax=ZMax;
     2472        UvData.Field.ZMin=ZMin;
    24422473    else
    2443         VarIndex=CellVarIndex{imax}; % list of variable indices
    2444         DimIndex=VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
    2445         nbpoints_x=DimValue(DimIndex(NbDim));
    2446         DX=(XMax-XMin)/(nbpoints_x-1);
    2447         if NbDim >1
    2448             nbpoints_y=DimValue(DimIndex(NbDim-1));
    2449             DY=(YMax-YMin)/(nbpoints_y-1);
    2450         end
    2451         if NbDim==3
    2452             nbpoints_z=DimValue(DimIndex(1));
    2453             DZ=(ZMax-ZMin)/(nbpoints_z-1);
    2454             UvData.Field.Mesh=(DX*DY*DZ)^(1/3);
    2455             UvData.Field.ZMax=ZMax;
    2456             UvData.Field.ZMin=ZMin;
    2457         else
    2458             UvData.Field.Mesh=DX;%sqrt(DX*DY);
    2459         end
    2460     end
    2461     % adjust the mesh to a value 1, 2 , 5 *10^n
    2462     ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude
    2463     if UvData.Field.Mesh/ord>=5
    2464         UvData.Field.Mesh=5*ord;
    2465     elseif UvData.Field.Mesh/ord>=2
    2466         UvData.Field.Mesh=2*ord;
    2467     else
    2468         UvData.Field.Mesh=ord;
    2469     end
    2470 end
     2474        UvData.Field.Mesh=DX;%sqrt(DX*DY);
     2475    end
     2476end
     2477% adjust the mesh to a value 1, 2 , 5 *10^n
     2478ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude
     2479if UvData.Field.Mesh/ord>=5
     2480    UvData.Field.Mesh=5*ord;
     2481elseif UvData.Field.Mesh/ord>=2
     2482    UvData.Field.Mesh=2*ord;
     2483else
     2484    UvData.Field.Mesh=ord;
     2485end
     2486
    24712487
    24722488%% 3D case (menuvolume)
     
    25602576%PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
    25612577PlotParam{1}=read_GUI(handles.uvmat);
    2562 %default settings if vectors not visible (should not be needed)
     2578%default settings if vectors not visible
    25632579if ~isfield(PlotParam{1},'Vectors')
    25642580    PlotParam{1}.Vectors.MaxVec=1;
     
    25952611        return
    25962612    end
    2597     if testnewseries && isfield(ObjectData,'CoordUnit')
     2613    if testnewseries
     2614        PlotParam{imap}.Scalar.CheckBW=[]; %B/W option depends on the input field (image or scalar)
     2615        if isfield(ObjectData,'CoordUnit')
    25982616        PlotParam{imap}.Coordinates.CheckFixEqual=1;% set x and y scaling equal if CoordUnit is defined (common unit for x and y)
     2617        end
    25992618    end
    26002619    %use of mask (TODO: check)
     
    44254444hset_object=set_object(data,handles);% call the set_object interface
    44264445hhset_object=guidata(hset_object);
    4427 set(hhset_object.PLOT,'enable','on')% activate the refresh button
     4446hchild=get(hset_object,'children');
     4447set(hchild,'enable','on')
     4448%set(hhset_object.PLOT,'enable','on')% activate the refresh button
    44284449%set(handles.MenuObject,'checked','on')
    44294450set(handles.uvmat,'UserData',UvData)
Note: See TracChangeset for help on using the changeset viewer.