VarAttName Becoming a Variable Attribute itself

From: Gregory Deemer <gjdeemer_at_nyahnyahspammersnyahnyah>
Date: Tue Sep 17 2013 - 13:08:26 MDT


The following snippet of code shows my setup for creating a new variable, variable attributes, and attribute values.

f_out.create_variable('Tsfc', 'f', ('time', 'lat', 'lon'))
    # Create variable attributes
    f_out.variables['Tsfc'].varAttName = 'standard_name'
    f_out.variables['Tsfc'].varAttName = 'units'
    f_out.variables['Tsfc'].varAttName = '_FillValue'
    f_out.variables['Tsfc'].varAttName = 'missing_value'
    f_out.variables['Tsfc'].varAttName = 'scale_factor'
    f_out.variables['Tsfc'].varAttName = 'add_offset'
    setattr(f_out.variables['Tsfc'], 'standard_name', 'surface_temperature_where_sea_ice')
    setattr(f_out.variables['Tsfc'], 'units', 'DegC')
    setattr(f_out.variables['Tsfc'], '_FillValue', _FillandMiss)
    setattr(f_out.variables['Tsfc'], 'missing_Value', _FillandMiss)
    setattr(f_out.variables['Tsfc'], 'scale_factor', np.array(0.002, dtype=np.float32))
    setattr(f_out.variables['Tsfc'], 'add_offset', offset)
    # Write value to file

Where _FillandMiss, offset, and Tsfc have values previously assigned to them. My script functions without error and I have been able to use the resulting NetCDF file in GrADS without error as well. My question comes in here: after executing an 'ncdump -h *.nc' command for the output file (below), I get the following snippet where the last f_out.variables['var'].varrAttName = 'varAttName' becomes an actual attribute of the variable created. Why is this occurring? I would like to clean this up.

ncdump -h *.nc
 float Tsfc(time, lat, lon) ;
                Tsfc:varAttName = "add_offset" ;
                Tsfc:standard_name = "surface_temperature_where_sea_ice" ;
                Tsfc:units = "DegC" ;
                Tsfc:_FillValue = -30000.f ;
                Tsfc:missing_Value = -30000.f ;
                Tsfc:scale_factor = 0.002f ;
                Tsfc:add_offset = 0.f ;

Thank you kindly,

pyngl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Tue Sep 17 13:08:37 2013

This archive was generated by hypermail 2.1.8 : Fri Nov 22 2013 - 09:37:03 MST