[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[python #QOU-764758]: Writing int attributes with Python netCDF4 ?


The easiest way is to use the NumPy type corresponding to what you want, in 
this case numpy.int32:

    from netCDF4 import Dataset
    import numpy as np
    nc = Dataset('test3.nc', 'w')
    nc.myattr = np.int32(5)

    nc = Dataset('test3.nc')
    print(type(nc.myattr))  # Prints "numpy.int32"

Hope this helps,


> Hello -
> Is it possible to write 32-bit integer attributes with the Python netCDF4 
> module, rather than the default 64 bit integers? Iâve tried the obvious 
> thing of using {attribute_name:int(1)} in the all to ncsetattrs().

Ticket Details
Ticket ID: QOU-764758
Department: Support Python
Priority: Low
Status: Closed
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.