Home > atmlab > arts > netcdf > arts_nc_write_arrayofvector.m

arts_nc_write_arrayofvector

PURPOSE ^

ARTS_NC_WRITE_ARRAYOFVECTOR Write ArrayOfVector to ARTS NetCDF file.

SYNOPSIS ^

function arts_nc_write_arrayofvector (filename, v, varargin)

DESCRIPTION ^

 ARTS_NC_WRITE_ARRAYOFVECTOR   Write ArrayOfVector to ARTS NetCDF file.

    Writes an ArrayOfVector to a NetCDF file for use with Arts.
    Array elements must be column vectors!

 FORMAT   arts_nc_write_arrayofvector(filename, v, varargin)
        
 IN    filename  Name of NetCDF file.
 IN    v         ArrayOfVector variable.
 OPT   varargin  Cell array of name/value pair cells for global attributes

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

arts_nc_write_arrayofvector.m

SOURCE CODE ^

0001 % ARTS_NC_WRITE_ARRAYOFVECTOR   Write ArrayOfVector to ARTS NetCDF file.
0002 %
0003 %    Writes an ArrayOfVector to a NetCDF file for use with Arts.
0004 %    Array elements must be column vectors!
0005 %
0006 % FORMAT   arts_nc_write_arrayofvector(filename, v, varargin)
0007 %
0008 % IN    filename  Name of NetCDF file.
0009 % IN    v         ArrayOfVector variable.
0010 % OPT   varargin  Cell array of name/value pair cells for global attributes
0011 
0012 % 2010-02-03   Created by Oliver Lemke.
0013 
0014 function arts_nc_write_arrayofvector (filename, v, varargin)
0015 
0016 ncid = netcdf.create (filename, 'NC_CLOBBER');
0017 
0018 attributes = optargs( varargin, { [] } );
0019 
0020 if (~isempty(attributes))
0021       addncattributes (ncid, attributes);
0022 end
0023 
0024 ndim = netcdf.defDim (ncid, 'nelem', length(v));
0025 
0026 vdims = zeros (length(v), 1, 'int32');
0027 for i = 1:length(v)
0028     vdims(i) = length(v{i});
0029 end
0030 
0031 ntdim = netcdf.defDim (ncid, 'nelem_total', sum(vdims));
0032 
0033 evarid = netcdf.defVar (ncid, 'Vector_nelem', 'int', ndim);
0034 varid = netcdf.defVar (ncid, 'ArrayOfVector', 'double', ntdim);
0035 
0036 netcdf.endDef (ncid);
0037 
0038 netcdf.putVar (ncid, evarid, vdims);
0039 netcdf.putVar (ncid, varid, vertcat(v{:}));
0040 
0041 netcdf.close (ncid);

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005