Changeset 41 for trunk/src/series.m


Ignore:
Timestamp:
Mar 10, 2010, 11:03:36 AM (11 years ago)
Author:
sommeria
Message:

-relabel_i_j: improve the question dlg box for image transform
-aver_stat,time_series,merge_proj: include modification of field transform and call of set_object.
-series: introduce a browser for set_object
-ima2vol: create volume images (png images of a slice concacened along y) for PIV 3D
-set_object: suppress TITLE, introduce Tooltip helps for parameters
-civ: fixed bug on BATCH sequences

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r39 r41  
    12951295        end
    12961296end
    1297 %---------------------------------------------------
     1297
     1298%------------------------------------------------------------------------
    12981299% --- Executes on button press in RUN.
    1299 %------------------------------------------------------
    13001300function RUN_Callback(hObject, eventdata, handles)
    1301 
     1301%------------------------------------------------------------------------
    13021302%read root name and field type
    13031303set(handles.RUN,'BusyAction','queue');
     
    13111311end
    13121312SeriesData=get(handles.figure1,'UserData');
    1313 if isfield(SeriesData,'sethandles')
    1314     if iscell(SeriesData.sethandles)
    1315         Series.sethandles=SeriesData.sethandles{1};
    1316     else
    1317         Series.sethandles=SeriesData.sethandles;%retrieve the handles of the set_object interface (to define projection objects)
    1318     end
    1319 end
     1313% if isfield(SeriesData,'sethandles')
     1314%     if iscell(SeriesData.sethandles)
     1315%         Series.sethandles=SeriesData.sethandles{1};
     1316%     else
     1317%         Series.sethandles=SeriesData.sethandles;%retrieve the handles of the set_object interface (to define projection objects)
     1318%     end
     1319% end
    13201320
    13211321%reinitiate waitbar position
     
    13581358Series.CoordType='';%default
    13591359if isequal(menu_coord_state,'on')
    1360     menu_coord=get(handles.transform_fct,'String');
     1360%     menu_coord=get(handles.transform_fct,'String');
    13611361    menu_index=get(handles.transform_fct,'Value');
    1362     Series.CoordType=menu_coord{menu_index};
    1363 end
    1364 Series.hseries=get(hObject,'Parent');
    1365 if isequal(get(handles.ParamVal,'Visible'),'on')
    1366     ParamKey=get(handles.ParamKey,'String');
    1367     if ischar(ParamKey)
    1368         ParamKey{1}=ParamKey;
    1369     end
    1370     ParamString=get(handles.ParamVal,'String');
    1371     if ischar(ParamString)
    1372         for ilist=1:size(ParamString,1)
    1373             ParamVal{ilist}=ParamString(ilist,:);
    1374         end
    1375     else
    1376         ParamVal=ParamString;
    1377     end   
    1378 end
     1362    transform_list=get(handles.transform_fct,'UserData');
     1363    Series.transform_fct=transform_list{menu_index};% transform function handles
     1364end
     1365Series.hseries=handles.figure1; % handles to the series GUI
     1366% if isequal(get(handles.ParamVal,'Visible'),'on')
     1367%     ParamKey=get(handles.ParamKey,'String');
     1368%     if ischar(ParamKey)
     1369%         ParamKey{1}=ParamKey;
     1370%     end
     1371%     ParamString=get(handles.ParamVal,'String');
     1372%     if ischar(ParamString)
     1373%         for ilist=1:size(ParamString,1)
     1374%             ParamVal{ilist}=ParamString(ilist,:);
     1375%         end
     1376%     else
     1377%         ParamVal=ParamString;
     1378%     end   
     1379% end
    13791380
    13801381%read the set of field numbers
     
    14821483end
    14831484
    1484 % RUN RUN'
     1485% defining the ACTION function handle
    14851486path_series=which('series');
    14861487list_path=get(handles.ACTION,'UserData');
     
    14891490if ~isequal(fct_path,path_series)
    14901491    eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION
    1491     if ~isequal(spath,fct_path)& exist(fct_path,'dir')
     1492    if ~exist(fct_path,'dir')
     1493        msgbox_uvmat('ERROR',['The prescibed function path ' fct_path ' does not exist'])
     1494        return
     1495    end
     1496    if ~isequal(spath,fct_path)
    14921497        addpath(fct_path)% add the prescribed path if not the current one
    14931498    end
    14941499end
    1495 % fct_path
    1496 eval(['h_fun=@' action ';'])
     1500eval(['h_fun=@' action ';'])%create a function handle for ACTION
    14971501if ~isequal(fct_path,path_series)
    14981502        rmpath(fct_path)% add the prescribed path if not the current one   
    14991503end
    15001504
     1505% RUN ACTION
    15011506Series.Action=action;%name of the processing programme
    15021507set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
    15031508drawnow
    15041509if length(RootPath)>1
    1505 %    feval(action,num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series);
    15061510    h_fun(num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series);
    15071511else
    15081512    h_fun(num_i1,num_i2,num_j1,num_j2,Series);
    1509 %     feval(action,num_i1,num_i2,num_j1,num_j2,Series);
    15101513end
    15111514set(handles.RUN,'BackgroundColor',[1 0 0])
     
    15251528% saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER  .xml)
    15261529
    1527 %----------------------------------------------------
     1530%------------------------------------------------------------------------
    15281531function STOP_Callback(hObject, eventdata, handles)
     1532%------------------------------------------------------------------------
    15291533set(handles.RUN, 'BusyAction','cancel')
    15301534set(handles.RUN,'BackgroundColor',[1 0 0])
    15311535
    1532 %----------------------------------------------
    1533 
    1534 %----------------------------------------------------
     1536
     1537%------------------------------------------------------------------------
    15351538function first_i_Callback(hObject, eventdata, handles)
     1539%------------------------------------------------------------------------
    15361540last_i_Callback(hObject, eventdata, handles)
    15371541
    1538 %----------------------------------------------
     1542%------------------------------------------------------------------------
    15391543function last_i_Callback(hObject, eventdata, handles)
     1544%------------------------------------------------------------------------
    15401545%     hseries=get(handles.last_i,'parent');
    15411546first_i=str2num(get(handles.first_i,'String'));
     
    15501555displ_time(handles,SeriesData.Time{1});
    15511556
    1552 %-------------------------------------------------------
     1557%------------------------------------------------------------------------
    15531558function first_j_Callback(hObject, eventdata, handles)
     1559%------------------------------------------------------------------------
    15541560 last_j_Callback(hObject, eventdata, handles)
    15551561
    1556 %-------------------------------------------------------
     1562%------------------------------------------------------------------------
    15571563function last_j_Callback(hObject, eventdata, handles)
    1558    % hseries=get(handles.last_i,'parent');
     1564%------------------------------------------------------------------------
    15591565first_j=str2num(get(handles.first_j,'String'));
    15601566last_j=str2num(get(handles.last_j,'String'));
    15611567ref_j=ceil((first_j+last_j)/2);
    15621568set(handles.ref_j,'String', num2str(ref_j))
    1563 
    15641569ref_j_Callback(hObject, eventdata, handles)
    15651570SeriesData=get(handles.figure1,'UserData');
     
    15701575
    15711576
    1572 
    1573 
    1574 %-------------------------------------------------------
     1577%------------------------------------------------------------------------
    15751578function ref_i_Callback(hObject, eventdata, handles)
     1579%------------------------------------------------------------------------
    15761580mode_list=get(handles.mode,'String');
    15771581mode_value=get(handles.mode,'Value');
     
    15931597end
    15941598
    1595 %----------------------------------------------------
     1599%------------------------------------------------------------------------
    15961600function ref_j_Callback(hObject, eventdata, handles)
     1601%------------------------------------------------------------------------
    15971602mode_list=get(handles.mode,'String');
    15981603mode_value=get(handles.mode,'Value');
     
    16111616end
    16121617
    1613 %----------------------------------------------------
     1618%------------------------------------------------------------------------
    16141619% --- Executes on selection change in ACTION.
    16151620function ACTION_Callback(hObject, eventdata, handles)
     1621%------------------------------------------------------------------------
    16161622global nb_builtin
    16171623list_ACTION=get(handles.ACTION,'String');% list menu fields
     
    17101716set(handles.transform_fct,'Enable','off')
    17111717%set the displayed GUI item needed for input parameters
    1712 %list_input=feval(ACTION);% input list asked by the selected function
    17131718if ~isequal(path_series,PathName)
    17141719    addpath(PathName)
     
    17201725
    17211726varargout=h_function();
    1722 %varargout=feval(ACTION);% input list asked by the selected function
    17231727Param_list={};
    1724 % RootPath=get(handles.RootPath,'String');
    1725 % RootFile=get(handles.RootFile,'String');
    17261728
    17271729%nb_series=length(RootFile);
     
    18391841end
    18401842
    1841 %-------------------------------------------------------------------
     1843%------------------------------------------------------------------------
    18421844% --- Executes on selection change in FieldMenu.
    1843 %-------------------------------------------------------------------
    18441845function FieldMenu_Callback(hObject, eventdata, handles)
    1845 
     1846%------------------------------------------------------------------------
    18461847field_str=get(handles.FieldMenu,'String');
    18471848field_index=get(handles.FieldMenu,'Value');
     
    18681869end
    18691870
    1870 %------------------------------------------------------
     1871%------------------------------------------------------------------------
    18711872% --- Executes on selection change in FieldMenu_1.
    1872 %-----------------------------------------------------
    18731873function FieldMenu_1_Callback(hObject, eventdata, handles)
     1874%------------------------------------------------------------------------
    18741875field_str=get(handles.FieldMenu_1,'String');
    18751876field_index=get(handles.FieldMenu_1,'Value');
     
    18961897     update_menu(handles.FieldMenu_1,scalar)
    18971898end   
    1898 
    1899 
    1900 % %group the variables (fields of 'FieldData') in cells of variables with the same dimensions
    1901 % %%%%%%%%%%%%%%%%%%%%%%% Function independante maintenant
    1902 % %-----------------------------------------------------------------
    1903 % [CellVarIndex,NbDim,VarTypeCell]=find_field_indices(Data{1});
    1904 % %LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
    1905 % % CellVarIndex=cells of variable index arrays
    1906 % ivar_new=0; % index of the current variable in the projected field
    1907 % icoord=0;
    1908 % for icell=1:length(CellVarIndex)
    1909 %     if NbDim(icell)==1
    1910 %         continue
    1911 %     end
    1912 %     VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list FieldData.ListVarName
    1913 %     VarType=VarTypeCell{icell};
    1914 %     ivar_X=VarType.coord_x;
    1915 %     ivar_Y=VarType.coord_y;
    1916 %     ivar_FF=VarType.errorflag;
    1917 %     if isempty(ivar_X)
    1918 %         test_grid=1;%test for input data on regular grid (e.g. image)coordinates
    1919 %     else
    1920 %         if length(ivar_Y)~=1
    1921 %                 warndlg_uvmat('y coordinate missing in proj_field.m','ERROR')
    1922 %                 return
    1923 %         end
    1924 %         test_grid=0;
    1925 %     end
    1926 % %    DimIndices=Data{1}.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell)
    1927 %     %case of input fields with unstructured coordinates
    1928 %     if ~test_grid
    1929 %         for ivar=VarIndex
    1930 %             VarName=MergeData.ListVarName{ivar};
    1931 %             for iview=1:nbview
    1932 %                 eval(['MergeData.' VarName '=[MergeData.' VarName '; Data{iview}.' VarName ';'])
    1933 %             end
    1934 %         end
    1935 %     %case of fields defined on a structured  grid
    1936 %     else 
    1937 % %        DimValue=MergeData.DimValue(DimIndices);%set of dimension values
    1938 %         testFF=0;
    1939 %         for iview=2:nbview
    1940 % %             if ~isequal(DimValue,Data{iview}.DimValue(DimIndices))
    1941 % %                 MergeData.Txt='ERROR: attempt at merging structured fields with different sizes';
    1942 % %                 return
    1943 % %             end
    1944 %             for ivar=VarIndex
    1945 %                 VarName=MergeData.ListVarName{ivar};
    1946 %                 if isfield(MergeData,'VarAttribute')
    1947 %                     if length(MergeData.VarAttribute)>=ivar && isfield(MergeData.VarAttribute{ivar},'Role') && isequal(MergeData.VarAttribute{ivar}.Role,'errorflag')
    1948 %                         testFF=1;
    1949 %                     end
    1950 %                 end
    1951 %                 eval(['MergeData.' VarName '=MergeData.' VarName '+ Data{iview}.' VarName ';'])
    1952 %             end
    1953 %         end
    1954 %         if testFF
    1955 %             nbaver=nbview-MergeData.FF;
    1956 %             indgood=find(nbaver>0);
    1957 %             for ivar=VarIndex
    1958 %                 VarName=MergeData.ListVarName{ivar};
    1959 %                 eval(['MergeData.' VarName '(indgood)=double(MergeData.' VarName '(indgood))./nbaver(indgood);'])
    1960 %             end
    1961 %         else
    1962 %             for ivar=VarIndex
    1963 %                 VarName=MergeData.ListVarName{ivar};
    1964 %                 eval(['MergeData.' VarName '=double(MergeData.' VarName ')./nbview;'])
    1965 %             end   
    1966 %         end
    1967 %     end
    1968 % end
    1969 %     
    19701899
    19711900%-----------------------------
     
    20451974end
    20461975
    2047  
    2048 %-----------------------------------------------------------
    2049 % find the times corresponding to the first and last indices of a series
    2050 %
     1976%------------------------------------------------------------------------
     1977% ---- find the times corresponding to the first and last indices of a series
    20511978function displ_time(handles,times)
     1979%------------------------------------------------------------------------
    20521980hseries=get(handles.last_i,'parent');
    20531981SeriesData=get(hseries,'UserData');%
     
    21462074set(handles.time_last,'String',time_last_cell);
    21472075
    2148 %--------------------------------------------------------------------
    2149 % --- Executes on selection change in VelTypeMenu.
    2150 function VelTypeMenu_Callback(hObject, eventdata, handles)
    2151 % VelTypeList=get(handles.VelTypeMenu,'String');
    2152 % VelTypeIndex=get(handles.VelTypeMenu,'Value');
    2153 % VelTypeCell=get(handles.VelType,'String');
    2154 % VelTypeCell{1}=VelTypeList{VelTypeIndex};
    2155 % set(handles.VelType,'String',VelTypeCell)
    2156 
    2157 
    2158 %--------------------------------------------------------------------
     2076%------------------------------------------------------------------------
    21592077% --- Executes on button press in GetObject.
    21602078function GetObject_Callback(hObject, eventdata, handles)
     2079%------------------------------------------------------------------------
    21612080hseries=get(handles.GetObject,'parent');
    21622081SeriesData=get(hseries,'UserData');
     
    21692088         [SeriesData.hset_object,SeriesData.sethandles]=set_object(DataInit); %open the set_object interface
    21702089     else
    2171          DataInit.TITLE='POINTS';%default option
    2172          [SeriesData.hset_object,SeriesData.sethandles]=set_object(DataInit); %open the set_object interface
     2090         %get the object file
     2091         defaultname=get(handles.RootPath,'String');
     2092        [FileName, PathName, filterindex] = uigetfile( ...
     2093       {'*.xml;*.mat', ' (*.xml,*.mat)';
     2094       '*.xml',  '.xml files '; ...
     2095        '*.mat',  '.mat matlab files '}, ...
     2096        'Pick a file',defaultname{1});
     2097        fileinput=[PathName FileName];%complete file name
     2098        testblank=findstr(fileinput,' ');%look for blanks
     2099        if ~isempty(testblank)
     2100            msgbox_uvmat('ERROR','forbidden input file name: contain blanks')
     2101            return
     2102        end
     2103        sizf=size(fileinput);
     2104        if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
     2105        %read the file
     2106        t=xmltree(fileinput);
     2107        data=convert(t);
     2108        if ~isfield(data,'Style')
     2109             data.Style='points';
     2110        end
     2111        if ~isfield(data,'ProjMode')
     2112             data.ProjMode='projection';
     2113        end
     2114        transform_menu=get(handles.transform_fct,'String');
     2115        ichoice=get(handles.transform_fct,'Value');
     2116        if isequal(transform_menu{ichoice},'px');
     2117            data.CoordType='px';
     2118        else
     2119            data.CoordType='phys';
     2120        end
     2121        data.desable_plot=1;
     2122        [SeriesData.hset_object,SeriesData.sethandles]=set_object(data);% call the set_object interface
    21732123     end
    21742124else
    21752125    set(handles.GetObject,'BackgroundColor',[0 1 0])%put activated buttons to green
    2176     if isfield(SeriesData,'hset_object')&& ishandle(SeriesData.hset_object)
    2177         close(SeriesData.hset_object)
    2178     end
     2126%     if isfield(SeriesData,'hset_object')&& ishandle(SeriesData.hset_object)
     2127%         close(SeriesData.hset_object)
     2128%     end
    21792129end
    21802130set(hseries,'UserData',SeriesData)
     
    21842134value=get(handles.GetMask,'Value');
    21852135if value
    2186     errordlg('not implemented yet')
     2136    msgbox_uvmat('ERROR','not implemented yet')
    21872137end
    21882138%--------------------------------------------------------------
    21892139
    2190 %--------------------------------------------------------------------------
     2140%-------------------------------------------------------------------
    21912141%'uv_ncbrowser': interactively calls the netcdf file browser 'get_field.m'
    21922142function ncbrowser_uvmat(hObject, eventdata)
     2143%-------------------------------------------------------------------
    21932144     bla=get(gcbo,'String');
    21942145     ind=get(gcbo,'Value');
     
    21982149     get_field(filename)
    21992150
    2200 % --------------------------------------------------------------------
     2151% ------------------------------------------------------------------
    22012152function MenuHelp_Callback(hObject, eventdata, handles)
    2202 
     2153%-------------------------------------------------------------------
    22032154path_to_uvmat=which ('uvmat');% check the path of uvmat
    22042155pathelp=fileparts(path_to_uvmat);
     
    22102161end
    22112162
    2212 
     2163%-------------------------------------------------------------------
    22132164% --- Executes on selection change in transform_fct.
    22142165function transform_fct_Callback(hObject, eventdata, handles)
    2215 
     2166%-------------------------------------------------------------------
    22162167global nb_transform
    22172168
Note: See TracChangeset for help on using the changeset viewer.