Changeset 421 for trunk


Ignore:
Timestamp:
May 14, 2012, 7:03:14 AM (12 years ago)
Author:
sommeria
Message:

bugs corrections and improvements following tutorial presentation

Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r419 r421  
    922922if isempty(hfig)
    923923    hfig=figure('DeleteFcn',@stop_status);
     924    set(hfig,'MenuBar','none')% suppress the menu bar
     925    set(hfig,'NumberTitle','off')%suppress the fig number in the title
    924926    set(hfig,'name','civ_status')
    925      uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', {'open_uvmat'},'tag','list');
     927    set(hfig,'tag','civ_status')
     928    set(hfig,'UserData',civ_files)
     929    hlist= uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', {'open_uvmat'},'tag','list');
    926930    uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...');
    927931    uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
    928     uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','OK','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI);
     932    uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI);
     933    hrefresh=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@refresh_GUI);
    929934    BarPosition=[0.05 0.81 0.01 0.05];
    930     hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar');
    931     drawnow
    932 end
     935    uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar');
     936    drawnow
     937end
     938set(hrefresh,'UserData',option_civ)
     939        filepath=fileparts(civ_files{1});
     940set(hlist,'UserData',fileparts(filepath))
     941refresh_GUI(hrefresh,[])
     942
     943%------------------------------------------------------------------------   
     944% launched by refreshing the status figure
     945function refresh_GUI(hObject, eventdata)
     946%------------------------------------------------------------------------
    933947Tabchar={};
     948BarPosition=[0.05 0.81 0.01 0.05];
     949hfig=get(hObject,'parent');
     950civ_files=get(hfig,'UserData');
     951        [filepath,filename,ext]=fileparts(civ_files{1});
     952        [tild,SubDir,extdir]=fileparts(filepath);
     953        SubDir=[SubDir extdir];
     954option_civ=get(hObject,'UserData');
    934955nbfiles=numel(civ_files);
    935956count=0;
    936957testrecent=0;
    937 while count<nbfiles
     958% while count<nbfiles
    938959    count=0;
    939960    datnum=zeros(1,nbfiles);
     
    976997            count=count+1;
    977998        end
    978         [rr,filename,ext]=fileparts(civ_files{ifile});
    979         Tabchar{ifile,1}=[fullfile([SubDir extdir],filename) ext  '...' option_str];
     999        [filepath,filename,ext]=fileparts(civ_files{ifile});
     1000        Tabchar{ifile,1}=[fullfile(SubDir,filename) ext  '...' option_str];
    9801001    end
    9811002    datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
     
    9901011        [first,ind]=min(datnum);
    9911012        [last,indlast]=max(datnum);
    992         if test_new
    993             message='existing file status, no processing launched yet';
    994         else
     1013%         if test_new
     1014%             message='existing file status, no processing launched yet';
     1015%         else
    9951016        message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
    9961017            ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
    997         end
    998     end
    999     hfig=findobj(allchild(0),'name','civ_status');
    1000     if isempty(hfig)% the status list has been deleted
    1001         return
    1002     else
     1018%         end
     1019    end
     1020    %hfig=findobj(allchild(0),'name','civ_status');
     1021%     if isempty(hfig)% the status list has been deleted
     1022%         return
     1023%     else
    10031024        hlist=findobj(hfig,'tag','list');
    10041025        hmsgbox=findobj(hfig,'tag','msgbox');
     
    10061027        set(hlist,'String',Tabchar)
    10071028        set(hmsgbox,'String', message)
    1008         if count>0 && ~test_new
     1029        if count>0 %&& ~test_new
    10091030            BarPosition(3)=0.9*count/nbfiles;
    10101031            set(hwaitbar,'Position',BarPosition)
    10111032        end
    1012     end
    1013     set(hlist,'UserData',rootroot)
    1014     if count<10||(nbfiles-count)<10
    1015     pause(.5)% wait 0.5 seconds for next check
    1016     else
    1017         pause(10)% wait 10 seconds for next check
    1018     end
    1019 end
     1033%     end
     1034%     [root,filename,ext]=fileparts(civ_files{1});
     1035% [rootroot,SubDir,extdir]=fileparts(root);
     1036%
     1037%     set(hlist,'UserData',rootroot)
     1038%     if count<10||(nbfiles-count)<10
     1039%     pause(.5)% wait 0.5 seconds for next check
     1040%     else
     1041%         pause(10)% wait 10 seconds for next check
     1042%     end
     1043% end
     1044
     1045%------------------------------------------------------------------------   
     1046% launched by deleting the status figure
     1047function stop_status(hObject, eventdata)
     1048%------------------------------------------------------------------------
     1049hciv=findobj(allchild(0),'tag','civ');
     1050hhciv=guidata(hciv);
     1051set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ
     1052set(hhciv.status,'BackgroundColor',[0 1 0])
     1053
     1054%------------------------------------------------------------------------   
     1055% launched by pressing OK on the status figure
     1056function close_GUI(hObject, eventdata)
     1057%------------------------------------------------------------------------
     1058    delete(gcbf)
     1059
    10201060
    10211061%------------------------------------------------------------------------
     
    11431183for bin_name=binary_list %loop on the list of binaries
    11441184    if isfield(Param.xml,bin_name{1})% bin_name{1} =current name in the list
    1145         if ~exist(Param.xml.(bin_name{1}),'file')%look for the full path if the file name has been defined with a relative path in PARAM.xml
     1185        if exist(Param.xml.(bin_name{1}),'file')
     1186            [path,name,ext]=fileparts(Param.xml.(bin_name{1}));
     1187            currentdir=pwd;
     1188            if exist(path,'dir')
     1189                cd(path);
     1190                binpath=pwd;%path of the binary
     1191                Param.xml.(bin_name{1})=fullfile(binpath,[name ext]);
     1192                cd(currentdir)
     1193            else
     1194                errormsg=['path ' path ' for binaries defined in PARAM.xml does not exist'];
     1195                return
     1196            end
     1197        else  %look for the full path if the file name has been defined with a relative path in PARAM.xm
    11461198            fullname=fullfile(path_civ,Param.xml.(bin_name{1}));
    11471199            if exist(fullname,'file')
     
    11511203                return
    11521204            end
    1153         else
    1154             [path,name,ext]=fileparts(Param.xml.(bin_name{1}));
    1155             currentdir=pwd;
    1156             cd(path);
    1157             binpath=pwd;%path of the binary
    1158             Param.xml.(bin_name{1})=fullfile(binpath,[name ext]);
    1159             cd(currentdir);
    1160         end
    1161        
     1205        end
    11621206    end
    11631207end
     
    32153259% end
    32163260
    3217 %------------------------------------------------------------------------   
    3218 % launched by pressing OK on the status figure
    3219 function close_GUI(hObject, eventdata)
    3220 %------------------------------------------------------------------------
    3221     delete(gcbf)
    3222    
    3223 %------------------------------------------------------------------------   
    3224 % launched by deleting the status figure
    3225 function stop_status(hObject, eventdata)
    3226 %------------------------------------------------------------------------
    3227 hciv=findobj(allchild(0),'tag','civ');
    3228 hhciv=guidata(hciv);
    3229 set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ
    3230 set(hhciv.status,'BackgroundColor',[0 1 0])
    3231 
    32323261
    32333262%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  • trunk/src/find_file_series.m

    r399 r421  
    222222        ref_ij=ref_i_list*max_j+ref_j_list; % ordered by index i, then by j for a given i.
    223223    end
    224     [tild,ifile_min]=min(ref_ij(ref_ij>0));
     224    %[tild,ifile_min]=min(ref_ij(ref_ij>0));
     225    ifile_min=find(ref_ij>0 , 1);
    225226    if isempty(ifile_min)
    226227        %         RootPath='';
  • trunk/src/msgbox_uvmat.m

    r296 r421  
    3838
    3939% --- Executes just before msgbox_uvmat is made visible.
    40 function msgbox_uvmat_OpeningFcn(hObject, eventdata, handles,title,display,default_answer,Position)
     40function msgbox_uvmat_OpeningFcn(hObject, eventdata, handles,title,display_str,default_answer,Position)
    4141% This function has no output args, see OutputFcn.
    4242
     
    7474        case 'ERROR'
    7575            icontype='error';
     76            if exist('display_str','var')
     77                disp(display_str); %display the error message in the Matlab command window
     78            end
    7679        case 'WARNING'
    7780            icontype='warn';
     
    9295    end
    9396end
    94 if exist('display','var')
    95     set(handles.text1, 'String', display);
     97if exist('display_str','var')
     98    set(handles.text1, 'String', display_str);
    9699end
    97100% if testinputstring
  • trunk/src/nc2struct.m

    r404 r421  
    204204    if ~isempty(var_index)     
    205205        dim_index=find(flag_used);%list of netcdf dimensions indices corresponding to used dimensions
    206         ListDimName=ListDimNameNetcdf(dim_index);
    207         DimValue=dim_value(dim_index);
     206        Data.ListDimName=ListDimNameNetcdf(dim_index);
     207        Data.DimValue=dim_value(dim_index);
    208208    end
    209209   
  • trunk/src/plot_field.m

    r415 r421  
    5353%    .Scalar.CheckFixScal: =0 (default) lower and upper bounds of the scalar representation set to the min and max of the field
    5454%               =1 lower and upper bound imposed by .AMax and .MinA
    55 %    .Scalar.CheckBW= 1 black and white representation imposed, =0 by default.
     55%    .Scalar.CheckBW= 1: black and white representation imposed, =0 color imposed (color scale or rgb),
     56%                   =[]: automatic (B/W for integer positive scalars, color  else)
    5657%    .Scalar.CheckContours= 1: represent scalars by contour plots (Matlab function 'contour'); =0 by default
    5758%    .IncrA : contour interval
     
    214215    if isempty(index_2D)
    215216        plot_plane([],[],[],haxes);%removes images or vector plots if any
    216     else
     217    else  %plot 2D field
    217218        [tild,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),haxes,PlotParam,PosColorbar);
    218219        AxeData.NbDim=2;
     
    226227            plot_profile([],[],[],haxes);%
    227228        end
    228     else
     229    else %plot 1D field (usual graph y vs x)
    229230        Coordinates=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,PlotParam.Coordinates);%
    230231        if testzoomaxes
     
    717718   
    718719    %set the color map
    719     if isfield(PlotParam.Scalar,'CheckBW')
    720         BW=PlotParam.Scalar.CheckBW; %test for BW gray scale images
    721     else
     720    if isfield(PlotParam.Scalar,'CheckBW') && ~isempty(PlotParam.Scalar.CheckBW)
     721        BW=PlotParam.Scalar.CheckBW; %BW=0 color imposed, else gray scale imposed.
     722    else % BW imposed automatically chosen
    722723        BW=(siz==2) && (isa(A,'uint8')|| isa(A,'uint16'));% non color images represented in gray scale by default
    723     end
    724    
     724        PlotParamOut.Scalar.CheckBW=BW;
     725    end
    725726    %case of grey level images or contour plot
    726727    if siz==2
     
    11451146    xN=NaN*ones(size(xc));
    11461147    matx=[xc(:)-uc(:)/2 xc(:)+uc(:)/2 xN(:)]';
    1147     %     matx=[xc(:) xc(:)+uc(:) xN(:)]';
    11481148    matx=reshape(matx,1,3*n(2));
    11491149    maty=[yc(:)-vc(:)/2 yc(:)+vc(:)/2 xN(:)]';
    1150     %     maty=[yc(:) yc(:)+vc(:) xN(:)]';
    11511150    maty=reshape(maty,1,3*n(2));
    11521151   
     
    11651164    matyar=reshape(matyar,1,4*n(2));
    11661165    %draw the line or modify the existing ones
    1167     tri=reshape(1:3*length(uc),3,[])';   
     1166%     tri=reshape(1:3*length(uc),3,[])';   
    11681167    isn=isnan(colorlist(icolor,:));%test if color NaN
    11691168    if 2*icolor > sizh(1) %if icolor exceeds the number of existing ones
  • trunk/src/proj_field.m

    r408 r421  
    839839            ProjData.VarDimName=[ProjData.VarDimName {AXName}];
    840840            for ivar=VarIndex
    841                 VarName{ivar}=FieldData.ListVarName{ivar};
     841                %VarName{ivar}=FieldData.ListVarName{ivar};
    842842                if test_interp2% interpolate on new grid
    843                     eval(['FieldData.' VarName{ivar} '=interp2(FieldData.' AXName ',FieldData.' AYName ',FieldData.' VarName{ivar} ',AXI,AYI'');']) %TO TEST
    844                 end
    845                 eval(['vec_A=reshape(squeeze(FieldData.' VarName{ivar} '),npx*npy,nbcolor);']) %put the original image in colum
     843                    FieldData.(FieldData.ListVarName{ivar})=interp2(FieldData.(AXName),FieldData.(AYName),FieldData.(FieldData.ListVarName{ivar}),AXI,AYI);%TO TEST
     844                end
     845                vec_A=reshape(squeeze(FieldData.(FieldData.ListVarName{ivar})),npx*npy,nbcolor); %put the original image in colum
    846846                if nbcolor==1
    847847                    vec_B(ind_in)=vec_A(ICOMB);
    848848                    vec_B(ind_out)=zeros(size(ind_out));
    849849                    A_out=reshape(vec_B,npY,npX);
    850                     eval(['ProjData.' VarName{ivar} '=((sum(A_out,1)/npY))'';']);
     850                    ProjData.(FieldData.ListVarName{ivar}) =sum(A_out,1)/npY;
    851851                elseif nbcolor==3
    852852                    vec_B(ind_in,1:3)=vec_A(ICOMB,:);
     
    855855                    vec_B(ind_out,3)=zeros(size(ind_out));
    856856                    A_out=reshape(vec_B,npY,npX,nbcolor);
    857                     eval(['ProjData.' VarName{ivar} '=squeeze(sum(A_out,1)/npY);']);
     857                    ProjData.(FieldData.ListVarName{ivar})=squeeze(sum(A_out,1)/npY);
    858858                end 
    859                 ProjData.ListVarName=[ProjData.ListVarName VarName{ivar} ];
     859                ProjData.ListVarName=[ProjData.ListVarName FieldData.ListVarName{ivar}];
    860860                ProjData.VarDimName=[ProjData.VarDimName {AXName}];%to generalize with the initial name of the x coordinate
    861861                ProjData.VarAttribute{ivar}.Role='continuous';% for plot with continuous line
    862862            end
    863863            if testU
    864                  eval(['vector_x =ProjData.' VarName{VarType.vector_x} ';'])
    865                  eval(['vector_y =ProjData.' VarName{VarType.vector_y} ';'])
    866                  eval(['ProjData.' VarName{VarType.vector_x} '=cos(theta)*vector_x+sin(theta)*vector_y;'])
    867                  eval(['ProjData.' VarName{VarType.vector_y} '=-sin(theta)*vector_x+cos(theta)*vector_y;'])
     864                 vector_x =ProjData.(FieldData.ListVarName{VarType.vector_x});
     865                 vector_y =ProjData.(FieldData.ListVarName{VarType.vector_y});
     866                 ProjData.(FieldData.ListVarName{VarType.vector_x}) =cos(theta)*vector_x+sin(theta)*vector_y;
     867                 ProjData.(FieldData.ListVarName{VarType.vector_y}) =-sin(theta)*vector_x+cos(theta)*vector_y;
    868868            end
    869869            ProjData.VarAttribute{nbvar+1}.long_name='abscissa along line';
  • trunk/src/series.m

    r419 r421  
    15711571% last_j=str2num(get(handles.num_last_j,'String'));
    15721572TimeTable=get(handles.TimeTable,'Data');
    1573 
     1573Pairs=get(handles.PairString,'Data');
    15741574for iview=1:size(TimeTable,1)
    1575     Pairs=get(handles.PairString,'Data');
     1575    if size(SeriesData.Time,1)<iview
     1576        break
     1577    end
    15761578    i1=ref_i;
    15771579    j1=ref_j;
    15781580    i2=ref_i;
    15791581    j2=ref_j;
     1582    % case of pairs
    15801583    if ~isempty(Pairs{iview,1})
    1581         r=regexp(Param.Pairs.list_pair_civ,'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');
     1584        r=regexp(Pairs{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');
    15821585        if isempty(r)
    1583             r=regexp(Param.Pairs.list_pair_civ,'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');
     1586            r=regexp(Pairs.list_pair_civ,'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');
    15841587        end
    15851588        switch r.mode
     
    15951598        end
    15961599    end
    1597     if isempty(ref_j)
    1598     time_first=(SeriesData.Time{iview}(i1(1))+SeriesData.Time{iview}(i2(1)))/2;
    1599     time_last=(SeriesData.Time{iview}(i1(2))+SeriesData.Time{iview}(i2(2)))/2;
    1600     else
    1601         time_first=(SeriesData.Time{iview}(i1(1),j1(1))+SeriesData.Time{iview}(i2(1),j2(1)))/2;
    1602         time_last=(SeriesData.Time{iview}(i1(2),j1(2))+SeriesData.Time{iview}(i2(2),j2(2)))/2;
    1603     end
    1604     TimeTable{iview,2}=time_first; %TODO: take into account pairs
    1605     TimeTable{iview,3}=time_last; %TODO: take into account pairs
     1600    TimeTable{iview,2}=[];
     1601    TimeTable{iview,3}=[];
     1602    if size(SeriesData.Time{iview},1)>=i2(2)&&size(SeriesData.Time{iview},1)>=j2(2)
     1603        if isempty(ref_j)
     1604            time_first=(SeriesData.Time{iview}(i1(1))+SeriesData.Time{iview}(i2(1)))/2;
     1605            time_last=(SeriesData.Time{iview}(i1(2))+SeriesData.Time{iview}(i2(2)))/2;
     1606        else
     1607            time_first=(SeriesData.Time{iview}(i1(1),j1(1))+SeriesData.Time{iview}(i2(1),j2(1)))/2;
     1608            time_last=(SeriesData.Time{iview}(i1(2),j1(2))+SeriesData.Time{iview}(i2(2),j2(2)))/2;
     1609        end
     1610        TimeTable{iview,2}=time_first; %TODO: take into account pairs
     1611        TimeTable{iview,3}=time_last; %TODO: take into account pairs
     1612    end
    16061613end
    16071614set(handles.TimeTable,'Data',TimeTable)
    1608 return
    1609 
    1610 
    1611 NomType=InputTable(:,4);
    1612 mode_list=get(handles.mode,'String');
    1613 index_mode=get(handles.mode,'Value');
    1614 
    1615 mode=mode_list{index_mode};
    1616 
    1617 time_first=[];
    1618 time_last=[];
    1619 if ~isfield(SeriesData,'Time')
    1620     SeriesData.Time{1}=[];
    1621 end
    1622 TimeTable=get(handles.TimeTable,'Data');
    1623 for iview=1:size(TimeTable,1)
    1624     time_first_cell{iview}='?';
    1625     time_last_cell{iview}='?';%default
    1626     time=SeriesData.Time{iview};
    1627     if isequal(NomType{iview},'_1-2_1')|isequal(NomType{iview},'_1_1-2')|isequal(NomType{iview},'#_ab')|isequal(NomType{iview},'_1-2')
    1628         if isfield(SeriesData,'displ_num')& ~isempty(SeriesData.displ_num)
    1629             ind_shift=SeriesData.displ_num(iview,:);
    1630             if isequal(mode,'bursts')
    1631                 first_j=0;
    1632                 last_j=0;
    1633             end
    1634             first_i1=first_i +ind_shift(3);
    1635             first_i2 =first_i +ind_shift(4);
    1636             first_j1 =first_j +ind_shift(1);
    1637             first_j2 =first_j +ind_shift(2);
    1638             last_i1=last_i +ind_shift(3);
    1639             last_i2 =last_i +ind_shift(4);   
    1640             last_j1 =last_j +ind_shift(1);
    1641             last_j2 =last_j +ind_shift(2);
    1642             siz=size(SeriesData.Time{1});
    1643             if first_i1>=1 && first_j1>=1 && siz(1)>=last_i2 && siz(2)>=last_j2
    1644                 time_first=(time(first_i1,first_j1)+time(first_i2,first_j2))/2;
    1645                 time_last=(time(last_i1,last_j1)+time(last_i2,last_j2))/2;
    1646             else%read the time in the nc files
    1647                 RootPath=get(handles.RootPath,'String');
    1648                 RootFile=get(handles.RootFile,'String');
    1649                 SubDir=get(handles.SubDir,'String');
    1650                 %VelType=get(handles.VelType,'String');
    1651                 VelType_str=get(handles.VelTypeMenu,'String');
    1652                 VelType_val=get(handles.VelTypeMenu,'Value');
    1653                 VelType=VelType_str{VelType_val};
    1654                 filebase=fullfile(RootPath{1},RootFile{1});
    1655                 [filefirst]=name_generator(filebase,first_i1,first_j1,'.nc',NomType{iview},1,first_i2,first_j2,SubDir{iview});
    1656                 if  exist(filefirst,'file')
    1657                     Attrib=nc2struct(filefirst,[]);
    1658                     if isfield(Attrib,'Time')
    1659                         time_first=Attrib.Time;
    1660                     else
    1661                         if isfield(Attrib,'absolut_time_T0')
    1662                             time_first=Attrib.absolut_time_T0;
    1663                         end
    1664                         if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1'))
    1665                             time_first=Attrib.absolut_time_T0_2;
    1666                         end
    1667                     end
    1668                 end
    1669                 [filelast]=name_generator(filebase,last_i1,last_j1,'.nc',NomType{iview},1,last_i2,last_j2,SubDir{iview});
    1670                 if exist(filelast,'file')
    1671                    Attrib=nc2struct(filelast,[]);
    1672                     if isfield(Attrib,'Time')
    1673                         time_last=Attrib.Time;
    1674                     else
    1675                         if isfield(Attrib,'absolut_time_T0')
    1676                             time_last=Attrib.absolut_time_T0;
    1677                         end
    1678                         if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1'))
    1679                             time_last=Attrib.absolut_time_T0_2;
    1680                         end
    1681                     end
    1682                 end
    1683             end
    1684         end
    1685     else
    1686         siz=size(time);
    1687         if siz(1)>=last_i && siz(2)>=last_j && first_i>=1 && first_j>=1
    1688             time_first=times(first_i,first_j);
    1689             time_last=times(last_i,last_j);
    1690         end
    1691     end
    1692     time_first_cell{iview}=num2str(time_first,4);
    1693     time_last_cell{iview}=num2str(time_last,4);
    1694 end
    1695 
     1615
     1616
     1617%
     1618% NomType=InputTable(:,4);
     1619% mode_list=get(handles.mode,'String');
     1620% index_mode=get(handles.mode,'Value');
     1621%
     1622% mode=mode_list{index_mode};
     1623%
     1624% time_first=[];
     1625% time_last=[];
     1626% if ~isfield(SeriesData,'Time')
     1627%     SeriesData.Time{1}=[];
     1628% end
     1629% TimeTable=get(handles.TimeTable,'Data');
     1630% for iview=1:size(TimeTable,1)
     1631%     time_first_cell{iview}='?';
     1632%     time_last_cell{iview}='?';%default
     1633%     time=SeriesData.Time{iview};
     1634%     if isequal(NomType{iview},'_1-2_1')|isequal(NomType{iview},'_1_1-2')|isequal(NomType{iview},'#_ab')|isequal(NomType{iview},'_1-2')
     1635%         if isfield(SeriesData,'displ_num')& ~isempty(SeriesData.displ_num)
     1636%             ind_shift=SeriesData.displ_num(iview,:);
     1637%             if isequal(mode,'bursts')
     1638%                 first_j=0;
     1639%                 last_j=0;
     1640%             end
     1641%             first_i1=first_i +ind_shift(3);
     1642%             first_i2 =first_i +ind_shift(4);
     1643%             first_j1 =first_j +ind_shift(1);
     1644%             first_j2 =first_j +ind_shift(2);
     1645%             last_i1=last_i +ind_shift(3);
     1646%             last_i2 =last_i +ind_shift(4);   
     1647%             last_j1 =last_j +ind_shift(1);
     1648%             last_j2 =last_j +ind_shift(2);
     1649%             siz=size(SeriesData.Time{1});
     1650%             if first_i1>=1 && first_j1>=1 && siz(1)>=last_i2 && siz(2)>=last_j2
     1651%                 time_first=(time(first_i1,first_j1)+time(first_i2,first_j2))/2;
     1652%                 time_last=(time(last_i1,last_j1)+time(last_i2,last_j2))/2;
     1653%             else%read the time in the nc files
     1654%                 RootPath=get(handles.RootPath,'String');
     1655%                 RootFile=get(handles.RootFile,'String');
     1656%                 SubDir=get(handles.SubDir,'String');
     1657%                 %VelType=get(handles.VelType,'String');
     1658%                 VelType_str=get(handles.VelTypeMenu,'String');
     1659%                 VelType_val=get(handles.VelTypeMenu,'Value');
     1660%                 VelType=VelType_str{VelType_val};
     1661%                 filebase=fullfile(RootPath{1},RootFile{1});
     1662%                 [filefirst]=name_generator(filebase,first_i1,first_j1,'.nc',NomType{iview},1,first_i2,first_j2,SubDir{iview});
     1663%                 if  exist(filefirst,'file')
     1664%                     Attrib=nc2struct(filefirst,[]);
     1665%                     if isfield(Attrib,'Time')
     1666%                         time_first=Attrib.Time;
     1667%                     else
     1668%                         if isfield(Attrib,'absolut_time_T0')
     1669%                             time_first=Attrib.absolut_time_T0;
     1670%                         end
     1671%                         if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1'))
     1672%                             time_first=Attrib.absolut_time_T0_2;
     1673%                         end
     1674%                     end
     1675%                 end
     1676%                 [filelast]=name_generator(filebase,last_i1,last_j1,'.nc',NomType{iview},1,last_i2,last_j2,SubDir{iview});
     1677%                 if exist(filelast,'file')
     1678%                    Attrib=nc2struct(filelast,[]);
     1679%                     if isfield(Attrib,'Time')
     1680%                         time_last=Attrib.Time;
     1681%                     else
     1682%                         if isfield(Attrib,'absolut_time_T0')
     1683%                             time_last=Attrib.absolut_time_T0;
     1684%                         end
     1685%                         if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1'))
     1686%                             time_last=Attrib.absolut_time_T0_2;
     1687%                         end
     1688%                     end
     1689%                 end
     1690%             end
     1691%         end
     1692%     else
     1693%         siz=size(time);
     1694%         if siz(1)>=last_i && siz(2)>=last_j && first_i>=1 && first_j>=1
     1695%             time_first=times(first_i,first_j);
     1696%             time_last=times(last_i,last_j);
     1697%         end
     1698%     end
     1699%     time_first_cell{iview}=num2str(time_first,4);
     1700%     time_last_cell{iview}=num2str(time_last,4);
     1701% end
     1702%
    16961703
    16971704%------------------------------------------------------------------------
     
    20692076if value
    20702077     set(handles.GetObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow
    2071 %      DataInit.ParentButton=handles.GetObject;
    20722078     hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle
    20732079     if ishandle(hset_object)
    2074          uistack(hset_object,'top')
    2075         %[SeriesData.hset_object,SeriesData.sethandles]=set_object(DataInit); %open the set_object interface
     2080         uistack(hset_object,'top')% show the GUI set_object if opened
    20762081     else
    20772082         %get the object file
    20782083         InputTable=get(handles.InputTable,'Data');
    20792084         defaultname=InputTable{1,1};
    2080 %          defaultname=get(handles.RootPath,'String');
    20812085         if isempty(defaultname)
    20822086            defaultname={''};
     
    20882092        'Pick an xml object file (or use uvmat to create it)',defaultname{1});
    20892093        fileinput=[PathName FileName];%complete file name
    2090         testblank=findstr(fileinput,' ');%look for blanks
    2091         if ~isempty(testblank)
    2092             msgbox_uvmat('ERROR','forbidden input file name: contain blanks')
    2093             return
    2094         end
    20952094        sizf=size(fileinput);
    20962095        if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
     
    21042103             data.ProjMode='projection';
    21052104        end
    2106         transform_menu=get(handles.transform_fct,'String');
    2107         ichoice=get(handles.transform_fct,'Value');
    2108 %         if isequal(transform_menu{ichoice},'px');
    2109 %             data.CoordType='px';
    2110 %         else
    2111 %             data.CoordType='phys';
    2112 %         end
    2113         data.desable_plot=1;
     2105%         data.desable_plot=1;
    21142106        [SeriesData.hset_object,SeriesData.sethandles]=set_object(data);% call the set_object interface
    21152107     end
    21162108else
    21172109    set(handles.GetObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green
    2118 %     if isfield(SeriesData,'hset_object')&& ishandle(SeriesData.hset_object)
    2119 %         close(SeriesData.hset_object)
    2120 %     end
    21212110end
    21222111set(handles.series,'UserData',SeriesData)
  • trunk/src/uvmat.m

    r415 r421  
    411411[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    412412oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    413 % oldfile=read_file_box,es(handles);
    414413if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
    415414         dir_perso=prefdir;
     
    422421         end
    423422end
    424 [FileName, PathName] = uigetfile( ...
    425        {'*.xml;*.xls;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol;*.nc;*.cmx;*.fig;*.log;*.dat;*.bat;', ' (*.xml,*.xls,*.civ,*.jpg ,*.png, .tif, *.avi,*.vol,*.nc,*.cmx,*.fig,*.log,*.dat,*.bat)';
    426        '*.xml',  '.xml files '; ...
    427         '*.xls',  '.xls files '; ...
    428         '*.civ',  '.civ files '; ...
    429         '*.jpg',' jpeg image files'; ...
    430         '*.png','.png image files'; ...
    431         '*.tif','.tif image files'; ...
    432         '*.avi;*.AVI','.avi movie files'; ...
    433         '*.vol','.volume images (png)'; ...
    434         '*.nc','.netcdf files'; ...
    435         '*.cdf','.netcdf files'; ...
    436         '*.cmx','.cmx text files ';...
    437         '*.fig','.fig files (matlab fig)';...
    438         '*.log','.log text files ';...
    439         '*.dat','.dat text files ';...
    440         '*.bat','.bat system command text files';...
    441         '*.*',  'All Files (*.*)'}, ...
    442         'Pick a file',oldfile);
     423% [FileName, PathName] = uigetfile( ...
     424%        {'*.xml;*.xls;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol;*.nc;*.cmx;*.fig;*.log;*.dat;*.bat;', ' (*.xml,*.xls,*.civ,*.jpg ,*.png, .tif, *.avi,*.vol,*.nc,*.cmx,*.fig,*.log,*.dat,*.bat)';
     425%        '*.xml',  '.xml files '; ...
     426%         '*.xls',  '.xls files '; ...
     427%         '*.civ',  '.civ files '; ...
     428%         '*.jpg',' jpeg image files'; ...
     429%         '*.png','.png image files'; ...
     430%         '*.tif','.tif image files'; ...
     431%         '*.avi;*.AVI','.avi movie files'; ...
     432%         '*.vol','.volume images (png)'; ...
     433%         '*.nc','.netcdf files'; ...
     434%         '*.cdf','.netcdf files'; ...
     435%         '*.cmx','.cmx text files ';...
     436%         '*.fig','.fig files (matlab fig)';...
     437%         '*.log','.log text files ';...
     438%         '*.dat','.dat text files ';...
     439%         '*.bat','.bat system command text files';...
     440%         '*.*',  'All Files (*.*)'}, ...
     441%         'Pick a file',oldfile);
     442
     443[FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',oldfile);
    443444fileinput=[PathName FileName];%complete file name
    444445sizf=size(fileinput);
     
    488489function MenuBrowse_1_Callback(hObject, eventdata, handles)
    489490%------------------------------------------------------------------------
    490 % huvmat=get(handles.run0,'parent');
    491 UvData=get(handles.uvmat,'UserData');
    492 
    493491RootPath=get(handles.RootPath,'String');
    494 [FileName, PathName, filterindex] = uigetfile( ...
    495        {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
    496        '*.xml',  '.xml files '; ...
    497         '*.xls',  '.xls files '; ...
    498         '*.civ',  '.civ files '; ...
    499         '*.jpg','.jpg image files'; ...
    500         '*.png','.png image files'; ...
    501         '*.avi;*.AVI','.avi movie files'; ...
    502         '*.nc','.netcdf files'; ...
    503         '*.cdf','.netcdf files'; ...
    504         '*.cmx','.cmx text files';...
    505         '*.cmx2','.cmx2 text files';...
    506         '*.fig','.fig files (matlab fig)';...
    507         '*.log','.log text files ';...
    508         '*.dat','.dat text files ';...
    509         '*.*',  'All Files (*.*)'}, ...
    510         'Pick a second file for comparison',RootPath);
     492% [FileName, PathName, filterindex] = uigetfile( ...
     493%        {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
     494%        '*.xml',  '.xml files '; ...
     495%         '*.xls',  '.xls files '; ...
     496%         '*.civ',  '.civ files '; ...
     497%         '*.jpg','.jpg image files'; ...
     498%         '*.png','.png image files'; ...
     499%         '*.avi;*.AVI','.avi movie files'; ...
     500%         '*.nc','.netcdf files'; ...
     501%         '*.cdf','.netcdf files'; ...
     502%         '*.cmx','.cmx text files';...
     503%         '*.cmx2','.cmx2 text files';...
     504%         '*.fig','.fig files (matlab fig)';...
     505%         '*.log','.log text files ';...
     506%         '*.dat','.dat text files ';...
     507%         '*.*',  'All Files (*.*)'}, ...
     508%         'Pick a second file for comparison',RootPath);
     509[FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',RootPath);
    511510fileinput_1=[PathName FileName];%complete file name
    512511sizf=size(fileinput_1);
     
    19971996
    19981997%% read the first input field if a filename has been introduced
     1998ParamIn.ColorVar='';%default variable name for vector color
    19991999if ~isempty(filename)
    20002000    ObjectName=filename;
     
    23502350
    23512351%% calculate scalar
    2352 if (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))%&&~strcmp(ParamOut.FieldName,'velocity')&& ~strcmp(ParamOut.FieldName,'get_field...');% ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
     2352if ~strcmp(ParamOut.FieldName,'get_field...')&& (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))%&&~strcmp(ParamOut.FieldName,'velocity')&& ~strcmp(ParamOut.FieldName,'get_field...');% ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
    23532353    Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1});
    23542354end
    2355 if numel(Field)==2 && ~test_keepdata_1 && (strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{2},'civx'))  &&~strcmp(ParamOut_1.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...')
     2355if numel(Field)==2 && ~strcmp(ParamOut_1.FieldName,'get_field...')&& ~test_keepdata_1 && (strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{2},'civx'))  &&~strcmp(ParamOut_1.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...')
    23562356     Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2});
    23572357end
     
    23862386    return
    23872387end
    2388 [NbDim,imax]=max(NbDim);
     2388[NbDim,imax]=max(NbDim);% spatial dimension of the input field
    23892389if isfield(UvData.Field,'NbDim')
    23902390    NbDim=UvData.Field.NbDim;% deal with plane fields containing z coordinates
    23912391end
     2392XName=''; %default
     2393YName='';
    23922394if ~isempty(VarType{imax}.coord_x)  && ~isempty(VarType{imax}.coord_y)    %unstructured coordinates
    23932395    XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
    23942396    YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
    2395     eval(['nbvec=length(UvData.Field.' XName ');'])%nbre of measurement points (e.g. vectors)
     2397    nbvec=length(UvData.Field.(XName));%nbre of measurement points (e.g. vectors)
    23962398    test_x=1;%test for unstructured coordinates
    23972399    if ~isempty(VarType{imax}.coord_z)
     
    24022404elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 %structured coordinate
    24032405    XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
    2404     if NbDim>1
     2406    if NbDim> 1 && VarType{imax}.coord(NbDim-1)>0
    24052407        YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
    24062408    end
     2409    VarIndex=CellVarIndex{imax}; % list of variable indices
     2410DimIndex=VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
     2411nbpoints_x=DimValue(DimIndex(NbDim));
     2412XMax=nbpoints_x;%default
     2413XMin=1;%default
    24072414end
    24082415if NbDim==3
     
    24202427    end
    24212428end
    2422 if exist('XName','var')
    2423     eval(['XMax=max(max(UvData.Field.' XName '));'])
    2424     eval(['XMin=min(min(UvData.Field.' XName '));'])
     2429
     2430if ~isempty (XName)
     2431    XMax=max(max(UvData.Field.(XName)));
     2432    XMin=min(min(UvData.Field.(XName)));
    24252433    UvData.Field.NbDim=NbDim;
    24262434    UvData.Field.XMax=XMax;
    24272435    UvData.Field.XMin=XMin;
    2428     if NbDim >1
    2429         eval(['YMax=max(max(UvData.Field.' YName '));'])
    2430         eval(['YMin=min(min(UvData.Field.' YName '));'])
     2436    if NbDim >1&& ~isempty(YName)
     2437        YMax=max(max(UvData.Field.(YName)));
     2438        YMin=min(min(UvData.Field.(YName)));
    24312439        UvData.Field.YMax=YMax;
    2432         UvData.Field.YMin=YMin;
    2433     end
    2434     eval(['nbvec=length(UvData.Field.' XName ');'])
     2440        UvData.Field.YMin=YMin; 
     2441    end
     2442    nbvec=length(UvData.Field.(XName));
    24352443    if test_x %unstructured coordinates
    24362444        if test_z
     
    24402448            UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D
    24412449        end
     2450    end
     2451end
     2452if ~test_x
     2453    %         VarIndex=CellVarIndex{imax}; % list of variable indices
     2454    %         DimIndex=VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
     2455    %         nbpoints_x=DimValue(DimIndex(NbDim));
     2456    DX=(XMax-XMin)/(nbpoints_x-1);
     2457    if NbDim >1
     2458        nbpoints_y=DimValue(DimIndex(NbDim-1));
     2459        if isempty(YName)% if the y coordinate is not expressed, it is taken as the matrix index
     2460            DY=1;
     2461            UvData.Field.YMax=nbpoints_y;
     2462            UvData.Field.YMin=1;
     2463        else
     2464            DY=(YMax-YMin)/(nbpoints_y-1);
     2465        end
     2466    end
     2467    if NbDim==3
     2468        nbpoints_z=DimValue(DimIndex(1));
     2469        DZ=(ZMax-ZMin)/(nbpoints_z-1);
     2470        UvData.Field.Mesh=(DX*DY*DZ)^(1/3);
     2471        UvData.Field.ZMax=ZMax;
     2472        UvData.Field.ZMin=ZMin;
    24422473    else
    2443         VarIndex=CellVarIndex{imax}; % list of variable indices
    2444         DimIndex=VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
    2445         nbpoints_x=DimValue(DimIndex(NbDim));
    2446         DX=(XMax-XMin)/(nbpoints_x-1);
    2447         if NbDim >1
    2448             nbpoints_y=DimValue(DimIndex(NbDim-1));
    2449             DY=(YMax-YMin)/(nbpoints_y-1);
    2450         end
    2451         if NbDim==3
    2452             nbpoints_z=DimValue(DimIndex(1));
    2453             DZ=(ZMax-ZMin)/(nbpoints_z-1);
    2454             UvData.Field.Mesh=(DX*DY*DZ)^(1/3);
    2455             UvData.Field.ZMax=ZMax;
    2456             UvData.Field.ZMin=ZMin;
    2457         else
    2458             UvData.Field.Mesh=DX;%sqrt(DX*DY);
    2459         end
    2460     end
    2461     % adjust the mesh to a value 1, 2 , 5 *10^n
    2462     ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude
    2463     if UvData.Field.Mesh/ord>=5
    2464         UvData.Field.Mesh=5*ord;
    2465     elseif UvData.Field.Mesh/ord>=2
    2466         UvData.Field.Mesh=2*ord;
    2467     else
    2468         UvData.Field.Mesh=ord;
    2469     end
    2470 end
     2474        UvData.Field.Mesh=DX;%sqrt(DX*DY);
     2475    end
     2476end
     2477% adjust the mesh to a value 1, 2 , 5 *10^n
     2478ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude
     2479if UvData.Field.Mesh/ord>=5
     2480    UvData.Field.Mesh=5*ord;
     2481elseif UvData.Field.Mesh/ord>=2
     2482    UvData.Field.Mesh=2*ord;
     2483else
     2484    UvData.Field.Mesh=ord;
     2485end
     2486
    24712487
    24722488%% 3D case (menuvolume)
     
    25602576%PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
    25612577PlotParam{1}=read_GUI(handles.uvmat);
    2562 %default settings if vectors not visible (should not be needed)
     2578%default settings if vectors not visible
    25632579if ~isfield(PlotParam{1},'Vectors')
    25642580    PlotParam{1}.Vectors.MaxVec=1;
     
    25952611        return
    25962612    end
    2597     if testnewseries && isfield(ObjectData,'CoordUnit')
     2613    if testnewseries
     2614        PlotParam{imap}.Scalar.CheckBW=[]; %B/W option depends on the input field (image or scalar)
     2615        if isfield(ObjectData,'CoordUnit')
    25982616        PlotParam{imap}.Coordinates.CheckFixEqual=1;% set x and y scaling equal if CoordUnit is defined (common unit for x and y)
     2617        end
    25992618    end
    26002619    %use of mask (TODO: check)
     
    44254444hset_object=set_object(data,handles);% call the set_object interface
    44264445hhset_object=guidata(hset_object);
    4427 set(hhset_object.PLOT,'enable','on')% activate the refresh button
     4446hchild=get(hset_object,'children');
     4447set(hchild,'enable','on')
     4448%set(hhset_object.PLOT,'enable','on')% activate the refresh button
    44284449%set(handles.MenuObject,'checked','on')
    44294450set(handles.uvmat,'UserData',UvData)
  • trunk/src/write_plot_param.m

    r405 r421  
    3939        set(handles.num_IncrA,'String',num2str(PlotParam.Scalar.IncrA,3))
    4040    end
     41    set(handles.CheckBW,'Value',PlotParam.Scalar.CheckBW)
    4142else
    4243    set(handles.Scalar,'Visible','off')
Note: See TracChangeset for help on using the changeset viewer.