Changeset 1195 for trunk/src/nc2struct.m


Ignore:
Timestamp:
Feb 26, 2026, 4:16:03 PM (5 days ago)
Author:
sommeria
Message:

format of PIV data made more compact/4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/nc2struct.m

    r1194 r1195  
    199199    end
    200200    ListVarName=ListVarName(:,logical(check_keep));
    201     if size(ListVarName,1)>1 %multiple choice of variable ranked by order of priority
    202         for iline=1:size(ListVarName,1)
    203             search_index=find(strcmp(ListVarName{iline,1},ListVarNameNetcdf),1);%look for the first variable name in the list of NetCDF variables
    204             if ~isempty(search_index)
    205                 break % go to the next line
    206             end
    207         end
    208         ichoice=iline-1;%selected line number in the list of input names of variables
    209     else
    210         iline=1;
    211     end
     201    iline=size(ListVarName,1);   
    212202    %ListVarName=ListVarName(iline,:);% select the appropriate option for input variable (lin ein the input name matrix)
    213203    if CheckTimeVar
     
    274264        VarName=Data.ListVarName{ivar};
    275265        VarName=regexprep(VarName,'-','_'); %suppress '-' if it exists in the NetCDF variable name (leads to errors in matlab)
    276         %             CheckSub=0;
    277266        if input_index==4% if a dimension is selected as time
    278267            ind_vec=zeros(1,numel(var_dim{ivar}));% vector with zeros corresponding to al the dimensions of the variable VarName
     
    290279                end
    291280            end
    292 %            tstart = tic;
    293           % disp(VarName)
    294281            Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1,ind_vec,ind_size); %read the variable data
    295 %              telapsed = toc(tstart)
    296282            Data.(VarName)=squeeze(Data.(VarName));%remove singeton dimension
    297 
    298283        else
     284                       disp(VarName)
     285           xtype(var_index(ivar))
    299286            Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1); %read the whole variable data
    300         end
    301         if xtype(var_index(ivar))==5% indicate single precision variable
    302             Data.(VarName)=double(Data.(VarName)); %transform to double for single pecision
     287        end       
     288        Data.(VarName)=double(Data.(VarName)); %transform all variables to double  pecision
     289        if isfield(Data,'VarAttribute') && numel(Data.VarAttribute)>=ivar && isfield(Data.VarAttribute{ivar},'scale_factor')
     290            Data.(VarName)=Data.VarAttribute{ivar}.scale_factor *Data.(VarName);
    303291        end
    304292    end
Note: See TracChangeset for help on using the changeset viewer.