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

[netCDF #NFZ-507170]: Writing data to netcdf


In this case, since you only need to store a single character, it's definitely 
more efficient to use a 'char' (character) variable. To do that, instead of 
`str`, pass `'c'` to `createVariable()`, like I do in this example:

    nc = Dataset('test_char.nc', 'w')
    nc.createDimension('time', 4)
    var = nc.createVariable('ident', 'c', ('time',))
    var[:] = [' ', 'R', 'G', 'R']

Hope this helps!


> Good afternoon Ryan,
> I ran into an issue writing an array of characters (G for gps or R for
> GLONASS) into my netcdf file. reading online it sounds like i might need to
> convert the array in some way but everything i find online seems to point
> to changing a string to a character. My understanding is that I already
> have characters. Can you advise?
> the array
> [image: Screen Shot 2021-08-11 at 2.36.08 PM.png]
> my setup of the variable
> [image: Screen Shot 2021-08-11 at 2.36.52 PM.png]
> and my attempt to load the data to the variable
> [image: Screen Shot 2021-08-11 at 2.37.13 PM.png]
> my attempts to add this variable are commented out right now so that i
> could check that other work on my code while waiting to resolve this issue.

Ticket Details
Ticket ID: NFZ-507170
Department: Support netCDF
Priority: Critical
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.