Ignore:
Timestamp:
Mar 3, 2010, 11:58:05 PM (11 years ago)
Author:
sommeria
Message:

get_field: list of actions put as functions in subdir get_field (like done for series), store and retrieve the latest opened files.
series: bug repair for action functions
read_get_field: bug repair for the case of vectors with unstructured coordinates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/read_get_field.m

    r32 r34  
    3131empty_coord_x=0;
    3232empty_coord_y=0;
    33 dimname_y={};
     33%dimname_y={};
    3434ListVarName={};
    3535VarDimName={};
    3636SubVarAttribute={};
    37 dim_x=0;
    38 dim_y=0;
     37%dim_x=0;
     38%dim_y=0;
    3939dim_z=0;
    40 dim_vec_x=0;
    41 dim_vec_y=0;
    42 dim_vec_z=0;
    43 c_index=[];
     40%dim_vec_x=0;
     41%dim_vec_y=0;
     42%dim_vec_z=0;
     43%c_index=[];
    4444
    4545%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    5050    val=get(handles.ordinate,'Value');% selection(s) for ordinate
    5151    VarNameCell=inputlist(val); %names of the variable(s) in the list
     52    VarIndex_y=[];
     53    dim_ordinate={};
     54    testpermute=[];
     55    subvarindex=[];
    5256    for ilist=1:length(VarNameCell)
    5357        VarIndex_y(ilist)=name2index(VarNameCell{ilist},Field.ListVarName);%index of the variable in ListVarName
     
    211215        if isempty(VarIndex)% default abscissa = matrix index
    212216%             coord_z_name=dimname_A{1};% name of the x coordinate = dimension of the plotted quantity
    213             empty_coord_z=1;
     217%            empty_coord_z=1;
    214218        else
    215219            dimname_z=Field.VarDimName{VarIndex};
     
    244248%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    245249% vectors
    246 test_vec_x_dimvar=0;%default
    247 test_vec_y_dimvar=0;%default
    248 test_vec_z_dimvar=0;%defaul
     250% test_vec_x_dimvar=0;%default
     251% test_vec_y_dimvar=0;%default
     252% test_vec_z_dimvar=0;%defaul
    249253dimname_vec_x=[];
    250254dimname_vec_y=[];
     
    317321                end
    318322            end
    319             test_vec_x_dimvar=1;
     323%             test_vec_x_dimvar=1;
    320324            SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
    321325        else
     
    350354                end
    351355            end
    352             test_vec_y_dimvar=1;
     356%             test_vec_y_dimvar=1;
    353357            SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
    354358        else
     
    365369        if isempty(VarIndex)% default abscissa = matrix indexTODO like scalar
    366370    %         coord_x_name=dimname_u{2};% name of the x coordinate = dimension of the plotted quantity
    367             empty_coord_vec_z=1;
     371%             empty_coord_vec_z=1;
    368372        else
    369373            dimname_vec_z=Field.VarDimName{VarIndex};
     
    384388                    end
    385389                end
    386                 test_vec_z_dimvar=1;
     390%                 test_vec_z_dimvar=1;
    387391                SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
    388392            else
     
    405409        end
    406410        nbvar=nbvar+1;
    407         w_index=nbvar;
     411%         w_index=nbvar;
    408412        ListVarName{nbvar}=Field.ListVarName{VarIndex};
    409413        VarDimName{nbvar}=dimname_u;
     
    426430        end
    427431        nbvar=nbvar+1;
    428         c_index=nbvar;
     432%         c_index=nbvar;
    429433        ListVarName{nbvar}=Field.ListVarName{VarIndex};
    430434        VarDimName{nbvar}=Field.VarDimName{VarIndex};
     
    528532        if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=field_var_index
    529533            if isfield(Field.VarAttribute{field_var_index},'Coord_2')&& isfield(Field.VarAttribute{field_var_index},'Coord_1')
    530                 Coord_2=Field.VarAttribute{field_var_index}.Coord_2;
    531                 Coord_1=Field.VarAttribute{field_var_index}.Coord_1;
     534%                 Coord_2=Field.VarAttribute{field_var_index}.Coord_2;
     535%                 Coord_1=Field.VarAttribute{field_var_index}.Coord_1;
    532536                testold=1;
    533537            end
     
    571575%permute indices if coord_y is not the first matrix index: vector case
    572576if test_vector
    573     VarNameU=Field.ListVarName{VarIndexU};
    574     DimCellU=Field.VarDimName{VarIndexU} % list of dimensions for u component 
     577    VarNameU=Field.ListVarName{VarIndexU}; % name of u component variable
     578    DimCellU=Field.VarDimName{VarIndexU}; % list of dimensions for u component 
    575579    eval(['npxy=size(SubField.' VarNameU ')']) % npxy= dimension values for the u component
    576580    SingleCellU={};
     
    579583        DimCellU=DimCellU(end-numel(npxy)+1:end); %suppress the first singletons) dimensions
    580584    end
    581     ind_single=find(npxy==1);
    582     SingleCellU=[SingleCellU DimCellU(ind_single)];
     585    ind_single=find(npxy==1);%indices of singleton dimensions
     586    if ind_single<=numel(DimCellU)
     587        SingleCellU=[SingleCellU DimCellU(ind_single)];
     588    end
    583589    ind_select=find(npxy~=1);%look for non singleton dimensions
    584590    DimCellU=DimCellU(ind_select);
     
    627633        end
    628634    end
    629     dimextra=(1:numel(DimCellU));
    630     dimextra(dimU)=[]; %list of unselected dimension indices
    631     DimCellU=DimCellU([dimU dimextra]);
    632     eval(['SubField.' VarNameU '=permute(squeeze(SubField.' VarNameU '),[dimU dimextra]);'])
    633     eval(['SubField.' VarNameV '=permute(squeeze(SubField.' VarNameV '),[dimU dimextra]);'])
    634     SubField.VarDimName{VarSubIndexU}=DimCellU;
    635     SubField.VarDimName{VarSubIndexV}=DimCellU;
    636    
     635    if numel(DimCellU)>1
     636        dimextra=(1:numel(DimCellU));
     637        dimextra(dimU)=[]; %list of unselected dimension indices
     638        DimCellU=DimCellU([dimU dimextra]);
     639        eval(['SubField.' VarNameU '=permute(squeeze(SubField.' VarNameU '),[dimU dimextra]);'])
     640        eval(['SubField.' VarNameV '=permute(squeeze(SubField.' VarNameV '),[dimU dimextra]);'])
     641        SubField.VarDimName{VarSubIndexU}=DimCellU;
     642        SubField.VarDimName{VarSubIndexV}=DimCellU;
     643    end
    637644    %add default coord_x and/or coord_y if empty
    638645    if empty_coord_vec_x || empty_coord_vec_y
     
    650657        if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=field_var_index
    651658            if isfield(Field.VarAttribute{field_var_index},'Coord_2')&& isfield(Field.VarAttribute{field_var_index},'Coord_1')
    652                 Coord_2=Field.VarAttribute{field_var_index}.Coord_2;
    653                 Coord_1=Field.VarAttribute{field_var_index}.Coord_1;
     659%                 Coord_2=Field.VarAttribute{field_var_index}.Coord_2;
     660%                 Coord_1=Field.VarAttribute{field_var_index}.Coord_1;
    654661                testold=1;
    655662            end
     
    711718        eval(['npxy=size(SubField.' VarName ')'])
    712719        if numel(npxy) < numel(DimCell)
    713             DimCell=DimCell(end-numel(npxy)+1:end); %suppress the first singletons) dimensions
    714         end
    715         ind_select=find(npxy~=1) ;%look for non singleton dimensions
    716         DimCell=DimCell(ind_select);
    717         npxy=npxy(ind_select);
     720%             DimCell=DimCell(end-numel(npxy)+1:end); %suppress the first singletons) dimensions
     721        end
     722%         ind_select=find(npxy~=1) ;%look for non singleton dimensions
     723%         DimCell=DimCell(ind_select);
     724%         npxy=npxy(ind_select);
    718725        if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=VarIndex_y(1) ...
    719726                             && isfield(Field.VarAttribute{VarIndex_y(1)},'Coord_1')
    720              Coord_1=Field.VarAttribute{VarIndex_y(1)}.Coord_1;%old convention; use of coord_1
     727%              Coord_1=Field.VarAttribute{VarIndex_y(1)}.Coord_1;%old convention; use of coord_1
    721728             eval(['SubField.' coord_x_name '_index=linspace(Coord_1(1),Coord_1(end),npxy(1));'])
    722729        else
Note: See TracChangeset for help on using the changeset viewer.