Ignore:
Timestamp:
Apr 18, 2015, 11:03:01 PM (9 years ago)
Author:
sommeria
Message:

bugs solved for reading general netcdf files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_field_cells.m

    r809 r890  
    210210%            2)the coordinate variable contains only two elements, representing the coordinate bounds for the dimension with the same name as the cordinate
    211211ivar_remain=find(~check_select);% indices of remaining variables, not already taken into account
    212 ListVarName=Data.ListVarName(~check_select);%list of remaining variables
     212ListVarName=Data.ListVarName(~check_select);%list of names of remaining variables
    213213VarDimName=Data.VarDimName(~check_select);%dimensions of remaining variables
    214214check_coord_select= cellfun(@numel,VarDimName)==1|cellfun(@ischar,VarDimName)==1;% find remaining variables with a single dimension
    215215check_coord_select=check_coord_select & ~strcmp('ancillary',Role(~check_select));% do not select ancillary variables as coordinates
    216 %check_coord(~check_select)=check_coord_select;
    217216ListCoordIndex=ivar_remain(check_coord_select);% indices of remaining variables with a single dimension
    218217ListCoordName=ListVarName(check_coord_select);% corresponding names of remaining variables with a single dimension
     
    220219
    221220%remove redondant variables -> keep only one variable per dimension
    222 check_keep=logical(ones(size(ListDimName)));
     221check_keep=true(size(ListDimName));
    223222for idim=1:numel(ListDimName)
    224     prev_ind=strcmp(ListDimName{idim},ListDimName(1:idim-1));% check whether the dimension is already taken into account
    225     if ~isempty(prev_ind)
     223    prev_ind=find(strcmp(ListDimName{idim},ListDimName(1:idim-1)));% check whether the dimension is already taken into account
     224    if ~isempty(prev_ind)% in case of multiple coord variable
    226225        if strcmp(ListCoordName{idim},ListDimName{idim}) %variable with the same name as the coordinate taken in priority
    227             check_keep(prev_ind)=0;
     226            check_keep(prev_ind)=0;% choose a variable with the same name as coordinate in priority
    228227        else
    229            check_keep(idim)=0;
     228           check_keep(idim)=0; %keep the first coordiante variable found
    230229        end
    231230    end
     
    256255NewCellDimIndex={};
    257256NewNbDim=[];
    258 for ivardim=1:numel(VarDimName) % loop at the list of remaining variables
     257for ivardim=1:numel(VarDimName) % loop at the list of dimensions for the remaining variables
    259258    DimCell=VarDimName{ivardim};% dimension names of the current variable
    260259    if ischar(DimCell), DimCell={DimCell}; end %transform char to cell if needed
Note: See TracChangeset for help on using the changeset viewer.