Changeset 229 for trunk/src/civ.m


Ignore:
Timestamp:
Apr 2, 2011, 9:48:51 AM (14 years ago)
Author:
sommeria
Message:

mode 'compare' tested and updated. dt in civ1 was set to 1 for test in last version , now
dt is the actual value

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r227 r229  
    11301130end
    11311131set(handles.list_pair_civ1,'String',displ_pair');
    1132 ichoice=min(find(select));
     1132ichoice=find(select,1);
    11331133if (isempty(ichoice) || ichoice < 1); ichoice=1; end;
    11341134initial=get(handles.list_pair_civ1,'Value');%initial choice of pair
     
    13101310end
    13111311val=get(handles.list_pair_civ2,'Value');
    1312 ichoice=min(find(select));
     1312ichoice=find(select,1);
    13131313if (isempty(ichoice) || ichoice < 1); ichoice=1; end;
    13141314if get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0
     
    13521352    lastfield=str2double(get(handles.nb_field,'String'));
    13531353    if ~isnan(lastfield)
    1354         ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ...
    1355             (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield));
    1356         num1=num1(ind);
     1354        test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ...
     1355            (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield);
     1356        num1=num1(test_find);
    13571357    end
    13581358    set(handles.first_i,'String',num2str(num1(1)));
     
    13651365    lastfield2=str2double(get(handles.nb_field2,'String'));
    13661366    if ~isnan(lastfield2)
    1367         ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
    1368             (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2));
    1369         num1=num_j(ind);
     1367        test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
     1368            (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2);
     1369        num1=num_j(test_find);
    13701370    end
    13711371    set(handles.first_j,'String',num2str(num1(1)));
     
    13901390    lastfield=str2double(get(handles.nb_field,'String'));
    13911391    if ~isnan(lastfield)
    1392         ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ...
    1393             (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield));
    1394         num1=num1(ind);
     1392        test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ...
     1393            (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield);
     1394        num1=num1(test_find);
    13951395    end
    13961396    set(handles.first_i,'String',num2str(num1(1)));
     
    14031403    lastfield2=str2double(get(handles.nb_field2,'String'));
    14041404    if ~isnan(lastfield2)
    1405         ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
    1406             (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2));
    1407         num1=num_j(ind);
     1405        test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
     1406            (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2);
     1407        num1=num_j(test_find);
    14081408    end
    14091409    set(handles.first_j,'String',num2str(num1(1)));
     
    14181418set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
    14191419batch=0;
    1420 launch_jobs(hObject, eventdata, handles,batch);
     1420errormsg=launch_jobs(hObject, eventdata, handles,batch);
    14211421set(handles.RUN, 'Enable','On')
    14221422set(handles.RUN,'BackgroundColor',[1 0 0])
    14231423
    14241424% start status callback to visualise results
    1425 if isfield(handles,'status') && ~isequal(get(handles.CivAll,'Value'),3)
     1425if ~isempty(errormsg)
     1426    display(errormsg)
     1427    msgbox_uvmat('ERROR',errormsg)
     1428elseif  isfield(handles,'status') && ~isequal(get(handles.CivAll,'Value'),3)
    14261429    set(handles.status,'Value',1);%suppress status display
    14271430    status_Callback(hObject, eventdata, handles)
     
    14351438set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])
    14361439batch=1;
    1437 launch_jobs(hObject, eventdata, handles, batch)
     1440errormsg=launch_jobs(hObject, eventdata, handles, batch);
    14381441set(handles.BATCH, 'Enable','On')
    14391442set(handles.BATCH,'BackgroundColor',[1 0 0])
    14401443
    14411444% start status callback to visualise results
    1442 if isfield(handles,'status')
    1443 set(handles.status,'Value',1);%suppress status display
    1444 status_Callback(hObject, eventdata, handles)
     1445if ~isempty(errormsg)
     1446    display(errormsg)
     1447    msgbox_uvmat('ERROR',errormsg)
     1448elseif isfield(handles,'status')
     1449    set(handles.status,'Value',1);%suppress status display
     1450    status_Callback(hObject, eventdata, handles)
    14451451end
    14461452
    14471453%------------------------------------------------------------------------
    14481454% --- Lauch command called by RUN and BATCH: remote processing
    1449 function launch_jobs(hObject, eventdata, handles, batch)
     1455function errormsg=launch_jobs(hObject, eventdata, handles, batch)
    14501456%-----------------------------------------------------------------------
     1457errormsg='';%default
    14511458%% check the selected list of operations:
    14521459operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'};
     
    14591466index_first=find(box_test==1,1);
    14601467if isempty(index_first)
    1461     msgbox_uvmat('ERROR','no selected operation')
     1468    errormsg='no selected operation';
    14621469    return
    14631470end
     
    14661473[box_missing,ind_missing]=min(box_used);
    14671474if isequal(box_missing,0); %there is a missing step in the sequence of operations
    1468     msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]);
     1475    errormsg=['missing' cell2mat(operations(ind_missing))];
    14691476    return
    14701477end
     
    15061513[ref_i,ref_j,errormsg]=find_ref_indices(handles);
    15071514if ~isempty(errormsg)
    1508     msgbox_uvmat('ERROR',errormsg)
    15091515    return
    15101516end
     
    15301536        sparam=s.BatchParam;
    15311537        if ~ismember(sparam.BatchMode,{'sge'})
    1532             msgbox_uvmat('ERROR',['batch mode ' sparam.BatchMode ' not supported by UVMAT'])
     1538            errormsg=['batch mode ' sparam.BatchMode ' not supported by UVMAT'];
     1539            return
    15331540        end
    15341541    else
    1535         msgbox_uvmat('ERROR','no batch civ binaries defined in PARAM.xml')
     1542        errormsg='no batch civ binaries defined in PARAM.xml';
    15361543        return
    15371544    end
     
    15501557            'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3);
    15511558        if isequal(v,0) % to handle Cancel button and figure close,
     1559            errormsg='job cancelled';
    15521560            return % a better way should be create
    15531561        end
     
    15771585if isfield(sparam,'Civ1Bin')
    15781586    Civ1Bin=sparam.Civ1Bin;
    1579     which(Civ1Bin)
    15801587    if ~exist(Civ1Bin,'file')||~isempty(which(Civ1Bin))% if path defined as relative to uvmat
    15811588        sparam.Civ1Bin=fullfile(path_UVMAT,Civ1Bin);
     
    17911798            i_cmd=i_cmd+1;
    17921799            if isequal(civAll,0)
    1793                 if(isunix)
    1794                      cmd=[cmd 'cp -f ' flname '.civ1.cmx ' flname '.cmx\n'];
    1795                 else
    1796                     flname=regexprep(flname,'\\','\\\\');
    1797                     cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n'];
    1798                 end
    1799                 cmd=[cmd CIV1_CMD(fullfile(Rootbat,Filebat),'',par_civ1,handles,sparam) '\n']
     1800%                 if(isunix)
     1801%                      cmd=[cmd 'cp -f ' flname '.civ1.cmx ' flname '.cmx\n'];
     1802%                 else
     1803%                     flname=regexprep(flname,'\\','\\\\');
     1804%                     cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n'];
     1805%                 end
     1806                cmd=[cmd CIV1_CMD(fullfile(Rootbat,Filebat),'',par_civ1,handles,sparam) '\n'];
    18001807            else
    18011808                civAllCmd=[civAllCmd ' civ1 '];
     
    19071914        if box_test(4)==1 || box_test(5)==1 || box_test(6)==1
    19081915            filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file
    1909             filename_cmx([end-1:end+1])=[ 'cmx'];%name of cmx file
     1916            filename_cmx(end-1:end+1)='cmx';%name of cmx file
    19101917        end
    19111918       
     
    19191926            par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc);
    19201927            par_civ2.filename_nc1=filecell.nc.civ1{ifile,j};
    1921             par_civ2.filename_nc1([end-2:end])=[]; % remove '.nc'
     1928            par_civ2.filename_nc1(end-2:end)=[]; % remove '.nc'
    19221929            test_mask=get(handles.get_mask_civ2,'Value');
    19231930            if test_mask==0
     
    21602167if ~batch && ~isequal(get(handles.CivAll,'Value'),3)
    21612168    [Rootbat,Filebat,extbat]=fileparts(filename_bat);
    2162     filename_superbat=fullfile(Rootbat,['job_list.bat']);
     2169    filename_superbat=fullfile(Rootbat,'job_list.bat');
    21632170    fid=fopen(filename_superbat,'w');
    21642171    fprintf(fid,super_cmd');
     
    23612368        last_j=str2double(get(handles.last_j,'String'));
    23622369        incr_j=str2double(get(handles.incr_j,'String'));
    2363         num_i_ref=[first_i:incr_i:last_i];
    2364         num_j_ref=[first_j:incr_j:last_j];
     2370        num_i_ref=first_i:incr_i:last_i;
     2371        num_j_ref=first_j:incr_j:last_j;
    23652372        if isequal(mode,'displacement')
    23662373            num_i1=num_i_ref;
     
    29202927    end
    29212928    if box_test(4)==1 %if civ2 is performed
    2922         h = waitbar(0,['copy images to the .png format for civ2']);% display a wait bar
     2929        h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar
    29232930        for ifile=1:nbfield
    29242931            waitbar(ifile/nbfield);
     
    29692976    num_a_civ1=ref_j;
    29702977    num_b_civ1=ref_j;
    2971     num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i));;
     2978    num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i));
    29722979    num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i));
    29732980    num_a_civ2=ref_j;
     
    32863293        filebase_a=get(handles.RootName_1,'String');
    32873294        [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
    3288         if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice)
     3295        if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice)
    32893296            mask_displ='no mask';
    32903297        end
     
    33303337        filebase_a=get(handles.RootName_1,'String');
    33313338        [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
    3332         if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice)
     3339        if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice)
    33333340            mask_displ='no mask';
    33343341        end
     
    33713378        filebase_a=get(handles.RootName_1,'String');
    33723379        [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
    3373         if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice)
     3380        if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice)
    33743381            mask_displ='no mask';
    33753382        end
     
    36033610            'Pick a file',filebase);
    36043611        filegrid=fullfile(PathName,FileName);
    3605         if isempty(FileName)|isempty(PathName)|isequal(FileName,0)|~exist(filegrid,'file')
     3612        if isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')
    36063613            set(handles.browse_gridciv2,'Value',0);
    36073614            set(handles.grid_civ2,'string','');
     
    41564163    civ1.mask=par.maskname;
    41574164end
    4158 civ1.dt=1%par.Dt;
     4165civ1.dt=par.Dt;
    41594166civ1.unit='pixel';
    41604167civ1.absolut_time_T0=par.T0;
     
    43874394    end
    43884395   
    4389     % open an image file with the browser
     4396    %% open an image file with the browser
    43904397    ind_opening=1;%default
    43914398    browse.incr_pair=[0 0]; %default
    43924399    oldfile=get(handles.RootName,'String');
    4393     menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ...
    4394         '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';...
    4395         '*.*', 'All Files (*.*)'};
    4396     [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile);
     4400     menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)';
     4401       '*.xml',  '.xml files '; ...
     4402        '*.civ',  '.civ files '; ...
     4403        '*.png','.png image files'; ...
     4404        '*.jpg',' jpeg image files'; ...
     4405        '*.tif','.tif image files'; ...
     4406        '*.avi;*.AVI','.avi movie files'; ...
     4407        '*.nc','.netcdf files'; ...
     4408        '*.*',  'All Files (*.*)'};
     4409    [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file of the second series',oldfile);
    43974410    fileinput=[PathName FileName];%complete file name
    43984411    sizf=size(fileinput);
    4399     if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
     4412    if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
    44004413    [path,name,ext]=fileparts(fileinput);
    44014414    [path1]=fileparts(filebase);
     4415%     if isunix
     4416%         ['readlink ' path]
     4417%         [status,path]=system(['readlink ' path])
     4418%         [status,path1]=system(['readlink ' path1])% look for the true path in case of symbolic paths
     4419%     end
    44024420    if ~strcmp(path1,path)
    44034421        msgbox_uvmat('ERROR','The two  input image series must be in the same directory')
     
    44124430    %check image extension
    44134431    if ~strcmp(ext,get(handles.ImaExt,'String'))
    4414         msgbox_uvmat('ERROR','The two  input image series must have the same extenion name')
     4432        msgbox_uvmat('ERROR','The two  input image series must have the same extension name')
    44154433        return
    44164434    end
    44174435   
    4418     %check image size
    4419     A=imread(fileinput);
    4420     npxy=get(handles.ImaExt,'UserData');
    4421     if ~isequal(npxy(1),size(A,1))|| ~isequal(npxy(2),size(A,2))
    4422         msgbox_uvmat('ERROR','The two input image series must have the same size')
     4436    %% check coincidence of image sizes
     4437    ref_i=get(handles.ref_i,'string');
     4438    ref_j=get(handles.ref_j,'string');
     4439    [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]);
     4440    A=imread(filecell.ima1.civ1{1});
     4441    A_1=imread(fileinput);
     4442    npxy=size(A);
     4443    npxy_1=size(A_1);
     4444    if ~isequal(size(A),size(A_1))
     4445        msgbox_uvmat('ERROR','The two input image series do not have the same size')
    44234446        return
    44244447    end
Note: See TracChangeset for help on using the changeset viewer.