Changeset 729 for trunk


Ignore:
Timestamp:
Mar 4, 2014, 10:21:08 PM (10 years ago)
Author:
sommeria
Message:

bugs repaired for line plots

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plot_field.m

    r690 r729  
    406406        end
    407407    end
    408     MinX(icell)=min(coord_x{icell});
    409     MaxX(icell)=max(coord_x{icell});
    410     testplot(coord_x_index)=0;
    411     if isfield(CellInfo{icell},'VarIndex_ancillary')
    412         testplot(CellInfo{icell}.VarIndex_ancillary)=0;
    413     end
    414     if isfield(CellInfo{icell},'VarIndex_warnflag')
    415         testplot(CellInfo{icell}.VarIndex_warnflag)=0;
    416     end
    417     if isfield(data,'VarAttribute')
    418         VarAttribute=data.VarAttribute;
     408    if ~isempty(coord_x{icell})
     409        MinX(icell)=min(coord_x{icell});
     410        MaxX(icell)=max(coord_x{icell});
     411        testplot(coord_x_index)=0;
     412        if isfield(CellInfo{icell},'VarIndex_ancillary')
     413            testplot(CellInfo{icell}.VarIndex_ancillary)=0;
     414        end
     415        if isfield(CellInfo{icell},'VarIndex_warnflag')
     416            testplot(CellInfo{icell}.VarIndex_warnflag)=0;
     417        end
     418        if isfield(data,'VarAttribute')
     419            VarAttribute=data.VarAttribute;
     420            for ivar=1:length(VarIndex)
     421                if length(VarAttribute)>=VarIndex(ivar) && isfield(VarAttribute{VarIndex(ivar)},'long_name')
     422                    plotname{VarIndex(ivar)}=VarAttribute{VarIndex(ivar)}.long_name;
     423                else
     424                    plotname{VarIndex(ivar)}=data.ListVarName{VarIndex(ivar)};%name for display in plot A METTRE
     425                end
     426            end
     427        end
     428        if isfield(CellInfo{icell},'VarIndex_discrete')
     429            charplot_0='''+''';
     430        else
     431            charplot_0='''-''';
     432        end
     433        MinY=[];
     434        MaxY=[];%default
     435       
     436        nbplot=0;
    419437        for ivar=1:length(VarIndex)
    420             if length(VarAttribute)>=VarIndex(ivar) && isfield(VarAttribute{VarIndex(ivar)},'long_name')
    421                 plotname{VarIndex(ivar)}=VarAttribute{VarIndex(ivar)}.long_name;
    422             else
    423                 plotname{VarIndex(ivar)}=data.ListVarName{VarIndex(ivar)};%name for display in plot A METTRE
    424             end
    425         end
    426     end
    427     if isfield(CellInfo{icell},'VarIndex_discrete')
    428         charplot_0='''+''';
    429     else
    430         charplot_0='''-''';
    431     end
    432     MinY=[];
    433     MaxY=[];%default
    434    
    435     nbplot=0;
    436     for ivar=1:length(VarIndex)
    437         if testplot(VarIndex(ivar))
    438             VarName=data.ListVarName{VarIndex(ivar)};
    439             nbplot=nbplot+1;
    440             ytitle=[ytitle VarName];
    441             if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=VarIndex(ivar) && isfield(data.VarAttribute{VarIndex(ivar)},'units')
    442                 ytitle=[ytitle '(' data.VarAttribute{VarIndex(ivar)}.units '), '];
    443             else
    444                 ytitle=[ytitle ', '];
    445             end
    446             eval(['data.' VarName '=squeeze(data.' VarName ');'])
    447             MinY(ivar)=min(min(data.(VarName)));
    448             MaxY(ivar)=max(max(data.(VarName)));
    449             plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ','];
    450             eval(['nbcomponent2=size(data.' VarName ',2);']);
    451             eval(['nbcomponent1=size(data.' VarName ',1);']);
    452             if numel(coord_x{icell})==2
    453                 coord_x{icell}=linspace(coord_x{icell}(1),coord_x{icell}(2),nbcomponent1);
    454             end
    455             if nbcomponent1==1|| nbcomponent2==1
    456                 legend_str=[legend_str {VarName}]; %variable with one component
    457             else  %variable with severals  components
    458                 for ic=1:min(nbcomponent1,nbcomponent2)
    459                     legend_str=[legend_str [VarName '_' num2str(ic)]]; %variable with severals  components
    460                 end                                                   % labeled by their index (e.g. color component)
    461             end
    462         end
    463     end
    464     if ~isempty(MinY)
    465         MinY_cell(icell)=min(MinY);
    466         MaxY_cell(icell)=max(MaxY);
     438            if testplot(VarIndex(ivar))
     439                VarName=data.ListVarName{VarIndex(ivar)};
     440                nbplot=nbplot+1;
     441                ytitle=[ytitle VarName];
     442                if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=VarIndex(ivar) && isfield(data.VarAttribute{VarIndex(ivar)},'units')
     443                    ytitle=[ytitle '(' data.VarAttribute{VarIndex(ivar)}.units '), '];
     444                else
     445                    ytitle=[ytitle ', '];
     446                end
     447                eval(['data.' VarName '=squeeze(data.' VarName ');'])
     448                MinY(ivar)=min(min(data.(VarName)));
     449                MaxY(ivar)=max(max(data.(VarName)));
     450                plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ','];
     451                eval(['nbcomponent2=size(data.' VarName ',2);']);
     452                eval(['nbcomponent1=size(data.' VarName ',1);']);
     453                if numel(coord_x{icell})==2
     454                    coord_x{icell}=linspace(coord_x{icell}(1),coord_x{icell}(2),nbcomponent1);
     455                end
     456                if nbcomponent1==1|| nbcomponent2==1
     457                    legend_str=[legend_str {VarName}]; %variable with one component
     458                else  %variable with severals  components
     459                    for ic=1:min(nbcomponent1,nbcomponent2)
     460                        legend_str=[legend_str [VarName '_' num2str(ic)]]; %variable with severals  components
     461                    end                                                   % labeled by their index (e.g. color component)
     462                end
     463            end
     464        end
     465        if ~isempty(MinY)
     466            MinY_cell(icell)=min(MinY);
     467            MaxY_cell(icell)=max(MaxY);
     468        end
    467469    end
    468470end
  • trunk/src/set_object.m

    r705 r729  
    578578    % update the representation of all objects in view_field
    579579    for iobj=1:numel(UvData.ProjObject)
    580         if isfield(UvData.ProjObject{iobj}.DisplayHandle,'view_field')
     580        if isfield(UvData.ProjObject{iobj},'DisplayHandle') && isfield(UvData.ProjObject{iobj}.DisplayHandle,'view_field')
    581581            UvData.ProjObject{iobj}.DisplayHandle.view_field=...
    582582                plot_object(UvData.ProjObject{iobj},UvData.ProjObject{iobj},UvData.ProjObject{iobj}.DisplayHandle.view_field,'b');
  • trunk/src/uvmat.m

    r726 r729  
    37083708list_path=get(handles.TransformName,'UserData');
    37093709
    3710 %% handles uicontrol visibility
     3710%% handles  visibility of the path to the transform function
    37113711if isempty(transform_name)
    37123712    set(handles.TransformPath,'Visible','off')
     
    37143714    set(handles.TransformPath,'Visible','on')
    37153715end
    3716 
    37173716
    37183717%% add a new item to the menu if the option 'more...' has been selected
     
    37873786if ~isempty(list_path{ichoice})
    37883787    if nargin(transform_handle)>1 && isfield(UvData,'XmlData')&&~isempty(UvData.XmlData)
    3789         XmlData=UvData.XmlData{1};
    3790         DataOut=feval(transform_handle,'*',XmlData);
     3788        %XmlData=UvData.XmlData{1};
     3789        DataOut=feval(transform_handle,'*',UvData.XmlData{1});
    37913790        if isfield(DataOut,'CoordUnit')% set the requested coord unit (info used to possibly delete the current projection objects)
    37923791            CoordUnit=DataOut.CoordUnit;
     
    37953794            UvData.InputFieldType=DataOut.InputFieldType;
    37963795        end
    3797         if isfield(DataOut,'XmlData')%  used to add transform parameters at selection of the transform fct
    3798             ListFields=fieldnames(DataOut.XmlData);
    3799             for ilist=1:numel(ListFields)
    3800             UvData.XmlData{1}.(ListFields{ilist})=DataOut.XmlData.(ListFields{ilist});
    3801             end
    3802         end
    3803     else
    3804         DataOut=feval(transform_handle,'*');
     3796        if isfield(DataOut,'TransformInput')%  used to add transform parameters at selection of the transform fct
     3797            UvData.XmlData{1}.TransformInput=DataOut.TransformInput;
     3798%             ListFields=fieldnames(DataOut.XmlData);
     3799%             for ilist=1:numel(ListFields)
     3800%             UvData.XmlData{1}.(ListFields{ilist})=DataOut.XmlData.(ListFields{ilist});
     3801%             end
     3802        end
     3803%     else
     3804%         DataOut=feval(transform_handle,'*');
    38053805    end
    38063806end
     
    42604260IndexObj=get(handles.ListObject,'Value');%present object selection
    42614261UvData=get(handles.uvmat,'UserData');
     4262if numel(UvData.ProjObject)<IndexObj
     4263    return
     4264end
    42624265ObjectData=UvData.ProjObject{IndexObj};
    42634266    ZBounds=0; % default
     
    45464549    end
    45474550    UvData.ProjObject(IndexObj)=[];
     4551end
    45484552    if ~isempty(list_str)
    45494553        list_str(IndexObj)=[];
    45504554    end
    4551 end
     4555% end
    45524556set(huvmat,'UserData',UvData);
    45534557set(hlist_object,'String',list_str)
Note: See TracChangeset for help on using the changeset viewer.