creating netcdf file

From: Oleksandr Huziy <guziy.sasha_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 07 2010 - 11:10:32 MDT

Dear list,

I am trying to create netcdf file using Nio.
I cannot save the variable of type integer to the file. Get the following

fatal:FileWriteVar: Type mismatch, can't perform assignment

Traceback (most recent call last):
  File "/Users/huziy/Netbeans
Projects/Python/PlotWatrouteData/src/binary/", line 35, in <module>
  File "/Users/huziy/Netbeans
Projects/Python/PlotWatrouteData/src/binary/", line 28, in test
    the_var[:] = data.astype('i')
line 334, in __setitem__
    self._obj[xsel] = value
SystemError: error return without exception set

The code which results in this error:
import Nio as nio
import os
import numpy as np

X_DIM = 'x'
Y_DIM = 'y'
def test():
    file_path = ''
    if os.path.isfile(file_path):
    file = nio.open_file(file_path, 'c')
    nx = 10
    ny = 10
    file.create_dimension('x', nx)
    file.create_dimension('y', ny)

    the_var = file.create_variable('int_var', 'i', (X_DIM, Y_DIM))
    data = np.zeros((nx, ny))
    the_var[:] = data.astype('i')


if __name__ == "__main__":

If I change file.create_variable('int_var', 'i', (X_DIM, Y_DIM)) to
                  file.create_variable('int_var', 'd', (X_DIM, Y_DIM))
it works. Any help is appreciated, thank you.

Oleksandr Huziy

pyngl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Wed Jul 7 11:10:41 2010

This archive was generated by hypermail 2.1.8 : Wed Aug 04 2010 - 09:35:05 MDT