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

[netCDF #WDC-117990]: Help in creating scalar variable with 0 dimension



Hi,

Sorry you've been having problems. What you need to do is pass an empty tuple 
for the dimension parameter for the creating the variable:

    numLines = goesr_remap.createVariable('numLines', np.short, ())

Then to set the value you do a full slice of the variable and set it to the 
value:

    numLines[:] = 1401

Ryan

> Hello,
> I am struggling in creating a netcdf file in python that containing two
> dimension data, and additional variables with have no dimension.
> I am trying to create a netcdf file that contains 2-dimesional data arrays
> and additional scalar variables with no dimension, just to hold one value.
> I appreciate any help you can provide me to succeed what I am trying to do.
> 
> 
> Here how I tried to created my netCDF file (using PYTHON):
> ydim = goesr_remap.createDimension('ydim', 1401)
> xdim = goesr_remap.createDimension('xdim', 3152)
> 
> # Create the actual 2-d variable
> gvar_ch8 = goesr_remap.createVariable('gvar_ch8', np.short,
> ('ydim','xdim'))
> # define lat/lon grid for remapping
> latitudes = goesr_remap.createVariable('latitude', np.short,   ('ydim',))
> longitudes = goesr_remap.createVariable('longitude', np.short,  ('xdim',))
> 
> 
> # Here how I tried to creating scalar variables
> # But this results in creating these variables with unlimited dimension
> numLines = goesr_remap.createVariable('numLines', short)   ======> e.g.
> numLines = 1401
> numElems = goesr_remap.createVariable('numElems', short)
> lineRes = goesr_remap.createVariable('lineRes', short)
> elemRes = goesr_remap.createVariable('elemRes', short)
> imageDate = goesr_remap.createVariable('imageDate', int32)
> imageTime = goesr_remap.createVariable('imageTime', int32)

Ticket Details
===================
Ticket ID: WDC-117990
Department: Support Python
Priority: Normal
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.