Changeset 674 for trunk/src/struct2nc.m


Ignore:
Timestamp:
Aug 23, 2013, 2:56:17 PM (11 years ago)
Author:
sommeria
Message:

various bugs repaired, in particula timing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/struct2nc.m

    r530 r674  
    4747    return
    4848end
    49 %  [Data,errormsg]=check_field_structure(Data);%check the validity of the input field structure
     49%check the validity of the input field structure
    5050[errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data);
    5151if ~isempty(errormsg)
     
    139139%'check_field_structure': check the validity of the field struture representation consistant with the netcdf format
    140140%------------------------------------------------------------------------
    141 % function [DataOut,errormsg]=check_field_structure(Data)
     141% [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data)
    142142%
    143143% OUTPUT:
    144 % DataOut: structure reproducing the input structure Data (TODO: suppress this output)
    145144% errormsg: error message which is not empty when the input structure does not have the right form
     145% ListDimName: list of dimension names (cell array of cahr strings)
     146% DimValue: list of dimension values (numerical array with the same dimension as ListDimName)
     147% VarDimIndex: cell array of dimension index (in the list ListDimName) for each element of Data.ListVarName
    146148%
    147149% INPUT:
     
    179181    return
    180182end
    181 % if isfield(Data,'DimValue')
    182 %     Data=rmfield(Data,'DimValue');
    183 % end
    184183nbdim=0;
    185184ListDimName={};
    186185
    187186%% main loop on the list of variables
     187VarDimIndex=cell(1,nbfield);
    188188for ivar=1:nbfield
    189189    VarName=Data.ListVarName{ivar};
     
    198198    elseif ~iscell(DimCell)
    199199        errormsg=['wrong format for .VarDimName{' num2str(ivar) ' (must be the cell of dimension names of the variable ' VarName];
    200         return
    201        
     200        return       
    202201    end
    203202    nbcoord=numel(sizvar);%nbre of coordinates for variable named VarName
     
    209208        if nbcoord==2
    210209            if sizvar(1)==1
    211                 nbcoord=1;
    212210                sizvar(1)=sizvar(2);
    213211            elseif sizvar(2)==1
    214                 nbcoord=1;
    215212            else
    216213                errormsg=['1 dimension declared in .VarDimName{' num2str(ivar) '} inconsistent with the nbre of dimensions =2 of the variable ' VarName];
     
    227224        if numel(DimCell)>nbcoord
    228225            sizvar(nbcoord+1:numel(DimCell))=1;% case of singleton dimensions (not seen by the function size)
    229            % DimCell=DimCell(end-nbcoord+1:end)%first singleton diemensions omitted,
    230226        elseif nbcoord > numel(DimCell)
    231227            errormsg=['nbre of declared dimensions in .VarDimName{' num2str(ivar) '} smaller than the nbre of dimensions =' num2str(nbcoord) ' of the variable ' VarName];
     
    234230    end
    235231    DimIndex=[];
    236     %for idim=1:nbcoord
    237232    for idim=1:numel(DimCell) %loop on the coordinates of variable #ivar
    238233        DimName=DimCell{idim};
     
    261256    VarDimIndex{ivar}=DimIndex;
    262257end
    263 DataOut=Data;
Note: See TracChangeset for help on using the changeset viewer.