Changeset 651 for trunk/src


Ignore:
Timestamp:
Jun 25, 2013, 12:48:10 AM (12 years ago)
Author:
sommeria
Message:

various bugs corrected. Introduction of campaign lists in Open menu

Location:
trunk/src
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/browse_data.m

    r630 r651  
    121121    MirrorDir=get(handles.MirrorDir,'String');
    122122else
    123     MirrorRoot=uigetdir('','select the dir which must contain the mirror directory, then press OK'); %file browser
    124     if ~ischar(MirrorRoot)
     123    MirrorRoot=uigetfile_uvmat('select the folder which must contain the mirror directory:',SourcePath,'uigetdir');
     124%     MirrorRoot=uigetdir('','select the dir which must contain the mirror directory, then press OK'); %file browser
     125    if isempty(MirrorRoot)
    125126        return
    126127    else
     
    148149            if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')
    149150                idir=idir+1;
    150                 ExpName{idir}=hdir(ilist).name;
    151 
    152                 mirror=fullfile(MirrorDir,ExpName{idir});
     151                mirror=fullfile(MirrorDir,hdir(ilist).name);
    153152                if ~exist(mirror,'dir')
    154153                   mkdir(mirror)
    155154                end
     155                ExpName{idir}=['+/' hdir(ilist).name];
    156156            end
    157157            % look for the list of 'devices'
     
    186186%SourceDir=get(handles.SourceDir,'String');
    187187%MirrorDir=get(handles.MirrorDir,'String');
    188 ExpName={''};
     188% ExpName={''};
    189189if exist(Campaign,'dir')
    190     hdir=dir(Campaign); %list files and dirs
    191     idir=0;
    192     for ilist=1:length(hdir)
    193         if hdir(ilist).isdir
    194             dirname=hdir(ilist).name;
    195             if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')
    196                 idir=idir+1;
    197                 ExpName{idir}=hdir(ilist).name;
    198             end
    199         end
    200     end
    201     set(handles.ListExperiments,'String',[{'*'};ExpName'])
     190    ListStruct=dir(Campaign); %list files and dirs
     191    ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
     192    ListFiles=ListCells(1,:);%list of dir and file  names
     193    check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
     194    ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
     195    cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
     196    check_keep=cellfun('isempty', cell_remove);
     197    ListFiles=sort((ListFiles(check_keep))');
     198    set(handles.ListExperiments,'String',[{'*'};ListFiles])
    202199    set(handles.ListExperiments,'Value',1)
    203200    ListExperiments_Callback([],[], handles)
     
    210207%------------------------------------------------------------------------
    211208% --- Executes on selection change in ListExperiments.
     209%------------------------------------------------------------------------
    212210 function ListExperiments_Callback(hObject, eventdata, handles)
    213 %------------------------------------------------------------------------
     211
    214212MirrorPath='';
    215213CampaignPath=get(handles.SourceDir,'String');
    216214if strcmp(get(handles.MirrorDir,'Visible'),'on')
    217 %     CampaignPath=get(handles.MirrorDir,'String');
    218215    MirrorPath=get(handles.MirrorDir,'String');
    219 else
    220 %     CampaignPath=get(handles.SourceDir,'String');
    221 end
    222 % MirrorPath=get(handles.MirrorDir,'String');
     216end
    223217ListExperiments=get(handles.ListExperiments,'String');
    224218list_val=get(handles.ListExperiments,'Value');
    225219if isequal(list_val(1),1)
    226220    ListExperiments=ListExperiments(2:end); %choose all experiments
    227     testList=1;
    228221    set(handles.ListExperiments,'Value',1)
    229222else
    230223    ListExperiments=ListExperiments(list_val);%choose selected experiments
    231     testList=0;
    232224end
    233225scan_experiments(handles,ListExperiments,CampaignPath,MirrorPath)
     
    236228%------------------------------------------------------------------------
    237229% --- Executes on selection change in ListExperiments.
     230%------------------------------------------------------------------------
    238231 function scan_experiments(handles,ListExperiments,CampaignPath,MirrorPath)
    239 %------------------------------------------------------------------------
     232
    240233ListDevices={};
    241234for iexp=1:numel(ListExperiments)
    242     hdir=dir(fullfile(CampaignPath,ListExperiments{iexp})); %list files and dir in the experiment directory
    243     idir=0;
    244     for ilist=1:length(hdir)
    245         if ~isequal(hdir(ilist).name(1),'.')
    246             DataSeries=fullfile(CampaignPath,ListExperiments{iexp},hdir(ilist).name);
    247             if ~isempty(MirrorPath)
    248                 mirror=fullfile(MirrorPath,ListExperiments{iexp},hdir(ilist).name);
    249                 if ~exist(mirror)% create mirror if needed
    250                     system(['ln -s ' DataSeries ' ' mirror])
    251                 end
    252             end
    253             check_list=strcmp(hdir(ilist).name,ListDevices);
    254             if isempty(find(check_list, 1))
    255                 ListDevices=[ListDevices;hdir(ilist).name];
     235    if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory
     236        ListExperiments{iexp}(1)=[];
     237        ListStruct=dir(fullfile(CampaignPath,ListExperiments{iexp})); %list files and dir in the experiment directory
     238        ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
     239        ListFiles=ListCells(1,:);%list of dir and file  names
     240        cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
     241        check_keep=cellfun('isempty', cell_remove);
     242        check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
     243        for ilist=1:numel(ListFiles)
     244            if check_keep(ilist)
     245                DataSeries=fullfile(CampaignPath,ListExperiments{iexp},ListFiles{ilist});
     246                if ~isempty(MirrorPath)
     247                    mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist});
     248                    if ~exist(mirror)% create mirror if needed
     249                        system(['ln -s ' DataSeries ' ' mirror])
     250                    end
     251                end
     252                if isempty(find(strcmp(ListFiles{ilist},ListDevices), 1))% if the item is not already in ListDevices
     253                    if check_dir(ilist)
     254                        ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list
     255                    end
     256                    ListDevices=[ListDevices;ListFiles{ilist}]; %append the item to the list
     257                end
    256258            end
    257259        end
    258260    end
    259261end
    260 set(handles.ListDevices,'String',ListDevices)
    261 
    262 %------------------------------------------------------------------------
    263 % --- Executes on button press in update_headings.
    264 function ListDevices_Callback(hObject, eventdata, handles)
    265 % CurrentPath=get(handles.SourceDir,'String');
    266 % ListExperiments=get(handles.ListExperiments,'String');
    267 % list_val=get(handles.ListExperiments,'Value');
    268 % if isequal(list_val,1)
    269 %     ListExperiments=ListExperiments(2:end);
    270 % else
    271 %     ListExperiments=ListExperiments(list_val);
    272 % end
    273 % set(handles.ListRecords,'Value',1)
    274 % set(handles.ListXml,'Value',1)
    275 % ListDevices=get(handles.ListDevices,'String');
    276 % list_val=get(handles.ListDevices,'Value');
    277 % if isequal(list_val,1)
    278 %     ListDevices=ListDevices(2:end);
    279 % else
    280 %     ListDevices=ListDevices(list_val);
    281 % end
    282 % [ListDevices,ListRecords,ListXml]=ListDir(CurrentPath,ListExperiments,ListDevices,{});
    283 % set(handles.ListRecords,'String',[{'*'};ListRecords'])
    284 % set(handles.ListXml,'String',[{'*'};ListXml'])
    285 %
    286 %
    287 % if strcmp(get(handles.MirrorDir,'Visible'),'on')
    288 %     CurrentPath=get(handles.MirrorDir,'String');
    289 % else
    290 %     CurrentPath=get(handles.SourceDir,'String');
    291 % end
    292 % ListDevices=get(handles.ListDevices,'String');
    293 % Device=ListDevices(get(handles.ListDevices,'Value'));
    294 % % else
    295 % hdir=dir(fullfile(SourcePath,Device)); %list files and dirs
    296 
    297 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    298 
    299 
    300 
    301 %------------------------------------------------------------------------
    302 % --- Executes on selection change in ListRecords.
    303 function ListRecords_Callback(hObject, eventdata, handles)
    304 Value=get(handles.ListRecords,'Value');
    305 if isequal(Value(1),1)
    306     set(handles.ListRecords,'Value',1);
    307 end
     262set(handles.ListDevices,'String',sort(ListDevices))
    308263
    309264%------------------------------------------------------------------------
     
    311266function CampaignDoc_Callback(hObject, eventdata, handles)
    312267%------------------------------------------------------------------------   
    313 answer=msgbox_uvmat('INPUT_Y-N','This function will update the global xml rpresentation of the data set and the Heading of each xml file')
     268answer=msgbox_uvmat('INPUT_Y-N','This function will update the global xml rpresentation of the data set and the Heading of each xml file');
    314269if ~isequal(answer{1},'OK')
    315270    return
     
    351306                    [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest);
    352307                    if test
    353                         [List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated']
     308                        disp([List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated'])
    354309                    end
    355310                    if isequal(Title,'ImaDoc')
     
    369324                            [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest);
    370325                            if test
    371                                 [FileName ' , Heading updated']
     326                                disp([FileName ' , Heading updated'])
    372327                            end
    373328                            [t,uid_xml]=add(t,uid_record,'element','ImaDoc');
     
    426381            if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')
    427382                for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)
    428                     FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}
     383                    FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml};
    429384                    if isequal(FileName,XmlName)
    430385                        editxml(fullfile(CurrentPath,ExpName,DeviceName,FileName));
     
    556511
    557512%------------------------------------------------------------------------
    558 % --- Executes on button press in HELP.
    559 function HELP_Callback(hObject, eventdata, handles)
    560 path_to_uvmat=which ('uvmat')% check the path of uvmat
    561 pathelp=fileparts(path_to_uvmat);
    562 helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
    563 if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
    564 else
    565 web([helpfile '#dataview'])   
    566 end
    567 
    568 
    569 
    570 % --- Executes on selection change in ListXml.
    571 function ListXml_Callback(hObject, eventdata, handles)
    572 Value=get(handles.ListXml,'Value');
    573 if isequal(Value(1),1)
    574     set(handles.ListXml,'Value',1);
    575 end
    576 
    577 
    578 % --- Executes on button press in clean_civ_cmx.
    579 function clean_civ_cmx_Callback(hObject, eventdata, handles)
    580 message='this function will delete all files with extensions .log, .bat, .cmx,.cmx2,.errors in the input directory(ies)';
    581 answer=msgbox_uvmat('INPUT_Y-N',message);
    582 if ~isequal(answer,'Yes')
    583     return
    584 end
    585 set(handles.ListExperiments,'Value',1)
    586 ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories
    587 DataviewData=get(handles.browse_data,'UserData')
    588 List=DataviewData.List;
    589 Currentpath=get(handles.SourceDir,'String');
    590 [Currentpath,Campaign,DirExt]=fileparts(Currentpath);
    591 Campaign=[Campaign DirExt];
    592 SubCampaignTest=get(handles.SubCampaignTest,'Value');
    593 nbdelete_tot=0;
    594 for iexp=1:length(List.Experiment)
    595     set(handles.ListExperiments,'Value',iexp+1)
    596     drawnow
    597     test_mod=0;
    598     ExpName=List.Experiment{iexp}.name; 
    599     nbdelete=0;
    600     if isfield(List.Experiment{iexp},'Device')
    601         for idevice=1:length(List.Experiment{iexp}.Device)
    602             DeviceName=List.Experiment{iexp}.Device{idevice}.name;     
    603             if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')
    604                 currentdir=fullfile(Currentpath,Campaign,ExpName,DeviceName);
    605                 hdir=dir(currentdir); %list files and dirs
    606                 idir=0;
    607                 for ilist=1:length(hdir)
    608                     if hdir(ilist).isdir
    609                         dirname=hdir(ilist).name;
    610                         if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')
    611                             CivDir=fullfile(currentdir,dirname)
    612                             hCivDir=dir(CivDir);
    613                             for ilist=1:length(hCivDir)
    614                                 FileName=hCivDir(ilist).name;
    615                                 [dd,ff,Ext]=fileparts(FileName);
    616                                 if isequal(Ext,'.log')||isequal(Ext,'.bat')||isequal(Ext,'.cmx')||isequal(Ext,'.cmx2')|| isequal(Ext,'.errors')
    617                                     delete(fullfile(CivDir,FileName))
    618                                     nbdelete=nbdelete+1;
    619                                 end
    620                             end
    621                         end
    622                     end
    623                 end
    624              elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')
    625                 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)
    626                     RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;
    627                     if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile')
    628                         'look at subdirectories'
    629                     end
    630                 end
    631             end
    632         end
    633     end
    634     display([num2str(nbdelete) ' files deleted'])
    635     nbdelete_tot=nbdelete_tot+nbdelete;
    636 end
    637 msgbox_uvmat('CONFIRMATION',['END: ' num2str(nbdelete_tot) ' files deleted by clean_civ_cmx'])
    638 set(handles.ListExperiments,'Value',1)
    639 
    640 
    641513% --- Executes on button press in OK.
     514%------------------------------------------------------------------------
    642515function OK_Callback(hObject, eventdata, handles)
    643 %------------------------------------------------------------------------
     516
    644517if strcmp(get(handles.MirrorDir,'Visible'),'on')
    645518    Campaign=get(handles.MirrorDir,'String');
     
    653526    Experiment=Experiment(IndicesExp);% use the selection of the list of experiments
    654527end
     528Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir
    655529Device=get(handles.ListDevices,'String');
    656530Value=get(handles.ListDevices,'Value');
    657531Device=Device(Value);
     532Device=regexprep(Device,'^\+/','');% remove the +/ used to mark dir
    658533handles.output.Experiment=Experiment;
    659 handles.output.Device=Device;
     534handles.output.DataSeries=Device;
    660535guidata(hObject, handles);% Update handles structure
    661536uiresume(handles.browse_data);
    662537drawnow
    663 return
    664 
    665 
    666 % ListRecords=get(handles.ListRecords,'String');
    667 % Value=get(handles.ListRecords,'Value');
    668 % if ~isequal(Value,1)
    669 %     ListRecords=ListRecords(Value);
    670 % end
    671 
    672 %[ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices);
    673 ListXml=get(handles.ListXml,'String');
    674 Value=get(handles.ListXml,'Value');
    675 if isequal(Value,1)
    676     msgbox_uvmat('ERROR','you need to select in the GUI browse_data the xml files to edit')
    677     return
    678 else
    679     ListXml=ListXml(Value);
    680 end
    681 
    682 %update all the selected xml files
    683 DataviewData=get(handles.browse_data,'UserData');
    684 % answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' ...
    685 %     DataviewData.GeometryCalib.CalibrationType ' calibration data'])
    686 % if ~isequal(answer,'Yes')
    687 %     return
    688 % end
    689 %List.Experiment{1}.Device{1}
    690 %List.Experiment{2}.Device{1}
    691 for iexp=1:length(List.Experiment)
    692     ExpName=List.Experiment{iexp}.name;
    693     set(handles.ListExperiments,'Value',IndicesExp(iexp));
    694     if isfield(List.Experiment{iexp},'Device')
    695         for idevice=1:length(List.Experiment{iexp}.Device)
    696             DeviceName=List.Experiment{iexp}.Device{idevice}.name;     
    697             if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')
    698                 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)
    699                     FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml};
    700                     for ilistxml=1:length(ListXml)
    701                         if isequal(FileName,ListXml{ilistxml})
    702                             set(handles.ListXml,'Value',Value(ilistxml))
    703                             drawnow
    704                             xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName);
    705                             update_imadoc(DataviewData.GeometryCalib,xmlfullname,'GeometryCalib')
    706                             display([xmlfullname ' updated'])
    707                             break
    708                         end
    709                     end
    710                 end
    711              elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')
    712                 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)
    713                     RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;
    714                     if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile')
    715                         for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile)
    716                             FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml};
    717                             for ilistxml=1:length(ListXml)
    718                                 if isequal(FileName,ListXml{ilistxml})
    719                                     set(handles.ListXml,'Value',Value(ilistxml))
    720                                     drawnow
    721                                     xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName);
    722                                     update_imadoc(DataviewData.GeometryCalib,xmlfullname,'GeometryCalib')
    723                                     display([xmlfullname ' updated'])
    724                                     break
    725                                 end
    726                             end
    727                         end
    728                     end
    729                 end
    730             end
    731         end
    732     end
    733 end
    734 set(handles.ListXml,'Value',Value)   
    735 %     
    736 %     
    737 %     
    738 %     
    739 %     
    740 %     
    741 %     
    742 % CurrentPath=get(handles.SourceDir,'String');%= get(hObject,'String');
    743 % ListExperiments=get(handles.ListExperiments,'String');
    744 % Value=get(handles.ListExperiments,'Value');
    745 % if ~isequal(Value,1)
    746 %     ListExperiments=ListExperiments(Value);
    747 % end
    748 % ListDevices=get(handles.ListDevices,'String');
    749 % Value=get(handles.ListDevices,'Value');
    750 % if isequal(Value,1)
    751 %     msgbox_uvmat('ERROR','manually select in the GUI browse_data the device being calibrated')
    752 %     return
    753 % else
    754 %     ListDevices=ListDevices(Value);
    755 % end
    756 % ListRecords=get(handles.ListRecords,'String');
    757 % Value=get(handles.ListRecords,'Value');
    758 % if ~isequal(Value,1)
    759 %     ListRecords=ListRecords(Value);
    760 % end
    761 % [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords);
    762 % ListXml=get(handles.ListXml,'String');
    763 % Value=get(handles.ListXml,'Value');
    764 % if isequal(Value,1)
    765 %     msgbox_uvmat('ERROR','you need to select in the GUI browse_data the xml files to edit')
    766 %     return
    767 % else
    768 %     ListXml=ListXml(Value);
    769 % end
    770 % handles.output.CurrentPath=CurrentPath;
    771 % handles.output.ListExperiments=ListExperiments;
    772 % handles.output.ListDevices=ListDevices;
    773 % handles.output.ListRecords=ListRecords;
    774 % handles.output.ListXml=ListXml;
    775 % handles.output.List=List;
    776 % handles.output ='OK, Calibration replicated';
    777 % guidata(hObject, handles);% Update handles structure
    778 % uiresume(handles.browse_data);
    779 
     538
     539%------------------------------------------------------------------------
     540% --- Executes on button press in HELP.
     541function HELP_Callback(hObject, eventdata, handles)
     542path_to_uvmat=which ('uvmat');% check the path of uvmat
     543pathelp=fileparts(path_to_uvmat);
     544helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
     545if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
     546else
     547web([helpfile '#dataview'])   
     548end
     549
     550%------------------------------------------------------------------------
    780551% --- Executes on button press in Cancel.
     552%------------------------------------------------------------------------
    781553function Cancel_Callback(hObject, eventdata, handles)
     554   
    782555handles.output = get(hObject,'String');
    783556guidata(hObject, handles); % Update handles structure
     
    785558uiresume(handles.browse_data);
    786559
     560%------------------------------------------------------------------------
    787561% --- Executes when user attempts to close browse_data.
     562%------------------------------------------------------------------------
    788563function browse_data_CloseRequestFcn(hObject, eventdata, handles)
     564   
    789565if isequal(get(handles.browse_data, 'waitstatus'), 'waiting')
    790566    % The GUI is still in UIWAIT, us UIRESUME
     
    795571end
    796572
     573%------------------------------------------------------------------------
    797574% --- Executes on key press over figure1 with no controls selected.
     575%------------------------------------------------------------------------
    798576function browse_data_KeyPressFcn(hObject, eventdata, handles)
     577   
    799578% Check for "enter" or "escape"
    800579if isequal(get(hObject,'CurrentKey'),'escape')
  • trunk/src/calc_field_tps.m

    r581 r651  
    22%'calc_field_tps': defines fields (velocity, vort, div...) from civ data and calculate them with tps interpolation
    33%---------------------------------------------------------------------
    4 % [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbSites,SubRange,FieldVar,FieldName,Coord_interp)
     4% [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbCentre,SubRange,FieldVar,FieldName,Coord_interp)
    55%
    66% OUTPUT:
     
    88%
    99% INPUT:
    10 % Coord_tps:
    11 % NbSites
    12 % SubRange
    13 % FieldVar
    14 % FieldName: cell array representing the list of operations (eg div, rot..)
    15 % Coord_interp: coordiantes of sites on which the fields need to be calculated
     10% Coord_tps: coordinates of the centres, of dimensions [nb_point,nb_coord,nb_subdomain], where
     11%            nb_point is the max number of data point in a subdomain,
     12%            nb_coord the space dimension,
     13%            nb_subdomain the nbre of subdomains used for tps
     14% NbCentre: nbre of tps centres for each subdomain, of dimension nb_subdomain
     15% SubRange: coordinate range for each subdomain, of dimensions [nb_coord,2,nb_subdomain]
     16% FieldVar: cell array of list of variables needed to calculate the requested fields
     17% FieldName: cell array representing the list of operations (eg div(U,V), rot(U,V))
     18% Coord_interp: coordinates of sites on which the fields need to be calculated of dimensions
     19%            [nb_site,nb_coord] for an array of interpolation sites
     20%            [nb_site_y,nb_site_x,nb_coord] for interpolation on a plane grid of size [nb_site_y,nb_site_x]
    1621
    17 function [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbSites,SubRange,FieldVar,FieldName,Coord_interp)
     22function [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbCentre,SubRange,FieldVar,FieldName,Coord_interp)
    1823
    1924%list of defined scalars to display in menus (in addition to 'ima_cor').
     
    6873%% loop on subdomains
    6974for isub=1:NbSubDomain
    70     nbvec_sub=NbSites(isub);
     75    nbvec_sub=NbCentre(isub);
    7176    check_range=(Coord_interp >=ones(nb_sites,1)*SubRange(:,1,isub)' & Coord_interp<=ones(nb_sites,1)*SubRange(:,2,isub)');
    7277    ind_sel=find(sum(check_range,2)==nb_coord);
  • trunk/src/civ_matlab.m

    r604 r651  
    193193    Data.Patch1_SubDomainSize=Param.Patch1.SubDomainSize;
    194194    nbvar=length(Data.ListVarName);
    195     Data.ListVarName=[Data.ListVarName {'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbCentres','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}];
    196     Data.VarDimName=[Data.VarDimName {'nb_vec_1','nb_vec_1',{'nb_coord','nb_bounds','nb_subdomain_1'},'nb_subdomain_1',...
     195    Data.ListVarName=[Data.ListVarName {'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbCentre','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}];
     196    Data.VarDimName=[Data.VarDimName {'nb_vec_1','nb_vec_1',{'nb_coord','nb_bound','nb_subdomain_1'},'nb_subdomain_1',...
    197197        {'nb_tps_1','nb_coord','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'}}];
    198198    Data.VarAttribute{nbvar+1}.Role='vector_x';
     
    208208        ind_good=1:numel(Data.Civ1_X);
    209209    end
    210     [Data.Civ1_SubRange,Data.Civ1_NbCentres,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=...
     210    [Data.Civ1_SubRange,Data.Civ1_NbCentre,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=...
    211211        filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomainSize,Data.Patch1_FieldSmooth,Data.Patch1_MaxDiff);
    212212    Data.Civ1_U_smooth(ind_good)=Ures;
     
    292292    % get the guess from patch1
    293293    for isub=1:NbSubDomain
    294         nbvec_sub=Data.Civ1_NbCentres(isub);
     294        nbvec_sub=Data.Civ1_NbCentre(isub);
    295295        ind_sel=find(GridX>=Data.Civ1_SubRange(1,1,isub) & GridX<=Data.Civ1_SubRange(1,2,isub) & GridY>=Data.Civ1_SubRange(2,1,isub) & GridY<=Data.Civ1_SubRange(2,2,isub));
    296296        epoints = [GridX(ind_sel) GridY(ind_sel)];% coordinates of interpolation sites
     
    401401    Data.Patch2_SubDomainSize=Param.Patch2.SubDomainSize;
    402402    nbvar=length(Data.ListVarName);
    403     Data.ListVarName=[Data.ListVarName {'Civ2_U_smooth','Civ2_V_smooth','Civ2_SubRange','Civ2_NbCentres','Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps'}];
    404     Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2',{'nb_coord','nb_bounds','nb_subdomain_2'},{'nb_subdomain_2'},...
     403    Data.ListVarName=[Data.ListVarName {'Civ2_U_smooth','Civ2_V_smooth','Civ2_SubRange','Civ2_NbCentre','Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps'}];
     404    Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2',{'nb_coord','nb_bound','nb_subdomain_2'},{'nb_subdomain_2'},...
    405405        {'nb_tps_2','nb_coord','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'}}];
    406406   
     
    417417        ind_good=1:numel(Data.Civ2_X);
    418418    end
    419     [Data.Civ2_SubRange,Data.Civ2_NbCentres,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures, Vres,tild,FFres]=...
     419    [Data.Civ2_SubRange,Data.Civ2_NbCentre,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures, Vres,tild,FFres]=...
    420420        filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomainSize,Data.Patch2_FieldSmooth,Data.Patch2_MaxDiff);
    421421    Data.Civ2_U_smooth(ind_good)=Ures;
  • trunk/src/filter_tps.m

    r582 r651  
    11%'filter_tps': find the thin plate spline coefficients for interpolation-smoothing
    22%------------------------------------------------------------------------
    3 % [SubRange,NbCentres,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold)
     3% [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold)
    44%
    55% OUTPUT:
    66% SubRange(NbCoord,NbSubdomain,2): range (min, max) of the coordiantes x and y respectively, for each subdomain
    7 % NbCentres(NbSubdomain): number of source points for each subdomain
     7% NbCentre(NbSubdomain): number of source points for each subdomain
    88% FF: false flags
    99% U_smooth, V_smooth: filtered velocity components at the positions of the initial data
    10 % Coord_tps(NbCentres,NbCoord,NbSubdomain): positions of the tps centres
     10% Coord_tps(NbCentre,NbCoord,NbSubdomain): positions of the tps centres
    1111% U_tps,V_tps: weight of the tps for each subdomain
    1212% to get the interpolated field values, use the function calc_field.m
     
    1919% Subdomain: estimated number of data points in each subdomain
    2020
    21 function [SubRange,NbCentres,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold)
     21function [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold)
    2222
    2323%% adjust subdomain decomposition
     
    4646%% default output
    4747SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the positions of subdomains
    48 NbCentres=zeros(1,NbSubDomain);%number of interpolated values per subdomain, =0 by default
    49 %Coord_tps=zeros(NbVec,NbCoord,NbSubDomain);% default positions of the tps source= initial positions of the good vectors sorted by subdomain
    50 %U_tps=zeros(NbVec,NbSubDomain);%default spline
    51 %V_tps=zeros(NbVec,NbSubDomain);%default spline
     48NbCentre=zeros(1,NbSubDomain);%number of interpolated values per subdomain, =0 by default
    5249W_tps=[];%default (2 component case)
    5350U_smooth=zeros(NbVec,1); % smoothed velocity U at the initial positions
     
    9390                U_smooth(ind_sel)=U_smooth(ind_sel)+U_smooth_sub;
    9491                V_smooth(ind_sel)=V_smooth(ind_sel)+V_smooth_sub;
    95                 NbCentres(isub)=numel(ind_sel);
    96                 Coord_tps(1:NbCentres(isub),:,isub)=Coord(ind_sel,:);
    97                 U_tps(1:NbCentres(isub)+3,isub)=U_tps_sub;
    98                 V_tps(1:NbCentres(isub)+3,isub)=V_tps_sub;
     92                NbCentre(isub)=numel(ind_sel);
     93                Coord_tps(1:NbCentre(isub),:,isub)=Coord(ind_sel,:);
     94                U_tps(1:NbCentre(isub)+3,isub)=U_tps_sub;
     95                V_tps(1:NbCentre(isub)+3,isub)=V_tps_sub;
    9996                nb_select(ind_sel)=nb_select(ind_sel)+1;
    10097                display('good')
     
    110107                U_smooth(ind_sel(ind_ind_sel))=U_smooth(ind_sel(ind_ind_sel))+U_smooth_sub;
    111108                V_smooth(ind_sel(ind_ind_sel))=V_smooth(ind_sel(ind_ind_sel))+V_smooth_sub;
    112                 NbCentres(isub)=numel(ind_ind_sel);
    113                 Coord_tps(1:NbCentres(isub),:,isub)=Coord(ind_sel(ind_ind_sel),:);
    114                 U_tps(1:NbCentres(isub)+3,isub)=U_tps_sub;
    115                 V_tps(1:NbCentres(isub)+3,isub)=V_tps_sub;
     109                NbCentre(isub)=numel(ind_ind_sel);
     110                Coord_tps(1:NbCentre(isub),:,isub)=Coord(ind_sel(ind_ind_sel),:);
     111                U_tps(1:NbCentre(isub)+3,isub)=U_tps_sub;
     112                V_tps(1:NbCentre(isub)+3,isub)=V_tps_sub;
    116113                nb_select(ind_sel(ind_ind_sel))=nb_select(ind_sel(ind_ind_sel))+1;
    117114                display('good2')
  • trunk/src/plot_field.m

    r644 r651  
    353353
    354354%% set the colors of the successive plots (designed to produce rgb for the three components of color images)
    355 ColorOrder=[1 0 0;0 0.5 0;0 0 1;0 0.75 0.75;0.75 0 0.75;0.75 0.75 0;0.25 0.25 0.25];
    356 set(haxes,'ColorOrder',ColorOrder)
     355ColorOrder=[1 0 0;0 1 0;0 0 1;0 0.75 0.75;0.75 0 0.75;0.75 0.75 0;0.25 0.25 0.25];
     356set(hfig,'DefaultAxesColorOrder',ColorOrder)
    357357% if isfield(Coordinates,'NextPlot')
    358358%     set(haxes,'NextPlot',Coordinates.NextPlot)
     
    459459    eval(plotstr)                  %execute plot (instruction  plotstr)
    460460    %%%
    461     set(haxes,'tag',tag)
     461    set(haxes,'tag',tag)% restitute the axes tag (removed by the command plot)
     462    set(haxes,'ColorOrder',ColorOrder)% restitute the plot color order (to get red green blue for histograms or cuts of color images)
    462463    grid(haxes, 'on')
    463464    hxlabel=xlabel(xtitle(1:end-2));% xlabel (removes ', ' at the end)
  • trunk/src/proj_field.m

    r650 r651  
    10531053    switch CellInfo{icell}.CoordType
    10541054       
    1055         %% case of input fields with unstructured coordinates
    10561055        case 'scattered'
     1056        %% case of input fields with unstructured coordinates (applies for projMode ='projection' or 'interp_lin')
    10571057            if strcmp(ProjMode{icell},'interp_tps')
    10581058                continue %skip for next cell (needs tps field cell)
     
    10731073           
    10741074            % selection of the vectors in the projection range (3D case)
    1075             if check3D&&  width > 0
     1075            if check3D &&  width > 0
    10761076                %components of the unitiy vector normal to the projection plane
    10771077                fieldZ=norm_plane(1)*coord_x + norm_plane(2)*coord_y+ norm_plane(3)*coord_z;% distance to the plane
     
    10791079                for ivar=VarIndex
    10801080                    VarName=FieldData.ListVarName{ivar};
    1081                     eval(['FieldData.' VarName '=FieldData.' VarName '(indcut);'])
    1082                     % A VOIR : CAS DE VAR STRUCTUREE MAIS PAS GRILLE REGULIERE : INTERPOLER SUR GRILLE REGULIERE
     1081                    FieldData.(VarName)=FieldData.(VarName)(indcut);
    10831082                end
    10841083                coord_x=coord_x(indcut);
     
    11381137            end
    11391138           
    1140             % different cases of projection
     1139            % two cases of projection
    11411140            switch ProjMode{icell}
    11421141                case 'projection' 
     
    11741173                        end
    11751174                    end
    1176 %                     testFF=0;
    1177 %                     nbvar=numel(ProjData.ListVarName);                           
    1178 %                     if isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y')
    1179 %                         VarName_x=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x};
    1180 %                         VarName_y=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y};
    1181 %                         if isfield(CellInfo{icell},'VarIndex_errorflag')
    1182 %                             FieldData.(VarName_x)=FieldData.(VarName_x)(indsel);
    1183 %                             FieldData.(VarName_y)=FieldData.(VarName_y)(indsel);
    1184 %                         end
    1185 %                         %FieldVar=cat(2,FieldData.(VarName_x),FieldData.(VarName_y));
    1186 %                         if ~isfield(CellInfo{icell},'CheckSub') || ~CellInfo{icell}.CheckSub
    1187 %                             vector_x_proj=numel(ProjData.ListVarName)+1;
    1188 %                             vector_y_proj=numel(ProjData.ListVarName)+2;
    1189 %                         end
    1190 %                     end
    1191 %                     if isfield(CellInfo{icell},'VarIndex_scalar')
    1192 %                         VarName_scalar=FieldData.ListVarName{CellInfo{icell}.VarIndex_scalar};
    1193 %                         if isfield(CellInfo{icell},'errorflag') && ~isempty(CellInfo{icell}.errorflag)
    1194 %                             FieldData.(VarName_scalar)=FieldData.(VarName_scalar)(indsel);
    1195 %                         end
    1196 %                     end
    1197 %                     if isfield(CellInfo{icell},'VarIndex_ancillary')% do not project ancillary data with interp
    1198 %                         FieldData=rmfield(FieldData,FieldData.ListVarName{CellInfo{icell}.VarIndex_ancillary});
    1199 %                     end
    1200 %                     if isfield(CellInfo{icell},'VarIndex_warnflag')% do not project ancillary data with interp
    1201 %                         FieldData=rmfield(FieldData,FieldData.ListVarName{CellInfo{icell}.VarIndex_warnflag});
    1202 %                     end
    12031175                    % interpolate and calculate field on the grid
    12041176                    [VarVal,ListFieldProj,VarAttribute,errormsg]=calc_field_interp([coord_X coord_Y],FieldData,CellInfo{icell}.FieldName,XI,YI);
     
    12231195            end
    12241196
    1225             %% case of tps interpolation (applies only in interp_tps mode and for spatial derivatives)
    12261197        case 'tps'
     1198        %% case of tps data (applies only in interp_tps mode)
    12271199            if strcmp(ProjMode{icell},'interp_tps')
    12281200                Coord=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex});
  • trunk/src/read_civdata.m

    r613 r651  
    216216    %    units={'pixel','pixel','pixel','pixel','pixel','pixel','','',''};
    217217    case 'filter1'
    218         var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbCentres','NbCentres';...
     218        var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbCentre','NbCentre','NbCentre';...
    219219            'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U_smooth','Civ1_V_smooth','Civ1_W','Civ1_C','Civ1_F','Civ1_FF',...
    220             'Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps','Civ1_W_tps','Civ1_SubRange','Civ1_NbCentres','Civ1_NbSites'};
     220            'Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps','Civ1_W_tps','Civ1_SubRange','Civ1_NbCentre','Civ1_NbCentres','Civ1_NbSites'};
    221221        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','coord_tps','vector_x_tps',...
    222             'vector_y_tps','vector_z_tps','ancillary','ancillary','ancillary'};
    223      %  rmq: NbSites obsolete replaced by NbCentres, kept for consistency with previous data
     222            'vector_y_tps','vector_z_tps','ancillary','ancillary','ancillary','ancillary'};
     223     %  rmq: NbCentres and NbSites obsolete replaced by NbCentre, kept for consistency with previous data
    224224    case 'civ2'
    225225        var={'X','Y','Z','U','V','W','C','F','FF';...
     
    227227        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'};
    228228    case 'filter2'
    229         var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbCentres','NbCentres';...
     229        var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbCentre','NbCentre','NbCentre';...
    230230            'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U_smooth','Civ2_V_smooth','Civ2_W','Civ2_C','Civ2_F','Civ2_FF',...
    231             'Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps','','Civ2_SubRange','Civ2_NbCentres','Civ2_NbSites'};
     231            'Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps','','Civ2_SubRange','Civ2_NbCentre','Civ2_NbCentres','Civ2_NbSites'};
    232232        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','coord_tps','vector_x_tps',...
    233             'vector_y_tps','vector_z_tps','ancillary','ancillary','ancillary'};
     233            'vector_y_tps','vector_z_tps','ancillary','ancillary','ancillary','ancillary'};
    234234end
    235235if ~strcmp(ProjModeRequest,'interp_tps')
  • trunk/src/series.m

    r650 r651  
    153153    if isfield(h,'MenuFile')
    154154        for ifile=1:min(length(h.MenuFile),5)
    155             eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});'])
     155            set(handles.(['MenuFile_' num2str(ifile)]),'Label',h.MenuFile{ifile});
     156        end
     157    end
     158    %get the list of previous camapigns in the upper bar menu Open campaign
     159    if isfield(h,'MenuCampaign')
     160        for ifile=1:min(length(h.MenuCampaign),5)
     161            set(handles.(['MenuCampaign_' num2str(ifile)]),'Label',h.MenuCampaign{ifile});
    156162        end
    157163    end
     
    224230    set(handles.Coord_y,'Value',Param.Coord_y_val);% selected string index
    225231end
    226 
    227 %% Adjust the GUI according to the binaries available in PARAM.xml
    228 % path_uvmat=fileparts(which('uvmat')); %path to civ
    229 % addpath (path_uvmat) ; %add the path to civ, (useful in case of change of working directory after civ has been s opened in the working directory)
    230 % errormsg=[];%default error message
    231 % xmlfile='PARAM.xml';
    232 % if exist(xmlfile,'file')
    233 %     try
    234 %         t=xmltree(xmlfile);
    235 %         sparam=convert(t);
    236 %     catch ME
    237 %         errormsg={' Unable to read the file PARAM.xml defining the  binaries:';ME.message};
    238 %     end
    239 % else
    240 %     errormsg=[xmlfile ' not found: path to binaries undefined'];
    241 % end
    242 % if ~isempty(errormsg)
    243 %     msgbox_uvmat('WARNING',errormsg);
    244 % end
    245 % test_batch=0;%default: ,no batch mode available
    246 % if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode')
    247 %     test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod
    248 % end
    249 % RUNVal=get(handles.RunMode,'Value');
    250 % if test_batch==0
    251 %    if RUNVal>2
    252 %        set(handles.RunMode,'Value',1)
    253 %    end
    254 %    set(handles.RunMode,'String',{'local';'background'})
    255 % else
    256 %     set(handles.RunMode,'String',{'local';'background';'cluster'})
    257 % end
    258232
    259233%% introduce the input file name(s) if defined from input Param
     
    296270%------------------------------------------------------------------------
    297271%------------------------------------------------------------------------
     272% --- fct activated by the browser under 'Open'
     273%------------------------------------------------------------------------ 
    298274function MenuBrowse_Callback(hObject, eventdata, handles)
    299 %------------------------------------------------------------------------   
    300 %get the previous input file in the Input Table
     275
     276%% look for the previously opened file 'oldfile'
    301277oldfile=''; %default
    302 SeriesData=get(handles.series,'UserData');
    303 if isfield(SeriesData,'RefFile')
    304     oldfile=SeriesData.RefFile{1};
    305 end
    306 if ~exist(oldfile,'file')
     278if get(handles.CheckAppend,'Value')
     279    % case 'checkappend': new series appended to the input table
     280    InputTable=get(handles.InputTable,'Data');
     281    RootPathCell=InputTable(:,1);
     282    SubDirCell=InputTable(:,3);
     283    oldfile=''; %default
     284    if ~(isempty(RootPathCell) || isequal(RootPathCell,{''}))%loads the previously stored file name and set it as default in the file_input box
     285        oldfile=fullfile(RootPathCell{1},SubDirCell{1});
     286    end
     287else
     288    % case refresh the input table by a new series
     289    SeriesData=get(handles.series,'UserData');
     290    if isfield(SeriesData,'RefFile')
     291        oldfile=SeriesData.RefFile{1};
     292    end
     293end
     294
     295%% use a file name stored in prefdir
     296dir_perso=prefdir;
     297profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     298if exist(profil_perso,'file')
     299    h=load (profil_perso);
     300    if isfield(h,'RootPath') && ischar(h.RootPath)
     301        oldfile=h.RootPath;
     302    end
     303end
     304
     305%% launch the browser
     306fileinput=uigetfile_uvmat('pick a file to append in the input table',oldfile);
     307if ~isempty(fileinput)
     308    if get(handles.CheckAppend,'Value')
     309        display_file_name(handles,fileinput,'append')
     310    else
     311        display_file_name(handles,fileinput,'one')
     312    end
     313end
     314
     315%------------------------------------------------------------------------
     316% --- fct activated by selecting a previous file under the menu Open
     317%------------------------------------------------------------------------
     318function MenuFile_Callback(hObject, eventdata, handles)
     319
     320fileinput=get(hObject,'Label');
     321if get(handles.CheckAppend,'Value')
     322    display_file_name(handles,fileinput,'append')
     323else
     324    display_file_name(handles,fileinput,'one')
     325end
     326
     327%------------------------------------------------------------------------
     328% --- fct activated by the browser under 'Open campaign'
     329%------------------------------------------------------------------------
     330function MenuBrowseCampaign_Callback(hObject, eventdata, handles)
     331
     332set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0])
     333drawnow
     334InputTable=get(handles.InputTable,'Data');
     335RootPath=InputTable{1,1};
     336CampaignPath=fileparts(fileparts(RootPath));
     337DirFull=uigetfile_uvmat('define this path as the Campaign folder:',CampaignPath,'uigetdir');
     338if ~ischar(DirFull)|| ~exist(DirFull,'dir')
     339    return
     340end
     341OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device
     342if ~isfield(OutPut,'Campaign')
     343    return
     344end
     345DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
     346ListStruct=dir(DirName); %list files and the dir DataSeries
     347% select the first appropriate file in the dir
     348FileName='';
     349for ilist=1:numel(ListStruct)
     350    if ~isequal(ListStruct(ilist).isdir,1)%look for files, not dir
     351        FileName=ListStruct(ilist).name;
     352        FileType=get_file_type(fullfile(DirName,FileName));
     353        switch FileType
     354            case {'image','multimage','civx','civdata','netcdf'}
     355                break
     356        end
     357    end
     358end
     359if isempty(FileName)
     360    msgbox_uvmat('ERROR',['no appropriate input file in the DataSeries folder ' fullfile(DirName)])
     361    return
     362end
     363
     364%% update the list of campaigns in the menubar
     365MenuCampaign=[{get(handles.MenuCampaign_1,'Label')};{get(handles.MenuCampaign_2,'Label')};...
     366    {get(handles.MenuCampaign_3,'Label')};{get(handles.MenuCampaign_4,'Label')};{get(handles.MenuCampaign_5,'Label')}];
     367check_dir=isempty(find(strcmp(DirFull,MenuCampaign)));
     368if check_dir %insert the new campaign in the list if it is not found
     369    MenuCampaign(end)=[]; %suppress the last item
     370    MenuCampaign=[{DirFull};MenuCampaign];%insert the new campaign
     371    for ilist=1:numel(MenuCampaign)
     372        set(handles.(['MenuCampaign_' num2str(ilist)]),'Label',MenuCampaign{ilist})
     373    end
     374    % save the list for future opening:
    307375    dir_perso=prefdir;
    308376    profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    309377    if exist(profil_perso,'file')
    310          h=load (profil_perso);
    311         if isfield(h,'RootPath')&&ischar(h.RootPath)
    312             oldfile=h.RootPath;
    313         end
    314     end
    315 end
    316 fileinput=uigetfile_uvmat('pick a file to refresh the input table',oldfile);
    317 if ~isempty(fileinput)
    318      display_file_name(handles,fileinput,'one')
    319 end
    320 
     378        save (profil_perso,'MenuCampaign','RootPath','-append'); %store the file names for future opening of uvmat
     379    else
     380        save (profil_perso,'MenuCampaign','RootPath','-V6'); %store the file names for future opening of uvmat
     381    end
     382end
     383
     384%% display the selected field and related information
     385if get(handles.CheckAppend,'Value')
     386    display_file_name(handles,fullfile(DirName,FileName),'append')
     387else
     388    display_file_name(handles,fullfile(DirName,FileName),'one')
     389end
     390set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
    321391
    322392% --------------------------------------------------------------------
    323 function MenuFile_1_Callback(hObject, eventdata, handles)
    324 fileinput=get(handles.MenuFile_1,'Label');
    325 display_file_name(handles,fileinput,'one')
    326 
    327 % --------------------------------------------------------------------
    328 function MenuFile_2_Callback(hObject, eventdata, handles)
    329 fileinput=get(handles.MenuFile_2,'Label');
    330 display_file_name(handles,fileinput,'one')
    331 
    332 % --------------------------------------------------------------------
    333 function MenuFile_3_Callback(hObject, eventdata, handles)
    334 fileinput=get(handles.MenuFile_3,'Label');
    335 display_file_name( handles,fileinput,'one')
    336 
    337 % --------------------------------------------------------------------
    338 function MenuFile_4_Callback(hObject, eventdata, handles)
    339 fileinput=get(handles.MenuFile_4,'Label');
    340 display_file_name(handles,fileinput,'one')
    341 
    342 % --------------------------------------------------------------------
    343 function MenuFile_5_Callback(hObject, eventdata, handles)
    344 fileinput=get(handles.MenuFile_5,'Label');
    345 display_file_name(handles,fileinput,'one')
    346 
    347 % --------------------------------------------------------------------
    348 function MenuBrowse_insert_Callback(hObject, eventdata, handles)
    349 InputTable=get(handles.InputTable,'Data');
    350 RootPathCell=InputTable(:,1);
    351 SubDirCell=InputTable(:,3);
    352 RootFileCell=InputTable(:,2);
    353 oldfile=''; %default
    354 if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box
    355      dir_perso=prefdir;
    356      profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    357      if exist(profil_perso,'file')
    358           h=load (profil_perso);
    359          if isfield(h,'filebase')&ischar(h.filebase)
    360                  oldfile=h.filebase;
    361          end
    362          if isfield(h,'RootPath')&ischar(h.RootPath)
    363                  oldfile=h.RootPath;
    364          end
    365      end
    366  else
    367      oldfile=fullfile(RootPathCell{1},RootFileCell{1});
    368 end
    369  fileinput=uigetfile_uvmat('pick a file to append in the input table',oldfile);
    370 if ~isempty(fileinput)
    371      display_file_name(handles,fileinput,'append')
    372 end
    373 % [FileName, PathName, filterindex] = uigetfile( ...
    374 %        {'*.xml;*.xls;*.png;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png, *.avi,*.nc)';
    375 %        '*.xml',  '.xml files '; ...
    376 %         '*.xls',  '.xls files '; ...
    377 %         '*.png','.png image files'; ...
    378 %         '*.avi;*.AVI','.avi movie files'; ...
    379 %         '*.nc','.netcdf files'; ...
    380 %         '*.*',  'All Files (*.*)'}, ...
    381 %         'Pick a file',oldfile);
    382 % fileinput=[PathName FileName];%complete file name
    383 % sizf=size(fileinput);
    384 % if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
    385 % [path,name,ext]=fileparts(fileinput);
    386 % if isequal(ext,'.xml')
    387 %     msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
    388 % elseif isequal(ext,'.xls')
    389 %     msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
    390 % else
    391 %     display_file_name(handles,fileinput,'append')
    392 % end
    393 
    394 % --------------------------------------------------------------------
    395 function MenuFile_insert_1_Callback(hObject, eventdata, handles)
    396 % --------------------------------------------------------------------   
    397 fileinput=get(handles.MenuFile_insert_1,'Label');
    398 display_file_name(handles,fileinput,'append')
    399 
    400 % --------------------------------------------------------------------
    401 function MenuFile_insert_2_Callback(hObject, eventdata, handles)
    402 % --------------------------------------------------------------------   
    403 fileinput=get(handles.MenuFile_insert_2,'Label');
    404 display_file_name(handles,fileinput,'append')
    405 
    406 % --------------------------------------------------------------------
    407 function MenuFile_insert_3_Callback(hObject, eventdata, handles)
    408 % --------------------------------------------------------------------   
    409 fileinput=get(handles.MenuFile_insert_3,'Label');
    410 display_file_name( handles,fileinput,'append')
    411 
    412 % --------------------------------------------------------------------
    413 function MenuFile_insert_4_Callback(hObject, eventdata, handles)
    414 % --------------------------------------------------------------------   
    415 fileinput=get(handles.MenuFile_insert_4,'Label');
    416 display_file_name( handles,fileinput,'append')
    417 
    418 % --------------------------------------------------------------------
    419 function MenuFile_insert_5_Callback(hObject, eventdata, handles)
    420 % --------------------------------------------------------------------   
    421 fileinput=get(handles.MenuFile_insert_5,'Label');
    422 display_file_name(handles,fileinput,'append')
     393function MenuCampaign_Callback(hObject, eventdata, handles)
     394% --------------------------------------------------------------------
     395set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0])
     396OutPut=browse_data(get(hObject,'Label'));% open the GUI browse_data to get select a campaign dir, experiment and device
     397if ~isfield(OutPut,'Campaign')
     398    return
     399end
     400DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
     401hdir=dir(DirName); %list files and dirs
     402for ilist=1:numel(hdir)
     403    if ~isequal(hdir(ilist).isdir,1)%look for files, not dir
     404        FileName=hdir(ilist).name;
     405        FileType=get_file_type(fullfile(DirName,FileName));
     406        switch FileType
     407            case {'image','multimage','civx','civdata','netcdf'}
     408            break
     409        end
     410    end
     411end
     412if get(handles.CheckAppend,'Value')
     413    display_file_name(handles,fullfile(DirName,FileName),'append')
     414else
     415    display_file_name(handles,fullfile(DirName,FileName),'one')
     416end
     417set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
     418
     419
    423420
    424421%------------------------------------------------------------------------
     
    434431end
    435432%% enable other menus and uicontrols
    436 set(handles.MenuOpen_insert,'Enable','on')
    437 set(handles.MenuFile_insert_1,'Enable','on')
    438 set(handles.MenuFile_insert_2,'Enable','on')
    439 set(handles.MenuFile_insert_3,'Enable','on')
    440 set(handles.MenuFile_insert_4,'Enable','on')
    441 set(handles.MenuFile_insert_5,'Enable','on')
     433set(handles.MenuOpenCampaign,'Enable','on')
     434set(handles.MenuCampaign_1,'Enable','on')
     435set(handles.MenuCampaign_2,'Enable','on')
     436set(handles.MenuCampaign_3,'Enable','on')
     437set(handles.MenuCampaign_4,'Enable','on')
     438set(handles.MenuCampaign_5,'Enable','on')
    442439set(handles.RUN, 'Enable','On')
    443440set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red
     
    492489% iview: line index in the input table
    493490%       or 'one': refresh the list
    494 %       'append': add a new line to the list
     491%       'checkappend': add a new line to the list
    495492
    496493%% get the input root name, indices, file extension and nomenclature NomType
     
    521518
    522519%% enable other menus and uicontrols
    523 set(handles.MenuOpen_insert,'Enable','on')
    524 set(handles.MenuFile_insert_1,'Enable','on')
    525 set(handles.MenuFile_insert_2,'Enable','on')
    526 set(handles.MenuFile_insert_3,'Enable','on')
    527 set(handles.MenuFile_insert_4,'Enable','on')
    528 set(handles.MenuFile_insert_5,'Enable','on')
     520set(handles.MenuOpenCampaign,'Enable','on')
     521set(handles.MenuCampaign_1,'Enable','on')
     522set(handles.MenuCampaign_2,'Enable','on')
     523set(handles.MenuCampaign_3,'Enable','on')
     524set(handles.MenuCampaign_4,'Enable','on')
     525set(handles.MenuCampaign_5,'Enable','on')
    529526set(handles.RUN, 'Enable','On')
    530527set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red
     
    595592for ifile=1:min(length(MenuFile),5)
    596593    eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
    597     eval(['set(handles.MenuFile_insert_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
    598594end
    599595dir_perso=prefdir;
     
    731727%% number of slices set by default
    732728NbSlice=1;%default
    733 % read  value set by the first series for the append mode (iwiew >1)
     729% read  value set by the first series for the checkappend mode (iwiew >1)
    734730if iview>1 && strcmp(get(handles.num_NbSlice,'Visible'),'on')
    735731    NbSlice=str2num(get(handles.num_NbSlice,'String'));
     
    738734%% default time unit
    739735TimeUnit='';
    740 % read  value set by the first series for the append mode (iwiew >1)
     736% read  value set by the first series for the checkappend mode (iwiew >1)
    741737if iview>1
    742738    TimeUnit=get(handles.TimeUnit,'String');
  • trunk/src/series/civ_input.m

    r647 r651  
    5656guidata(hObject, handles); % Update handles structure
    5757set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display)
    58 SeriesData.ParentHandle=gcbf;
    59 SeriesData=get(gcbf,'UserData');
     58hseries=findobj(allchild(0),'Tag','series');
     59SeriesData.ParentHandle=hseries;
     60SeriesData=get(hseries,'UserData');
    6061% relevant data in gcbf:.FileType,.FileInfo,.Time,.TimeUnit,.GeometryCalib{1};
    6162
     
    19441945%     set(handles.num_FieldSmooth,'Visible','on')
    19451946% else
     1947
    19461948%     set(handles.num_subdomainsize,'Visible','off')
    19471949%     set(handles.num_FieldSmooth,'Visible','off')
     
    19551957drawnow
    19561958if get(handles.TestCiv1,'Value')
    1957     set(handles.TestCiv1,'BackgroundColor',[0.7 0.7 0.7])% paint TestCiv1 button to grey to confirm civ launch
     1959    set(handles.TestCiv1,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch
    19581960    ref_i=str2double(get(handles.ref_i,'String'));% read reference i index
    19591961    if strcmp(get(handles.ref_j,'Visible'),'on')
     
    19621964        ref_j=1;%default j index
    19631965    end
    1964     [filecell,i1,i2]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]);% get the corresponding file name and indices
     1966   % [filecell,i1,i2]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]);% get the corresponding file name and indices
    19651967    Data.ListVarName={'ny','nx','A'};
    19661968    Data.VarDimName= {'ny','nx',{'ny','nx'}};
    1967 
     1969    hseries=findobj(allchild(0),'Tag','series');
     1970    hhseries=guidata(hseries);
     1971    InputTable=get(hhseries.InputTable,'Data');
     1972    ind_A=1;
     1973    if strcmp(InputTable{1,5},'.nc');
     1974        ind_A=2;
     1975    end
     1976    [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=...
     1977            find_pair_indices(PairCiv1,i_series{1},j_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j);
     1978 
     1979    ImageName_A=fullfile_uvmat(InputTable{ind_A,1},InputTable{ind_A,2},InputTable{ind_A,3},InputTable{ind_A,5},InputTable{ind_A,4},...
     1980        ref_i,[],ref_j);
    19681981    Data.A=imread(filecell.ima1.civ1{1}); % read the first image
    19691982    if ndims(Data.A)==3 %case of color image
  • trunk/src/set_subdomains.m

    r587 r651  
    11%'set_subdomains': sort a set of points defined by scattered coordinates in subdomains, as needed for tps interpolation
    22%------------------------------------------------------------------------
    3 % [SubRange,NbSites,IndSelSubDomain] =set_subdomains(Coord,SubDomainNbPoint)
     3% [SubRange,NbCentre,IndSelSubDomain] =set_subdomains(Coord,SubDomainNbPoint)
    44%
    55% OUTPUT:
    66% SubRange(NbCoord,NbSubdomain,2): range (min, max) of the coordinates x and y respectively, for each subdomain
    7 % NbSites(NbSubdomain): number of source points for each subdomain
     7% NbCentre(NbSubdomain): number of source points for each subdomain
    88% IndSelSubDomain(SubDomainNbPointMax,NbSubdomain): set of indices of the input point array
    9 % selected in each subdomain, =0 beyond NbSites points
     9% selected in each subdomain, =0 beyond NbCentre points
    1010%
    1111% INPUT:
     
    1313% SubdomainNbPoint: estimated number of data points whished for each subdomain
    1414
    15 function [SubRange,NbSites,IndSelSubDomain] =set_subdomains(Coord,SubDomainNbPoint)
     15function [SubRange,NbCentre,IndSelSubDomain] =set_subdomains(Coord,SubDomainNbPoint)
    1616
    1717%% adjust subdomain decomposition
     
    3636%% default output
    3737SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the positions of subdomains
    38 NbSites=zeros(NbSubDomain);%number of interpolated values per subdomain, =0 by default
     38NbCentre=zeros(1,NbSubDomain);%number of interpolated values per subdomain, =0 by default
    3939%Coord_tps=zeros(NbVec,NbCoord,NbSubDomain);% default positions of the tps source= initial positions of the good vectors sorted by subdomain
    4040check_empty=zeros(1,NbSubDomain);
     
    6161        end
    6262    end
    63     NbSites(isub)=numel(IndSel);
    64     IndSelSubDomain(:,isub)=IndSel;
     63    NbCentre(isub)=numel(IndSel);
     64    IndSelSubDomain(1:numel(IndSel),isub)=IndSel;
    6565end
    6666
     
    7070if ~isempty(ind_empty)
    7171    SubRange(:,:,ind_empty)=[];
    72     NbSites(ind_empty)=[];
     72    NbCentre(ind_empty)=[];
    7373    IndSelSubDomain(:,ind_empty)=[];
    7474end
  • trunk/src/tps_coeff_field.m

    r586 r651  
    1 %'tps_coeff_field': calculate the thin plate spline (tps) coefficients with subdomains for a field structure
     1%'tps_coeff_field': calculate the thin plate spline (tps) coefficients within subdomains for a field structure
    22%---------------------------------------------------------------------
    33% DataOut=tps_coeff_field(DataIn,checkall)
    44%
    55% OUTPUT:
    6 % DataOut: output field structure
     6% DataOut: output field structure, reproducing the input field structure DataIn and adding the fields:
     7%         .Coord_tps
     8%         .[VarName '_tps'] for each eligible input variable VarName (scalar ofr vector components)
     9% errormsg: error message, = '' by default
    710%
    811% INPUT:
     
    7275            end
    7376            ListNewVar=cell(1,numel(VarIndexInterp)+3);
    74             ListNewVar(1:3)={['SubRange' term],['NbCentres' term],['Coord_tps' term]};
     77            ListNewVar(1:3)={['SubRange' term],['NbCentre' term],['Coord_tps' term]};
    7578            for ilist=1:numel(VarIndexInterp)
    7679                ListNewVar{ilist+3}=[ListVarInterp{ilist} '_tps' term];
     
    8285                {{['nb_tps' term],'nb_coord',['nb_subdomain' term]}}];
    8386            DataOut.VarAttribute{nbvar+3}.Role='coord_tps';
    84             [SubRange,NbCentres,IndSelSubDomain] =set_subdomains([X Y],SubDomainNbPoint);% create subdomains for tps
     87            [SubRange,NbCentre,IndSelSubDomain] =set_subdomains([X Y],SubDomainNbPoint);% create subdomains for tps
    8588            for isub=1:size(SubRange,3)
    86                 ind_sel=IndSelSubDomain(1:NbCentres(isub),isub);% array indices selected for the subdomain
    87                 Coord_tps=[X(ind_sel) Y(ind_sel)];
    88                 fill=zeros(NbCoord+1,NbCoord,size(SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
    89                 Coord_tps=cat(1,Coord_tps,fill);
     89                ind_sel=IndSelSubDomain(1:NbCentre(isub),isub);% array indices selected for the subdomain
     90                DataOut.(['Coord_tps' term])(1:NbCentre(isub),1:2,isub)=[X(ind_sel) Y(ind_sel)];
     91                DataOut.(['Coord_tps' term])(NbCentre(isub)+1:NbCentre(isub)+3,1:2,isub)=0;%matrix of zeros to complement the matrix Coord_tps (conveninent for file storage)
     92                %fill=zeros(NbCoord+1,NbCoord,size(SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
     93%                 fill=zeros(NbCoord+1,NbCoord+1,NbCoord); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
     94%                 Coord_tps=cat(1,Coord_tps,fill);
    9095            end         
    9196            for ivar=1:numel(VarIndexInterp)
     
    106111            end
    107112            DataOut.(['SubRange' term])=SubRange;
    108             DataOut.(['NbCentres' term])=NbCentres;
    109             DataOut.(['Coord_tps' term])=Coord_tps;
     113            DataOut.(['NbCentre' term])=NbCentre;
     114%             DataOut.(['Coord_tps' term])=Coord_tps;
    110115            for ilist=1:numel(VarIndexInterp)
     116%                 Var_tps=zeros(size(IndSelSubDomain)+[NbCoord+1 0]);%default spline
    111117                for isub=1:size(SubRange,3)
    112                     Var_tps=zeros(size(IndSelSubDomain)+[NbCoord+1 0]);%default spline
    113                     [tild,Var_tps(:,isub)]=tps_coeff([X(ind_sel) Y(ind_sel)],DataIn.(ListVarInterp{ilist}),0);%calculate the tps coeff in the subdomain
     118                    ind_sel=IndSelSubDomain(1:NbCentre(isub),isub);% array indices selected for the subdomain
     119                    [tild,Var_tps(1:NbCentre(isub)+NbCoord+1,isub)]=tps_coeff([X(ind_sel) Y(ind_sel)],DataIn.(ListVarInterp{ilist})(ind_sel),0);%calculate the tps coeff in the subdomain
    114120                end
    115121                DataOut.(ListNewVar{ilist+3})=Var_tps;
  • trunk/src/uigetfile_uvmat.m

    r648 r651  
    1515%          'image': any image or movie
    1616%          '.ext': display only files with extension '.ext'
     17%          'uigetdir'; browser used to select a directory (like the matlab browser 'uigetdir')
    1718
    1819function fileinput=uigetfile_uvmat(title,InputName,FilterExt)
     
    5253    Width=350;% fig width in points (1/72 inch)
    5354    Height=min(0.8*ScreenSize(4),500);
    54     Left=ScreenSize(3)- Width-40; %right edge close to the right, with margin=40 
     55    Left=ScreenSize(3)- Width-40; %right edge close to the right, with margin=40
    5556    Bottom=ScreenSize(4)-Height-40; %put fig at top right
    5657    hfig=figure('name',option,'tag',option,'MenuBar','none','NumberTitle','off','Unit','points','Position',[Left,Bottom,Width,Height],'UserData',InputDir);
    5758    BackgroundColor=get(hfig,'Color');
    58     uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.97 0.5 0.03],'BackgroundColor',BackgroundColor,...
    59             'String','path:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left');
    60     uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.89 0.9 0.08],'tag','titlebox','Max',2,'BackgroundColor',[1 1 1],'Callback',@titlebox_Callback,...
    61         'String',InputDir,'FontUnits','points','FontSize',12,'FontWeight','bold');
    62     uicontrol('Style','pushbutton','Tag','backward','Units','normalized','Position',[0.05 0.75 0.1 0.07],...
    63             'String','<--','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@backward);
    64     uicontrol('Style','togglebutton','Units','normalized', 'Position', [0.75 0.75 0.2 0.04],'tag','check_date','Callback',@dates_Callback,...
    65             'String','dates','FontUnits','points','FontSize',12,'FontWeight','bold');
    66     uicontrol('Style','text','Units','normalized', 'Position', [0.4 0.8 0.35 0.03],'BackgroundColor',BackgroundColor,...
    67             'String','sort: ','FontUnits','points','FontSize',12,'FontWeight','bold','HorizontalAlignment','right');
    68     uicontrol('Style','popupmenu','Units','normalized', 'Position', [0.75 0.8 0.2 0.04],'tag','sort_option','Callback',@refresh_GUI,'Visible','off',...
    69             'String',{'name';'date'},'FontUnits','points','FontSize',12,'FontWeight','bold');   
    70     uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.08 0.9 0.66], 'Callback', @(src,event)list_Callback(option,FilterExt,src,event),'tag','list',...
    71         'FontUnits','points','FontSize',12);
    72     uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.005 0.2 0.07],'Callback',@(src,event)close(option,src,event),...
     59    path_title=uicontrol('Style','text','Units','normalized', 'Position', [0.02 0.97 0.9 0.03],'BackgroundColor',BackgroundColor,'Tag','Path_title',...
     60        'String','path:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left');
     61    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,...
     62        'String',InputDir,'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''titlebox'':current path');
     63    uicontrol('Style','pushbutton','Tag','backward','Units','normalized','Position',[0.02 0.77 0.1 0.05],...
     64        'String','<--','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@backward,'TooltipString','move backward');
     65    home_button=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.35 0.005 0.3 0.07],...
     66        'String','Work dir','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@home_dir,'TooltipString','reach the current Matlab working directory');
     67   
     68    uicontrol('Style','popupmenu','Units','normalized', 'Position', [0.75 0.75 0.23 0.04],'tag','sort_option','Callback',@refresh_GUI,'Visible','off',...
     69        'String',{'sort name';'sort date'},'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''sort_option'': sort the files by names or dates');
     70    uicontrol('Style','listbox','Units','normalized', 'Position',[0.02 0.08 0.96 0.66], 'Callback', @(src,event)list_Callback(option,FilterExt,src,event),'tag','list',...
     71        'FontUnits','points','FontSize',12,'TooltipString','''list'':current list of directories, marked by +/, and files');
     72    uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.78 0.005 0.2 0.07],'Callback',@(src,event)close(option,src,event),...
    7373        'String','Close','FontWeight','bold','FontUnits','points','FontSize',12);
    74     uicontrol('Style','pushbutton','Tag','refresh','Units','normalized','Position', [0.1 0.005 0.2 0.07],'Callback',@refresh_GUI,...
     74    uicontrol('Style','pushbutton','Tag','refresh','Units','normalized','Position', [0.02 0.005 0.2 0.07],'Callback',@refresh_GUI,...
    7575        'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',12);
     76    OK_button=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.75 0.81 0.23 0.07],'BackgroundColor',[0 1 0],...
     77        'String','OK','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@(src,event)OK_Callback(option,FilterExt,src,event));
    7678    %set(hrefresh,'UserData',StatusData)
    7779    if strcmp(option,'status_display') %put a run advancement display
    7880        set(hfig,'DeleteFcn',@(src,event)close(option,src,event))
    79               uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.85 0.9 0.04]);
    80         uicontrol('Style','frame','Units','normalized', 'Position',[0.05 0.85 0.01 0.04],'BackgroundColor',[1 0 0],'tag','waitbar');
    81 
     81        uicontrol('Style','frame','Units','normalized', 'Position', [0.02 0.85 0.9 0.04]);
     82        uicontrol('Style','frame','Units','normalized', 'Position',[0.02 0.85 0.01 0.04],'BackgroundColor',[1 0 0],'tag','waitbar');
     83        %             uicontrol('Style','text','Units','normalized', 'Position', [0.4 0.8 0.35 0.03],'BackgroundColor',BackgroundColor,...
     84        %             'String','sort: ','FontUnits','points','FontSize',12,'FontWeight','bold','HorizontalAlignment','right');
     85        delete(home_button)
     86        set(OK_button,'String','OPEN')
     87    elseif strcmp(FilterExt,'uigetdir') %pick a  directory
     88        set(path_title,'String',title); %show the input title for path (directory)
    8289    else  %put a title and additional pushbuttons
    83         uicontrol('Style','text','Units','normalized', 'Position', [0.15 0.75 0.6 0.03],'BackgroundColor',BackgroundColor,...
     90        uicontrol('Style','text','Units','normalized', 'Position', [0.02 0.74 0.6 0.03],'BackgroundColor',BackgroundColor,...
    8491            'String',title,'FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left');
    85 
    86         uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.4 0.005 0.2 0.07],...
    87             'String','Home','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@home_dir);
     92        uicontrol('Style','togglebutton','Units','normalized', 'Position', [0.75 0.78 0.23 0.04],'tag','check_date','Callback',@dates_Callback,...
     93            'String','show dates','FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''check_date'':press button to display dates');
     94%         uicontrol('Style','text','Units','normalized', 'Position', [0.37 0.8 0.35 0.03],'BackgroundColor',BackgroundColor,...
     95%             'String','sort: ','FontUnits','points','FontSize',12,'FontWeight','bold','HorizontalAlignment','right');
     96       
    8897    end
    8998    drawnow
    9099end
    91 refresh_GUI(findobj(hfig,'Tag','refresh'),InputFileName,FilterExt)% refresh the list of content of the current dir 
    92 if ~strcmp(option,'status_display') 
     100refresh_GUI(findobj(hfig,'Tag','refresh'),InputFileName,FilterExt)% refresh the list of content of the current dir
     101if ~strcmp(option,'status_display')
    93102    uiwait(hfig)
    94103    if ishandle(hfig)
    95     htitlebox=findobj(hfig,'Tag','titlebox');
    96     fileinput=get(htitlebox,'String');% retrieve the input file selection
    97     delete(hfig)
     104        htitlebox=findobj(hfig,'Tag','titlebox');
     105        fileinput=get(htitlebox,'String');% retrieve the input file selection
     106        delete(hfig)
    98107    end
    99108end
     
    101110%------------------------------------------------------------------------   
    102111% --- launched by refreshing the display figure
     112%------------------------------------------------------------------------
    103113function titlebox_Callback(hObject,event)
    104114refresh_GUI(hObject)
    105 %------------------------------------------------------------------------
     115
     116%------------------------------------------------------------------------   
     117% --- launched by selecting OK (relevant for FilterExt='uigetdir')
     118%------------------------------------------------------------------------
     119function OK_Callback(option,filter_ext,hObject,event)
     120hfig=get(hObject,'parent');%handle of the fig
     121% if ~strcmp(get(hfig,'SelectionType'),'open')
     122%     return %select double click
     123% end
     124%set(hObject,'BackgroundColor',[1 1 0])% paint list in yellow to indicate action
     125%     drawnow
     126htitlebox=findobj(hfig,'tag','titlebox');  % display the current dir name 
     127DirName=get(htitlebox,'String');
     128
     129if ~strcmp(filter_ext,'uigetdir')% a file is expected as output, not a dir
     130    hlist=findobj(hfig,'Tag','list');
     131    list=get(hlist,'String');
     132    index=get(hlist,'Value');
     133    SelectName=regexprep(list{index},'^\+/','');% remove the +/ used to mark dir
     134    ind_dot=regexp(SelectName,'\s*\.\.\.');%remove what is beyond  '...'
     135    if ~isempty(ind_dot)
     136        SelectName=SelectName(1:ind_dot-1);
     137    end
     138    % if strcmp(SelectName,'..')% the upward dir option has been selected
     139    %     FullSelectName=fileparts(DirName);
     140    % else
     141    FullSelectName=fullfile(DirName,SelectName);
     142    % end
     143    if exist(FullSelectName,'file')
     144        switch option
     145            case 'browser'
     146                set(htitlebox,'String',FullSelectName);
     147                uiresume(hfig)
     148            case 'status_display'
     149                FileType=get_file_type(FullSelectName);
     150                if strcmp(FileType,'txt')
     151                    edit(FullSelectName)
     152                elseif strcmp(FileType,'xml')
     153                    editxml(FullSelectName)
     154                elseif strcmp(FileType,'figure')
     155                    open(FullSelectName)
     156                else
     157                    uvmat(FullSelectName);
     158                end
     159        end
     160    end
     161end
     162%set(hObject,'BackgroundColor',[0.7 0.7 0.7])% paint list in grey to indicate action end
     163
     164uiresume(get(hObject,'parent'))
    106165
    107166%------------------------------------------------------------------------   
     
    113172end
    114173if ~exist('FilterExt','var')
     174    FilterExt='*';
     175end
     176if strcmp(FilterExt,'uigetdir')
    115177    FilterExt='*';
    116178end
     
    165227set(hlist,'Value',Value)
    166228set(hlist,'BackgroundColor',[0.7 0.7 0.7])
     229
    167230%------------------------------------------------------------------------   
    168231% --- launched by selecting an item on the file list
     232%------------------------------------------------------------------------
    169233function dates_Callback(hObject,event)
    170 %------------------------------------------------------------------------
     234
    171235hfig=get(hObject,'parent');
    172236hsort_option=findobj(hfig,'tag','sort_option');
     
    178242end
    179243refresh_GUI(hObject,[])
     244
    180245
    181246%------------------------------------------------------------------------   
     
    205270end
    206271if exist(FullSelectName,'dir')% a directory has been selected
    207     %     ListFiles=dir(FullSelectName);
    208     %     ListDisplay=cell(numel(ListFiles),1);
    209     %     for ilist=2:numel(ListDisplay)% suppress the first line '.'
    210     %         ListDisplay{ilist-1}=ListFiles(ilist).name;
    211     %     end
    212     %     set(hObject,'Value',1)
    213     %     set(hObject,'String',ListDisplay)
    214     %     if strcmp(selectname,'..')
    215     %         FullSelectName=fileparts(fileparts(FullSelectName));
    216     %     end
    217272    set(hObject,'BackgroundColor',[1 1 0])% paint list in yellow to indicate action
    218273    drawnow
     
    231286    set(hObject,'BackgroundColor',[0.7 0.7 0.7])
    232287    set(htitlebox,'String',FullSelectName)% record the new dir name
    233 elseif exist(FullSelectName,'file')%visualise the field if it exists 
    234     switch option
    235         case 'browser'
    236             set(htitlebox,'String',FullSelectName);
    237             uiresume(hfig)
    238         case 'status_display'
    239             FileType=get_file_type(FullSelectName);
    240             if strcmp(FileType,'txt')
    241                 edit(FullSelectName)
    242             elseif strcmp(FileType,'xml')
    243                 editxml(FullSelectName)
    244             elseif strcmp(FileType,'figure')
    245                 open(FullSelectName)
    246             else
    247                 uvmat(FullSelectName);
    248             end
    249     end
    250288end
    251289set(hObject,'BackgroundColor',[0.7 0.7 0.7])% paint list in grey to indicate action end
     
    265303check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
    266304ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
    267 if exist('filter_ext','var') && ~strcmp(filter_ext,'*')
     305if exist('filter_ext','var') && ~strcmp(filter_ext,'*') &&~strcmp(filter_ext,'uigetdir')
    268306    if strcmp(filter_ext,'image')
    269307        check_keep=cellfun(@isimage,ListFiles) ;
     
    277315    check_dir=check_dir(check_keep);
    278316end
     317check_emptydate=cellfun('isempty',ListCells(5,:));% = 1 if datenum undefined
     318ListCells(5,find(check_emptydate))={0}; %set to 0 the empty dates
    279319ListDates=cell2mat(ListCells(5,:));%list of numerical dates
    280320if isnumeric(sort_option)
  • trunk/src/uvmat.m

    r650 r651  
    4949%
    5050%
    51 % 1) Input filenames are determined by MenuBrowse (first field), MenuBrowse_1
     51% 1) Input filenames are determined by MenuBrowse (first field), MenuBrowseCampaign
    5252% (second field), or by the stored file name .FileName_1, or as an input of uvmat.
    5353% 2) These functions call 'uvmat/display_file_name.m' which detects the file series, and fills the file index boxes
     
    229229 dir_perso=prefdir; % path to the directory .matlab containing the personal data of the current user
    230230 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmat_perso.mat' in .matlab
    231  if exist(profil_perso,'file')
    232      h=load (profil_perso);
    233      if isfield(h,'MenuFile')% load the menu of previously opened files
     231 if exist(profil_perso,'file')% if the file exists
     232     h=load (profil_perso); % open the personal file
     233     if isfield(h,'MenuFile')% load the saved menu of previously opened files
    234234         for ifile=1:min(length(h.MenuFile),5)
    235235             set(handles.(['MenuFile_' num2str(ifile)]),'Label',h.MenuFile{ifile});
    236              set(handles.(['MenuFile_' num2str(ifile) '_1']),'Label',h.MenuFile{ifile});
     236         end
     237     end
     238     if isfield(h,'MenuCampaign')% load the saved menu of previously opened campaigns
     239         for ifile=1:min(length(h.MenuCampaign),5)
     240             set(handles.(['MenuCampaign_' num2str(ifile)]),'Label',h.MenuCampaign{ifile});
    237241         end
    238242     end
     
    434438    oldfile=get(handles.RootPath,'UserData');
    435439end
    436 fileinput=uigetfile_uvmat('select an input file:',oldfile);
     440fileinput=uigetfile_uvmat('pick an input file',oldfile);
    437441
    438442%% display the selected field and related information
     
    442446
    443447% -----------------------------------------------------------------------
     448% --- Open again the file whose name has been recorded in MenuFile_1
     449function MenuFile_Callback(hObject, eventdata, handles)
     450%------------------------------------------------------------------------
     451fileinput=get(hObject,'Label');
     452display_file_name( handles,fileinput)
     453%
     454% % -----------------------------------------------------------------------
     455% % --- Open again the file whose name has been recorded in MenuFile_2
     456% function MenuFile_2_Callback(hObject, eventdata, handles)
     457% %------------------------------------------------------------------------
     458% fileinput=get(handles.MenuFile_2,'Label');
     459% display_file_name(handles,fileinput)
     460%
     461% % -----------------------------------------------------------------------
     462% % --- Open again the file whose name has been recorded in MenuFile_3
     463% function MenuFile_3_Callback(hObject, eventdata, handles)
     464% %------------------------------------------------------------------------
     465% fileinput=get(handles.MenuFile_3,'Label');
     466% display_file_name(handles,fileinput)
     467%
     468% % -----------------------------------------------------------------------
     469% % --- Open again the file whose name has been recorded in MenuFile_4
     470% function MenuFile_4_Callback(hObject, eventdata, handles)
     471% %------------------------------------------------------------------------
     472% fileinput=get(handles.MenuFile_4,'Label');
     473% display_file_name(handles,fileinput)
     474%
     475% % -----------------------------------------------------------------------
     476% % --- Open again the file whose name has been recorded in MenuFile_5
     477% function MenuFile_5_Callback(hObject, eventdata, handles)
     478% %------------------------------------------------------------------------
     479% fileinput=get(handles.MenuFile_5,'Label');
     480% display_file_name(handles,fileinput)
     481
     482
     483% -----------------------------------------------------------------------
    444484% --- Executes on the menu Open/Browse campaign...
    445 % search the file inside a campaign, using the GUI view_data
     485% --- search the file inside a campaign, using the GUI browse_data
     486% -----------------------------------------------------------------------
    446487function MenuBrowseCampaign_Callback(hObject, eventdata, handles)
    447 % -----------------------------------------------------------------------
     488set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0])
     489drawnow
    448490RootPath=get(handles.RootPath,'String');
    449491if isempty(RootPath)
     
    451493end
    452494CampaignPath=fileparts(fileparts(RootPath));
    453 DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK');
    454 if ~ischar(DirFull)|| ~exist(DirFull,'dir')
     495DirFull=uigetfile_uvmat('define this path as the Campaign folder:',CampaignPath,'uigetdir');
     496%DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK');
     497if isempty(DirFull)
    455498    return
    456499end
     
    459502    return
    460503end
    461 DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.Device{1});
     504DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
     505ListStruct=dir(DirName); %list files and the dir DataSeries
     506% select the first appropriate file in the dir
     507FileName='';
     508for ilist=1:numel(ListStruct)
     509    if ~isequal(ListStruct(ilist).isdir,1)%look for files, not dir
     510        FileName=ListStruct(ilist).name;
     511        FileType=get_file_type(fullfile(DirName,FileName));
     512        switch FileType
     513            case {'image','multimage','civx','civdata','netcdf'}
     514                break
     515        end
     516    end
     517end
     518if isempty(FileName)
     519    msgbox_uvmat('ERROR',['no appropriate input file in the DataSeries folder ' fullfile(DirName)])
     520    return
     521end
     522
     523%% update the list of campaigns in the menubar
     524MenuCampaign=[{get(handles.MenuCampaign_1,'Label')};{get(handles.MenuCampaign_2,'Label')};...
     525    {get(handles.MenuCampaign_3,'Label')};{get(handles.MenuCampaign_4,'Label')};{get(handles.MenuCampaign_5,'Label')}];
     526check_dir=isempty(find(strcmp(DirFull,MenuCampaign)));
     527if check_dir %insert the new campaign in the list if it is not found
     528    MenuCampaign(end)=[]; %suppress the last item
     529    MenuCampaign=[{DirFull};MenuCampaign];%insert the new campaign
     530    for ilist=1:numel(MenuCampaign)
     531        set(handles.(['MenuCampaign_' num2str(ilist)]),'Label',MenuCampaign{ilist})
     532    end
     533    % save the list for future opening:
     534    dir_perso=prefdir;
     535    profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     536    if exist(profil_perso,'file')
     537        save (profil_perso,'MenuCampaign','RootPath','-append'); %store the file names for future opening of uvmat
     538    else
     539        save (profil_perso,'MenuCampaign','RootPath','-V6'); %store the file names for future opening of uvmat
     540    end
     541end
     542
     543%% display the selected field and related information
     544display_file_name( handles,fullfile(DirName,FileName))
     545
     546set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
     547
     548% -----------------------------------------------------------------------
     549% --- Open again as second field the file whose name has been recorded in MenuFile_1
     550% -----------------------------------------------------------------------
     551function MenuCampaign_Callback(hObject, eventdata, handles)
     552
     553set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0])
     554OutPut=browse_data(get(hObject,'Label'));% open the GUI browse_data to get select a campaign dir, experiment and device
     555if ~isfield(OutPut,'Campaign')
     556    return
     557end
     558DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
    462559hdir=dir(DirName); %list files and dirs
    463560for ilist=1:numel(hdir)
     
    471568    end
    472569end
    473 
    474 %% display the selected field and related information
    475 display_file_name( handles,fullfile(DirName,FileName))
    476 
    477 % -----------------------------------------------------------------------
    478 % --- Open again the file whose name has been recorded in MenuFile_1
    479 function MenuFile_1_Callback(hObject, eventdata, handles)
    480 %------------------------------------------------------------------------
    481 fileinput=get(handles.MenuFile_1,'Label');
    482 display_file_name( handles,fileinput)
    483 
    484 % -----------------------------------------------------------------------
    485 % --- Open again the file whose name has been recorded in MenuFile_2
    486 function MenuFile_2_Callback(hObject, eventdata, handles)
    487 %------------------------------------------------------------------------
    488 fileinput=get(handles.MenuFile_2,'Label');
    489 display_file_name(handles,fileinput)
    490 
    491 % -----------------------------------------------------------------------
    492 % --- Open again the file whose name has been recorded in MenuFile_3
    493 function MenuFile_3_Callback(hObject, eventdata, handles)
    494 %------------------------------------------------------------------------
    495 fileinput=get(handles.MenuFile_3,'Label');
    496 display_file_name(handles,fileinput)
    497 
    498 % -----------------------------------------------------------------------
    499 % --- Open again the file whose name has been recorded in MenuFile_4
    500 function MenuFile_4_Callback(hObject, eventdata, handles)
    501 %------------------------------------------------------------------------
    502 fileinput=get(handles.MenuFile_4,'Label');
    503 display_file_name(handles,fileinput)
    504 
    505 % -----------------------------------------------------------------------
    506 % --- Open again the file whose name has been recorded in MenuFile_5
    507 function MenuFile_5_Callback(hObject, eventdata, handles)
    508 %------------------------------------------------------------------------
    509 fileinput=get(handles.MenuFile_5,'Label');
    510 display_file_name(handles,fileinput)
    511 
    512 %------------------------------------------------------------------------
    513 % --- Executes on the menu Open/Browse_1 for the second input field,
    514 %     search the files, recognize their type according to their name and fill the rootfile input windows
    515 function MenuBrowse_1_Callback(hObject, eventdata, handles)
    516 %------------------------------------------------------------------------
    517 RootPath=get(handles.RootPath,'String');
    518 SubDir=get(handles.SubDir,'String');
    519 fileinput_1=uigetfile_uvmat('select a second input file:',fullfile(RootPath,SubDir));
    520 
    521 if ~isempty(fileinput_1)
    522    
    523     % refresh the current displayed field
    524     set(handles.SubField,'Value',1)
    525     display_file_name(handles,fileinput_1,2)
    526    
    527     %update list of recent files in the menubar
    528     MenuFile_1=fileinput_1;
    529     MenuFile_2=get(handles.MenuFile_1,'Label');
    530     MenuFile_3=get(handles.MenuFile_2,'Label');
    531     MenuFile_4=get(handles.MenuFile_3,'Label');
    532     MenuFile_5=get(handles.MenuFile_4,'Label');
    533     set(handles.MenuFile_1,'Label',MenuFile_1)
    534     set(handles.MenuFile_2,'Label',MenuFile_2)
    535     set(handles.MenuFile_3,'Label',MenuFile_3)
    536     set(handles.MenuFile_4,'Label',MenuFile_4)
    537     set(handles.MenuFile_5,'Label',MenuFile_5)
    538     set(handles.MenuFile_1_1,'Label',MenuFile_1)
    539     set(handles.MenuFile_2_1,'Label',MenuFile_2)
    540     set(handles.MenuFile_3_1,'Label',MenuFile_3)
    541     set(handles.MenuFile_4_1,'Label',MenuFile_4)
    542     set(handles.MenuFile_5_1,'Label',MenuFile_5)
    543 end
    544 
    545 % --------------------------------------------------------------------
    546 function MenuBrowseCampaign_1_Callback(hObject, eventdata, handles)
    547 % -----------------------------------------------------------------------
    548 CampaignPath=fileparts(fileparts(get(handles.RootPath,'String')));
    549 DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK');
    550 if ~ischar(DirFull)|| ~exist(DirFull,'dir')
    551     return
    552 end
    553 OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device
    554 if ~isfield(OutPut,'Campaign')
    555     return
    556 end
    557 DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.Device{1});
    558 hdir=dir(DirName); %list files and dirs
    559 for ilist=1:numel(hdir)
    560     if ~isequal(hdir(ilist).isdir,1)%look for files, not dir
    561         FileName=hdir(ilist).name;
    562         FileType=get_file_type(fullfile(DirName,FileName));
    563         switch FileType
    564             case {'image','multimage','civx','civdata','netcdf'}
    565             break
    566         end
    567     end
    568 end
    569 
    570 %% display the selected field and related information
    571 set(handles.SubField,'Value',1)
    572 display_file_name( handles,fullfile(DirName,FileName),2)
    573 
    574 % -----------------------------------------------------------------------
    575 % --- Open again as second field the file whose name has been recorded in MenuFile_1
    576 function MenuFile_1_1_Callback(hObject, eventdata, handles)
    577 % -----------------------------------------------------------------------
    578 fileinput_1=get(handles.MenuFile_1_1,'Label');
    579 set(handles.SubField,'Value',1)
    580 display_file_name(handles,fileinput_1,2)
    581 
    582 % -----------------------------------------------------------------------
    583 % --- Open again as second field the file whose name has been recorded in MenuFile_2
    584 function MenuFile_2_1_Callback(hObject, eventdata, handles)
    585 % -----------------------------------------------------------------------
    586 fileinput_1=get(handles.MenuFile_2_1,'Label');
    587 set(handles.SubField,'Value',1)
    588 display_file_name(handles,fileinput_1,2)
    589 
    590 % -----------------------------------------------------------------------
    591 % --- Open again as second field the file whose name has been recorded in MenuFile_3
    592 function MenuFile_3_1_Callback(hObject, eventdata, handles)
    593 % -----------------------------------------------------------------------
    594 fileinput_1=get(handles.MenuFile_3_1,'Label');
    595 set(handles.SubField,'Value',1)
    596 display_file_name(handles,fileinput_1,2)
    597 
    598 % -----------------------------------------------------------------------
    599 % --- Open again as second field the file whose name has been recorded in MenuFile_4
    600 function MenuFile_4_1_Callback(hObject, eventdata, handles)
    601 % -----------------------------------------------------------------------
    602 fileinput_1=get(handles.MenuFile_4_1,'Label');
    603 set(handles.SubField,'Value',1)
    604 display_file_name(handles,fileinput_1,2)
    605 
    606 % -----------------------------------------------------------------------
    607 % --- Open again as second field the file whose name has been recorded in MenuFile_5
    608 function MenuFile_5_1_Callback(hObject, eventdata, handles)
    609 % -----------------------------------------------------------------------
    610 fileinput_1=get(handles.MenuFile_5_1,'Label');
    611 set(handles.SubField,'Value',1)
    612 display_file_name(handles,fileinput_1,2)
     570display_file_name(handles,fullfile(DirName,FileName))
     571set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
    613572
    614573%------------------------------------------------------------------------
     
    855814       
    856815        %enable other menus
    857         set(handles.MenuOpen_1,'Enable','on')
    858         set(handles.MenuFile_1_1,'Enable','on')
    859         set(handles.MenuFile_2_1,'Enable','on')
    860         set(handles.MenuFile_3_1,'Enable','on')
    861         set(handles.MenuFile_4_1,'Enable','on')
    862         set(handles.MenuFile_5_1,'Enable','on')
     816        set(handles.MenuOpenCampaign,'Enable','on')
     817%         set(handles.MenuCampaign_1,'Enable','on')
     818%         set(handles.MenuCampaign_2,'Enable','on')
     819%         set(handles.MenuCampaign_3,'Enable','on')
     820%         set(handles.MenuCampaign_4,'Enable','on')
     821%         set(handles.MenuCampaign_5,'Enable','on')
    863822        set(handles.MenuExport,'Enable','on')
    864823        set(handles.MenuExportFigure,'Enable','on')
     
    880839for ifile=1:min(length(MenuFile),5)
    881840    set(handles.(['MenuFile_' num2str(ifile)]),'Label',MenuFile{ifile});
    882     set(handles.(['MenuFile_' num2str(ifile) '_1']),'Label',MenuFile{ifile});
     841    %set(handles.(['MenuFile_' num2str(ifile) '_1']),'Label',MenuFile{ifile});
    883842end
    884843dir_perso=prefdir;
     
    25702529    end
    25712530    UvData.Field.CoordMesh=min(Mesh);
    2572     UvData.Field.XMax=max(CoordMax(ind,end));
    2573     UvData.Field.XMin=min(CoordMin(ind,end));
    2574     UvData.Field.YMax=max(CoordMax(ind,end-1));
    2575     UvData.Field.YMin=max(CoordMin(ind,end-1));
     2531    UvData.Field.XMax=max(CoordMax(:,end));
     2532    UvData.Field.XMin=min(CoordMin(:,end));
     2533    UvData.Field.YMax=max(CoordMax(:,end-1));
     2534    UvData.Field.YMin=min(CoordMin(:,end-1));
    25762535    if NbDim==3
    25772536        UvData.Field.ZMax=max(CoordMax(ind,1));
     
    30733032    if strcmp(transform_fct,'sub_field')
    30743033        set(handles.TransformName,'Value',1)%suppress the sub_field transform
    3075         T
    3076        
    3077        
    3078         ransformName_Callback(hObject, eventdata, handles);
     3034        TransformName_Callback(hObject, eventdata, handles);
    30793035    else
    30803036        run0_Callback(hObject, eventdata, handles)
    30813037    end 
    30823038else
    3083     MenuBrowse_1_Callback(hObject, eventdata, handles)
     3039    %RootPath=get(handles.RootPath,'String');
     3040    %SubDir=get(handles.SubDir,'String');
     3041    fileinput_1=uigetfile_uvmat('select a second input file:',get(handles.RootPath,'String'));
     3042    if isempty(fileinput_1)
     3043        set(handles.SubField,'Value',0)
     3044    else
     3045       
     3046        % refresh the current displayed field
     3047        set(handles.SubField,'Value',1)
     3048        display_file_name(handles,fileinput_1,2)
     3049       
     3050        %update list of recent files in the menubar
     3051        MenuFile_1=fileinput_1;
     3052        MenuFile_2=get(handles.MenuFile_1,'Label');
     3053        MenuFile_3=get(handles.MenuFile_2,'Label');
     3054        MenuFile_4=get(handles.MenuFile_3,'Label');
     3055        MenuFile_5=get(handles.MenuFile_4,'Label');
     3056        set(handles.MenuFile_1,'Label',MenuFile_1)
     3057        set(handles.MenuFile_2,'Label',MenuFile_2)
     3058        set(handles.MenuFile_3,'Label',MenuFile_3)
     3059        set(handles.MenuFile_4,'Label',MenuFile_4)
     3060        set(handles.MenuFile_5,'Label',MenuFile_5)
     3061    end
     3062    %     MenuBrowse_1_Callback(hObject, eventdata, handles)
    30843063end
    30853064
     
    32443223        % display the selected field and related information
    32453224        display_file_name(handles,imagename)%display the image
    3246 %     otherwise
     3225     otherwise
    32473226%         ext=get(handles.FileExt,'String');
    32483227%         if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
     
    32543233%             if ~ischar(FileName),return,end %abandon if the browser is cancelled
    32553234%             FullFileName=[PathName FileName];
    3256 %             % display the selected field and related information
    3257 %             display_file_name( handles,FullFileName)
    3258 %             return
    3259 %         end
    3260 end
    3261 % indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
    3262 % set(handles.FileIndex,'String',indices)
    3263 %
    3264 % %common to Fields_1_Callback
    3265 % list_fields_1=get(handles.FieldName_1,'String');% list menu fields
    3266 % field_1='';
    3267 % if ~isempty(list_fields_1)
    3268 %     field_1= list_fields_1{get(handles.FieldName_1,'Value')}; % selected string
    3269 % end
    3270 % if isequal(field,'image')||isequal(field_1,'image')
    3271 %     set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons
    3272 %     set(handles.num_Npx,'Visible','on')
    3273 %     set(handles.num_Npy,'Visible','on')
    3274 % else
    3275 %     set(handles.TitleNpxy,'Visible','off')% visible npx,pxcm... buttons
    3276 %     set(handles.num_Npx,'Visible','off')
    3277 %     set(handles.num_Npy,'Visible','off')
    3278 % end
    3279 % if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
    3280 %     run0_Callback(hObject, eventdata, handles)
    3281 % end
     3235            % display the selected field and related information
     3236             run0_Callback(hObject, eventdata, handles)
     3237end
    32823238
    32833239%----------------------------------------------------------------
     
    52405196function MenuSeries_Callback(hObject, eventdata, handles)
    52415197%------------------------------------------------------------------------
     5198Param=read_param(handles);
     5199series(Param); %run the series interface
     5200
     5201% --------------------------------------------------------------------
     5202function MenuPIV_Callback(hObject, eventdata, handles)
     5203    Param=read_param(handles);
     5204    Param.ActionName='civ_series';
     5205series(Param)
     5206
     5207%------------------------------------------------------------------------
     5208% -- open the GUI civ.fig for PIV
     5209function MenuCIVx_Callback(hObject, eventdata, handles)
     5210%------------------------------------------------------------------------
     5211 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
     5212 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
     5213civ(FileName);% interface de civ(not in the uvmat file)
     5214
     5215function Param=read_param(handles)
     5216   
    52425217[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    52435218Param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%first input file name
     
    52825257Param.Coord_x_str=get(handles.Coord_x,'String');
    52835258Param.Coord_x_val=get(handles.Coord_x,'Value');
    5284 %Param.Coord_y_str=get(handles.Coord_y,'String');
    52855259Param.Coord_y_str=get(handles.Coord_y,'Data');
    5286 %Param.Coord_y_val=get(handles.Coord_y,'Value');
    5287 series(Param); %run the series interface
    5288 
    5289 %------------------------------------------------------------------------
    5290 % -- open the GUI civ.fig for PIV
    5291 function MenuCIVx_Callback(hObject, eventdata, handles)
    5292 %------------------------------------------------------------------------
    5293  [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    5294  FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
    5295 civ(FileName);% interface de civ(not in the uvmat file)
    5296 
    5297 
    5298 % --------------------------------------------------------------------
    5299 function MenuPIV_Callback(hObject, eventdata, handles)
    5300 MenuSeries_Callback(hObject, eventdata, handles)
    5301 
    53025260
    53035261% --------------------------------------------------------------------
     
    54355393    end
    54365394end
    5437 
    5438 
Note: See TracChangeset for help on using the changeset viewer.