Changeset 1179 for trunk/src


Ignore:
Timestamp:
Mar 23, 2025, 11:13:38 AM (4 weeks ago)
Author:
sommeria
Message:

a few bug repairs and cleaning

Location:
trunk/src
Files:
1 added
3 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/angle2normal.m

    r1108 r1179  
    1 %calculate the components of the unit vector norm_plane normal to the plane
    2 %defined by the rotation vector PlaneAngle (in degree)
     1%angle2normal: calculate the components of the unit vector defined by a rotation vector
    32% this gives the equation of the plane as norm_plane(1)x + norm_plane(2)y +norm_plane(3)z = cte
     3
     4% OUTPUT:
     5%norm_plane: three components of the normal unit vector
     6% INPUT:
     7%PlaneAngle: rotation vector, with three components in degree)
    48
    59function norm_plane=rotate(PlaneAngle)
  • trunk/src/browse_data.m

    r1150 r1179  
    242242    ListExperiments_Callback([],[], handles)
    243243else
    244     msgbox_uvmat('ERROR',['The input ' Campaign ' is not a directory'])
     244    msgbox_uvmat('ERROR',['The input ' SourceDir ' is not a folder'])
    245245end
    246246
  • trunk/src/check_files.m

    r1127 r1179  
    2828%=======================================================================
    2929
    30 function [checkmsg,date_str,svn_info]=check_files
     30function [checkmsg,date_str,svn_info,list_fct]=check_files
    3131checkmsg={};%default
    3232svn_info.rep_rev=[];
     
    3535list_fct={...
    3636    'activate';...% emulate the mouse selection of a GUI element, for demo
     37    'angle2normal';...%rotation vector PlaneAngle (in degree)
    3738    'browse_data';...% function for scanning directories in a project/campaign
    3839    'browse_data.fig';...% GUI corresponding to dataview
     
    4142    'cell2tab';... %transform a Matlab cell in a character array suitable for display in a table
    4243    'check_files';...
     44    'civ';... % key function  for image correlations (called by series/cvi_series.m)
     45    'cluster_command';...% creates the command string for launching jobs in the cluster system 'oar'.
     46    'command_launch_matlab';% creates the command strings for opening a new Matlab session
     47    'command_load_python';% creates the command strings for loading Python
    4348    'compile';...% compile a Matlab function, create a binary in a subdirectory /bin
    4449    'copyfields';...% copy fields between two matlab structures
  • trunk/src/civ.m

    r1169 r1179  
    11%--------------------------------------------------------------------------
    2 %  'civ': function  adapted from PIVlab http://pivlab.blogspot.com/
     2%  'civ': key function  for image correlations (called by series/cvi_series.m)
    33% function [xtable ytable utable vtable typevector] = civ (image1,image2,ibx,iby step, subpixfinder, mask, roi)
    44%
  • trunk/src/cluster_command.m

    r1171 r1179  
    1 %'cluster_command': creates the command string for launching jobs in the cluster
    2 %------------------------------------------------------------------------
     1%'cluster_command': creates the command string for launching jobs in the cluster system 'oar'
     2% other cluster options 'pbs' and 'psmn' are available in cluster_command_pbs and
     3% cluster_command_psmn. The choice is made in the xml file for parameters: series.xml
     4%-- ----------------------------------------------------------------------
    35% function cmd=cluster_command(ListProcess,ActionFullName,DirLog,NbProcess, NbCore,CPUTimeProcess)
    46%
     
    1921filename_log=fullfile(DirLog,'job_list.stdout'); % file for output messages of the master oar process
    2022filename_errors=fullfile(DirLog,'job_list.stderr'); % file for error messages of the master oar process
    21         if NbProcess>=6
    22             bigiojob_string=['+{type = ' char(39) 'bigiojob' char(39) '}/licence=1'];% char(39) is quote - bigiojob limit UVmat parallel launch on cluster to avoid saturation of disk access to data
    23         else
    24             bigiojob_string='';
    25         end
     23if NbProcess>=6
     24    bigiojob_string=['+{type = ' char(39) 'bigiojob' char(39) '}/licence=1'];% char(39) is quote - bigiojob limit UVmat parallel launch on cluster to avoid saturation of disk access to data
     25else
     26    bigiojob_string='';
     27end
    2628
    2729WallTimeMax=23;% absolute limit on computation time (in hours)
    28 WallTimeTotal=min(WallTimeMax,4*CPUTimeProcess/60);% chosen limit on computation time (in hours),possibly smaller than the absolute limit to favor job priority in the system. 
    29 WallTimeOneProcess=min(4*CPUTimeProcess+10,WallTimeTotal*60/2); % estimated max time of an individual process, used for checkpoint: 
    30                                                                 %if less than this time remains before walltime, the job is stopped and a new one can be launched ( by the option 'idempotent')
     30WallTimeTotal=min(WallTimeMax,4*CPUTimeProcess/60);% chosen limit on computation time (in hours),possibly smaller than the absolute limit to favor job priority in the system.
     31WallTimeOneProcess=min(4*CPUTimeProcess+10,WallTimeTotal*60/2); % estimated max time of an individual process, used for checkpoint:
     32%if less than this time remains before walltime, the job is stopped and a new one can be launched ( by the option 'idempotent')
    3133
    32       if NbCore==1
    33           corestring='cpu=1/core=4'; %increases the allowed memory in case of single core job
    34       else
    35          % corestring=['/core=' num2str(NbCore)];
    36          corestring=['{cluster=''calcul8''}/core=' num2str(NbCore)];
    37       end
    38                                                                 cmd=['oarsub -n UVmat_' ActionFullName ' '...
    39             '-t idempotent --checkpoint ' num2str(WallTimeOneProcess*60) ' '...
    40             '-l "' corestring bigiojob_string... % char(39) is quote - bigiojob limit UVmat parallel launch on cluster
    41             ',walltime=' datestr(WallTimeTotal/24,13) '" '...
    42             '-E ' filename_errors ' '...
    43             '-O ' filename_log ' '...
    44             '"oar-parexec -s -f ' ListProcessFile ' '...
    45             '-l ' ListProcessFile '.log"'];
     34% if NbCore==1
     35%     corestring='cpu=1/core=4'; %increases the allowed memory in case of single core job
     36% else
     37    corestring=['{cluster=''calcul8''}/core=' num2str(max(NbCore,4))];
     38% end
     39cmd=['oarsub -n UVmat_' ActionFullName ' '...
     40    '-t idempotent --checkpoint ' num2str(WallTimeOneProcess*60) ' '...
     41    '-l "' corestring bigiojob_string... % char(39) is quote - bigiojob limit UVmat parallel launch on cluster
     42    ',walltime=' datestr(WallTimeTotal/24,13) '" '...
     43    '-E ' filename_errors ' '...
     44    '-O ' filename_log ' '...
     45    '"oar-parexec -s -f ' ListProcessFile ' '...
     46    '-l ' ListProcessFile '.log"'];
  • trunk/src/command_launch_matlab.m

    r1134 r1179  
    1 %'command_launch_matlab': creates the command strings for opening a new Matlab
    2 %session and running a programme in a Linux system('GLNX86','GLNXA64','MACI64')
     1%'command_launch_matlab': creates the command strings for opening a new Matlab session
     2% and running a programme in a Linux system('GLNX86','GLNXA64','MACI64')
    33%------------------------------------------------------------------------
    44% function cmd=command_launch_matlab(filelog,path_uvmat,ActionPath,ActionName,inputxml,option)
     
    4747    end
    4848
    49 %% case cluster:
    50 % matlab_ver = ver('MATLAB');
    51 %                     matlab_version = matlab_ver.Version;
    52 %                     cmd=[...
    53 %                         '#!/bin/bash\n'...
    54 %                         'source /etc/profile\n'...
    55 %                         'module purge\n'...
    56 %                         'module load matlab/' matlab_version '\n'...% CHOICE OF CURRENT MATLAB VERSION
    57 %                         'matlab -nodisplay -nosplash -nojvm -singleCompThread -logfile ''' filelog{iprocess} ''' <<END_MATLAB\n'...% open a new Matlab session without display
    58 %                         'addpath(''' path_series ''');\n'...
    59 %                         'addpath(''' ActionPath ''');\n'...
    60 %                         '' ActionName  '(''' filexml{iprocess} ''');\n'...% launch the Matlab function selected by the GUI 'series'
    61 %                         'exit\n'...
    62 %                         'END_MATLAB\n'];
    63 %                 end
    6449
    6550
  • trunk/src/editxml.m

    r1127 r1179  
    862862filedat=[];
    863863if ~isempty(list_uid)
    864     filedat=get(t,list_uid(1))
    865     if isfield(filedat,'type') & isequal(filedat.type,'chardata') &isfield(filedat,'value')
     864    filedat=get(t,list_uid(1));
     865    if isfield(filedat,'type') && isequal(filedat.type,'chardata') && isfield(filedat,'value')
    866866        testsimple=1;%simple element
    867867    end
     
    876876    if isequal(attr.key,'source')% look for 'source' attribute
    877877        if isequal(attr.val,'file')%if the source is 'file', look for the path and open it
    878            if isfield(filedat,'type') & isequal(filedat.type,'chardata') &isfield(filedat,'value')
     878           if isfield(filedat,'type') && isequal(filedat.type,'chardata') && isfield(filedat,'value')
    879879               cur_file=filedat.value;
    880880               uidparent=root_uid;%initialization
     
    882882                    uidparent=parent(t,uidparent);
    883883                    dirdat=get(t,uidparent);
    884                     if isfield(dirdat,'type') & isequal(dirdat.type,'element') & isfield(dirdat,'name')
     884                    if isfield(dirdat,'type') && isequal(dirdat.type,'element') && isfield(dirdat,'name')
    885885                        nbattrib_up= attributes(t,'length',uidparent);
    886886                        for iattr_up=1:nbattrib_up
     
    893893               end
    894894               RootPath=fileparts(CurrentFile);%path to the current .xml file
    895                cur_file=fullfile(RootPath,cur_file)
     895               cur_file=fullfile(RootPath,cur_file);
    896896               set(handles.CurrentAttributes,'UserData',cur_file)%will be searched by uvmat
    897                [path,fil,ext]=fileparts(cur_file);
     897               [~,~,ext]=fileparts(cur_file);
    898898               if ~exist(cur_file,'file')
    899899                   msgbox_uvmat('ERROR',['non-existent link file' cur_file]) % A FAIRE: propose to updtate the .xml file
     
    909909                   CurrentFile_Callback(handles.CurrentFile, [], handles)
    910910               else
    911                    if isequal(get(heditxml,'Tag'),'browser'); %if editxml has been called as a browser
     911                   if isequal(get(heditxml,'Tag'),'browser') %if editxml has been called as a browser
    912912                       set(heditxml,'Tag','idle')% signal for uvmat browser
    913913                   else
     
    925925%list subtree
    926926if ~testsimple
    927     list_element=[];
     927    list_element=cell(length(list_uid));
    928928    for iline=1:length(list_uid)
    929929        element=get(t,list_uid(iline));
    930         if isfield(element,'type')&isequal(element.type,'element')
     930        if isfield(element,'type')&& isequal(element.type,'element')
    931931             list_element{iline,2}=element.name;
    932932             child_uid=children(t,list_uid(iline));
    933933             subelem=get(t,child_uid);
    934              if isfield(subelem,'type')& isfield(subelem,'value') & isequal(subelem.type,'chardata')
     934             if isfield(subelem,'type')&& isfield(subelem,'value') && isequal(subelem.type,'chardata')
    935935                data_read=subelem.value;
    936936                list_element{iline,3}=['= ' data_read];
    937937            end
    938             if iscell(subelem)|(isfield(subelem,'type')&isequal(subelem.type,'element'))
     938            if iscell(subelem)||(isfield(subelem,'type')&& isequal(subelem.type,'element'))
    939939                list_element{iline,1}='+ ';%sign for subtree existence
    940940            else
     
    965965function update_ref_list(hh,xs_element,element,node,xs_subelem,subelem)
    966966%-----------------------------
    967 pref_col='';
     967%pref_col='';
    968968key_col='';
    969 equal_sign='';
     969%equal_sign='';
    970970val_col='';
    971971for iline=1:length(subelem)
     
    10001000global xs  t
    10011001
    1002 export_list=get(handles.export_list,'String');
    1003 export_val=get(handles.export_list,'UserData');
     1002%export_list=get(handles.export_list,'String');
     1003%export_val=get(handles.export_list,'UserData');
    10041004heditxml=get(handles.replicate,'parent');
    10051005Data=get(heditxml,'UserData');
     
    10071007hdataview=findobj(allchild(0),'Name','dataview');
    10081008if isempty(hdataview)
    1009     hdataview=dataview;
    10101009    return
    10111010end
     
    10271026    ListRecords=ListRecords(Value);
    10281027end
    1029 [ListDevices,ListRecords,ListXml,List]=dir_scan(CurrentPath,ListExperiments,ListDevices,ListRecords);
     1028[~,~,~,List]=dir_scan(CurrentPath,ListExperiments,ListDevices,ListRecords);
    10301029ListXml=get(hhdataview.ListXml,'String');
    10311030Value=get(hhdataview.ListXml,'Value');
     
    10651064                                % fill the root elements if absent
    10661065                                for index=2:length(uidlist)
    1067                                     name_t=get(t,uidlist(index),'name')
    1068                                     findstr=[findstr '/' name_t]
    1069                                     uid=find(t_export,findstr)
     1066                                    name_t=get(t,uidlist(index),'name');
     1067                                    findstr=[findstr '/' name_t];
     1068                                    uid=find(t_export,findstr);
    10701069                                    if isempty(uid)
    10711070                                        [t_export,uid_export(index)]=add(t_export,uid_export(index-1),'element',name_t);
     
    10881087                            for ilistxml=1:length(ListXml)
    10891088                                if isequal(FileName,ListXml{ilistxml})
    1090                                     xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName)
     1089                                    xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName);
    10911090                                    break
    10921091                                end
  • trunk/src/script_readlvm.m

    r1123 r1179  
    11%% get the input file
    2 project='/fsnet/project/coriolis/2016/16CREST';
    3 % if ~exist(project,'dir')
    4 %     project='U:\project\coriolis\2015\15MINI_MEDDY\PROBES';%windows
    5 % end
     2project='/fsnet/project/coriolis/2024/24PLUME';
    63fileinput=uigetfile_uvmat('pick an input file',project);
    74[Path,Name,Ext]=fileparts(fileinput);
  • trunk/src/series.m

    r1178 r1179  
    22212221            msgbox_uvmat('CONFIRMATION',[num2str(currJobIndex-1) ' jobs launched on queue ' qstat_Queue '.'])
    22222222        case 'python'
    2223             command = command_launch_python(filexml{iprocess});
     2223            command = ['python -m fluidimage.run_from_xml ' filexml{iprocess}];
    22242224            fprintf(['command:\n' command '\n\n'])
    22252225            [status, result] = call_command_clean(command);
  • trunk/src/series/beam_forming.m

    r1127 r1179  
    147147    time=(b/rsf+[0:A-1]/rsf); %b=250, rsf=10,
    148148    freq1=0.5;freq2=1.5;
    149     [BB AA]=butter(4,[freq1 freq2]/rsf*2);.sback
     149    [BB AA]=butter(4,[freq1 freq2]/rsf*2);
    150150
    151151    for ii=1:length(nbvoie_reception)%=64
  • trunk/src/series/rdvision_check_time.m

    r1178 r1179  
    243243    end
    244244    copyfile_modif(filexml,timestamp,newxml)
    245    % [nbfield2,msg]=copyfile_modif(filexml,timestamp,newxml); %copy the xml file in the upper folder
     245 
    246246    [XmlData,errormsg]=imadoc2struct(newxml);% check reading of the new xml file
    247247    if ~isempty(errormsg)
     
    267267   
    268268   
    269    
    270     % check the existence of the expected output image files (from the xml)
    271 
    272 
    273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    274 %--------- reads a series of bin files
    275 
    276 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    277 function [BinList,errormsg]=binread_rdv_series(PathDir,SeqData,SqbData,nbfield2,NomTypeNew)
    278 % BINREAD_RDV Permet de lire les fichiers bin g???n???r???s par Hiris ??? partir du
    279 % fichier seq associ???.
    280 %   [IMGS,TIMESTAMPS,NB_FRAMES] = BINREAD_RDV(FILENAME,FRAME_IDX) lit
    281 %   l'image d'indice FRAME_IDX de la s???quence FILENAME.
    282 %
    283 %   Entr???es
    284 %   -------
    285 %   FILENAME  : Nom du fichier s???quence (.seq).
    286 %   FRAME_IDX : Indice de l'image ??? lire. Si FRAME_IDX vaut -1 alors la
    287 %   s???quence est enti???rement lue. Si FRAME_IDX est un tableau d'indices
    288 %   alors toutes les images d'incides correspondant sont lues. Si FRAME_IDX
    289 %   est un tableau vide alors aucune image n'est lue mais le nombre
    290 %   d'images et tous les timestamps sont renvoy???s. Les indices commencent ???
    291 %   1 et se termines ??? NB_FRAMES.
    292 %
    293 %   Sorties
    294 %   -------
    295 %   IMGS        : Images de sortie.
    296 %   TIMESTAMPS  : Timestaps des images lues.
    297 %   NB_FRAMES   : Nombres d'images dans la s???quence.
    298 NbBinFile=0;
    299 BinSize=0;
    300 fid=0;
    301 errormsg='';
    302 BinList={};
    303 
    304 classname=sprintf('uint%d',SeqData.bytesperpixel*8);
    305 
    306 classname=['*' classname];
    307 BitDepth=8*SeqData.bytesperpixel;%needed to write images (8 or 16 bits)
    308 binrepertoire=fullfile(PathDir,SeqData.binrepertoire);
    309 FileDir=SeqData.sequencename;
    310 FileDir=regexprep(FileDir,'_Master_Dalsa_4M180$','');%suppress '_Master_Dalsa_4M180'
    311 OutputDir=fullfile(PathDir,FileDir);
    312 if ~exist(OutputDir,'dir')
    313     %     errormsg=[OutputDir ' already exist, delete it first'];
    314     %     return
    315     % end
    316     [s,errormsg]=mkdir(OutputDir);
    317    
    318     if s==0
    319         disp(errormsg)
    320         return%not able to create new image dir
    321     end
    322 end
    323 bin_file_counter=0;
    324 for ii=1:SeqData.nb_frames
    325     j1=[];
    326     if ~isequal(nbfield2,1)
    327         j1=mod(ii-1,nbfield2)+1;
    328     end
    329     i1=floor((ii-1)/nbfield2)+1;
    330     OutputFile=fullfile_uvmat(PathDir,FileDir,'img','.png',NomTypeNew,i1,[],j1);% TODO: set NomTypeNew from SeqData.mode
    331     fname=fullfile(binrepertoire,sprintf('%s%.5d.bin',SeqData.binfile,SqbData(ii).file_idx));
    332     if exist(OutputFile,'file')% do not recreate existing image file
    333         fid=0;
    334     else
    335         if fid==0 || ~strcmp(fname,fname_prev) % open the bin file if not in use
    336             if fid~=0
    337                 fclose(fid);%close the previous bin file if relevant
    338             end
    339             [fid,msg]=fopen(fname,'rb');
    340             if isequal(fid,-1)
    341                 errormsg=['error in opening ' fname ': ' msg];
    342                 return
    343             else
    344                 disp([fname ' opened for reading'])
    345                 bin_file_counter=bin_file_counter+1;
    346                 BinList{bin_file_counter}=fname;
    347             end
    348             fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file
    349             NbBinFile=NbBinFile+1;%counter of binary files (for checking purpose)
    350             BinSize(NbBinFile)=0;% strat counter for new bin file
    351         else
    352             fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file
    353         end
    354         fname_prev=fname;
    355         A=reshape(fread(fid,SeqData.width*SeqData.height,classname),SeqData.width,SeqData.height);%read the current image
    356         A=A';
    357         BinSize(NbBinFile)=BinSize(NbBinFile)+SeqData.width*SeqData.height*SeqData.bytesperpixel*8; %record bits read
    358         try
    359             imwrite(A,OutputFile,'BitDepth',BitDepth) % case of 16 bit images
    360             disp([OutputFile ' written']);
    361             % [s,errormsg] = fileattrib(OutputFile,'-w','a'); %set images to read only '-w' for all users ('a')
    362             %         if ~s
    363             % %             disp_uvmat('ERROR',errormsg,checkrun);
    364             %             return
    365             %         end
    366         catch ME
    367             errormsg=ME.message;
    368             return
    369         end
    370     end
    371 end
    372 if fid~=0
    373 fclose(fid)
    374 end
    375 
    376 
    377 
    378 
     269 
    379270function [nbfield2,msg]=copyfile_modif(filexml,timestamp,newxml)
    380271msg='';
  • trunk/src/series/sub_background.m

    r1178 r1179  
    301301    indselect=reshape(1:nbfield,NbSlice,[]);
    302302    for j_slice=1:NbSlice
    303     indselect(j_slice,:)=j_slice:step*NbSlice:nbfield;% select file indices of the slice
     303    indselect(j_slice,:)=j_slice:NbSlice:nbfield;% select file indices of the slice
    304304    end
    305305end
  • trunk/src/series/test_civ.m

    r1163 r1179  
    11%'test_civ': test the civ fct on a simple shear produced by defomation of the input image
     2% use Matlab signal processing toolbox
    23%------------------------------------------------------------------------
    34% Method:
  • trunk/src/transform_field/ima_edge_detection.m

    r1127 r1179  
    11% 'ima_edge_detection': find edges
     2% requires MATLAB Image Processing toolbox
    23
    34%------------------------------------------------------------------------
  • trunk/src/transform_field/ima_patch_detection.m

    r1127 r1179  
    1 % 'ima_edge_detection': find edges
    2 
     1% 'ima_patch_detection': find patches
     2% requires the Matlab image processing toolbox
    33%------------------------------------------------------------------------
    44%%%%  Use the general syntax for transform fields with a single input and parameters %%%%
  • trunk/src/uigetfile_uvmat.m

    r1144 r1179  
    4141fileinput=''; %default file selection
    4242if strcmp(title,'status_display')
    43     option='status_display';
    44 else
    45     option='browser';
     43    option='status_display';% use with the button 'Status Display' from the GUI 'series'
     44else
     45    option='browser';% usual browser
    4646end
    4747InputDir=pwd;%look in the current work directory if the input file does not exist
    4848InputFileName='';%default
    4949if ischar(InputName)
    50     if isempty(regexp(InputName,'^http://'))%usual files
     50    if isempty(regexp(InputName,'^http://', 'once'))%usual files
    5151        if exist(InputName,'dir')
    5252            InputDir=InputName;
     
    6868            InputDir=[InputDir '\'];% append '\' for a correct action of dir
    6969        end
    70     else
    71         [InputDir,InputFileName,Ext]=fileparts(InputName);
    72     end
    73 end
    74 
     70    else % files accessed on the web by Opendap
     71        [InputDir,InputFileName]=fileparts(InputName);
     72    end
     73end
     74
     75%% Display the browser figure
    7576hfig=findobj(allchild(0),'tag',option);%look for existing browser fig
    7677if isempty(hfig)% create the browser fig if it does not exist
     
    8384    hfig=figure('name',option,'tag',option,'MenuBar','none','NumberTitle','off','Unit','points','Position',[Left,Bottom,Width,Height],'UserData',InputDir);
    8485    BackgroundColor=get(hfig,'Color');
     86    % text title
    8587    path_title=uicontrol('Style','text','Units','normalized', 'Position', [0.02 0.97 0.9 0.03],'BackgroundColor',BackgroundColor,'Tag','Path_title',...
    8688        'String','path:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left');
    87     htitlebox=uicontrol('Style','edit','Units','normalized', 'Position', [0.02 0.89 0.96 0.08],'tag','titlebox','Max',2,'BackgroundColor',[1 1 1],'Callback',@titlebox_Callback,...
     89    % edit box for the current folder name
     90    uicontrol('Style','edit','Units','normalized', 'Position', [0.02 0.89 0.96 0.08],'tag','titlebox','Max',2,'BackgroundColor',[1 1 1],'Callback',@titlebox_Callback,...
    8891        'String',InputDir,'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''titlebox'':current path');
     92    % button for backward move in the directory tree
    8993    uicontrol('Style','pushbutton','Tag','backward','Units','normalized','Position',[0.02 0.77 0.1 0.05],...
    9094        'String','<--','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@backward,'TooltipString','move backward');
     
    118122        uicontrol('Style','togglebutton','Units','normalized', 'Position', [0.75 0.78 0.23 0.04],'tag','check_date','Callback',@dates_Callback,...
    119123            'String','show dates','FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''check_date'':press button to display dates');
    120 %         uicontrol('Style','text','Units','normalized', 'Position', [0.37 0.8 0.35 0.03],'BackgroundColor',BackgroundColor,...
    121 %             'String','sort: ','FontUnits','points','FontSize',12,'FontWeight','bold','HorizontalAlignment','right');
    122124         set(OK_button,'String','Open')
    123125         set(close_button,'String','Cancel')   
     
    126128end
    127129refresh_GUI(findobj(hfig,'Tag','refresh'),InputFileName,FilterExt)% refresh the list of content of the current dir
    128 if ~strcmp(option,'status_display')
     130if ~strcmp(option,'status_display') && strcmp(get(hfig,'Type'),'figure')
    129131    uiwait(hfig)
    130132    if ishandle(hfig)
     
    140142function titlebox_Callback(hObject,event)
    141143refresh_GUI(hObject)
     144
     145
     146%------------------------------------------------------------------------
     147% --- launched by refreshing the display figure
     148function refresh_GUI(hObject,InputFileName,FilterExt)
     149%------------------------------------------------------------------------
     150if ~exist('InputFileName','var')
     151    InputFileName='';
     152end
     153if ~exist('FilterExt','var')
     154    FilterExt='*';
     155end
     156if strcmp(FilterExt,'uigetdir')
     157    FilterExt='*';
     158end
     159hfig=get(hObject,'parent');
     160hlist=findobj(hfig,'tag','list');% find the list object
     161set(hlist,'BackgroundColor',[1 1 0])
     162drawnow
     163htitlebox=findobj(hfig,'tag','titlebox');
     164DirName=get(htitlebox,'String');
     165hsort_option=findobj(hfig,'tag','sort_option');
     166
     167%% case of file browser opened by Status Display in the GUI series
     168if strcmp(get(hfig,'Tag'),'status_display') % use with GUI series
     169    hseries=findobj(allchild(0),'tag','series');
     170    hstatus=findobj(hseries,'tag','status');
     171    StatusData=get(hstatus,'UserData');
     172    TimeStart=0;
     173    if isfield(StatusData,'TimeStart')
     174        TimeStart=StatusData.TimeStart;
     175    end
     176    hlist=findobj(hfig,'tag','list');
     177    NbOutputFile=[];
     178    if isfield(StatusData,'NbOutputFile')
     179        NbOutputFile=StatusData.NbOutputFile;
     180    end
     181    [ListFiles,NumFiles]=list_files(DirName,1,TimeStart);% list the directory content
     182   
     183    % update the waitbar
     184    hwaitbar=findobj(hfig,'tag','waitbar');
     185    if ~isempty(NbOutputFile)
     186        BarPosition=get(hwaitbar,'Position');
     187        BarPosition(3)=0.9*max(0.01,NumFiles/NbOutputFile);% the bar width cannot be set to 0, set to 0.01 instead
     188        set(hwaitbar,'Position',BarPosition)
     189    end
     190%% case of usual browser
     191else  %use as usual browser
     192    sort_option='name';
     193    if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2)
     194        sort_option='date';
     195    end
     196    hcheck_date=findobj(hfig,'tag','check_date');
     197    ListFiles=list_files(DirName,get(hcheck_date,'Value'),sort_option,FilterExt);% list the directory content
     198end
     199if ~isempty(DirName) && isempty(ListFiles)
     200    if isempty(regexp(DirName,'^http://', 'once'))%usual files
     201        ListFiles='empty folder';
     202    else
     203        ListFiles='address http:// not found';
     204    end
     205end
     206set(hlist,'String',ListFiles)
     207Value=[];
     208if ~isempty(InputFileName)
     209    Value=find(strcmp(InputFileName,ListFiles));
     210end
     211if isempty(Value)
     212    Value=1;
     213end
     214set(hlist,'Value',Value)
     215set(hlist,'BackgroundColor',[0.7 0.7 0.7])
    142216
    143217%------------------------------------------------------------------------   
     
    158232    list=get(hlist,'String');
    159233    index=get(hlist,'Value');
    160     if ~isempty(regexp(list{index},'^\+/'))
     234    if ~isempty(regexp(list{index},'^\+/', 'once'))
    161235        return % quit if a dir has been opened
    162236    end
     
    167241        SelectName=SelectName(1:ind_dot-1);
    168242    end
    169     if isempty(regexp(DirName,'^http://'))% if the input dir is not a web site (begins by http://)
     243    if isempty(regexp(DirName,'^http://', 'once'))% if the input dir is not a web site (begins by http://)
    170244        FullSelectName=fullfile(DirName,SelectName);
    171245        check_exist=exist(FullSelectName,'file');
     
    201275end
    202276
    203 %------------------------------------------------------------------------
    204 % --- launched by refreshing the display figure
    205 function refresh_GUI(hObject,InputFileName,FilterExt)
    206 %------------------------------------------------------------------------
    207 if ~exist('InputFileName','var')
    208     InputFileName='';
    209 end
    210 if ~exist('FilterExt','var')
    211     FilterExt='*';
    212 end
    213 if strcmp(FilterExt,'uigetdir')
    214     FilterExt='*';
    215 end
    216 hfig=get(hObject,'parent');
    217 hlist=findobj(hfig,'tag','list');% find the list object
    218 set(hlist,'BackgroundColor',[1 1 0])
    219 drawnow
    220 htitlebox=findobj(hfig,'tag','titlebox');
    221 DirName=get(htitlebox,'String');
    222 hsort_option=findobj(hfig,'tag','sort_option');
    223 % use with GUI series
    224 if strcmp(get(hfig,'Tag'),'status_display') % use with GUI series
    225     hseries=findobj(allchild(0),'tag','series');
    226     hstatus=findobj(hseries,'tag','status');
    227     StatusData=get(hstatus,'UserData');
    228     TimeStart=0;
    229     if isfield(StatusData,'TimeStart')
    230         TimeStart=StatusData.TimeStart;
    231     end
    232     hlist=findobj(hfig,'tag','list');
    233     testrecent=0;
    234     NbOutputFile=[];
    235     if isfield(StatusData,'NbOutputFile')
    236         NbOutputFile=StatusData.NbOutputFile;
    237         NbOutputFile_str=num2str(NbOutputFile);
    238     end
    239     [ListFiles,NumFiles]=list_files(DirName,1,TimeStart);% list the directory content
    240    
    241     % update the waitbar
    242     hwaitbar=findobj(hfig,'tag','waitbar');
    243     if ~isempty(NbOutputFile)
    244         BarPosition=get(hwaitbar,'Position');
    245         BarPosition(3)=0.9*max(0.01,NumFiles/NbOutputFile);% the bar width cannot be set to 0, set to 0.01 instead
    246         set(hwaitbar,'Position',BarPosition)
    247     end
    248 else  %use as usual browser
    249     sort_option='name';
    250     if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2)
    251         sort_option='date';
    252     end
    253     hcheck_date=findobj(hfig,'tag','check_date');
    254     [ListFiles,NumFiles]=list_files(DirName,get(hcheck_date,'Value'),sort_option,FilterExt);% list the directory content
    255 end
    256 
    257 set(hlist,'String',ListFiles)
    258 Value=[];
    259 if ~isempty(InputFileName)
    260     Value=find(strcmp(InputFileName,ListFiles));
    261 end
    262 if isempty(Value)
    263     Value=1;
    264 end
    265 set(hlist,'Value',Value)
    266 set(hlist,'BackgroundColor',[0.7 0.7 0.7])
    267 
    268 %------------------------------------------------------------------------   
     277
     278%------------------------------------------------------------------------
    269279% --- launched by selecting an item on the file list
    270280%------------------------------------------------------------------------
     
    282292
    283293
    284 %------------------------------------------------------------------------   
     294%------------------------------------------------------------------------
    285295% --- launched by selecting an item on the file list
    286296function list_Callback(option,filter_ext,hObject,event)
     
    288298hfig=get(hObject,'parent');%handle of the fig
    289299set(hObject,'BackgroundColor',[1 1 0])% paint list in yellow to indicate action
    290     drawnow
     300drawnow
    291301list=get(hObject,'String');
    292302index=get(hObject,'Value');
    293303
    294 htitlebox=findobj(hfig,'tag','titlebox');  % display the new dir name 
     304htitlebox=findobj(hfig,'tag','titlebox');  % display the new dir name
    295305DirName=get(htitlebox,'String');
    296 CheckSubDir=~isempty(regexp(list{index},'^\+'));
     306CheckSubDir=~isempty(regexp(list{index},'^\+', 'once'));
    297307SelectName=regexprep(list{index},'^\+/','');% remove the +/ used to mark dir
    298308ind_dot=regexp(SelectName,'\s*\.\.\.');%remove what is beyond  '...'
     
    303313    FullSelectName=fileparts(DirName);
    304314else
    305     if isempty(regexp(DirName,'^http://'))% usual files
     315    if isempty(regexp(DirName,'^http://', 'once'))% usual files
    306316        FullSelectName=fullfile(DirName,SelectName);
    307317    else
     
    321331    end
    322332    hcheck_date=findobj(hfig,'tag','check_date');
    323    
     333
    324334    ListFiles=list_files(FullSelectName,get(hcheck_date,'Value'),sort_option,filter_ext);% list the directory content
    325335    set(hObject,'Value',1)
     
    330340set(hObject,'BackgroundColor',[0.7 0.7 0.7])% paint list in grey to indicate action end
    331341
    332 %-------------------------------------------------------------------------   
     342%-------------------------------------------------------------------------
    333343% list the content of a directory
    334344function [ListFiles,NumFiles]=list_files(DirName,check_date,sort_option,filter_ext)
    335345%-------------------------------------------------------------------------
     346ListFiles={};%default
     347NumFiles=0;
    336348ListStruct=dir_uvmat(DirName);% get structure of the current directory
    337349if ~isstruct(ListStruct)
    338350    return
    339351end
    340    
     352
    341353date_index=find(strcmp('datenum',fieldnames(ListStruct)));% find the index of the date displayin the list of fields
    342 NumFiles=0; %default
    343354if numel(ListStruct)<1  % case of empty dir
    344     ListFiles={};
    345355    return
    346356end
    347357ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
    348358ListFiles=ListCells(1,:);%list of file names
    349 index_dir=find(strcmp('isdir',fieldnames(ListStruct)));
     359index_dir=strcmp('isdir',fieldnames(ListStruct));
    350360check_dir=cell2mat(ListCells(index_dir,:));% =1 for directories, =0 for files
    351361ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
     
    362372    check_dir=check_dir(check_keep);
    363373end
    364 check_emptydate=cellfun('isempty',ListCells(date_index,:));% = 1 if datenum undefined 
    365 ListCells(date_index,find(check_emptydate))={0}; %set to 0 the empty dates
     374check_emptydate=cellfun('isempty',ListCells(date_index,:));% = 1 if datenum undefined
     375ListCells(date_index,check_emptydate)={0}; %set to 0 the empty dates
    366376ListDates=cell2mat(ListCells(date_index,:));%list of numerical dates
    367377if isnumeric(sort_option)
     
    369379    NumFiles=numel(find(~check_old&~check_dir));
    370380end
    371 if ~isempty(find(~check_dir))
    372 ListDates(check_dir)=max(ListDates(~check_dir))+1000; % we set the dir in front
     381if ~isempty(find(~check_dir, 1))
     382    ListDates(check_dir)=max(ListDates(~check_dir))+1000; % we set the dir in front
    373383end
    374384
    375385if isnumeric(sort_option)|| strcmp(sort_option,'date')
    376     [tild,index_sort]=sort(ListDates,2,'descend');% sort files by chronological order, recent first, put the dir first in the list
    377 else
    378     [tild,index_sort]=sort(check_dir,2,'descend');% put the dir first in the list
     386    [~,index_sort]=sort(ListDates,2,'descend');% sort files by chronological order, recent first, put the dir first in the list
     387else
     388    [~,index_sort]=sort(check_dir,2,'descend');% put the dir first in the list
    379389end
    380390ListFiles=ListFiles(index_sort);% list of names sorted by alaphabetical order and dir and file
     
    447457function CheckImage=isimage(filename)
    448458
    449 [pp,name,ext]=fileparts(filename);
     459[~,~,ext]=fileparts(filename);
    450460CheckImage=~isempty(ext)&&~strcmp(ext,'.')&&~isempty(imformats(regexprep(ext,'^.','')));
  • trunk/src/uvmat.m

    r1178 r1179  
    461461[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    462462if isempty(regexp(RootPath,'^http://'))%usual files
    463 oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     463    oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    464464else %Opendap
    465465    oldfile=[RootPath '/' SubDir '/' RootFile FileIndices FileExt];
     
    484484% --------------------------------------------------------------------
    485485function MenuBrowseOpendap_Callback(hObject, eventdata, handles)
    486     oldfile=get(hObject,'Label');
     486oldfile=get(hObject,'Label');
    487487fileinput=uigetfile_uvmat('pick an input file',oldfile);
    488488hh=dir(fileinput);
     
    710710    delete(figure_movie)%delete existing figure_movie
    711711end
    712 figure_movie=figure;% create a new movie figure 
     712figure_movie=figure;% create a new movie figure
    713713nbpix=[640 480];% resolution VGA
    714714set(figure_movie,'name','figure_movie','Position',[1 1 nbpix])
     
    24282428TimeName='';%default
    24292429CheckIndexing=false;%default
     2430XmlData=[];
    24302431if isempty(XmlFileName)
    24312432    set(handles.view_xml,'Visible','off')
     
    25602561
    25612562%% read parameters (time, geometric calibration..) from a documentation file (.xml advised)
    2562 XmlData.GeometryCalib=[];%default
     2563%XmlData.GeometryCalib=[];%default
    25632564if input_line==1
    25642565    [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
Note: See TracChangeset for help on using the changeset viewer.