Home > atmlab > arts > netcdf > arts_nc_read_arrayofmatrix.m

arts_nc_read_arrayofmatrix

PURPOSE ^

ARTS_NC_READ_ARRAYOFMATRIX Read ArrayOfMatrix from ARTS NetCDF file.

SYNOPSIS ^

function [ret, gattr] = arts_nc_read_arrayofmatrix (filename)

DESCRIPTION ^

 ARTS_NC_READ_ARRAYOFMATRIX   Read ArrayOfMatrix from ARTS NetCDF file.

    Reads an ArrayOfMatrix from a NetCDF file saved with Arts.

 FORMAT   ret = arts_nc_read_arrayofmatrix(filename)
        
 OUT   ret      ArrayOfMatrix
 OUT   gattr    Global attributes
       
 IN    filename Name of NetCDF input file.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

arts_nc_read_arrayofmatrix.m

SOURCE CODE ^

0001 % ARTS_NC_READ_ARRAYOFMATRIX   Read ArrayOfMatrix from ARTS NetCDF file.
0002 %
0003 %    Reads an ArrayOfMatrix from a NetCDF file saved with Arts.
0004 %
0005 % FORMAT   ret = arts_nc_read_arrayofmatrix(filename)
0006 %
0007 % OUT   ret      ArrayOfMatrix
0008 % OUT   gattr    Global attributes
0009 %
0010 % IN    filename Name of NetCDF input file.
0011 
0012 % 2010-02-01   Created by Oliver Lemke.
0013 
0014 function [ret, gattr] = arts_nc_read_arrayofmatrix (filename)
0015 
0016 ncid = netcdf.open (filename, 'NOWRITE');
0017 
0018 gattr = loadncglobalattr (filename);
0019 
0020 varid = netcdf.inqVarID (ncid, 'Matrix_nrows');
0021 nr = netcdf.getVar (ncid, varid);
0022 
0023 varid = netcdf.inqVarID (ncid, 'Matrix_ncols');
0024 nc = netcdf.getVar (ncid, varid);
0025 
0026 varid = netcdf.inqVarID (ncid, 'ArrayOfMatrix');
0027 m = netcdf.getVar (ncid, varid);
0028 netcdf.close (ncid);
0029 
0030 startelem = 1;
0031 
0032 ret=cell(length(nr),1);
0033 for i = 1:length(nr)
0034     endelem = startelem + nr(i)*nc(i) - 1;
0035     ret{i} = reshape (m(startelem:endelem), nc(i), nr(i))';
0036     startelem = endelem + 1;
0037 end
0038

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