Changeset 606


Ignore:
Timestamp:
Apr 7, 2013, 10:14:45 AM (8 years ago)
Author:
sommeria
Message:

bug on compilation solved (still to test with transform_field fct). faster browser inrtroduced. Various bug corrections

Location:
trunk/src
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/check_files.m

    r598 r606  
    193193for ilist=1:numel(list_compile)
    194194    mfile=regexprep(list_compile(ilist).name,'.sh$','.m');
    195     datfile=dir(mfile);
    196     if isfield(datfile,'datenum') && datfile.datenum>list_compile(ilist).datenum
    197         checkmsg=[checkmsg;{[list_compile(ilist).name ' needs to be updated by compile_functions']}];
    198     end
    199 end
    200 
     195    if exist(mfile,'file')
     196        datfile=dir(mfile);
     197        if ~isempty(datfile) && isfield(datfile,'datenum') && datfile.datenum>list_compile(ilist).datenum
     198            checkmsg=[checkmsg;{[list_compile(ilist).name ' needs to be updated by compile_functions']}];
     199        end
     200    end
     201end
     202cd(currentdir)
     203
  • trunk/src/compile.m

    r593 r606  
    66%FctName: name of the Matlab fct to compile (without .m extension)
    77%
    8 function compile (FctName)
     8function compile (FctName,SubfctPath)
    99if isempty(which('mcc'))
    1010    msgbox_uvmat('no Matlab compiler toolbox mcc installed')
    1111    return
    1212end
    13 display(['compiling ' FctName ' ...'])
     13disp(['compiling ' FctName ' ...'])
    1414% commands to compile civ_matlab and eventually other functions
    1515if ~exist('bin','dir')
     
    1919    end
    2020end
    21 eval(['mcc -m -R -nojvm -R -nodisplay ' FctName '.m']);
    22 system(['mv -f ' FctName ' bin/']);
    23 system(['sed -e ''''s#/' FctName '#/bin/' FctName '#'''' run_' FctName '.sh > ' FctName '.sh']);
    24 system(['rm run_' FctName '.sh']);
    25 system(['chmod +x ' FctName '.sh']);
     21if ~isempty(SubfctPath)
     22    SubfctPath=['-I ' SubfctPath];%string indicating the option of including the path SubfctPath
     23end
     24disp(['mcc -m -R -nojvm -R -nodisplay ' SubfctPath ' ' FctName '.m'])
     25eval(['mcc -m -R -nojvm -R -nodisplay ' SubfctPath ' ' FctName '.m'])% compile the source file [FctName .m], which produces a binary file FctName and a cmd file [run_' FctName '.sh]
     26%eval(['mcc -m -R -nojvm -R -nodisplay ' FctName '.m'])% compile the source file [FctName .m], which produces a binary file FctName and a cmd file [run_' FctName
     27system(['mv -f ' FctName ' bin/']);%move the binary file FctName to the subdir /bin
     28system(['sed -e ''''s#/' FctName '#/bin/' FctName '#'''' run_' FctName '.sh > ' FctName '.sh']);%modify the cmd file and copy it to [FctName '.sh']
     29system(['rm run_' FctName '.sh']);% remove the initial cmd file [run_' FctName '.sh]
     30system(['chmod +x ' FctName '.sh']); % set the cmd file to 'executable'
    2631display('** END **')
     32end
    2733
    2834
  • trunk/src/fill_GUI.m

    r603 r606  
    2828        if isfield(handles,fields{ifield})
    2929            set(handles.(fields{ifield}),'Visible','on')
    30 %             children=get(handles.(fields{ifield}),'children');
    31 %             for ichild=1:numel(children)
    32 %                 hchild.(get(children(ichild),'tag'))=children(ichild);
    33 %             end
    34          %   errormsg=fill_GUI(Param.(fields{ifield}),hchild);% apply the function to the substructure
    35          errormsg=fill_GUI(Param.(fields{ifield}),handles.(fields{ifield}));% apply the function to the substructure
    36            % if the input sub-structure fits with a tag name of the GUI and a
    37          % substructure of UserData
     30            %             children=get(handles.(fields{ifield}),'children');
     31            %             for ichild=1:numel(children)
     32            %                 hchild.(get(children(ichild),'tag'))=children(ichild);
     33            %             end
     34            %   errormsg=fill_GUI(Param.(fields{ifield}),hchild);% apply the function to the substructure
     35            errormsg=fill_GUI(Param.(fields{ifield}),handles.(fields{ifield}));% apply the function to the substructure
     36            % if the input sub-structure fits with a tag name of the GUI and a
     37            % substructure of UserData
    3838        elseif isfield(UserData,fields{ifield})&& isfield(handles,fields{ifield})&&isfield(Param.(fields{ifield}),'Name')
    3939            UserData.(fields{ifield})=Param.(fields{ifield});
    40             set(handles.(fields{ifield}),'String',Param.(fields{ifield}).Name) 
     40            set(handles.(fields{ifield}),'String',Param.(fields{ifield}).Name)
    4141        end
    42     % case of an element
     42        % case of an element
    4343    else
    4444        hh=[];
     
    5555                check_done=1;
    5656            end
    57         elseif isnumeric(input_data) 
    58             if numel(input_data)>1 
     57        elseif isnumeric(input_data)
     58            if numel(input_data)>1
    5959                %deals with array displayed in multiple boxes labeled by an index
    6060                for ibox=1:numel(input_data)
     
    6464                end
    6565            else % single box (usual case)
    66                if isfield(handles,['num_' fields{ifield}])
    67                    hh=handles.(['num_' fields{ifield}]);
    68                end
     66                if isfield(handles,['num_' fields{ifield}])
     67                    hh=handles.(['num_' fields{ifield}]);
     68                end
    6969            end
    7070        end
    7171        for ibox=1:numel(hh)
    72         if ~isempty(hh(ibox))&& ~check_done
    73             set(hh(ibox),'Visible','on')
    74 %             input_data
    75             switch get(hh(ibox),'Style')
    76                 case {'checkbox','radiobutton','togglebutton'}
    77                     if isnumeric(input_data)
    78                         set(hh(ibox),'Value',input_data(ibox))
     72            if ~isempty(hh(ibox))&& ~check_done
     73                set(hh(ibox),'Visible','on')
     74                %             input_data
     75                if isfield(hh(ibox),'Style')
     76                    switch get(hh(ibox),'Style')
     77                        case {'checkbox','radiobutton','togglebutton'}
     78                            if isnumeric(input_data)
     79                                set(hh(ibox),'Value',input_data(ibox))
     80                            end
     81                        case 'edit'
     82                            input_string='';
     83                            if isnumeric(input_data)
     84                                if numel(input_data)>0
     85                                    input_string=num2str(input_data(ibox));
     86                                end
     87                            else
     88                                input_string=input_data;
     89                            end
     90                            set(hh(ibox),'String',input_string)
     91                        case{'listbox','popupmenu'}
     92                            if isnumeric(input_data)
     93                                input_data=num2str(input_data);
     94                            end
     95                            menu=get(hh(ibox),'String');
     96                            if ischar(input_data)
     97                                input_data={input_data};
     98                            end
     99                            values=zeros(size(input_data));
     100                            for idata=1:numel(input_data)
     101                                iline=find(strcmp(input_data{idata},menu));
     102                                if isempty(iline)
     103                                    values(idata)=1;
     104                                    menu=[input_data(idata);menu];
     105                                else
     106                                    values(idata)=iline(1);
     107                                end
     108                            end
     109                            set(hh(ibox),'String',menu)
     110                            set(hh(ibox),'Value',values)
    79111                    end
    80                 case 'edit'
    81                     input_string='';
    82                     if isnumeric(input_data)
    83                         if numel(input_data)>0
    84                         input_string=num2str(input_data(ibox));
    85                         end
    86                     else
    87                         input_string=input_data;
    88                     end
    89                     set(hh(ibox),'String',input_string)
    90                 case{'listbox','popupmenu'}
    91                     if isnumeric(input_data)
    92                         input_data=num2str(input_data);
    93                     end
    94                     menu=get(hh(ibox),'String');
    95                     if ischar(input_data)
    96                         input_data={input_data};
    97                     end
    98                     values=zeros(size(input_data));
    99                     for idata=1:numel(input_data)
    100                         iline=find(strcmp(input_data{idata},menu));
    101                         if isempty(iline)
    102                             values(idata)=1;
    103                             menu=[input_data(idata);menu];
    104                         else
    105                             values(idata)=iline(1);
    106                         end
    107                     end
    108                     set(hh(ibox),'String',menu)
    109                     set(hh(ibox),'Value',values)
     112                end
    110113            end
    111         end
    112114        end
    113115    end
  • trunk/src/get_field.m

    r596 r606  
    367367for icell=1:numel(CellInfo)
    368368    VarIndex=CellInfo{icell}.VarIndex;
    369     if ~isempty(find(VarIndex==yindex,1)) && (isempty(VarRole{icell}.coord_x)||~isequal(VarRole{icell}.coord_x,VarIndex))
     369    if ~isempty(find(VarIndex==yindex,1)) && (isempty(CellInfo{icell}.VarIndex_coord_x)||~isequal(CellInfo{icell}.VarIndex_coord_x,VarIndex))
    370370        cell_select=icell;
    371371        break
     
    374374val=get(handles.abscissa,'Value');
    375375set(handles.abscissa,'Value',min(val,2));
    376 coord_x_index=VarRole{cell_select}.coord;
     376coord_x_index=CellInfo{cell_select}.VarIndex_coord_x;
    377377coord_x_index=coord_x_index(coord_x_index~=0);
    378 set(handles.XVarname,'String',[{''}; (Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))'])
     378set(handles.XVarName,'String',[{''}; (Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))'])
    379379
    380380%------------------------------------------------------------------------
  • trunk/src/series.m

    r605 r606  
    258258function MenuBrowse_Callback(hObject, eventdata, handles)
    259259%------------------------------------------------------------------------   
     260%get the previous input file in the Input Table
     261oldfile=''; %default
    260262InputTable=get(handles.InputTable,'Data');
    261 if isempty(InputTable)
    262     RootPathCell={};
    263 else
    264     RootPathCell=InputTable(:,1);
    265 end
    266 oldfile=''; %default
    267 if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box
    268      dir_perso=prefdir;
    269      profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    270      if exist(profil_perso,'file')
    271           h=load (profil_perso);
    272          if isfield(h,'filebase')&&ischar(h.filebase)
    273                  oldfile=h.filebase;
    274          end
    275          if isfield(h,'RootPath')&&ischar(h.RootPath)
    276                  oldfile=h.RootPath;
    277          end
    278      end
    279 else
    280      SubDirCell=InputTable(:,2);
    281     RootFileCell=InputTable(:,3);
    282      oldfile=fullfile(RootPathCell{1},SubDirCell{1},RootFileCell{1});
    283  end
    284 [FileName, PathName] = uigetfile( ...
    285        {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)';
    286        '*.xml',  '.xml files '; ...
    287         '*.xls',  '.xls files '; ...
    288         '*.png','.png image files'; ...
    289         '*.tif','.tif image files'; ...
    290         '*.avi;*.AVI','.avi movie files'; ...
    291         '*.nc','.netcdf files'; ...
    292         '*.*',  'All Files (*.*)'}, ...
    293         'Pick a file',oldfile);
    294 fileinput=[PathName FileName];%complete file name
    295 if isempty(fileinput),return;end %abandon if no file is introduced by the browser
    296 [path,name,ext]=fileparts(fileinput);
    297 if isequal(ext,'.xml')
    298     [Param,Heading]=xml2struct(fileinput);
    299     if ~strcmp(Heading,'Series')
    300         msg_box_uvmat('ERROR','xml file heading is not <Series>')
    301     else
    302         fill_GUI(Param,handles.series);%fill the GUI with the parameters retrieved from the xml file
    303         if isfield(Param,'CheckObject')&& Param.CheckObject
    304             set_object(Param.ProjObject)
    305         end
    306         set(handles.REFRESH,'UserData',1:size(Param.InputTable,1))
    307         REFRESH_Callback([],[], handles)
    308         return
    309     end
    310 elseif isequal(ext,'.xls')
    311     msg_box_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
    312 else
     263if isequal(InputTable(:,1),[{''};{''};{''};{''}])%open the personal file for empty previous input
     264    dir_perso=prefdir;
     265    profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     266    if exist(profil_perso,'file')
     267         h=load (profil_perso);
     268        if isfield(h,'RootPath')&&ischar(h.RootPath)
     269            oldfile=h.RootPath;
     270        end
     271    end
     272else% select the previous file as the first line of the input table
     273    oldfile=fullfile(InputTable{1,1},InputTable{1,2},InputTable{1,3});
     274end
     275hfig=uigetfile_uvmat('file browser',fileparts(fileparts(oldfile)));
     276uiwait(hfig);
     277if ishandle(hfig) % stop if browser closed without selection
     278    fileinput=get(hfig,'UserData');% retrieve the input file selection
     279    delete(hfig)
    313280    display_file_name(handles,fileinput,0)
    314281end
     282%
     283% [FileName, PathName] = uigetfile( ...
     284%        {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)';
     285%        '*.xml',  '.xml files '; ...
     286%         '*.xls',  '.xls files '; ...
     287%         '*.png','.png image files'; ...
     288%         '*.tif','.tif image files'; ...
     289%         '*.avi;*.AVI','.avi movie files'; ...
     290%         '*.nc','.netcdf files'; ...
     291%         '*.*',  'All Files (*.*)'}, ...
     292%         'Pick a file',oldfile);
     293% fileinput=[PathName FileName];%complete file name
     294% [path,name,ext]=fileparts(fileinput);
     295% if isequal(ext,'.xml')
     296%     [Param,Heading]=xml2struct(fileinput);
     297%     if ~strcmp(Heading,'Series')
     298%         msg_box_uvmat('ERROR','xml file heading is not <Series>')
     299%     else
     300%         fill_GUI(Param,handles.series);%fill the GUI with the parameters retrieved from the xml file
     301%         if isfield(Param,'CheckObject')&& Param.CheckObject
     302%             set_object(Param.ProjObject)
     303%         end
     304%         set(handles.REFRESH,'UserData',1:size(Param.InputTable,1))
     305%         REFRESH_Callback([],[], handles)
     306%         return
     307%     end
     308% elseif isequal(ext,'.xls')
     309%     msg_box_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
     310% else
     311%     display_file_name(handles,fileinput,0)
     312% end
    315313
    316314% --------------------------------------------------------------------
     
    20062004end
    20072005set(handles.FieldTransform,'Visible',FieldTransformVisible)
     2006if isfield(ParamOut,'TransformPath')
     2007    set(handles.ActionExt,'UserData',ParamOut.TransformPath)
     2008else
     2009    set(handles.ActionExt,'UserData',[])
     2010end
    20082011
    20092012%% Visibility of projection object
     
    22272230function CheckObject_Callback(hObject, eventdata, handles)
    22282231%------------------------------------------------------------------------
     2232hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle
    22292233value=get(handles.CheckObject,'Value');
    22302234if value
    2231 %      set(handles.CheckObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow
    2232      hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle
    2233      if ishandle(hset_object)
    2234          uistack(hset_object,'top')% show the GUI set_object if opened
    2235      else
    2236          %get the object file
    2237          InputTable=get(handles.InputTable,'Data');
    2238          defaultname=InputTable{1,1};
    2239          if isempty(defaultname)
    2240             defaultname={''};
    2241          end
    2242         [FileName, PathName] = uigetfile( ...
    2243        {'*.xml;*.mat', ' (*.xml,*.mat)';
    2244        '*.xml',  '.xml files '; ...
    2245         '*.mat',  '.mat matlab files '}, ...
    2246         'Pick an xml object file (or use uvmat to create it)',defaultname);
    2247         fileinput=[PathName FileName];%complete file name
    2248         sizf=size(fileinput);
    2249         if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
    2250         %read the file
    2251         data=xml2struct(fileinput);
    2252         if ~isfield(data,'Type')
    2253              msgbox_uvmat('ERROR',[fileinput ' is not an object xml file'])
    2254              return
    2255         end
    2256         if ~isfield(data,'ProjMode')
    2257              data.ProjMode='none';
    2258         end
    2259         hset_object=set_object(data);% call the set_object interface
    2260      end
    2261      ProjObject=read_GUI(hset_object);
    2262      set(handles.ProjObject,'String',ProjObject.Name);%display the object name
    2263      SeriesData=get(handles.series,'UserData');
    2264      SeriesData.ProjObject=ProjObject;
    2265      set(handles.series,'UserData',SeriesData);
    2266      set(handles.DeleteObject,'Visible','on');
    2267      set(handles.ViewObject,'Visible','on');
    2268      set(handles.ProjObject,'Visible','on');
     2235    SeriesData=get(handles.series,'UserData');
     2236    if ~(isfield(SeriesData,'ProjObject')&&~isempty(SeriesData.ProjObject))
     2237        if ishandle(hset_object)
     2238            uistack(hset_object,'top')% show the GUI set_object if opened
     2239        else
     2240            %get the object file
     2241            InputTable=get(handles.InputTable,'Data');
     2242            defaultname=InputTable{1,1};
     2243            if isempty(defaultname)
     2244                defaultname={''};
     2245            end
     2246            [FileName, PathName] = uigetfile( ...
     2247                {'*.xml;*.mat', ' (*.xml,*.mat)';
     2248                '*.xml',  '.xml files '; ...
     2249                '*.mat',  '.mat matlab files '}, ...
     2250                'Pick an xml object file (or use uvmat to create it)',defaultname);
     2251            fileinput=[PathName FileName];%complete file name
     2252            sizf=size(fileinput);
     2253            if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
     2254            %read the file
     2255            data=xml2struct(fileinput);
     2256            if ~isfield(data,'Type')
     2257                msgbox_uvmat('ERROR',[fileinput ' is not an object xml file'])
     2258                return
     2259            end
     2260            if ~isfield(data,'ProjMode')
     2261                data.ProjMode='none';
     2262            end
     2263            hset_object=set_object(data);% call the set_object interface
     2264        end
     2265        ProjObject=read_GUI(hset_object);
     2266        set(handles.ProjObject,'String',ProjObject.Name);%display the object name
     2267        SeriesData=get(handles.series,'UserData');
     2268        SeriesData.ProjObject=ProjObject;
     2269        set(handles.series,'UserData',SeriesData);
     2270    end
     2271    set(handles.DeleteObject,'Visible','on');
     2272    set(handles.ViewObject,'Visible','on');
     2273    set(handles.ProjObject,'Visible','on');
    22692274else
    2270          set(handles.DeleteObject,'Visible','off');
    2271      set(handles.ViewObject,'Visible','off');
    2272      set(handles.ProjObject,'Visible','off');
    2273 %     set(handles.CheckObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green
     2275    set(handles.DeleteObject,'Visible','off');
     2276    set(handles.ViewObject,'Visible','off');
     2277    if ~ishandle(hset_object)
     2278    set(handles.ViewObject,'Value',0);
     2279    end
     2280    set(handles.ProjObject,'Visible','off');
    22742281end
    22752282%set(handles.series,'UserData',SeriesData)
     
    24652472        uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
    24662473        uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@stop_status);
    2467         hrefresh=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@refresh_GUI);
     2474        uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@refresh_GUI);
    24682475        %set(hrefresh,'UserData',StatusData)
    24692476        BarPosition=[0.05 0.81 0.01 0.05];
     
    24712478        drawnow
    24722479    end
    2473     refresh_GUI(hrefresh,[])
     2480    refresh_GUI(hfig)
    24742481else
    24752482    %% delete current display fig if selection is off
     
    25262533%------------------------------------------------------------------------   
    25272534% launched by refreshing the status figure
    2528 function refresh_GUI(hObject, eventdata)
    2529 %------------------------------------------------------------------------
    2530 hfig=get(hObject,'parent');
     2535function refresh_GUI(hfig)
     2536%------------------------------------------------------------------------
    25312537htitlebox=findobj(hfig,'tag','titlebox');
    25322538hlist=findobj(hfig,'tag','list');
     
    25562562ListDisplay=ListDisplay(datnum~=0);
    25572563datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
     2564NbOutputFile=[];
    25582565if isempty(datnum)
    25592566    if testrecent
     
    26762683ActionList=get(handles.ActionName,'String');
    26772684ActionName=ActionList{get(handles.ActionName,'Value')};
     2685TransformPath='';
     2686if ~isempty(get(handles.ActionExt,'UserData'))
     2687    TransformPath=get(handles.ActionExt,'UserData');
     2688end
    26782689if strcmp(ActionExt,'.sh')
     2690    set(handles.ActionExt,'BackgroundColor',[1 1 0])
    26792691    ActionFullName=fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']);
    26802692    if ~exist(ActionFullName,'file')
    26812693        answer=msgbox_uvmat('INPUT_Y-N','compiled version has not been created: compile now?');
    26822694        if strcmp(answer,'Yes')
     2695            set(handles.ActionExt,'BackgroundColor',[1 1 0])
     2696            path_uvmat=fileparts(which('series'));
    26832697            currentdir=pwd;
    2684             cd(get(handles.ActionPath,'String'))
    2685             compile(ActionName)
     2698            cd(get(handles.ActionPath,'String'))% go to the directory of Action
     2699            %  addpath(get(handles.TransformPath,'String'))
     2700            addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'
     2701           % addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile'
     2702            compile(ActionName,TransformPath)
    26862703            cd(currentdir)
    26872704        end
    2688     end
    2689     sh_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']));
    2690     m_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.m']));
    2691     if isfield(m_file_info,'datenum') && m_file_info.datenum>sh_file_info.datenum
    2692         set(handles.ActionExt,'BackgroundColor',[1 1 0])
    2693         drawnow
    2694         answer=msgbox_uvmat('INPUT_Y-N',[ActionName '.sh needs to be updated: recompile now?']);
    2695         if strcmp(answer,'Yes')
    2696             currentdir=pwd;
    2697             cd(get(handles.ActionPath,'String'))
    2698             compile(ActionName)
    2699             cd(currentdir)
    2700         end
    2701         set(handles.ActionExt,'BackgroundColor',[1 1 1])
    2702     end
     2705       
     2706    else
     2707        sh_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']));
     2708        m_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.m']));
     2709        if isfield(m_file_info,'datenum') && m_file_info.datenum>sh_file_info.datenum
     2710            set(handles.ActionExt,'BackgroundColor',[1 1 0])
     2711            drawnow
     2712            answer=msgbox_uvmat('INPUT_Y-N',[ActionName '.sh needs to be updated: recompile now?']);
     2713            if strcmp(answer,'Yes')
     2714                path_uvmat=fileparts(which('series'));
     2715                currentdir=pwd;
     2716                cd(get(handles.ActionPath,'String'))% go to the directory of Action
     2717                %  addpath(get(handles.TransformPath,'String'))
     2718                addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'
     2719                addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile'
     2720                compile(ActionName,TransformPath)
     2721                cd(currentdir)
     2722            end
     2723        end
     2724    end
     2725    set(handles.ActionExt,'BackgroundColor',[1 1 1])
    27032726end
    27042727
     
    27172740    set(handles.DeleteObject,'Visible','off')
    27182741    set(handles.ViewObject,'Visible','off')
     2742    set(handles.DeleteObject,'Value',0)
    27192743end
    27202744
  • trunk/src/series/civ_series.m

    r605 r606  
    4242path_series=fileparts(which('series'));
    4343addpath(fullfile(path_series,'series'))
    44 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName
     44%% set the input elements needed on the GUI series when the action is selected in the menu ActionName or InputTable refreshed
    4545if isstruct(Param) && isequal(Param.Action.RUN,0)
    4646    Data=civ_input(Param);% introduce the civ parameters using the GUI civ_input
    47     Data.Program=mfilename;
    48     Data.AllowInputSort='off';...% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
    49         Data.WholeIndexRange='off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
    50         Data.NbSlice='off'; ...%nbre of slices ('off' by default)
    51         Data.VelType='off';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    52         Data.FieldName='off';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    53         Data.FieldTransform = 'off';...%can use a transform function
    54         Data.ProjObject='off';...%can use projection object(option 'off'/'on',
    55         Data.Mask='off';...%can use mask option   (option 'off'/'on', 'off' by default)
    56         Data.OutputDirExt='.civ';%set the output dir extension
    57        
     47    Data.Program=mfilename;%gives the name of the current function
     48    Data.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
     49    Data.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
     50    Data.NbSlice='off'; %nbre of slices ('off' by default)
     51    Data.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     52    Data.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     53    Data.FieldTransform = 'off';%can use a transform function
     54    Data.ProjObject='off';%can use projection object(option 'off'/'on',
     55    Data.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
     56    Data.OutputDirExt='.civ';%set the output dir extension
     57    filecell=get_file_series(Param);%check existence of the first input file
     58    if ~exist(filecell{1,1},'file')
     59        msgbox_uvmat('WARNING','the first input file does not exist')
     60    end
    5861    return
    5962end
     
    115118   
    116119    NbField=numel(i1_series_Civ1);
    117     ImageTypeOptions={'image','multimage','mmreader','video'};
    118120    [FileType_A,FileInfo,MovieObject_A]=get_file_type(filecell{1,1});
    119121    FileType_B=FileType_A;
     
    121123    if size(filecell,1)>=2 && ~strcmp(filecell{1,1},filecell{2,1})
    122124        [FileType_B,FileInfo,MovieObject_B]=get_file_type(filecell{2,1});
    123         CheckImage_B=~isempty(find(strcmp(FileType,ImageTypeOptions)));% =1 for images
    124125    end
    125126end
     
    141142check_patch1=0;%default
    142143
    143 
    144 
    145 
    146 
     144%% get timing from the ImaDoc file or input video
     145[XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series);
     146%TODO: get time_A and time_B
     147% case of movies TODO TODO TODO
     148if isempty(time) && (strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
     149    set(handles.ListPairMode,'Value',1);
     150    dt=1/get(MovieObject,'FrameRate');%time interval between successive frames
     151    if strcmp(NomTypeIma,'*')
     152        set(handles.ListPairMode,'String',{'series(Di)'})
     153        MaxIndex_i=get(MovieObject,'NumberOfFrames');
     154        time=(dt*(0:MaxIndex_i-1))';%list of image times
     155    else
     156        set(handles.ListPairMode,'String',[{'series(Dj)'};{'series(Di)'}])
     157        MaxIndex_i=max(i1_series(i1_series>0));
     158        MaxIndex_j=get(MovieObject,'NumberOfFrames');
     159        time=ones(MaxIndex_i,1)*(dt*(0:MaxIndex_j-1));%list of image times
     160        enable_j(handles,'on')
     161    end
     162    TimeUnit='s';
    147163%%%%% MAIN LOOP %%%%%%
    148164
     
    164180            end
    165181        else
    166             %         if ~isfield(Param.Civ1,'ImageA')
    167182            ImageName_A=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield));
    168183            [par_civ1.ImageA,MovieObject_A] = read_image(ImageName_A,FileType_A,MovieObject_A,FrameIndex_A_Civ1(ifield));
    169             %         elseif ischar(Param.Civ1.ImageA)
    170             %             Param.Civ1.ImageA=regexprep(Param.Civ1.ImageA,'''','\');
    171             %             [par_civ1.ImageA,VideoObject] = read_image(Param.Civ1.ImageA,par_civ1.FileTypeA,MovieObject_A,par_civ1.FrameIndexA);
    172             %         end
    173             %         if ~isfield(Param.Civ1,'ImageB')
    174184            ImageName_B=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield));
    175185            [par_civ1.ImageB,MovieObject_B] = read_image(ImageName_B,FileType_B,MovieObject_B,FrameIndex_B_Civ1(ifield));
    176             %         elseif isfield(Param.Civ1,'ImageB')&& ischar(Param.Civ1.ImageB)
    177             %              Param.Civ1.ImageB=regexprep(Param.Civ1.ImageB,'''','\');
    178             %              if strcmp(Param.Civ1.ImageA,Param.Civ1.ImageB)% use the same movie object
    179             %                  [par_civ1.ImageB,VideoObject] = read_image(Param.Civ1.ImageB,par_civ1.FileTypeB,VideoObject,par_civ1.FrameIndexB);
    180             %              else
    181             %             [par_civ1.ImageB,VideoObject] = read_image(Param.Civ1.ImageB,par_civ1.FileTypeB,par_civ1.ImageB,par_civ1.FrameIndexB);
    182             %              end
    183             %         end
    184186        end
    185187        ncfile=fullfile_uvmat(RootPath,OutputDir,RootFile,'.nc',NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),...
     
    188190        par_civ1.ImageHeight=FileInfo.Height;
    189191        list_param=(fieldnames(Param.ActionInput.Civ1))';
    190         Civ1_param=list_param;%default
    191        
    192         %set the values of all the global attributes in list_param 
     192        Civ1_param=regexprep(list_param,'^.+','Civ1_$0');% insert 'Civ1_' before  each string in list_param
     193        Civ1_param=[{'Civ1_ImageA','Civ1_ImageB','Civ1_Time','Civ1_Dt'} Civ1_param]; %insert the names of the two input images
     194        %indicate the values of all the global attributes in the output data
     195        Data.Civ1_ImageA=ImageName_A;
     196        Data.Civ1_ImageB=ImageName_B;
     197        Data.Civ1_Time=((time(i2_civ1(ifile)+1,j2_civ1(j)+1)+time(i1_civ1(ifile)+1,j1_civ1(j)+1))/2);
     198        Data.Civ1_Dt=(time(i2_civ1(ifile)+1,j2_civ1(j)+1)-time(i1_civ1(ifile)+1,j1_civ1(j)+1));
    193199        for ilist=1:length(list_param)
    194             Civ1_param{ilist}=['Civ1_' list_param{ilist}];
    195             Data.(['Civ1_' list_param{ilist}])=Param.ActionInput.Civ1.(list_param{ilist});
     200            Data.(Civ1_param{4+ilist})=Param.ActionInput.Civ1.(list_param{ilist});
    196201        end
    197202        Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param];
     
    391396        ibx2=ceil(par_civ2.CorrBoxSize(1)/2);
    392397        iby2=ceil(par_civ2.CorrBoxSize(2)/2);
    393         %     isx2=ibx2+4;% search ara +-4 pixels around the guess
    394         %     isy2=iby2+4;
    395398        par_civ2.SearchBoxSize(1)=2*ibx2+9;% search ara +-4 pixels around the guess
    396399        par_civ2.SearchBoxSize(2)=2*iby2+9;
    397         %par_civ2.SearchBoxSize(1)=2*isx2+1;
    398         %par_civ2.SearchBoxSize(2)=2*isy2+1;
    399400        par_civ2.SearchBoxShift=[Shiftx(nbval>=1)./nbval(nbval>=1) Shifty(nbval>=1)./nbval(nbval>=1)];
    400401        par_civ2.Grid=[GridX(nbval>=1)-par_civ2.SearchBoxShift(:,1)/2 GridY(nbval>=1)-par_civ2.SearchBoxShift(:,2)/2];% grid taken at the extrapolated origin of the displacement vectors
     
    409410
    410411        list_param=(fieldnames(Param.ActionInput.Civ2))';
    411         list_remove={'pxcmx','pxcmy','npx','npy','gridflag','maskflag','term_a','term_b','T0'};
    412         for ilist=1:length(list_remove)
    413             index=strcmp(list_remove{ilist},list_param);
    414             if ~isempty(find(index,1))
    415                 list_param(index)=[];
    416             end
    417         end
     412        Civ2_param=regexprep(list_param,'^.+','Civ2_$0');% insert 'Civ2_' before  each string in list_param
     413        Civ2_param=[{'Civ2_ImageA','Civ2_ImageB','Civ2_Time','Civ2_Dt'} Civ2_param]; %insert the names of the two input images
     414        %indicate the values of all the global attributes in the output data
     415        Data.Civ2_ImageA=ImageName_A;
     416        Data.Civ2_ImageB=ImageName_B;
     417        Data.Civ2_Time=1;
     418        Data.Civ2_Dt=1;
    418419        for ilist=1:length(list_param)
    419             Civ2_param{ilist}=['Civ2_' list_param{ilist}];
    420             eval(['Data.Civ2_' list_param{ilist} '=Param.ActionInput.Civ2.' list_param{ilist} ';'])
    421         end
    422         if isfield(Data,'Civ2_gridname') && strcmp(Data.Civ1_gridname(1:6),'noFile')
    423             Data.Civ1_gridname='';
    424         end
    425         if isfield(Data,'Civ2_maskname') && strcmp(Data.Civ1_maskname(1:6),'noFile')
    426             Data.Civ2_maskname='';
    427         end
    428         Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ2_param {'Civ2_Time','Civ2_Dt'}];
     420            Data.(Civ2_param{4+ilist})=Param.ActionInput.Civ2.(list_param{ilist});
     421        end
     422        Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ2_param];
     423       
    429424        nbvar=numel(Data.ListVarName);
    430425        Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_F','Civ2_C'}];%  cell array containing the names of the fields to record
  • trunk/src/series/ima_levels.m

    r604 r606  
    4343function ParamOut=ima_levels (Param)
    4444
    45 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName
     45%% set the input elements needed on the GUI series when the action is selected in the menu ActionName or InputTable refreshed
    4646if isstruct(Param) && isequal(Param.Action.RUN,0)
    4747    ParamOut.NbViewMax=1;% max nbre of input file series (default , no limitation)
     
    5858    %check the type of the existence and type of the first input file:
    5959    Param.IndexRange.last_i=Param.IndexRange.first_i;%keep only the first index in the series
     60    if isfield(Param.IndexRange,'first_j')
    6061    Param.IndexRange.last_j=Param.IndexRange.first_j;
     62    end
    6163    filecell=get_file_series(Param);
    6264    if ~exist(filecell{1,1},'file')
     
    7375%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
    7476%% read input parameters from an xml file if input is a file name (batch mode)
     77ParamOut=[]
    7578checkrun=1;
    7679if ischar(Param)
  • trunk/src/series/merge_proj.m

    r605 r606  
    4141function ParamOut=merge_proj(Param)
    4242
    43 %% set the input elements needed on the GUI series when the function is selected in the menu ActionName
     43%% set the input elements needed on the GUI series when the function is selected in the menu ActionName or InputTable refreshed
    4444if isstruct(Param) && isequal(Param.Action.RUN,0)
    45     ParamOut.AllowInputSort='off';...% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
    46     ParamOut.WholeIndexRange='on';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
    47     ParamOut.NbSlice='off'; ...%nbre of slices ('off' by default)
    48     ParamOut.VelType='one';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    49     ParamOut.FieldName='one';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    50     ParamOut.FieldTransform = 'on';...%can use a transform function
    51     ParamOut.ProjObject='on';...%can use projection object(option 'off'/'on',
    52     ParamOut.Mask='off';...%can use mask option   (option 'off'/'on', 'off' by default)
     45    ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
     46    ParamOut.WholeIndexRange='on';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
     47    ParamOut.NbSlice='off'; %nbre of slices ('off' by default)
     48    ParamOut.VelType='one';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     49    ParamOut.FieldName='one';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     50    ParamOut.FieldTransform = 'on';%can use a transform function
     51    ParamOut.TransformPath=fullfile(fileparts(which('uvmat')),'transform_field');% path to transform functions (needed for compilation only)
     52    ParamOut.ProjObject='on';%can use projection object(option 'off'/'on',
     53    ParamOut.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
    5354    ParamOut.OutputDirExt='.mproj';%set the output dir extension
    5455    ParamOut.OutputFileMode='NbInput';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
     
    5758        msgbox_uvmat('WARNING','the first input file does not exist')
    5859    elseif isequal(size(Param.InputTable,1),1) && ~isfield(Param,'ProjObject')
    59          msgbox_uvmat('WARNING','a projection object of type plane needs to be introduced for merge_proj')
    60     end
    61 return
     60        msgbox_uvmat('WARNING','a projection object of type plane needs to be introduced for merge_proj')
     61    end
     62    return
    6263end
    6364
    6465%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
    65 
    66 
    6766%% read input parameters from an xml file if input is a file name (batch mode)
    6867checkrun=1;
     
    7271end
    7372
    74 ParamOut=Param; %default output
     73ParamOut=[] %default output
    7574if ~isfield(Param,'InputFields')
    7675    Param.InputFields.FieldName='';
    7776end
    78 OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
     77OutputDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
    7978
    8079%% root input file type
     
    9392% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
    9493%%%%%%%%%%%%
    95 NbSlice=1;%default
    96 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
    97     NbSlice=Param.IndexRange.NbSlice;
    98 end
    99 nbview=numel(i1_series);%number of input file series (lines in InputTable)
    100 nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
    101 nbfield_i=size(i1_series{1},2); %nb of fields for the i index
    102 nbfield=nbfield_j*nbfield_i; %total number of fields
    103 nbfield_i=floor(nbfield/NbSlice);%total number of  indexes in a slice (adjusted to an integer number of slices)
    104 nbfield=nbfield_i*NbSlice; %total number of fields after adjustement
     94% NbSlice=1;%default
     95% if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
     96%     NbSlice=Param.IndexRange.NbSlice;
     97% end
     98NbView=numel(i1_series);%number of input file series (lines in InputTable)
     99NbField_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
     100NbField_i=size(i1_series{1},2); %nb of fields for the i index
     101NbField=NbField_j*NbField_i; %total number of fields
    105102
    106103%determine the file type on each line from the first input file
    107104ImageTypeOptions={'image','multimage','mmreader','video'};
    108105NcTypeOptions={'netcdf','civx','civdata'};
    109 for iview=1:nbview
     106for iview=1:NbView
    110107    if ~exist(filecell{iview,1}','file')
    111108        displ_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'],checkrun)
     
    122119end
    123120
    124 
    125121%% calibration data and timing: read the ImaDoc files
    126122[XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series);
     
    133129
    134130%% coordinate transform or other user defined transform
    135 transform_fct='';%default
     131% transform_fct='';%default fct handle
     132% if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)
     133%     if isdeployed
     134%         transform_fct=Param.FieldTransform.TransformName;
     135%         dd=phys([]);%activate phys for compilation
     136%     else
     137%         currentdir=pwd;
     138%         cd(Param.FieldTransform.TransformPath)
     139%         transform_fct=str2func(Param.FieldTransform.TransformName);
     140%         cd (currentdir)
     141%     end
     142% end
     143transform_fct='';%default fct handle
    136144if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)
    137     addpath(Param.FieldTransform.TransformPath)
    138     transform_fct=str2func(Param.FieldTransform.TransformName);
    139     rmpath(Param.FieldTransform.TransformPath)
    140 end
    141 
     145        currentdir=pwd;
     146        cd(Param.FieldTransform.TransformPath)
     147        transform_fct=str2func(Param.FieldTransform.TransformName);
     148        cd (currentdir)
     149end
    142150%%%%%%%%%%%% END STANDARD PART  %%%%%%%%%%%%
    143151 % EDIT FROM HERE
     
    152160    return
    153161end
    154 for iview=1:nbview
     162for iview=1:NbView
    155163        if ~isequal(CheckImage{iview},CheckImage{1})||~isequal(CheckNc{iview},CheckNc{1})
    156164        displ_uvmat('ERROR','input set of input series: need  either netcdf either image series',checkrun)
     
    169177%% MAIN LOOP ON SLICES
    170178%%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
    171 for i_slice=1:NbSlice
    172     index_slice=i_slice:NbSlice:nbfield;% select file indices of the slice
    173     nbfiles=0;
    174     nbmissing=0;
     179% for i_slice=1:NbSlice
     180%     index_slice=i_slice:NbSlice:NbField;% select file indices of the slice
     181%     NbFiles=0;
     182%     nbmissing=0;
    175183
    176184    %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
    177     for index=index_slice
    178         if checkrun
    179             stopstate=get(Param.RUNHandle,'BusyAction');
    180             update_waitbar(Param.WaitbarHandle,index/nbfield)
    181         else
    182             stopstate='queue';
    183         end
    184         if ~isequal(stopstate,'queue')% enable STOP command
    185             return
    186         end
    187         %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
    188         Data=cell(1,nbview);%initiate the set Data
    189         nbtime=0;
    190         for iview=1:nbview
    191             %% reading input file(s)
    192             [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},Param.InputFields,frame_index{iview}(index));
     185for index=1:NbField
     186    if checkrun
     187        stopstate=get(Param.RUNHandle,'BusyAction');
     188        update_waitbar(Param.WaitbarHandle,index/NbField)
     189    else
     190        stopstate='queue';
     191    end
     192    if ~isequal(stopstate,'queue')% enable STOP command
     193        return
     194    end
     195    %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
     196    Data=cell(1,NbView);%initiate the set Data
     197    nbtime=0;
     198    for iview=1:NbView
     199        %% reading input file(s)
     200        [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},Param.InputFields,frame_index{iview}(index));
     201        if ~isempty(errormsg)
     202            errormsg=['merge_proj/read_field/' errormsg];
     203            display(errormsg)
     204            break
     205        end
     206        timeread(iview)=0;
     207        if isfield(Data{iview},'Time')
     208            timeread(iview)=Data{iview}.Time;
     209            nbtime=nbtime+1;
     210        end
     211        if ~isempty(NbSlice_calib)
     212            Data{iview}.ZIndex=mod(i1_series{iview}(index)-1,NbSlice_calib{iview})+1;%Zindex for phys transform
     213        end
     214
     215        %% transform the input field (e.g; phys) if requested
     216        if ~isempty(transform_fct)
     217            if nargin(transform_fct)>=2
     218                Data{iview}=transform_fct(Data{iview},XmlData{iview});
     219            else
     220                Data{iview}=transform_fct(Data{iview});
     221            end
     222        end
     223%          Data{iview}=phys(Data{iview},XmlData{iview});
     224        %% check whether tps is needed, then calculate tps coefficients if needed
     225        check_tps=0;
     226        if isfield(Param.InputFields,'FieldName')
     227            if ischar(Param.InputFields.FieldName)
     228                Param.InputFields.FieldName={Param.InputFields.FieldName};
     229            end
     230        else
     231            Param.InputFields.FieldName={};
     232        end
     233        for ilist=1:numel(Param.InputFields.FieldName)
     234            switch Param.InputFields.FieldName{ilist}
     235                case {'vort','div','strain'}
     236                    check_tps=1;
     237            end
     238        end
     239
     240        %% calculate tps coeff if needed
     241        check_proj_tps= ~isempty(Param.ProjObject)&& strcmp(Param.ProjObject.ProjMode,'filter')&&~isfield(Data{iview},'Coord_tps');
     242        Data{iview}=tps_coeff_field(Data{iview},check_proj_tps);
     243
     244        %% projection on object (gridded plane)
     245        if Param.CheckObject
     246            [Data{iview},errormsg]=proj_field(Data{iview},Param.ProjObject);
    193247            if ~isempty(errormsg)
    194                 errormsg=['merge_proj/read_field/' errormsg];
    195                 display(errormsg)
    196                 break
    197             end
    198             timeread(iview)=0;
    199             if isfield(Data{iview},'Time')
    200                     timeread(iview)=Data{iview}.Time;
    201                     nbtime=nbtime+1;
    202                 end
    203             if ~isempty(NbSlice_calib)
    204                 Data{iview}.ZIndex=mod(i1_series{iview}(index)-1,NbSlice_calib{iview})+1;%Zindex for phys transform
    205             end
    206            
    207             %% transform the input field (e.g; phys) if requested
    208             if ~isempty(transform_fct)
    209                 if nargin(transform_fct)>=2
    210                     Data{iview}=transform_fct(Data{iview},XmlData{iview});
    211                 else
    212                     Data{iview}=transform_fct(Data{iview});
    213                 end
    214             end
    215            
    216             %% check whether tps is needed, then calculate tps coefficients if needed
    217             check_tps=0;
    218             if isfield(Param.InputFields,'FieldName')
    219                 if ischar(Param.InputFields.FieldName)
    220                     Param.InputFields.FieldName={Param.InputFields.FieldName};
    221                 end
    222             else
    223                 Param.InputFields.FieldName={};
    224             end
    225             for ilist=1:numel(Param.InputFields.FieldName)
    226                 switch Param.InputFields.FieldName{ilist}
    227                     case {'vort','div','strain'}
    228                         check_tps=1;
    229                 end
    230             end
    231                
    232             %% calculate tps coeff if needed
    233              check_proj_tps= ~isempty(Param.ProjObject)&& strcmp(Param.ProjObject.ProjMode,'filter')&&~isfield(Data{iview},'Coord_tps');
    234             Data{iview}=tps_coeff_field(Data{iview},check_proj_tps);
    235 
    236             %% projection on object (gridded plane)
    237             if Param.CheckObject
    238                 [Data{iview},errormsg]=proj_field(Data{iview},Param.ProjObject);
    239                 if ~isempty(errormsg)
    240                     displ_uvmat('ERROR',['error in merge_proge/proj_field: ' errormsg],checkrun)
    241                     return
    242                 end
    243             end
    244         end
    245         %----------END LOOP ON VIEWS----------------------
    246        
    247         %% merge the nbview fields
    248         MergeData=merge_field(Data);
    249         if isfield(MergeData,'Txt')
    250             displ_uvmat('ERROR',MergeData.Txt,checkrun)
    251             return
    252         end
    253        
    254         % time of the merged field:
    255         if ~isempty(time)% time defined from ImaDoc
    256             timeread=time(:,index);
    257         end
    258         timeread=mean(timeread);
    259        
    260         % generating the name of the merged field
    261         i1=i1_series{iview}(index);
    262         if ~isempty(i2_series{iview})
    263             i2=i2_series{iview}(index);
    264         else
    265             i2=i1;
    266         end
    267         j1=1;
    268         j2=1;
    269         if ~isempty(j1_series{iview})
    270             j1=j1_series{iview}(index);
    271             if ~isempty(j2_series{iview})
    272                 j2=j2_series{iview}(index);
    273             else
    274                 j2=j1;
    275             end
    276         end
    277         OutputFile=fullfile_uvmat(RootPath{1},OutputSubDir,RootFile{1},FileExtOut,NomType{1},i1,i2,j1,j2);
    278        
    279         % recording the merged field
    280         if CheckImage{1}    %in case of input images an image is produced
    281             if isa(MergeData.A,'uint8')
    282                 bitdepth=8;
    283             elseif isa(MergeData.A,'uint16')
    284                 bitdepth=16;
    285             end
    286             imwrite(MergeData.A,OutputFile,'BitDepth',bitdepth);
    287             %write xml calibration file
    288             siz=size(MergeData.A);
    289             npy=siz(1);
    290             npx=siz(2);
    291             if isfield(MergeData,'VarAttribute')&&isfield(MergeData.VarAttribute{1},'Coord_2')&&isfield(MergeData.VarAttribute{1},'Coord_1')
    292                 Rangx=MergeData.VarAttribute{1}.Coord_2;
    293                 Rangy=MergeData.VarAttribute{1}.Coord_1;
    294             elseif isfield(MergeData,'AX')&& isfield(MergeData,'AY')
    295                 Rangx=[MergeData.AX(1) MergeData.AX(end)];
    296                 Rangy=[MergeData.AY(1) MergeData.AY(end)];
    297             else
    298                 Rangx=[0.5 npx-0.5];
    299                 Rangy=[npy-0.5 0.5];%default
    300             end
    301             pxcmx=(npx-1)/(Rangx(2)-Rangx(1));
    302             pxcmy=(npy-1)/(Rangy(1)-Rangy(2));
    303             T_x=-pxcmx*Rangx(1)+0.5;
    304             T_y=-pxcmy*Rangy(2)+0.5;
    305             GeometryCal.focal=1;
    306             GeometryCal.R=[pxcmx,0,0;0,pxcmy,0;0,0,1];
    307             GeometryCal.Tx_Ty_Tz=[T_x T_y 1];
    308             ImaDoc.GeometryCalib=GeometryCal;
    309 %             t=struct2xml(ImaDoc);
    310 %             t=set(t,1,'name','ImaDoc');
    311 %             save(t,[filebase_merge '.xml'])
    312 %             display([filebase_merge '.xml saved'])
    313         else
    314             MergeData.ListGlobalAttribute={'Conventions','Project','InputFile_1','InputFile_end','nb_coord','nb_dim','dt','Time','civ'};
    315             MergeData.Conventions='uvmat';
    316             MergeData.nb_coord=2;
    317             MergeData.nb_dim=2;
    318             dt=[];
    319             if isfield(Data{1},'dt')&& isnumeric(Data{1}.dt)
    320                 dt=Data{1}.dt;
    321             end
    322             for iview =2:numel(Data)
    323                 if ~(isfield(Data{iview},'dt')&& isequal(Data{iview}.dt,dt))
    324                     dt=[];%dt not the same for all fields
    325                 end
    326             end
    327             if isempty(dt)
    328                 MergeData.ListGlobalAttribute(6)=[];
    329             else
    330                 MergeData.dt=dt;
    331             end
    332             MergeData.Time=timeread;
    333             error=struct2nc(OutputFile,MergeData);%save result file
    334             if isempty(error)
    335                 display(['output file ' OutputFile ' written'])
    336             else
    337                 display(error)
    338             end
    339         end
    340     end
    341 end
     248                displ_uvmat('ERROR',['error in merge_proge/proj_field: ' errormsg],checkrun)
     249                return
     250            end
     251        end
     252    end
     253    %----------END LOOP ON VIEWS----------------------
     254
     255    %% merge the NbView fields
     256    MergeData=merge_field(Data);
     257    if isfield(MergeData,'Txt')
     258        displ_uvmat('ERROR',MergeData.Txt,checkrun)
     259        return
     260    end
     261
     262    % time of the merged field:
     263    if ~isempty(time)% time defined from ImaDoc
     264        timeread=time(:,index);
     265    end
     266    timeread=mean(timeread);
     267
     268    % generating the name of the merged field
     269    i1=i1_series{iview}(index);
     270    if ~isempty(i2_series{iview})
     271        i2=i2_series{iview}(index);
     272    else
     273        i2=i1;
     274    end
     275    j1=1;
     276    j2=1;
     277    if ~isempty(j1_series{iview})
     278        j1=j1_series{iview}(index);
     279        if ~isempty(j2_series{iview})
     280            j2=j2_series{iview}(index);
     281        else
     282            j2=j1;
     283        end
     284    end
     285    OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomType{1},i1,i2,j1,j2);
     286
     287    % recording the merged field
     288    if CheckImage{1}    %in case of input images an image is produced
     289        if isa(MergeData.A,'uint8')
     290            bitdepth=8;
     291        elseif isa(MergeData.A,'uint16')
     292            bitdepth=16;
     293        end
     294        imwrite(MergeData.A,OutputFile,'BitDepth',bitdepth);
     295        %write xml calibration file
     296        siz=size(MergeData.A);
     297        npy=siz(1);
     298        npx=siz(2);
     299        if isfield(MergeData,'VarAttribute')&&isfield(MergeData.VarAttribute{1},'Coord_2')&&isfield(MergeData.VarAttribute{1},'Coord_1')
     300            Rangx=MergeData.VarAttribute{1}.Coord_2;
     301            Rangy=MergeData.VarAttribute{1}.Coord_1;
     302        elseif isfield(MergeData,'AX')&& isfield(MergeData,'AY')
     303            Rangx=[MergeData.AX(1) MergeData.AX(end)];
     304            Rangy=[MergeData.AY(1) MergeData.AY(end)];
     305        else
     306            Rangx=[0.5 npx-0.5];
     307            Rangy=[npy-0.5 0.5];%default
     308        end
     309        pxcmx=(npx-1)/(Rangx(2)-Rangx(1));
     310        pxcmy=(npy-1)/(Rangy(1)-Rangy(2));
     311        T_x=-pxcmx*Rangx(1)+0.5;
     312        T_y=-pxcmy*Rangy(2)+0.5;
     313        GeometryCal.focal=1;
     314        GeometryCal.R=[pxcmx,0,0;0,pxcmy,0;0,0,1];
     315        GeometryCal.Tx_Ty_Tz=[T_x T_y 1];
     316        ImaDoc.GeometryCalib=GeometryCal;
     317        %             t=struct2xml(ImaDoc);
     318        %             t=set(t,1,'name','ImaDoc');
     319        %             save(t,[filebase_merge '.xml'])
     320        %             display([filebase_merge '.xml saved'])
     321    else
     322        MergeData.ListGlobalAttribute={'Conventions','Project','InputFile_1','InputFile_end','nb_coord','nb_dim','dt','Time','civ'};
     323        MergeData.Conventions='uvmat';
     324        MergeData.nb_coord=2;
     325        MergeData.nb_dim=2;
     326        dt=[];
     327        if isfield(Data{1},'dt')&& isnumeric(Data{1}.dt)
     328            dt=Data{1}.dt;
     329        end
     330        for iview =2:numel(Data)
     331            if ~(isfield(Data{iview},'dt')&& isequal(Data{iview}.dt,dt))
     332                dt=[];%dt not the same for all fields
     333            end
     334        end
     335        if isempty(dt)
     336            MergeData.ListGlobalAttribute(6)=[];
     337        else
     338            MergeData.dt=dt;
     339        end
     340        MergeData.Time=timeread;
     341        error=struct2nc(OutputFile,MergeData);%save result file
     342        if isempty(error)
     343            display(['output file ' OutputFile ' written'])
     344        else
     345            display(error)
     346        end
     347    end
     348end
     349
    342350
    343351%'merge_field': concatene fields
     
    351359MergeData=Data{1};%default
    352360error=0;
    353 nbview=length(Data);
    354 if nbview==1
     361NbView=length(Data);
     362if NbView==1
    355363    return
    356364end
     
    382390        for ivar=VarIndex
    383391            VarName=MergeData.ListVarName{ivar};
    384             for iview=1:nbview
     392            for iview=1:NbView
    385393                MergeData.(VarName)=[MergeData.(VarName); Data{iview}.(VarName)];
    386394            end
     
    389397    else 
    390398        testFF=0;
    391         for iview=2:nbview
     399        for iview=2:NbView
    392400            for ivar=VarIndex
    393401                VarName=MergeData.ListVarName{ivar};
     
    401409        end
    402410        if testFF
    403             nbaver=nbview-MergeData.FF;
     411            nbaver=NbView-MergeData.FF;
    404412            indgood=find(nbaver>0);
    405413            for ivar=VarIndex
     
    410418            for ivar=VarIndex
    411419                VarName=MergeData.ListVarName{ivar};
    412                 MergeData.(VarName)=double(MergeData.(VarName))./nbview;
     420                MergeData.(VarName)=double(MergeData.(VarName))./NbView;
    413421            end   
    414422        end
  • trunk/src/series/time_series.m

    r605 r606  
    4242function ParamOut=time_series(Param)
    4343
    44 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName
     44%% set the input elements needed on the GUI series when the action is selected in the menu ActionName or InputTable refreshed
    4545if isstruct(Param) && isequal(Param.Action.RUN,0)
    4646    ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
     
    5050    ParamOut.FieldName='two';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    5151    ParamOut.FieldTransform = 'on';%can use a transform function
     52    ParamOut.TransformPath=fullfile(fileparts(which('uvmat')),'transform_field');% path to transform functions (needed for compilation only)
    5253    ParamOut.ProjObject='on';%can use projection object(option 'off'/'on',
    5354    ParamOut.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
     
    7172end
    7273
    73 ParamOut=Param; %default output
     74ParamOut=[]; %default output
    7475OutputDir=[Param.OutputSubDir Param.OutputDirExt];
    7576
     
    8990% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
    9091%%%%%%%%%%%%
    91 NbSlice=1;%default
    92 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
    93     NbSlice=Param.IndexRange.NbSlice;
    94 end
     92% NbSlice=1;%default
     93% if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
     94%     NbSlice=Param.IndexRange.NbSlice;
     95% end
    9596nbview=numel(i1_series);%number of input file series (lines in InputTable)
    96 nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
     97nbfield_j=size(j1_series{1},1); %nb of fields for the j index (bursts or volume slices)
    9798nbfield_i=size(i1_series{1},2); %nb of fields for the i index
    9899nbfield=nbfield_j*nbfield_i; %total number of fields
    99 nbfield_i=floor(nbfield/NbSlice);%total number of  indexes in a slice (adjusted to an integer number of slices)
    100 nbfield=nbfield_i*NbSlice; %total number of fields after adjustement
    101100
    102101%determine the file type on each line from the first input file
     
    153152end
    154153NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series
    155 if checkrun==1
    156     return % stop here for input checks
    157 end
    158154
    159155%% Set field names and velocity types
     
    419415
    420416%name of result file
    421 OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]);
     417OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),j1_series{1}(1),j1_series{1}(end));
    422418errormsg=struct2nc(OutputFile,DataOut); %save result file
    423419if isempty(errormsg)
  • trunk/src/set_object.m

    r591 r606  
    213213if ~isempty(hseries)
    214214    hhseries=guidata(hseries);
    215     set(hhseries.CheckObject,'Value',0)
    216     set(hhseries.CheckObject,'BackgroundColor',[0 1 0])%put unactivated buttons to green
     215    set(hhseries.ViewObject,'Value',0)
    217216end
    218217
  • trunk/src/uvmat.m

    r601 r606  
    341341    oldfile=get(handles.RootPath,'UserData');
    342342end
    343 [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',oldfile);
    344 if ~ischar(FileName),return,end %abandon if the browser is cancelled
    345 fileinput=[PathName FileName];%complete file name
     343hfig=uigetfile_uvmat('file browser',fileparts(oldfile));
     344uiwait(hfig);
     345if ishandle(hfig) % stop if browser closed without selection
     346    fileinput=get(hfig,'UserData');% retrieve the input file selection
     347    delete(hfig)
     348    % display the selected field and related information
     349    display_file_name(handles,fileinput)
     350end
     351
     352%
     353%
     354%
     355% [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',oldfile);
     356% if ~ischar(FileName),return,end %abandon if the browser is cancelled
     357% fileinput=[PathName FileName];%complete file name
    346358
    347359%% display the selected field and related information
    348 display_file_name( handles,fileinput)
     360% display_file_name( handles,fileinput)
    349361
    350362% -----------------------------------------------------------------------
     
    26732685    for imap=1:numel(IndexObj)
    26742686        iobj=IndexObj(imap);
     2687        if numel(UvData.Object)<iobj
     2688            break
     2689        end
    26752690        [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
    26762691        if ~isempty(errormsg)
Note: See TracChangeset for help on using the changeset viewer.