Re: creating netcdf file

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Jul 09 2010 - 07:40:58 MDT

Hi,

Daryl brings up something important. You can run into incompatibility issues
between versions of PyNIO, Python and numpy. I recommend using python 2.5 or 2.6, numpy 1.3.0,
and download PyNIO 1.3.0b5. If you use an older or newer version of numpy, especially, you
may run into problems.

BTW, Dave Brown and I are trying to get an official release of PyNIO out next week.

We want to clean up the compilation so that you don't need to have NCL installed
in order to build PyNIO from source code. This will not be the case for PyNGL,
as it requires several NCL libraries in order to be built.

--Mary

On Jul 7, 2010, at 11:14 AM, daryl herzmann wrote:

> Greetings,
>
> This test worked fine for me on python2.5, numpy 1.3.0 and Nio 1.3.0b5 ,
> which versions are you using?
>
> daryl
>
> On Wed, 7 Jul 2010, Oleksandr Huziy wrote:
>
>> 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 exception:
>>
>> fatal:FileWriteVar: Type mismatch, can't perform assignment
>>
>> Traceback (most recent call last):
>> File "/Users/huziy/Netbeans Projects/Python/PlotWatrouteData/src/binary/test.py", line 35, in <module>
>> test()
>> File "/Users/huziy/Netbeans Projects/Python/PlotWatrouteData/src/binary/test.py", line 28, in test
>> the_var[:] = data.astype('i')
>> File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PyNIO/Nio.py", 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 = 'test1.nc<http://test1.nc>'
>> if os.path.isfile(file_path):
>> os.remove(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')
>>
>> file.close()
>>
>> if __name__ == "__main__":
>> test()
>>
>> 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:
> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk

_______________________________________________
pyngl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Fri Jul 9 07:41:04 2010

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