Re: [Nio] assigning to a string/char NetCDF variable does not work

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Thu Jul 14 2011 - 18:19:57 MDT

Hi Michael,
Sorry for the delay, but I have finally been able to take a look at this problem. The issue is simply that the assignment must specify equal numbers of characters on both the left and right sides or
you get a dimensional mismatch. The simplest approach, that seems to work with all versions of numpy and PyNIO that I have tried is to subscript the file variable on the left using the length
of the string. You cannot use the assign_variable method because it does not allow for subscripting.

I am attaching a modified version of your original script that illustrates how this works.
 -dave

On Jun 16, 2011, at 3:09 AM, Michael Decker wrote:

> Hi everyone,
>
> I just noticed I don't manage to assign a string value to a non-scalar
> string/char-typed variable in a NetCDF file using Nio. I could not find
> any documentation on assignment of string values to NetCDF variables on
> the Nio webpages but I am relatively sure that it has already worked
> some time ago. (I can't be absolutely certain about that, though).
> Assigning a string of len 1 to a scalar char variable works as expected
> in straight-forward notation.
> I attached a small script that reproduces the problem on our system
> (Debian GNU/Linux stable). We're using Nio 1.4.0, which is the newest
> version as far as I can tell.
> I have tried a few alternative ways I thought might work (see commented
> lines) without any luck. Does anyone have an idea how it could work or
> if this is a bug in Nio?
>
> Regards,
> Michael
>
> --
> Michael Decker
> Forschungszentrum Jülich
> Institut für Energie- und Klimaforschung - Troposphäre (IEK-8)
>
> E-Mail: m.decker@fz-juelich.de
>
> ------------------------------------------------------------------------------------------------
> ------------------------------------------------------------------------------------------------
> Forschungszentrum Juelich GmbH
> 52425 Juelich
> Sitz der Gesellschaft: Juelich
> Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
> Vorsitzender des Aufsichtsrats: MinDirig Dr. Karl Eugen Huthmacher
> Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
> Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
> Prof. Dr. Sebastian M. Schmidt
> ------------------------------------------------------------------------------------------------
> ------------------------------------------------------------------------------------------------
>
> <nio_string.py>_______________________________________________
> 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 Thu Jul 14 18:20:02 2011

This archive was generated by hypermail 2.1.8 : Fri Jul 29 2011 - 08:51:37 MDT