Changeset 46


Ignore:
Timestamp:
Mar 15, 2010, 5:42:11 PM (14 years ago)
Author:
gostiaux
Message:

various bug fixes

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mouse_down.m

    r40 r46  
    203203            set(huvmat,'UserData',UvData)
    204204            list_str=get(hhuvmat.list_object,'String');
    205             list_str{IndexObj}=[num2str(IndexObj) '-' set_title(ObjectData.Style,ObjectData.ProjMode)];
     205            list_str{IndexObj}=[num2str(IndexObj) '-' ObjectData.Style];
    206206            if ~isequal(list_str{end},'...')
    207207                 list_str{end+1}='...';
  • trunk/src/plot_field.m

    r42 r46  
    137137    hfig=figure;
    138138    if isfield(Data,'IndexObj')&isfield(Data,'Style')&isfield(Data,'ProjMode')
    139         figname=[num2str(Data.IndexObj) '-' set_title(Data.Style,Data.ProjMode)];
     139        figname=[num2str(Data.IndexObj) '-' Data.Style];
    140140        set(hfig,'Name',figname)
    141141    end
     
    10161016        test_lim=0;
    10171017        if test_vec
    1018             'TESTplot'
    1019             Xlim=[min(vec_X) max(vec_X)]
    1020             Ylim=[min(vec_Y) max(vec_Y)]
     1018            Xlim=[min(vec_X) max(vec_X)];
     1019            Ylim=[min(vec_Y) max(vec_Y)];
    10211020            test_lim=1;
    10221021            if test_ima%both background image and vectors coexist, take the wider bound
     
    10331032            test_lim=1;
    10341033        end
    1035         if test_lim
    1036             set(haxes,'XLim',Xlim);% set x limits of frame in axes coordinates
    1037             set(haxes,'YLim',Ylim);% set y limits of frame in axes coordinate
     1034        if test_lim
     1035            if Xlim(2)>Xlim(1)
     1036                set(haxes,'XLim',Xlim);% set x limits of frame in axes coordinates
     1037            end
     1038            if Ylim(2)>Ylim(1)
     1039                set(haxes,'YLim',Ylim);% set y limits of frame in axes coordinate
     1040            end
    10381041        end
    10391042end
  • trunk/src/proj_field.m

    r42 r46  
    9090    return
    9191end
     92FieldData
    9293%introduce default field properties (reading old standards)
    9394if ~isfield(ObjectData,'Style')||~isfield(ObjectData,'Coord')||~isfield(ObjectData,'ProjMode')
     
    885886            ProjData.VarAttribute{nbvar+1}.long_name='abscissa along line';
    886887            if nbcolor==3
    887                 ProjData.VarDimName{end}={XName,'rgb'};
     888                ProjData.VarDimName{end}={AXName,'rgb'};
    888889            end
    889890        end     
     
    11771178            for ivar=VarIndex
    11781179                VarName=FieldData.ListVarName{ivar};
    1179                 if ~( ivar==ivar_X | ivar==ivar_Y | ivar==ivar_Z | ivar==ivar_F | ivar==ivar_FF | test_anc(ivar)==1)                 
     1180                if ~( ivar==ivar_X || ivar==ivar_Y || ivar==ivar_Z || ivar==ivar_F || ivar==ivar_FF || test_anc(ivar)==1)                 
    11801181                    ivar_new=ivar_new+1;
    11811182                    ProjData.ListVarName=[ProjData.ListVarName {VarName}];
    11821183                    ProjData.VarDimName=[ProjData.VarDimName {DimCell}];
    11831184                    %ProjData.VarDimIndex=[ProjData.VarDimIndex {[1 2]}];
    1184                     if isfield(FieldData,'VarAttribute') & length(FieldData.VarAttribute) >=ivar
     1185                    if isfield(FieldData,'VarAttribute') && length(FieldData.VarAttribute) >=ivar
    11851186                        ProjData.VarAttribute{ivar_new+nbcoord}=FieldData.VarAttribute{ivar};
    11861187                    end
     
    11901191                        eval(['FieldData.' VarName '=FieldData.' VarName '(indsel);'])
    11911192                    end
    1192                     eval(['ProjData.' VarName '=griddata_uvmat(coord_X,coord_Y,FieldData.' VarName ',coord_x_proj,coord_y_proj'');'])
     1193                    eval(['ProjData.' VarName '=griddata_uvmat(double(coord_X),double(coord_Y),double(FieldData.' VarName '),coord_x_proj,coord_y_proj'');'])
    11931194                    eval(['varline=reshape(ProjData.' VarName ',1,length(coord_y_proj)*length(coord_x_proj));'])
    11941195                    FFlag= isnan(varline); %detect undefined values NaN
     
    15171518    end
    15181519    %projection of  velocity components in the rotated coordinates
    1519     if ~isequal(Phi,0) & length(ivar_U)==1
     1520    if ~isequal(Phi,0) && length(ivar_U)==1
    15201521        if isempty(ivar_V)
    15211522            msgbox_uvmat('ERROR','v velocity component missing in proj_field.m')
  • trunk/src/series.m

    r41 r46  
    12891289       
    12901290        %update the first and last times of the series
    1291         if testupdate & isfield(SeriesData,'Time')
     1291        if testupdate && isfield(SeriesData,'Time')
    12921292        if ~isempty(SeriesData.Time{1})
    12931293            displ_time(handles,SeriesData.Time{1});
     
    13041304%hseries=get(handles.RUN,'parent');
    13051305set(0,'CurrentFigure',handles.figure1)
    1306 if isequal(get(handles.GetObject,'Value'),1)
     1306if isequal(get(handles.GetObject,'Visible'),'on') && isequal(get(handles.GetObject,'Value'),1)
    13071307    Series.GetObject=1;
    13081308    GetObject_Callback(hObject, eventdata, handles)
     
    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
    13201313
    13211314%reinitiate waitbar position
     
    15061499Series.Action=action;%name of the processing programme
    15071500set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
    1508 drawnow
     1501
    15091502if length(RootPath)>1
    15101503    h_fun(num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series);
     
    20832076if value
    20842077     set(handles.GetObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow
    2085      DataInit.ParentButton=handles.GetObject;
     2078%      DataInit.ParentButton=handles.GetObject;
    20862079     hset_object=findobj(allchild(0),'Name','set_object');%find the set_object interface handle
    20872080     if ishandle(hset_object)
    2088          [SeriesData.hset_object,SeriesData.sethandles]=set_object(DataInit); %open the set_object interface
     2081         uistack(hset_object,'top')
     2082        %[SeriesData.hset_object,SeriesData.sethandles]=set_object(DataInit); %open the set_object interface
    20892083     else
    20902084         %get the object file
     
    20942088       '*.xml',  '.xml files '; ...
    20952089        '*.mat',  '.mat matlab files '}, ...
    2096         'Pick a file',defaultname{1});
     2090        'Pick an xml object file (or use uvmat to create it)',defaultname{1});
    20972091        fileinput=[PathName FileName];%complete file name
    20982092        testblank=findstr(fileinput,' ');%look for blanks
     
    21232117     end
    21242118else
    2125     set(handles.GetObject,'BackgroundColor',[0 1 0])%put activated buttons to green
     2119    set(handles.GetObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green
    21262120%     if isfield(SeriesData,'hset_object')&& ishandle(SeriesData.hset_object)
    21272121%         close(SeriesData.hset_object)
     
    22172211set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
    22182212
    2219 
     2213%-------------------------------------------------------------
     2214%generates a series of file names with reference numbers between range1 and
     2215%range2 with increment incr. The reference number num_ref is the image number at the middle of the
     2216%image pair. The set of first numbers num1 of the image pairs is also
     2217%given as output
     2218%------------------------------------------------------
     2219function [num_i1,num_i2,num_j1,num_j2,nbmissing]=netseries_generator(filebase,subdir,mode,first_i,incr_i,last_i,first_j,incr_j,last_j)
     2220[Path,Name]=fileparts(filebase);
     2221filebasesub=fullfile(Path,subdir,Name);
     2222filecell={};%default
     2223num_i1=[];
     2224num_i2=[];
     2225num_j1=[];
     2226num_j2=[];
     2227ind0_i=first_i:incr_i:last_i;
     2228nbcolumn=length(ind0_i);
     2229ind0_j=first_j:incr_j:last_j;
     2230nbline=length(ind0_j);
     2231if isequal(mode,'#_ab')
     2232    dirpair=dir([filebasesub '*_*.nc']);
     2233elseif isequal(mode,'bursts')|isequal(mode,'series(Dj)') 
     2234    dirpair=dir([filebasesub '_*_*-*.nc']);
     2235elseif isequal(mode,'series(Di)')
     2236    dirpair=dir([filebasesub '_*-*_*.nc']);
     2237else
     2238    errordlg('option *|* not yet implemented')
     2239    return
     2240end
     2241if isempty(dirpair)
     2242        errordlg('no pair detected in the selected range')
     2243        return
     2244end
     2245    %ind0_i=first_i:incr_i:last_i;
     2246    %nbcolumn=length(ind0_i);
     2247    %dirpair=dir([filebasesub '_*_*-*.nc']);
     2248if isequal(mode,'bursts')|isequal(mode,'#_ab')
     2249    icount=0;
     2250    for ifile=1:length(dirpair)
     2251        [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name);
     2252       
     2253%         if isempty(str2num(str_1))
     2254%             dirpair(ifile).name
     2255%         end
     2256        num1_r=str2num(str_1);
     2257        if isequal(RootFile,Name) & ~isempty(num1_r)   
     2258            num_i1(ifile)=num1_r;
     2259            num_a(ifile)=stra2num(str_a);
     2260            num_b(ifile)=stra2num(str_b);
     2261%             icount=icount+1;
     2262        end     
     2263    end
     2264    length(dirpair)
     2265%     num_j=floor((num_a+num_b)/2); %list of reference indices of the detected files
     2266    test_range= (num_i1 >=first_i)&(num_i1<= last_i);% =1 when both numbers are in the range
     2267    ind_i=((num_i1-first_i)/incr_i)+1;%indices i in the list of prescribed file indices
     2268    select=find(test_range &(floor(ind_i)==ind_i));%selected indices of num_i1 in the file directory
     2269    ind_i=ind_i(select);%set of selected indices ind_i
     2270    [ind_i,indsort]=sort(ind_i);%sorted list of ind_i
     2271    select=select(indsort);
     2272    num_i1=num_i1(select);
     2273    num_a=num_a(select);
     2274    num_b=num_b(select);
     2275    dirpair=dirpair(select);
     2276    [ind_remove]=find_pairs(dirpair,ind_i,nbcolumn);
     2277    ind_i(ind_remove)=[];
     2278    num_a(ind_remove)=[];
     2279    num_b(ind_remove)=[];
     2280    num_j1=zeros(1,nbcolumn);%default
     2281    num_j2=num_j1;
     2282    num_j1(ind_i)=num_a;
     2283    num_j2(ind_i)=num_b;
     2284    num_i1=first_i:incr_i:last_i;
     2285    num_i2=num_i1;
     2286    nbmissing=nbcolumn-length(ind_i);
     2287
     2288elseif isequal(mode,'series(Di)')
     2289    %ind0_i=first_i:incr_i:last_i;
     2290    %nbcolumn=length(ind0_i);
     2291    %ind0_j=first_j:incr_j:last_j;
     2292    %nbline=length(ind0_j);
     2293    %dirpair=dir([filebasesub '_*-*_*.nc']);
     2294    for ifile=1:length(dirpair)
     2295        [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name);
     2296        num_i1_r(ifile)=str2num(str_1);
     2297        num_i2_r(ifile)=str2num(str_2);
     2298        num_j(ifile)=str2num(str_a);
     2299    end
     2300    num_i=floor((num_i1_r+num_i2_r)/2); %list of reference indices of the detected files
     2301    test_range= (num_i >=first_i)&(num_i<= last_i)&(num_j >=first_j)&(num_j<= last_j);% =1 when both numbers are in the range
     2302    ind_i=((num_i-first_i)/incr_i)+1;%indices i and j in the list of prescribed file indices
     2303    ind_j=((num_j-first_j)/incr_j)+1;
     2304    ind_ij=ind_j+nbline*(ind_i-1);%indices in the reshhaped series of prescribed file indices
     2305    select=find(test_range &(floor(ind_i)==ind_i)&(floor(ind_j)==ind_j));%selected indices in the file directory
     2306    ind_ij=ind_ij(select);%set of selected indices ind_ij
     2307    [ind_ij,indsort]=sort(ind_ij);%sorted list of ind_ij
     2308    select=select(indsort);
     2309    num_i1_r=num_i1_r(select);
     2310    num_i2_r=num_i2_r(select);
     2311%     num_j=num_j(select);
     2312    dirpair=dirpair(select);
     2313    [ind_remove]=find_pairs(dirpair,ind_ij,nbcolumn*nbline) ;
     2314    ind_ij(ind_remove)=[];
     2315    num_i1_r(ind_remove)=[];
     2316    num_i2_r(ind_remove)=[];
     2317    num_i1=zeros(1,nbline*nbcolumn);%default
     2318    num_i2=num_i1;
     2319    num_i1(ind_ij)=num_i1_r;
     2320    num_j2(ind_ij)=num_i2_r;
     2321    num_i1=reshape(num_i1,nbline,nbcolumn);
     2322    num_i2=reshape(num_i2,nbline,nbcolumn);
     2323    num_j1=meshgrid(ind0_i,ind0_j);
     2324    num_j2=num_j1;
     2325    nbmissing=nbline*nbcolumn-length(ind_ij);
     2326elseif isequal(mode,'series(Dj)')
     2327 %   ind0_i=first_i:incr_i:last_i;
     2328 %   nbcolumn=length(ind0_i);
     2329 %   ind0_j=first_j:incr_j:last_j;
     2330  %  nbline=length(ind0_j);
     2331  %  dirpair=dir([filebasesub '_*_*-*.nc']);
     2332    for ifile=1:length(dirpair)
     2333        [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name);
     2334        num_i(ifile)=str2num(str_1);
     2335        num_a(ifile)=str2num(str_a);
     2336        num_b(ifile)=str2num(str_b);
     2337    end
     2338    num_j=floor((num_a+num_b)/2); %list of reference indices of the detected files
     2339    test_range= (num_i >=first_i)&(num_i<= last_i)&(num_j >=first_j)&(num_j<= last_j);% =1 when both numbers are in the range
     2340    ind_i=((num_i-first_i)/incr_i)+1;%indices i and j in the list of prescribed file indices
     2341    ind_j=((num_j-first_j)/incr_j)+1;
     2342    ind_ij=ind_j+nbline*(ind_i-1);%indices in the reshhaped series of prescribed file indices
     2343    select=find(test_range &(floor(ind_i)==ind_i)&(floor(ind_j)==ind_j));%selected indices in the file directory
     2344    ind_ij=ind_ij(select);%set of selected indices ind_ij
     2345    [ind_ij,indsort]=sort(ind_ij);%sorted list of ind_ij
     2346    select=select(indsort);
     2347    num_i=num_i(select);
     2348    num_a=num_a(select);
     2349    num_b=num_b(select);
     2350    dirpair=dirpair(select);
     2351    [ind_remove]=find_pairs(dirpair,ind_ij,nbcolumn*nbline) ;
     2352    ind_ij(ind_remove)=[];
     2353    num_a(ind_remove)=[];
     2354    num_b(ind_remove)=[];
     2355    num_j1=zeros(1,nbline*nbcolumn);%default
     2356    num_j2=num_j1;
     2357    num_j1(ind_ij)=num_a;
     2358    num_j2(ind_ij)=num_b;
     2359    num_j1=reshape(num_j1,nbline,nbcolumn);
     2360    num_j2=reshape(num_j2,nbline,nbcolumn);
     2361    num_i1=meshgrid(ind0_i,ind0_j);
     2362    num_i2=num_i1;
     2363    nbmissing=nbline*nbcolumn-length(ind_ij);
     2364%     for i=1:length(indsel);%A SUPPRIMER ULTERIEUREMENT
     2365%         if indsel(i)==0
     2366%             filecell{i}='';
     2367%         else
     2368%             Name=dirpair(indsel(i)).name;
     2369%             filecell{i}=fullfile(Path,subdir,Name);
     2370%         end
     2371%     end
     2372%else
     2373%    errordlg('option *|* not yet implemented')
     2374%    return
     2375end
    22202376
    22212377function path_transform_Callback(hObject, eventdata, handles)
  • trunk/src/set_grid.m

    r38 r46  
    288288 t=xmltree(fileinput);
    289289 s=convert(t);
    290 %Display title
    291 title=set_title(s.Style,s.ProjMode);%update the title
    292 % menu=get(handles.TITLE,'String')
    293 % for iline=1:length(menu)
    294 %      if isequal(menu{iline},title)
    295 %          set(handles.TITLE,'Value',iline)
    296 %          break
    297 %      end
    298 % end
    299 % TITLE_Callback(hObject, eventdata, handles)
    300 % teststyle=0;
    301 % if isfield(s,'Style')
    302 %         menu=get(handles.ObjectStyle,'String');
    303 %         for iline=1:length(menu)
    304 %             if isequal(menu{iline},s.Style)
    305 %                 set(handles.ObjectStyle,'Value',iline)
    306 %                 teststyle=1;
    307 %                 break
    308 %             end
    309 %         end
    310 % end
    311 % if teststyle==0;
    312 %        s.Style='points';
    313 %        set(handles.ObjectStyle,'Value',1); %default (points)
    314 % end
    315290testmode=0;
    316291if isfield(s,'ProjMode')
     
    476451imageB=get(handles.image_2,'String');
    477452testB=1;
    478 if isempty(imageA) | isequal(imageA,'')
    479     if isempty(imageB) | isequal(imageB,'')
     453if isempty(imageA) || isequal(imageA,'')
     454    if isempty(imageB) || isequal(imageB,'')
    480455        msgbox_uvmat('ERROR','at least one image file name must be introduced')
    481456    else
     
    494469end
    495470[Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(imageA);
    496 form=imformats(ext([2:end]));
     471form=imformats(ext(2:end));
    497472if isempty(form)% if the extension corresponds to an image format recognized by Matlab
    498      msgbox_uvmat('ERROR',['error in read_image.m: ' imageA ' is not an image name recognized by Matlab '])
     473     msgbox_uvmat('ERROR',['error: ' imageA ' is not an image name recognized by Matlab '])
    499474     return
    500475end
     
    524499    form=imformats(ext([2:end]));
    525500    if isempty(form)% if the extension corresponds to an image format recognized by Matlab
    526          msgbox_uvmat('ERROR',['error in read_image.m: ' imageB ' is not an image name recognized by Matlab '])
     501         msgbox_uvmat('ERROR',['error: ' imageB ' is not an image name recognized by Matlab '])
    527502         return
    528503    end
     
    601576
    602577
    603 %------------------------------------------------
    604 function TITLE=set_title(Style,ProjMode)
    605 %------------------------------------------------
    606 if isequal(Style,'points')
    607     TITLE='POINTS';
    608 elseif isequal(Style,'line')|isequal(Style,'polyline')
    609     TITLE='LINE';
    610 elseif isequal(Style,'plane')
    611     TITLE='PLANE';
    612 elseif isequal(Style,'volume')
    613     TITLE='VOLUME';
    614 elseif isequal(Style,'polygon')|isequal(Style,'rectangle')|isequal(Style,'ellipse')
    615     if isequal(ProjMode,'inside')|isequal(ProjMode,'outside')
    616         TITLE='PATCH';
    617     else
    618         TITLE='LINE';
    619     end
    620 end
    621 
    622 
    623578% --- Executes on slider movement.
    624579function z_slider_Callback(hObject, eventdata, handles)
  • trunk/src/struct2nc_toolbox.m

    r19 r46  
    8989        siz=size(VarVal);
    9090        VarDimIndex=Data.VarDimIndex{ivar}; %indices of the variable dimensions in the list of dimensions
    91         VarDimName=Data.VarDimName{ivar};%NEW
    92         if ischar(VarDimName)%NEW
    93             VarDimName={VarDimName};%NEW
    94         end%NEW
    95         testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2); %NEW
     91        VarDimName=Data.VarDimName{ivar};
     92        if ischar(VarDimName)
     93            VarDimName={VarDimName};
     94        end
     95        testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2);
    9696        testline=isequal(length(siz),2) & isequal(siz(1),1)& isequal(siz(2), Data.DimValue(VarDimIndex));
    9797        testcolumn=isequal(length(siz),2) & isequal(siz(1), Data.DimValue(VarDimIndex))& isequal(siz(2),1);
     
    100100            break
    101101        end
    102         if testline || testrange%NEW
     102        if testline || testrange
    103103           dimname=Data.ListDimName{VarDimIndex};
    104            if testrange%NEW
    105                VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex));%NEW
    106            end%NEW
     104           if testrange
     105               VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex));
     106           end
    107107           nc{ListVarName{ivar}}=ncfloat(dimname);%vector of x coordinates
    108108           nc{ListVarName{ivar}}(:) = VarVal'; 
     
    113113        %write variable attributes
    114114        if testattr
    115             for ivar=1:length(VarAttribute) 
    116                 if isstruct(VarAttribute{ivar})
    117                     attr_names=fields(VarAttribute{ivar});
     115            for ivarattr=1:length(VarAttribute) 
     116                if isstruct(VarAttribute{ivarattr})
     117                    attr_names=fields(VarAttribute{ivarattr});
    118118                    for iattr=1:length(attr_names)
    119119                        eval(['attr_val=VarAttribute{ivar}.' attr_names{iattr} ';']);
Note: See TracChangeset for help on using the changeset viewer.