Re: Nio.open_file problem : object.__init__() takes no parameters

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Wed Feb 17 2010 - 11:50:24 MST

If you have a NetCDF4 version of ncdump you can answer these questions
using the '-k' option. It turns out that TM5.th.nc4 is a regular
NetCDF4 file, not a classic file, according to ncdump:

$ ncdump -k TM5.th.nc4
netCDF-4

whereas files that are produced by the current NIO library give this:

$ ncdump -k testout.nc4
netCDF-4 classic model

$ ncdump -h TM5.th.nc4
netcdf TM5.th {
dimensions:
        time = 17520 ;
variables:
        float conc(time) ;
}

Note that the NetCDF 4 file does not contain anything actually
incompatible with NetCDF 3. In looking at the NCL code, I see that it
checks the format of the file, but it does not error if it's a true
(not classic) NetCDF 4 file. So If it did encounter NetCDF4-only
features it would probably choke. Probably it should return an error
saying that the format is not supported yet...
  -dave

On Feb 17, 2010, at 9:48 AM, Mary Haley wrote:

> Hi Sourish,
>
> I've got the file. (Dave, it's on shadowy in /local/data/cdf.)
>
> I *think* it must be a classic nc4 file, because I was able to read
> it with both ncl and pynio. However, I'm not sure if there might be
> something else on the file that ncl/pynio is just ignoring.
> Hopefully Dave can clarify.
>
>
> Here's what I get with the latest versio of PyNIO on my Mac (OS 10.4):
>
> sheridan[53] python
> Python 2.6.2 (r262:71600, Aug 10 2009, 15:44:14)
> [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import Nio
> >>> a = Nio.open_file('TM5.th.nc4')
> >>> print(a)
> Nio file: TM5.th.nc4
> global attributes:
> dimensions:
> time = 17520
> variables:
> float conc [ time ]
> >>> conc = a.variables['conc'][:]
> >>> print(conc)
> [ 383.83953857 383.84231567 383.84408569 ..., 388.06155396
> 388.0663147
> 388.07000732]
>
> --Mary
>
>
> On Feb 17, 2010, at 5:41 AM, Sourish Basu wrote:
>
>> Hi Mary,
>>
>> Sorry, the FTP server deletes files in that directory after a few
>> days. I've put a smaller file there now, TM5.th.nc4. On my system,
>> PyNIO can open this file. Can you tell me if this is a "true
>> NetCDF4" file?
>>
>> -Sourish
>>
>> Mary Haley wrote:
>>> Hi Sourish,
>>>
>>> Dave Brown is the author of PyNIO, and will have a better idea of
>>> how it should handle NetCDF 4 files. I've CC'ed him.
>>>
>>> I tried to download your file, but it doesn't appear to be there
>>> anymore:
>>>
>>> ftp ftp.phys.uu.nl
>>> Connected to tijger.phys.uu.nl.
>>> 220 Anonymous ftp service Physics Department UU
>>> Name (ftp.phys.uu.nl:haley): anonymous
>>> 331 Please specify the password.
>>> Password:
>>> 230 Login successful.
>>> Remote system type is UNIX.
>>> Using binary mode to transfer files.
>>> cd ftp> cd uploads
>>> 250 Directory successfully changed.
>>> ftp> get DailyColDens.th.2002.nc4
>>> local: DailyColDens.th.2002.nc4 remote: DailyColDens.th.2002.nc4
>>> 229 Entering Extended Passive Mode (|||43608|)
>>> 550 Failed to open file.
>>> ftp> ls
>>> 229 Entering Extended Passive Mode (|||19497|)
>>> 150 Here comes the directory listing.
>>> 226 Directory send OK.
>>> ftp> pwd
>>> 257 "/uploads"
>>> ftp> quit
>>> 221 Goodbye.
>>>
>>> --Mary
>>>
>>> On Feb 12, 2010, at 6:10 AM, Sourish Basu wrote:
>>>
>>>> Hi Mary,
>>>>> But meanwhile, I'm not sure what's going on here. I think Dave
>>>>> said he might know, but he's out today.
>>>>>
>>>>> Is this file a true NetCDF4 file, or a NetCDF 4 classic file?
>>>>> NCL and PyNIO cannot yet read true NetCDF 4 files.
>>>>
>>>> It is a true NetCDF4 file, but I'm surprised at what you say. I
>>>> used to read the exact same file with PyNIO before I switched
>>>> over to a 64-bit Linux system and recompiled NCL and PyNIO. In
>>>> fact, now my old code, where I used Nio for reading, is causing
>>>> python to crash with messages such as 'ncdiminq: ncid 65536:
>>>> NetCDF: Invalid dimension ID or name'. But the same code, for
>>>> reading the same file, used to work, I think (unless I switched
>>>> the file format at some point, but I don't remember doing that).
>>>> Could you have a look at the following file:
>>>>
>>>> ftp.phys.uu.nl/uploads/DailyColDens.th.2002.nc4
>>>>
>>>> and tell me whether PyNIO is supposed to be able to read it?
>>>>
>>>> Thanks,
>>>>
>>>> -Sourish
>>>>
>>>
>>>
>>
>
Received on Wed Feb 17 11:50:26 2010

This archive was generated by hypermail 2.1.8 : Wed May 26 2010 - 10:38:10 MDT