Changeset 1028 for trunk


Ignore:
Timestamp:
Jan 8, 2018, 9:52:53 PM (6 years ago)
Author:
sommeria
Message:

option for reading fields in terms of matrix index

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_field_bounds.m

    r1027 r1028  
    4747end
    4848FieldOut.NbDim=NbDim;
    49 if  NbDim<=1; return; end% stop here for 1D fields
     49%if  NbDim<=1; return; end% stop here for 1D fields
    5050 
    5151%% get bounds and mesh (needed  to propose default options for projection objects)
     
    6666            CellInfo{imax(ind)}.CoordIndex(4:end)=[];
    6767        end
    68         XName=Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)};
    69         YName=Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)};
    70         CoordMax(ind,NbDim)=max(max(Field.(XName)));
    71         CoordMin(ind,NbDim)=min(min(Field.(XName)));
    72         CoordMax(ind,NbDim-1)=max(max(Field.(YName)));
    73         CoordMin(ind,NbDim-1)=min(min(Field.(YName)));
    74         %         test_x=1;%test for unstructured coordinates
    75         if NbDim==3
    76             ZName=Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)};
    77             CoordMax(ind,NbDim-2)=max(max(Field.(ZName)));
    78             CoordMin(ind,NbDim-2)=min(min(Field.(ZName)));
     68        if isempty(CellInfo{imax(ind)}.CoordIndex)
     69            FieldName=CellInfo{imax(ind)}.FieldName;
     70            DimList=Field.VarDimName{imax(ind)};
     71            siz=size(DimList);
     72
     73            FieldOut.(DimList{end})=1:siz(end);
     74            FieldOut.ListVarName=[FieldOut.ListVarName DimList(end)];
     75            FieldOut.VarDimName=[FieldOut.VarDimName DimList(end)];
     76            CoordMax(ind,numel(siz))=siz(end);
     77            if numel(siz)>=2
     78                FieldOut.(DimList{end-1})=1:siz(end-1);
     79                CoordMax(ind,numel(siz)-1)=siz(end-1);
     80                FieldOut.ListVarName=[FieldOut.ListVarName DimList(end-1)];
     81                FieldOut.VarDimName=[FieldOut.VarDimName DimList(end-1)];
     82            end
     83            if numel(siz)>=3
     84                FieldOut.(DimList{1})=1:siz(1);
     85                CoordMax(ind,1)=siz(1);
     86                FieldOut.ListVarName=[FieldOut.ListVarName DimList(1)];
     87                FieldOut.VarDimName=[FieldOut.VarDimName DimList(1)];
     88            end
     89            CoordMin(ind,1:numel(siz))=1;
     90            CellInfo{imax(ind)}.CoordSize=CoordMax(ind,:);
     91        else
     92            XName=Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)};
     93            YName=Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)};
     94            CoordMax(ind,NbDim)=max(max(Field.(XName)));
     95            CoordMin(ind,NbDim)=min(min(Field.(XName)));
     96            CoordMax(ind,NbDim-1)=max(max(Field.(YName)));
     97            CoordMin(ind,NbDim-1)=min(min(Field.(YName)));
     98            %         test_x=1;%test for unstructured coordinates
     99            if NbDim==3
     100                ZName=Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)};
     101                CoordMax(ind,NbDim-2)=max(max(Field.(ZName)));
     102                CoordMin(ind,NbDim-2)=min(min(Field.(ZName)));
     103            end
    79104        end
    80105    end
     
    87112            NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points in each direction
    88113            if Check4D
    89                NbPoints=NbPoints(1:3);
     114                NbPoints=NbPoints(1:3);
    90115            end
    91116            Mesh(ind)=min((CoordMax(ind,:)-CoordMin(ind,:))./(NbPoints-1));
     
    98123            FieldOut.ProjModeRequest='interp_lin';
    99124        end
    100     end 
     125    end
    101126end
    102127Mesh=min(Mesh);
  • trunk/src/get_field.m

    r1027 r1028  
    149149    ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];% the time can be chosen as a global attribute
    150150end
     151
     152Check_index=0;
    151153if Field.MaxDim>=2
    152154    ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'matrix index'}];% the time can be chosen as a dim index
     155else
     156    for ilist=1:numel(Field.Display.VarDimName)
     157        NbComponent=numel(Field.Display.VarDimName{ilist});
     158        if NbComponent>=2% multicomponent matrices without coordinate variables (thus not considered in the fct find_field_cell)
     159            ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'matrix index'}];% the time can be chosen as a dim index
     160            Check_index=1;
     161            break
     162        end
     163    end
    153164end
    154165
     
    220231    if check_vec_input
    221232        set(handles.FieldOption,'Value',3)% set vector selection option
    222     else
    223        
     233    else     
    224234        set(handles.FieldOption,'Value',2)% set scalar selection option
    225235    end
Note: See TracChangeset for help on using the changeset viewer.