m_add_default_variable_attributes.m 877 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
function m_add_default_variable_attributes(ncfile,var_name)
% function m_add_default_variable_attributes(ncfile,var_name)
%
% Add the default attributes for a variable to ncfile

vinfo = nc_getvarinfo(ncfile.name,var_name);


if vinfo.Nctype == 6 %this is a double variable
    attlist = {
        'long_name'         ' '
        'units'             ' '
        'min_value'          -99999
        'max_value'          -99999
        '_FillValue'         -99999
        'missing_value'      -99999
        'number_fillvalue'   0
        };

end

if vinfo.Nctype == 2 %this is a char variable
    attlist = {
        'long_name'         ' '
        'units'             ' '
        '_FillValue'        ' '
        'missing_value'     ' '
        'number_fillvalue'   0
        };

end

for k = 1:size(attlist,1)
    nc_attput(ncfile.name,var_name,attlist{k,1},attlist{k,2});
end