Changeset 483 for trunk/src


Ignore:
Timestamp:
Jun 26, 2012, 11:50:19 PM (12 years ago)
Author:
sommeria
Message:

civ set to accept automatic input in the absence of PARAM.xml. Still problem with run time address
zoom improved to deal with elongated plots
better link between PIV and images in uvmat.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r482 r483  
    6060errormsg=[];%default error message
    6161xmlfile='PARAM.xml';
     62test_batch=0;%default: ,no batch mode available
     63sparam=[];
    6264if exist(xmlfile,'file')
    6365    try
     
    6668    catch ME
    6769        errormsg={' Unable to read the file PARAM.xml defining the civx binaries:';ME.message};
     70         msgbox_uvmat('WARNING',errormsg);
    6871    end
    6972else
    70     errormsg=[xmlfile ' not found: path to civx binaries undefined'];
    71 end
    72 if ~isempty(errormsg)
    73     msgbox_uvmat('WARNING',errormsg);
    74 end
    75 
    76 
    77 test_batch=0;%default: ,no batch mode available
     73    %errormsg=[xmlfile ' not found: path to civx binaries undefined'];
     74    [s,w]=system('oarstat');
     75    if ~isequal(s,0)
     76        [s,w]=system('qstat');
     77    end
     78    if isequal(s,0)
     79        test_batch=1;
     80    end           
     81end
    7882if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode')
    7983    batch_mode=sparam.BatchParam.BatchMode; %sge is currently the only implemented batch mod
     
    100104%     set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated)
    101105end
    102 if isfield(sparam.RunParam,'CivBin')
    103     if ~exist(sparam.RunParam.CivBin,'file')
    104         sparam.RunParam.CivBin=fullfile(path_civ,sparam.RunParam.CivBin);
    105     end
    106 else
    107     sparam.RunParam.CivBin='';
    108 end
     106% if isfield(sparam.RunParam,'CivBin')
     107%     if ~exist(sparam.RunParam.CivBin,'file')
     108%         sparam.RunParam.CivBin=fullfile(path_civ,sparam.RunParam.CivBin);
     109%     end
     110% else
     111%     sparam.RunParam.CivBin='';
     112% end
    109113
    110114%% load the list of previously browsed files in the upper bar menu Open/
     
    888892    drawnow
    889893end
    890 set(hrefresh,'UserData',option_civ)
    891         filepath=fileparts(civ_files{1});
     894StatusData.time_ref=now;% store the current time
     895StatusData.option_civ=option_civ;
     896set(hrefresh,'UserData',StatusData)
     897filepath=fileparts(civ_files{1});
    892898set(hlist,'UserData',fileparts(filepath))
    893899refresh_GUI(hrefresh,[])
     
    900906BarPosition=[0.05 0.81 0.01 0.05];
    901907hfig=get(hObject,'parent');
     908StatusData=get(hObject,'UserData');
    902909civ_files=get(hfig,'UserData');
    903         [filepath,filename,ext]=fileparts(civ_files{1});
    904         [tild,SubDir,extdir]=fileparts(filepath);
    905         SubDir=[SubDir extdir];
    906 option_civ=get(hObject,'UserData');
     910[filepath,filename,ext]=fileparts(civ_files{1});
     911[tild,SubDir,extdir]=fileparts(filepath);
     912SubDir=[SubDir extdir];
     913option_civ=StatusData.option_civ;
    907914nbfiles=numel(civ_files);
     915testrecent=0;
    908916count=0;
    909 testrecent=0;
    910 % while count<nbfiles
    911     count=0;
    912     datnum=zeros(1,nbfiles);
    913     for ifile=1:nbfiles
    914         detect=exist(civ_files{ifile},'file'); % check the existence of the file
    915         option=0;
    916         if detect==0
    917             option_str='not created';
     917datnum=zeros(1,nbfiles);
     918filefound=cell(1,nbfiles);
     919for ifile=1:nbfiles
     920    detect=exist(civ_files{ifile},'file'); % check the existence of the file
     921    option=0;
     922    if detect==0
     923        option_str='not created';
     924    else
     925        datfile=dir(civ_files{ifile});
     926        if isfield(datfile,'datenum')
     927            datnum(ifile)=datfile.datenum;%only available in recent matlab versions
     928            testrecent=1;
     929        end
     930        filefound(ifile)={datfile.name};
     931       
     932        % check the content  netcdf file
     933        Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','CivStage','patch2','fix2','civ2','patch','fix');
     934        option_list={'civ1','fix1','patch1','civ2','fix2','patch2'};
     935        if ~isempty(Data.CivStage)
     936            option=Data.CivStage;%case of Matlab civ
    918937        else
    919             datfile=dir(civ_files{ifile});
    920             if isfield(datfile,'datenum')
    921                 datnum(ifile)=datfile.datenum;%only available in recent matlab versions
    922                 testrecent=1;
    923             end
    924             filefound(ifile)={datfile.name};
    925             lastfield='';
    926             % check the content  netcdf file
    927             Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','CivStage','patch2','fix2','civ2','patch','fix');
    928             option_list={'civ1','fix1','patch1','civ2','fix2','patch2'};
    929             if ~isempty(Data.CivStage)
    930                 option=Data.CivStage;%case of Matlab civ
     938            if ~isempty(Data.patch2) && isequal(Data.patch2,1)
     939                option=6;
     940            elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)
     941                option=5;
     942            elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);
     943                option=4;
     944            elseif ~isempty(Data.patch) && isequal(Data.patch,1);
     945                option=3;
     946            elseif ~isempty(Data.fix) && isequal(Data.fix,1);
     947                option=2;
    931948            else
    932                 if ~isempty(Data.patch2) && isequal(Data.patch2,1)
    933                     option=6;
    934                 elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)
    935                     option=5;
    936                 elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);
    937                     option=4;
    938                 elseif ~isempty(Data.patch) && isequal(Data.patch,1);
    939                     option=3;
    940                 elseif ~isempty(Data.fix) && isequal(Data.fix,1);
    941                     option=2;
    942                 else
    943                     option=1;
    944                 end
    945             end
    946             option_str=option_list{option};
    947         end
    948         if option >= option_civ
    949             count=count+1;
    950         end
    951         [filepath,filename,ext]=fileparts(civ_files{ifile});
    952         Tabchar{ifile,1}=[fullfile(SubDir,filename) ext  '...' option_str];
    953     end
     949                option=1;
     950            end
     951        end
     952        option_str=option_list{option};
     953        if datnum(ifile)<StatusData.time_ref
     954            option_str=[option_str '  --OLD--'];
     955        end
     956    end
     957    if option >= option_civ
     958        count=count+1;
     959    end
     960    [filepath,filename,ext]=fileparts(civ_files{ifile});
     961    Tabchar{ifile,1}=[fullfile(SubDir,filename) ext  '...' option_str];
     962end
     963datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
     964if isempty(datnum)
     965    if testrecent
     966        message='no civ result created yet';
     967    else
     968        message='';
     969    end
     970else
    954971    datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
    955     if isempty(datnum)
    956         if testrecent
    957             message='no civ result created yet';
    958         else
    959             message='';
    960         end
    961     else
    962         datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
    963         [first,ind]=min(datnum);
    964         [last,indlast]=max(datnum);
    965 %         if test_new
    966 %             message='existing file status, no processing launched yet';
    967 %         else
    968         message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
    969             ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
    970 %         end
    971     end
    972     %hfig=findobj(allchild(0),'name','civ_status');
    973 %     if isempty(hfig)% the status list has been deleted
    974 %         return
    975 %     else
    976         hlist=findobj(hfig,'tag','list');
    977         hmsgbox=findobj(hfig,'tag','msgbox');
    978         hwaitbar=findobj(hfig,'tag','waitbar');
    979         set(hlist,'String',Tabchar)
    980         set(hmsgbox,'String', message)
    981         if count>0 %&& ~test_new
    982             BarPosition(3)=0.9*count/nbfiles;
    983             set(hwaitbar,'Position',BarPosition)
    984         end
    985 %     end
    986 %     [root,filename,ext]=fileparts(civ_files{1});
    987 % [rootroot,SubDir,extdir]=fileparts(root);
    988 %
    989 %     set(hlist,'UserData',rootroot)
    990 %     if count<10||(nbfiles-count)<10
    991 %     pause(.5)% wait 0.5 seconds for next check
    992 %     else
    993 %         pause(10)% wait 10 seconds for next check
    994 %     end
    995 % end
     972    [first,ind]=min(datnum);
     973    [last,indlast]=max(datnum);
     974    message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
     975        ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
     976end
     977hlist=findobj(hfig,'tag','list');
     978hmsgbox=findobj(hfig,'tag','msgbox');
     979hwaitbar=findobj(hfig,'tag','waitbar');
     980set(hlist,'String',Tabchar)
     981set(hmsgbox,'String', message)
     982if count>0 %&& ~test_new
     983    BarPosition(3)=0.9*count/nbfiles;
     984    set(hwaitbar,'Position',BarPosition)
     985end
     986
    996987
    997988%------------------------------------------------------------------------   
     
    10721063path_civ=fileparts(which('civ')); %path to the source directory of uvmat
    10731064xmlfile='PARAM.xml';
     1065s=[];
    10741066if exist(xmlfile,'file')% search parameter xml file in the whole matlab path
    10751067    t=xmltree(xmlfile);
    10761068    s=convert(t);
    1077 else
    1078     errormsg=['no file ' xmlfile];
    1079     return
    1080 end
    1081 % test_interp=0; %eviter les variables test_ (LG)
     1069end% default configuration
     1070if ~isfield(s,'RunParam')
     1071    s.RunParam.Civ1Bin='bin/civ1';
     1072    s.RunParam.Civ2Bin='bin/civ2';
     1073    s.RunParam.FixBin='bin/fix_flag';
     1074    s.RunParam.PatchBin='bin/patch_up';
     1075    s.RunParam.CivmBin='bin/civ_matlab';
     1076end
    10821077if strcmp(Param.RunMode,'cluster') %computation dispatched on a cluster
    10831078    if isfield(s,'BatchParam')
     
    10911086        end
    10921087    else
    1093         errormsg='no batch civ binaries defined in PARAM.xml';
    1094         return
     1088        %standard configuration
     1089        Param.xml.Civ1Bin='bin/civ1';
     1090        Param.xml.Civ2Bin='bin/civ2';
     1091        Param.xml.FixBin='bin/fix_flag';
     1092        Param.xml.PatchBin='bin/patch_up';
     1093        s.RunParam.CivmBin='bin/civ_matlab';
     1094        Param.xml.BatchMode='oar';% TODO : allow choice for sge
    10951095    end
    10961096else % run
    10971097    if isfield(s,'RunParam')
    10981098        Param.xml=s.RunParam;
    1099     else
    1100         errormsg='no run civ binaries defined in PARAM.xml';
    1101         return
    1102     end
    1103 end
    1104 
     1099    else %standard default configuration
     1100        s.RunParam.Civ1Bin='bin/civ1';
     1101        s.RunParam.Civ2Bin='bin/civ2';
     1102        s.RunParam.FixBin='bin/fix_flag';
     1103        s.RunParam.PatchBin='bin/patch_up';
     1104        s.RunParam.CivmBin='bin/civ_matlab';
     1105    end
     1106end
    11051107
    11061108%% check if the binaries exist : to move in civ_opening
  • trunk/src/find_file_series.m

    r472 r483  
    5454    return % don't go further if the dir path does not exist
    5555end
    56 % NbFrame=1;
    57 % switch FileType
    58 %     case 'multimage'
    59 %     NbFrame=FileInfo.NumberOfFrames;
    60 %     case {'video','mmreader'}
    61 %     NomType='*';
    62 %     NbFrame=FileInfo.NumberOfFrames;
    63 % end
    64 
    65 % RootFile_i='';
    6656NomTypePref='';
    67 if strcmp(NomType,'')||strcmp(NomType,'*')
     57if isempty(NomType)
    6858    if exist(fullfileinput,'file')
    6959        [tild,RootFile]=fileparts(fileinput);% case of constant name (no indexing), get the filename without its extension
     
    7161        RootFile='';
    7262    end
    73 %     i1_input=1;% the index now refer to the frame in the movie, choose 1 at opening
    74 %     i2_input=[];
    75 %     j1_input=[];
    76 %     j2_input=[];
    7763else
    7864    %% possibly include the first index in the root name, if there exists a corresponding xml file
     
    224210        ref_ij=ref_i_list*max_j+ref_j_list; % ordered by index i, then by j for a given i.
    225211    end
    226     %[tild,ifile_min]=min(ref_ij(ref_ij>0));
    227212    ind_select=find(ref_ij>0);
    228213    if isempty(ind_select)
    229         %         RootPath='';
    230214        RootFile='';
    231215        NomType='';
     
    252236        i1_series=(1:FileInfo.NumberOfFrames)';
    253237        i1_input=1;
    254     else
    255        j1_series=(1:FileInfo.NumberOfFrames)';
    256        j1_input=1;
     238        NomType='*';
     239    else
     240        j1_series=(1:FileInfo.NumberOfFrames)';
     241        %  include the first index in the root name
     242        r=regexp(NomType,'^(?<tiretnum>_?\d+)','names');%look for a number or _1 at the beginning of NomType
     243        if ~isempty(r)
     244            fileinput_end=regexprep(fileinput,['^' RootFile],'');%remove RootFile at the beginning of fileinput
     245            if isempty(regexp(r.tiretnum,'^_','once'))% if a separator '_' is not  detected
     246                rr=regexp(fileinput_end,'^(?<i1>\d+)','names');
     247            else% if a separator '_' is  detected
     248                rr=regexp(fileinput_end,'^(?<i1>_\d+)','names');
     249            end
     250            if ~isempty(rr)
     251                RootFile=[RootFile rr.i1];% new root file
     252                NomTypePref=r.tiretnum;
     253                NomType=regexprep(NomType,['^'  NomTypePref],'');
     254                i1_input=j1_input;
     255                i2_input=j2_input;
     256                j1_input=1;
     257                j2_input=[];
     258            end
     259        end
    257260    end
    258261end
  • trunk/src/mouse_up.m

    r444 r483  
    244244    xlim=get(currentaxes,'XLim');
    245245    ylim=get(currentaxes,'YLim');
    246  % if left mouse button has been pressed, zoom in by a factor of 2
     246    % if left mouse button has been pressed, zoom in by a factor of 2
    247247    if  isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed, zoom in by a factor of 2
    248         xlim(1)=0.5*xy(1,1)+0.5*xlim(1);
    249         xlim(2)=0.5*xy(1,1)+0.5*xlim(2);%double the field whith the middle at the selected points
    250         set(currentaxes,'XLim',xlim)
    251         ylim(2)=0.5*xy(1,2)+0.5*ylim(2);
    252         ylim(1)=0.5*xy(1,2)+0.5*ylim(1);
    253         set(currentaxes,'YLim',ylim)
    254  % if right mouse button has been pressed, zoom out by a factor of 2
     248        PlotBoxAspectRatio=get(currentaxes,'PlotBoxAspectRatio');
     249        yoverx=PlotBoxAspectRatio(2)/PlotBoxAspectRatio(1);
     250        if yoverx <2
     251            xlim(1)=0.5*xy(1,1)+0.5*xlim(1);
     252            xlim(2)=0.5*xy(1,1)+0.5*xlim(2);%double the field whith the middle at the selected points
     253            set(currentaxes,'XLim',xlim)
     254        end
     255        if yoverx >0.5
     256            ylim(2)=0.5*xy(1,2)+0.5*ylim(2);
     257            ylim(1)=0.5*xy(1,2)+0.5*ylim(1);
     258            set(currentaxes,'YLim',ylim)
     259        end
     260       
     261        % if right mouse button has been pressed, zoom out by a factor of 2
    255262    else
    256263        xlim(1)=2*xlim(1)-xy(1,1);% reverse of the zoom on action
     
    267274                ylim=AxeData.RangeY;
    268275            end
    269          % desactivate the zoom if the full field is visible within the axes
     276            % desactivate the zoom if the full field is visible within the axes
    270277            if isequal(xlim,AxeData.RangeX) && isequal(ylim,AxeData.RangeY)
    271278                set(hhuvmat.CheckZoom,'Value',0)
     
    323330%% finalising ruler
    324331if test_ruler
    325     set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat 
    326     xy=get(currentaxes,'CurrentPoint');% get the current mouse coordinates 
    327     RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)];% append the recorded ruler origin to the current mouse coordinates 
     332    set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat
     333    xy=get(currentaxes,'CurrentPoint');% get the current mouse coordinates
     334    RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)];% append the recorded ruler origin to the current mouse coordinates
    328335    RulerCoord=diff(RulerCoord,1);% coordiante difference between segment end and beginning
    329336    RulerCoord=RulerCoord(1)+i*RulerCoord(2);
  • trunk/src/uvmat.m

    r477 r483  
    30843084FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    30853085[tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]);
    3086 % NomTypeNew=NomType;%default
    30873086if isequal(field,'image')
    3088 %     if isequal(NomType,'_1-2_1')||isequal(NomType,'_1_1-2')
    3089 %         NomTypeNew='_1_1';
    3090 %     elseif isequal(NomType,'#_ab')
    3091 %         NomTypeNew='#a';
    3092 %     elseif isequal(NomType,'_1-2')
    3093 %         NomTypeNew='_1';
    3094 %     end
    3095     imagename=fullfile_uvmat(RootPath,SubDir,RootFile,'.png',NomType,i1,[],j1,[]);
     3087    SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
     3088    imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]);
    30963089    if ~exist(imagename,'file')
    30973090        [FileName,PathName] = uigetfile( ...
     
    31973190    case 'image'
    31983191        % guess the image name corresponding to the current netcdf name (no unique correspondance)
    3199         imagename=fullfile_uvmat(RootPath_1,'',RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1);
     3192        SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.'
     3193        imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1);
    32003194        if ~exist(imagename,'file') % browse for images if it is not found
    32013195            [FileName,PathName] = uigetfile( ...
Note: See TracChangeset for help on using the changeset viewer.