Home > atmlab > arts > xml > xmlWriteScatteringMetaData.m

xmlWriteScatteringMetaData

PURPOSE ^

Writes ScatteringMetaData to an XML file.

SYNOPSIS ^

function xmlWriteScatteringMetaData(fid, fidb, data, precision)

DESCRIPTION ^

 Writes ScatteringMetaData to an XML file.

    Internal function that should never be called directly.
    Use *xmlStore* instead.

 FORMAT   xmlWriteScatteringMetaData(fid, fidb, data, precision)

 IN    fid        File descriptor
 IN    fidb       File descriptor for binary file
 IN    data       ScatteringMetaData
 IN    precision  Precision for floats

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

xmlWriteScatteringMetaData.m

SOURCE CODE ^

0001 % Writes ScatteringMetaData to an XML file.
0002 %
0003 %    Internal function that should never be called directly.
0004 %    Use *xmlStore* instead.
0005 %
0006 % FORMAT   xmlWriteScatteringMetaData(fid, fidb, data, precision)
0007 %
0008 % IN    fid        File descriptor
0009 % IN    fidb       File descriptor for binary file
0010 % IN    data       ScatteringMetaData
0011 % IN    precision  Precision for floats
0012 
0013 % 2003-01-09  Created by Oliver Lemke.
0014 
0015 function xmlWriteScatteringMetaData(fid, fidb, data, precision)
0016 
0017 attrlist = [];
0018 % If data doesn't contain a version number, assume latest version
0019 if isfield(data, 'version')
0020     nversion = data.version;
0021     if nversion > 2
0022         error('atmlab:xmlWriteScatteringMetaData:IllegalVersion', ...
0023             'Illegal ScatteringMetaData version number')
0024     end
0025 else
0026     nversion = 2;
0027 end
0028 
0029 attrlist = xmlAddAttribute(attrlist, 'version', sprintf ('%d', nversion));
0030 xmlWriteTag (fid, 'ScatteringMetaData', attrlist);
0031 
0032 xmlWriteString (fid, fidb, data.description, precision);
0033 xmlWriteString (fid, fidb, data.material, precision);
0034 xmlWriteString (fid, fidb, data.shape, precision);
0035 xmlWriteNumeric (fid, fidb, data.density, precision);
0036 xmlWriteNumeric (fid, fidb, data.diameter_max, precision);
0037 xmlWriteNumeric (fid, fidb, data.volume, precision);
0038 xmlWriteNumeric (fid, fidb, data.area_projected, precision);
0039 xmlWriteNumeric (fid, fidb, data.aspect_ratio, precision);
0040 
0041 if nversion == 2
0042     valid_particle_types = { ...
0043         'general', 'macroscopically_isotropic', ...
0044         'horizontally_aligned', 'spherical' };
0045     if ~any(ismember(valid_particle_types, data.particle_type))
0046         error('atmlab:xmlWriteScatteringMetaData:IllegalParticleType', ...
0047             ['Illegal particle_type ' data.particle_type '\n' ...
0048             'Valid types are: ' sprintf('%s ', valid_particle_types{:})])
0049     end
0050     
0051     xmlWriteVector (fid, fidb, data.scat_f_grid, precision);
0052     xmlWriteVector (fid, fidb, data.scat_T_grid, precision);
0053     xmlWriteString (fid, fidb, data.particle_type, precision);
0054     xmlWriteGriddedField3 (fid, fidb, data.complex_refr_index, precision);
0055 end
0056 
0057 xmlWriteCloseTag (fid, 'ScatteringMetaData');
0058

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