Re: Unlimited dimension troubles

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Mon, 2 Feb 2009 11:13:37 -0700

Hi Jesper,

You are correct that PyNIO currently does not give the updated value
of the unlimited dimension length
until the file is closed and reopened. This is probably an oversight
that can be corrected in our next release.

You can indeed write a new element of an unlimited dimension without
knowing how many exist currently.
If you skip over any elements that are currently undefined then those
elements will be filled with missing values.
On the other hand, if you write to an element that already exists
you will overwrite the existing data.

So for now if you want to keep the file open you would need to keep
your own counter of how many elements
currently exist along the unlimited dimension.

I am attaching the example referred to in the message you cite. It or
a slight variation will be part of PyNIO's example set in the
next release.
  -dave

On Feb 2, 2009, at 7:18 AM, Jesper Larsen wrote:

> Hi PyNIO people,
>
> I have written a converter which takes our ocean model output and
> converts it to NetCDF. Previously I closed and reopened my NetCDF file
> before adding a new timestep to the file. This way I had no problems
> getting the length of the unlimited time dimension using the
> NioFile.dimensions['time'] variable.
>
> For performance reasons I am now keeping the file opened. When I
> try to
> get the number of time steps in the file I now get None. How can I get
> the current number of time steps or can I write a new timestep to the
> file without knowing the number of time steps in it?
>
> There was an old post about something similar but the attached file
> has
> disappeared:
>
> http://www.pyngl.ucar.edu/User_forum/Archives/2007/0117.html
>
> Hope you can help
> Jesper
>
> --
> ---
> Jesper Larsen, Ph.D.
> National Environmental Research Institute, University of Aarhus
>
>
>
>
> _______________________________________________
> 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 Mon Feb 02 2009 - 11:13:37 MST

This archive was generated by hypermail 2.2.0 : Tue Mar 03 2009 - 09:55:28 MST