Changeset 387 for trunk/src/civ.m


Ignore:
Timestamp:
Apr 4, 2012, 3:31:30 PM (12 years ago)
Author:
sommeria
Message:

several bugs corrected: mask, color image...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r386 r387  
    10951095        Param.xml=s.RunParam;
    10961096    else
    1097         msgbox_uvmat('ERROR','no run civ binaries defined in PARAM.xml')
     1097        errormsg='no run civ binaries defined in PARAM.xml';
    10981098        return
    10991099    end
     
    11101110    [s,w]=system(test_command);
    11111111    if ~isequal(s,0)
    1112         msgbox_uvmat('ERROR',[batch_mode ' batch system not available'])
     1112        errormsg=[batch_mode ' batch system not available'];
    11131113        return
    11141114    end
     
    11371137                Param.xml.(bin_name{1})=fullname;
    11381138            else
    1139                 msgbox_uvmat('ERROR',['Binary ' Param.xml.(bin_name{1}) ' defined in PARAM.xml does not exist'])
     1139                errormsg=['Binary ' Param.xml.(bin_name{1}) ' defined in PARAM.xml does not exist'];
    11401140                return
    11411141            end
     
    12391239%                         Param.Civ1.Grid=[filecell.filebase '_' name_generator(Param.Civ1.Grid,i1_grid,1,'.grid','_i')];
    12401240                        if ~exist(Param.Civ1.GridName,'file')
    1241                             msgbox_uvmat('ERROR','grid file absent for civ1')
     1241                            errormsg='grid file absent for civ1';
     1242                            return
    12421243                        end
    12431244                    elseif ~exist(Param.Civ1.Grid,'file')
    1244                         msgbox_uvmat('ERROR','grid file absent for civ1')
     1245                        errormsg='grid file absent for civ1';
     1246                        return
    12451247                    end
    12461248                end
     
    12501252            switch CivMode
    12511253                case 'CivX'
    1252                     cmd=[cmd...
    1253                         cmd_civ1(filecell.nc.civ1{ifile,j},Param) '\n'];
     1254                    [cmd_civ,errormsg]=cmd_civ1(filecell.nc.civ1{ifile,j},Param);
     1255                    cmd=[cmd cmd_civ '\n'];
    12541256                    if ~isempty(errormsg)
    1255                         msgbox_uvmat('ERROR',errormsg)
    12561257                        return
    12571258                    end
     
    13181319%                                 patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')];
    13191320                                if ~exist(patch1.gridPatch,'file')
    1320                                     msgbox_uvmat('ERROR','grid file absent for patch1')
     1321                                    errormsg='grid file absent for patch1';
     1322                                    return
    13211323                                end
    13221324                            elseif exist(gridname,'file')
    13231325                                patch1.gridPatch=gridname;
    13241326                            else
    1325                                 msgbox_uvmat('ERROR','grid file absent for patch1')
     1327                                errormsg='grid file absent for patch1';
     1328                                return
    13261329                            end
    13271330                        end
     
    14561459%                                 patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')];
    14571460                                if ~exist(patch2.gridPatch,'file')
    1458                                     msgbox_uvmat('ERROR','grid file absent for patch2')
     1461                                    errormsg='grid file absent for patch2';
     1462                                    return
    14591463                                end
    14601464                            elseif exist(gridname,'file')
    14611465                                patch2.gridPatch=gridname;
    14621466                            else
    1463                                 msgbox_uvmat('ERROR','grid file absent for patch2')
     1467                                errormsg='grid file absent for patch2';
     1468                                return
    14641469                            end
    14651470                        end
     
    14951500                [fid,message]=fopen(filename_bat,'w');
    14961501                if isequal(fid,-1)
    1497                     msgbox_uvmat('ERROR', ['creation of .bat file: ' message])
     1502                    errormsg=['creation of .bat file: ' message];
    14981503                    return
    14991504                end
     
    15161521                        [fid,message]=fopen(filename_bat,'w');
    15171522                        if isequal(fid,-1)
    1518                             msgbox_uvmat('ERROR', ['creation of .bat file: ' message])
     1523                            errormsg= ['creation of .bat file: ' message];
    15191524                            return
    15201525                        end
     
    15371542                        if isempty(errormsg)
    15381543                            display([filecell.nc.civ1{ifile,j} ' written'])
    1539                         else
    1540                             msgbox_uvmat('ERROR',errormsg)
     1544%                         else
     1545%                             msgbox_uvmat('ERROR',errormsg)
    15411546                        end
    15421547                    end
     
    30313036else %case civ2 alone
    30323037    if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value')
    3033         if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir')
     3038        if ~exist(fullfile(RootPath,subdir_civ2,ext_dir),'dir')
    30343039            errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist'])
    30353040            set(handles.ListPairCiv2,'Value',1);
     
    36373642    end
    36383643end
    3639 %------------------------------------------------------------------------
    3640 % --- Executes on button press in CheckMask.
     3644
     3645%------------------------------------------------------------------------
     3646% --- Executes on button press in CheckMask: common to all panels (civ1, Civ2..)
    36413647function CheckMask_Callback(hObject, eventdata, handles)
    36423648%------------------------------------------------------------------------
     
    36453651parent_tag=get(hparent,'Tag');
    36463652hchildren=get(hparent,'children');
    3647 handle_txtbox=findobj(hchildren,'tag','txt_Mask');
    3648 % handle_dx=findobj(hchildren,'tag','num_Dx');
    3649 % handle_dy=findobj(hchildren,'tag','num_Dy');
     3653handle_txtbox=findobj(hchildren,'tag','Mask');% look for the mask name box in the same panel
    36503654testmask=0;
    36513655if value
     
    36733677end
    36743678if testmask
    3675 %     stage=4;%default
    36763679    if strcmp(parent_tag,'Civ1')
    3677             set(handles.Mask,'Visible','on')
     3680        set(handles.Mask,'Visible','on')
    36783681        set(handles.Mask,'String',filemask)
    36793682    set(handles.CheckMask,'Value',1)
     
    39073910    Data.VarDimName= {'ny','nx',{'ny','nx'}};
    39083911    Data.A=imread(filecell.ima1.civ1{1});
     3912    if ndims(Data.A)==3 %case of color image
     3913        Data.VarDimName= {'ny','nx',{'ny','nx','rgb'}};
     3914    end
    39093915    Data.ny=[size(Data.A,1) 1];
    39103916    Data.nx=[1 size(Data.A,2)];
     
    39153921    Param.Civ1=par_civ1;
    39163922    Grid=civ_matlab(Param);% get the grid of x, y positions set for PIV
    3917     hview_field=view_field(Data);
     3923    hview_field=view_field(Data); %view the image in the GUI view_field
    39183924    set(0,'CurrentFigure',hview_field)
    39193925    hhview_field=guihandles(hview_field);
     
    39603966
    39613967%------------------------------------------------------------------------
    3962 function cmd=cmd_civ1(filename,Param)
     3968function [cmd,errormsg]=cmd_civ1(filename,Param)
    39633969%------------------------------------------------------------------------
    39643970%pixels per cm and matrix of the image times, read from the .civ file by uvmat
    39653971%changes : filename_cmx -> filename ( no extension )
    39663972cmd='';
    3967 errormsg=''; %default
    39683973filename=regexprep(filename,'.nc',''); %file name for the result
    39693974if isequal(Param.Civ1.Dt,0)
     
    39723977Param.Civ1.ImageA=regexprep(Param.Civ1.ImageA,'.png','');
    39733978Param.Civ1.ImageB=regexprep(Param.Civ1.ImageB,'.png','');
    3974 fid=fopen([filename '.civ1.cmx'],'w');
     3979[fid,errormsg]=fopen([filename '.civ1.cmx'],'w');
    39753980if isequal(fid,-1)
    3976     display(['cmd file ' filename ' cannot be created'])
     3981    errormsg=['cmd file ' filename ' cannot be created: ' errormsg];
    39773982    return
    39783983end
     
    40544059filename=regexprep(filename,'.nc','');
    40554060MaskName_string='';%default
    4056 % if Param.(fixname).CheckMask
    4057 %     MaskName_string=[' -maskName "' Param.(fixname).Mask '"'];
    4058 % end
    40594061MaxVel_string='';%default
    40604062if ~isempty(Param.(fixname).MaxVel)
     
    40954097%------------------------------------------------------------------------
    40964098% --- CheckCiv2  CheckCiv2  CheckCiv2 CheckCiv2
    4097 function cmd=cmd_civ2(filename,Param)
     4099function [cmd,errormsg]=cmd_civ2(filename,Param)
    40984100%------------------------------------------------------------------------
    40994101%pixels per cm and matrix of the image times, read from the .civ file by uvmat
    41004102% global civ2Bin sge%name of the executable for checkciv1 calculation
     4103 cmd='';
    41014104filename=regexprep(filename,'.nc','');
    41024105if isequal(Param.Civ2.Dt,'0')
     
    41074110[fid,errormsg]=fopen([filename '.civ2.cmx'],'w');
    41084111if isequal(fid,-1)
    4109     msgbox_uvmat('ERROR',errormsg)
    4110     cmd='';
    41114112    return
    41124113end
Note: See TracChangeset for help on using the changeset viewer.