Changeset 450 for trunk/src/uvmat.m


Ignore:
Timestamp:
Jun 12, 2012, 12:27:42 AM (13 years ago)
Author:
sommeria
Message:

various bugs repaired

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r446 r450  
    4141%     - Information defined from the interface:
    4242%           .NewSeries: =1 when the first view of a new field series is displayed, else 0
    43 %           .filename:(char string)
     43%           .FileName:(char string)
    4444%           .FieldName: (char string) main field selected('image', 'velocity'...)
    4545%           .CName: (char string)name of the scalar used for vector colors
    4646%          .MovieObject{1}: movie object representing an input movie
    4747%          .MovieObject{2}: idem for a second input series (_1)
    48 %          .filename_1 : last second input file name (to deal with a constant second input without reading again the file)
     48%          .FileName_1 : last second input file name (to deal with a constant second input without reading again the file)
    4949%          .ZMin, .ZMax: range of the z coordinate
    5050%..... to complement
     
    787787            else
    788788                msgbox_uvmat('WARNING','unable to synchronise the indices of the two series')
    789 %                 set(handles.SubField,'Value',0)
    790 %                 SubField_Callback([], [], handles)
    791789            end
    792790        end
     
    846844UvData.j1_series{index}=j1_series;
    847845UvData.j2_series{index}=j2_series;
    848 % set(handles.CheckFixPair,'Value',1) % activate by default the comp_input '-'input window
    849846set(handles.FixVelType,'Value',0); %desactivate fixed veltype
    850847if index==1
     
    924921    [XmlData,warntext]=imadoc2struct(filexml);
    925922    if ~isempty(warntext)
    926         msgbox_uvmat('WARNING',warntext)
     923        display(warntext)
     924%         msgbox_uvmat('WARNING',warntext)
    927925    end
    928926    if isfield(XmlData,'TimeUnit')
     
    19681966% Field: structure describing an optional input field (then replace the input file)
    19691967
    1970 function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)
     1968function errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,Field)
    19711969%------------------------------------------------------------------------
    19721970
     
    19851983%% determine the main input file information for action
    19861984FileType=[];%default
    1987 if ~exist(filename,'file')
    1988     errormsg=['input file ' filename ' does not exist'];
     1985if ~exist(FileName,'file')
     1986    errormsg=['input file ' FileName ' does not exist'];
    19891987    return
    19901988end
     
    20102008ParamIn.ColorVar='';%default variable name for vector color
    20112009frame_index=1;%default
    2012 if ~isempty(filename)
    2013     ObjectName=filename;
     2010if ~isempty(FileName)
    20142011    FieldName='';%default
    20152012    VelType='';%default
     
    20362033            end
    20372034        case {'video','mmreader'}
    2038             ObjectName=UvData.MovieObject{1};     
     2035            ParamIn=UvData.MovieObject{1};     
    20392036            if ~strcmp(NomType,'*')
    20402037                frame_index=num_j1;%frame index for movies or multimage
     
    20602057    ParamIn.VelType=VelType;
    20612058    ParamIn.GUIName='get_field';
    2062     [Field{1},ParamOut,errormsg] = read_field(ObjectName,UvData.FileType{1},ParamIn,frame_index);
     2059    [Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index);
    20632060    if ~isempty(errormsg)
    2064         errormsg=['error in reading ' filename ': ' errormsg];
     2061        errormsg=['error in reading ' FileName ': ' errormsg];
    20652062        return
    20662063    end 
     
    20772074end
    20782075
    2079 %% choose and read a second field filename_1 if defined
     2076%% choose and read a second field FileName_1 if defined
    20802077VelType_1=[];%default
    20812078FieldName_1=[];
    20822079ParamOut_1=[];
    20832080frame_index_1=1;
    2084 if ~isempty(filename_1)
    2085     if ~exist(filename_1,'file')
    2086         errormsg=['second file ' filename_1 ' does not exist'];
     2081if ~isempty(FileName_1)
     2082    if ~exist(FileName_1,'file')
     2083        errormsg=['second file ' FileName_1 ' does not exist'];
    20872084        return
    20882085    end
    2089     Name=filename_1;
     2086    Name=FileName_1;
    20902087    switch UvData.FileType{2}
    20912088        case {'civx','civdata','netcdf'};
     
    21082105            end
    21092106        case {'video','mmreader'}
    2110             Name=UvData.MovieObject{2};
     2107            ParamIn_1=UvData.MovieObject{2};
    21112108                        if ~strcmp(NomType_1,'*')
    21122109                frame_index_1=num_j1;%frame index for movies or multimage
     
    21362133    test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
    21372134    if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
    2138         if isfield(UvData,'filename_1')%&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
    2139             test_keepdata_1= strcmp(filename_1,UvData.filename_1) ;%&& strcmp(FieldName_1,UvData.FieldName_1);
     2135        if isfield(UvData,'FileName_1')%&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
     2136            test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ;%&& strcmp(FieldName_1,UvData.FieldName_1);
    21402137        end
    21412138    end
     
    21492146        [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn_1,frame_index_1);
    21502147        if ~isempty(errormsg)
    2151             errormsg=['error in reading ' FieldName_1 ' in ' filename_1 ': ' errormsg];
     2148            errormsg=['error in reading ' FieldName_1 ' in ' FileName_1 ': ' errormsg];
    21522149            return
    21532150        end
     
    21952192%% update the display menu for the second velocity type (second menuline)
    21962193test_veltype_1=0;
    2197 if isempty(filename_1)
     2194if isempty(FileName_1)
    21982195    set(handles.Fields_1,'Value',1); %update the field menu
    21992196    set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu
     
    23392336
    23402337%% store the current open names, fields and vel types in uvmat interface
    2341 UvData.filename_1=filename_1;
     2338UvData.FileName_1=FileName_1;
    23422339
    23432340%% apply coordinate transform or other user fct
     
    23542351transform=transform_list{choice_value};%selected function handles
    23552352% z index
    2356 if ~isempty(filename)
     2353if ~isempty(FileName)
    23572354    Field{1}.ZIndex=z_index;
    23582355end
     
    27222719                hget_field=findobj(allchild(0),'name','get_field');
    27232720                if isempty(hget_field)
    2724                     get_field(filename)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
     2721                    get_field(FileName)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
    27252722                end
    27262723                errormsg='The field defined by get_field cannot be plotted';
     
    29472944% [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
    29482945[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    2949 filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    2950 %filename=read_file_boxes(handles);
    2951 [erread,message]=fileattrib(filename);
     2946FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     2947%FileName=read_file_boxes(handles);
     2948[erread,message]=fileattrib(FileName);
    29522949if ~isempty(message) && ~isequal(message.UserWrite,1)
    2953      msgbox_uvmat('ERROR',['no writting access to ' filename])
     2950     msgbox_uvmat('ERROR',['no writting access to ' FileName])
    29542951     return
    29552952end
     
    29732970hhh=which('netcdf.open');% look for built-in matlab netcdf library
    29742971if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
    2975     nc=netcdf.open(filename,'NC_WRITE');
     2972    nc=netcdf.open(FileName,'NC_WRITE');
    29762973    netcdf.reDef(nc);
    29772974    netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1);
     
    29862983    netcdf.close(nc); 
    29872984else %old netcdf library
    2988     netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
     2985    netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname)
    29892986end
    29902987
     
    29922989%----Correct the netcdf file, using toolbox (old versions of Matlab).
    29932990%-------------------------------------------------------------------
    2994 function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
    2995 nc=netcdf(filename,'write'); %open netcdf file
     2991function netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname)
     2992nc=netcdf(FileName,'write'); %open netcdf file
    29962993result=redef(nc);
    29972994eval(['nc.' attrname '=1;']);
     
    30903087    set(handles.VelType_1,'visible','off')
    30913088    [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    3092     filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    3093     %filename=read_file_boxes(handles);
     3089    FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     3090    %FileName=read_file_boxes(handles);
    30943091    hget_field=findobj(allchild(0),'name','get_field');
    30953092    if ~isempty(hget_field)
    30963093        delete(hget_field)
    30973094    end
    3098     hget_field=get_field(filename);
     3095    hget_field=get_field(FileName);
    30993096    set(hget_field,'Name','get_field')
    31003097    hhget_field=guidata(hget_field);
     
    31473144            '*.*',  'All Files (*.*)'}, ...
    31483145            'Pick a netcdf file',FileBase);
    3149         filename=[PathName FileName];
     3146        FullFileName=[PathName FileName];
    31503147        % display the selected field and related information
    3151         display_file_name( handles,filename)
     3148        display_file_name( handles,FullFileName)
    31523149        return
    31533150    end
     
    31863183    UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read)
    31873184end
    3188 UvData.filename_1='';% desactivate the use of a constant second file
     3185UvData.FileName_1='';% desactivate the use of a constant second file
    31893186list_fields=get(handles.Fields,'String');% list menu fields
    31903187field= list_fields{get(handles.Fields,'Value')}; % selected string
     
    32013198%% read the rootfile input display
    32023199[RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);
    3203 filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
     3200FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
    32043201[tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String'));
    32053202% set(handles.FileIndex_1,'Visible','on')
     
    32123209            delete(hget_field)
    32133210        end
    3214         hget_field=get_field(filename_1);
     3211        hget_field=get_field(FileName_1);
    32153212        set(hget_field,'name','get_field_1')
    32163213        hhget_field=guidata(hget_field);
     
    33263323set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic)
    33273324UvData=get(handles.uvmat,'UserData');
    3328 %refresh field with a second filename=first file name
     3325%refresh field with a second FileName=first file name
    33293326set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
    33303327drawnow   
    33313328InputFile=read_GUI(handles.InputFile);
    33323329[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    3333 filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     3330FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    33343331
    33353332if isempty(InputFile.VelType_1)
    3336         filename_1='';% we plot the current field without the second field
     3333        FileName_1='';% we plot the current field without the second field
    33373334        set(handles.SubField,'Value',0)
    33383335        SubField_Callback(hObject, eventdata, handles)
    33393336elseif get(handles.SubField,'Value')% if subfield is already 'on'
    33403337      [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
    3341      filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
     3338     FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
    33423339else
    3343      filename_1=filename;% we compare two fields in the same file by default
     3340     FileName_1=FileName;% we compare two fields in the same file by default
    33443341     UvData.FileType{2}=UvData.FileType{1};
    33453342     set(handles.SubField,'Value',1)
     
    33483345    UvData=rmfield(UvData,'Field_1');% removes the stored second field if it exists
    33493346end
    3350 UvData.filename_1='';% desactivate the use of a constant second file
     3347UvData.FileName_1='';% desactivate the use of a constant second file
    33513348set(handles.uvmat,'UserData',UvData)
    33523349num_i1=stra2num(get(handles.i1,'String'));
     
    33553352num_j2=stra2num(get(handles.j2,'String'));
    33563353
    3357 errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
     3354errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2);
    33583355
    33593356if ~isempty(errormsg)
Note: See TracChangeset for help on using the changeset viewer.