Re: [netcdf-java] How to determine netcdf file type/version?

Hi John,

Thanks for this suggestion. Yes, I think that would work as a stop-gap.

Perhaps, as you intimate, there is a case for a couple of additional
convenience methods in the IOSP interface, viz:

getFileType() - returns the acronym for the file type, e.g. 'PP'.
getFileDescriptor() - returns a 1-line description of the file type,
e.g. 'UK Met Office 32-bit IEEE-754 Post-Processed File'

But having only written one IOSP I suspect there are subtleties that I'm
unaware of :-)

Regards
Phil

-----Original Message-----
From: John Caron [mailto:caron@xxxxxxxxxxxxxxxx] 
Sent: Saturday, April 04, 2009 9:21 PM
To: Bentley, Philip
Cc: netcdf-java@xxxxxxxxxxxxxxxx
Subject: Re: [netcdf-java] How to determine netcdf file type/version?

Hi Philip:

NetcdfFile, despite its name, is the interface to all the "common data
model" files, not just netcdf format. So we dont have much of an
interface to netcdf specific info.

Currently what you can do is:
 
IOServiceProvider  iosp = NetcdfFile.getIosp();

if (iosp instanceof N3iosp) {
 ...
} else if (iosp instanceof H5iosp) {
...
}

Note that you are really breaking encapsolation. Theres no guarantee
that we might have a different netcdf or hdf5 implementation at some
point.

Let me know if that will suffice anyway. I will consider adding a
getFileType() method.

John



Bentley, Philip wrote:
> Hi,
>
> Is there a quick-and-easy way in nj 4.x to determine the type of a 
> passed-in netcdf file; that is, whether it's a netcdf-3 'classic' 
> binary file or a netcdf-4 hdf-based file? (i.e. without having to read

> the magic number at the head of the file)
>
> I guess I'm thinking of something like a getFileType() or getVersion()

> method on the NetcdfFile class, but looking at the javadoc I can't see

> such an operation.
>
> Regards,
> Phil
>
> _______________________________________________
> netcdf-java mailing list
> netcdf-java@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe, visit: 
> http://www.unidata.ucar.edu/mailing_lists/
>   



  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: