Changeset 477 for trunk/src/series.m


Ignore:
Timestamp:
Jun 26, 2012, 8:40:09 AM (9 years ago)
Author:
sommeria
Message:

various bugs repaired.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r476 r477  
    767767update_mode(handles,i1_series,i2_series,j1_series,j2_series,time)
    768768
    769 
    770 %% display the set of existing files as an image
    771 set(handles.waitbar_frame,'Units','pixels')
    772 pos=get(handles.waitbar_frame,'Position');
    773 xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices
    774 yima=0.5:pos(4)-0.5;
    775 [XIma,YIma]=meshgrid(xima,yima);
    776 nb_i=size(i1_series,1);
    777 nb_j=size(i1_series,2);
    778 ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i;
    779 ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j;
    780 [Ind_i,Ind_j]=meshgrid(ind_i,ind_j);
    781 CData=zeros([size(XIma) 3]);
    782 file_ima=double((i1_series(:,:,1)>0)');
    783 if numel(file_ima)>=2
    784 if size(file_ima,1)==1
    785     CLine=interp1(ind_i,file_ima,xima,'nearest');
    786     CData(:,:,2)=ones(size(yima'))*CLine;
    787 else
    788     CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest');
    789 end
    790 set(handles.waitbar_frame,'CData',CData)
    791 end
    792 set(handles.waitbar_frame,'Units','normalized')
    793 
    794 
    795769%% update the series info in 'UserData'
    796770SeriesData=get(handles.series,'UserData');
     
    812786end
    813787
     788%% display the set of existing files as an image
     789set(handles.FileStatus,'Units','pixels')
     790Position=get(handles.FileStatus,'Position');
     791set(handles.FileStatus,'Units','normalized')
     792xI=0.5:Position(3)-0.5;
     793nbview=numel(SeriesData.i1_series);
     794for iview=1:nbview
     795    index_min(iview)=min(find(SeriesData.i1_series{iview}(2:end,2:end,1)>0));
     796    index_max(iview)=max(find(SeriesData.i1_series{iview}(2:end,2:end,1)>0));
     797end
     798index_min=min(index_min);
     799index_max=max(index_max);
     800range_index=index_max-index_min+1;
     801scale_y=Position(4)/nbview;
     802scale_x=Position(3)/range_index;
     803x=(0.5:range_index-0.5)*Position(3)/range_index;
     804% y=(0.5:nbview-0.5)*Position(4)/nbview;
     805range_y=max(1,floor(Position(4)/nbview));
     806CData=zeros(nbview*range_y,Position(3));
     807for iview=1:nbview
     808    ind_y=1+(iview-1)*range_y:iview*range_y;
     809    LineData=zeros(1,range_index);
     810    x_index=find(SeriesData.i1_series{iview}(2:end,2:end,1)>0)-index_min+1;
     811    LineData(x_index)=1;
     812    LineData=interp1(x,LineData,xI,'nearest');
     813    CData(ind_y,:)=ones(size(ind_y'))*LineData;
     814end
     815CData=cat(3,zeros(size(CData)),CData,zeros(size(CData)));
     816set(handles.FileStatus,'CData',CData);
     817
     818%
     819%
     820% xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices
     821% yima=0.5:pos(4)-0.5;
     822% [XIma,YIma]=meshgrid(xima,yima);
     823% nb_i=size(i1_series,1);
     824% nb_j=size(i1_series,2);
     825% ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i;
     826% ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j;
     827% [Ind_i,Ind_j]=meshgrid(ind_i,ind_j);
     828% CData=zeros([size(XIma) 3]);%black color
     829% file_ima=double((i1_series(:,:,1)>0)');
     830% if numel(file_ima)>=2
     831% if size(file_ima,1)==1
     832%     CLine=interp1(ind_i,file_ima,xima,'nearest');
     833%     CData(:,:,2)=ones(size(yima'))*CLine;
     834% else
     835%     CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest');
     836% end
     837% set(handles.FileStatus,'CData',CData)
     838% end
     839% set(handles.FileStatus,'Units','normalized')
     840
     841
    814842%% enable field and veltype menus, in accordance with the current action
    815843ActionName_Callback([],[], handles)
     
    829857    set(handles.PairString,'Visible','off')
    830858end
     859
     860%% set length of waitbar
     861displ_time(handles)
     862
    831863
    832864% %% set default options in menu 'Fields'%% TODO: check VelType
     
    9871019displ_time(handles);
    9881020
     1021
    9891022%------------------------------------------------------------------------
    9901023% ---- find the times corresponding to the first and last indices of a series
     
    9941027ref_i=[str2num(get(handles.num_first_i,'String')) str2num(get(handles.num_last_i,'String'))];
    9951028ref_j=[str2num(get(handles.num_first_j,'String')) str2num(get(handles.num_last_j,'String'))];
    996 % last_i=str2num(get(handles.num_last_i,'String'));
    997 % last_j=str2num(get(handles.num_last_j,'String'));
    9981029TimeTable=get(handles.TimeTable,'Data');
    9991030Pairs=get(handles.PairString,'Data');
     
    10401071set(handles.TimeTable,'Data',TimeTable)
    10411072
     1073%% set the waitbar position with respect to the min and max in the series
     1074% for iview=1:numel(SeriesData.i1_series)
     1075% [tild,index_min(iview)]=min(SeriesData.i1_series{iview}(SeriesData.i1_series{iview}>0));
     1076% [tild,index_max(iview)]=max(SeriesData.i1_series{iview}(SeriesData.i1_series{iview}>0));
     1077% end
     1078for iview=1:numel(SeriesData.i1_series)
     1079    index_min(iview)=min(find(SeriesData.i1_series{iview}(2:end,2:end,1)>0));
     1080    index_max(iview)=max(find(SeriesData.i1_series{iview}(2:end,2:end,1)>0));
     1081end
     1082[index_min,iview_min]=min(index_min);
     1083[index_max,iview_max]=min(index_max);
     1084index_first=(ref_i(1)-1)*(size(SeriesData.i1_series{iview_min},2)-1)+ref_j(1);
     1085index_last=(ref_i(2)-1)*(size(SeriesData.i1_series{iview_max},2)-1)+ref_j(2);
     1086range=index_max-index_min+1;
     1087coeff_min=(index_first-index_min)/range;
     1088coeff_max=(index_last-index_min+1)/range;
     1089Position=get(handles.Waitbar,'Position');
     1090Position_status=get(handles.FileStatus,'Position');
     1091Position(1)=coeff_min*Position_status(3)+Position_status(1);
     1092Position(3)=Position_status(3)*(coeff_max-coeff_min);
     1093set(handles.Waitbar,'Position',Position)
     1094update_waitbar(handles.Waitbar,0)
     1095
    10421096%------------------------------------------------------------------------
    10431097% --- Executes when selected cell(s) is changed in PairString.
     
    13351389            Series=h_fun(Series);% no background in the absence of output file
    13361390        else
    1337         % update the xml file after interactive input with the function
    1338         Series.Specific='?';
    1339         Series=h_fun(Series);
    1340         t=struct2xml(Series);
    1341         t=set(t,1,'name','Series');
    1342         save(t,filexml);
    1343         path_uvmat=fileparts(which('uvmat'));
    1344        
    1345         filename_bat=regexprep(filexml,'.xml$','.bat');
    1346         [fid,message]=fopen(filename_bat,'w');
    1347         if isequal(fid,-1)
    1348             msgbox_uvmat('ERROR', ['creation of .bat file: ' message]);
    1349             return
     1391            % update the xml file after interactive input with the function
     1392            Series.Specific='?';
     1393            Series=h_fun(Series);
     1394            t=struct2xml(Series);
     1395            t=set(t,1,'name','Series');
     1396            save(t,filexml);
     1397            path_uvmat=fileparts(which('uvmat'));
     1398           
     1399            filename_bat=regexprep(filexml,'.xml$','.bat');
     1400            [fid,message]=fopen(filename_bat,'w');
     1401            if isequal(fid,-1)
     1402                msgbox_uvmat('ERROR', ['creation of .bat file: ' message]);
     1403                return
     1404            end
     1405            path_fct=get(handles.ActionPath,'String');
     1406            filelog=regexprep(filexml,'.xml$','.log');
     1407            text_matlabscript=[...
     1408                '#!/bin/bash \n'...
     1409                '. /etc/sysprofile \n'...
     1410                'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'...
     1411                'addpath(''' path_uvmat '''); \n'...
     1412                'addpath(''' Series.Action.ActionPath '''); \n'...
     1413                '' Series.Action.ActionName  '( ''' filexml '''); \n'...
     1414                'exit \n'...
     1415                'END_MATLAB \n'];
     1416            fprintf(fid,text_matlabscript);
     1417            fclose(fid);
     1418            if isunix
     1419                system(['chmod +x ' filename_bat]);% set the file to executable
     1420                system(['. ' filename_bat ' &']);%execute fct
     1421            else
     1422                system(filename_bat);
     1423            end
    13501424        end
    1351         path_fct=get(handles.ActionPath,'String');
    1352         filelog=regexprep(filexml,'.xml$','.log');
    1353         text_matlabscript=[...
    1354             '#!/bin/bash \n'...
    1355             '. /etc/sysprofile \n'...
    1356             'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'...
    1357             'addpath(''' path_uvmat '''); \n'...
    1358             'addpath(''' Series.Action.ActionPath '''); \n'...
    1359             '' Series.Action.ActionName  '( ''' filexml '''); \n'...
    1360             'exit \n'...
    1361             'END_MATLAB \n'];
    1362         fprintf(fid,text_matlabscript);
    1363         fclose(fid);
    1364         if isunix
    1365             system(['chmod +x ' filename_bat]);% set the file to executable
    1366             system(['. ' filename_bat ' &']);%execute fct
    1367         else
    1368             system(filename_bat);
    1369         end
    1370         end
     1425        update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate lounching is finished
    13711426end
    13721427
     
    16211676PathName=list_path{index_ACTION};%current recorded path
    16221677set(handles.ActionPath,'String',PathName); %show the path to the senlected function
     1678
     1679%reinitialise the waitbar
     1680update_waitbar(handles.Waitbar,0)
    16231681
    16241682%default setting for the visibility of the GUI elements
     
    21122170
    21132171%% display the set of existing files as an image
    2114 set(handles.waitbar_frame,'Units','pixels')
    2115 pos=get(handles.waitbar_frame,'Position');
     2172set(handles.Waitbar,'Units','pixels')
     2173pos=get(handles.Waitbar,'Position');
    21162174xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices
    21172175yima=0.5:pos(4)-0.5;
     
    21312189    CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest');
    21322190end
    2133 set(handles.waitbar_frame,'CData',CData)
    2134 end
    2135 set(handles.waitbar_frame,'Units','normalized')
     2191set(handles.Waitbar,'CData',CData)
     2192end
     2193set(handles.Waitbar,'Units','normalized')
    21362194
    21372195%% enable field and veltype menus
Note: See TracChangeset for help on using the changeset viewer.