comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » NetCDF4 problem
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
NetCDF4 problem [message #92995] Thu, 07 April 2016 06:52 Go to next message
DK is currently offline  DK
Messages: 12
Registered: June 2015
Junior Member
Hi,

I'm using IDL 7.1. How can I read the NetCDF4 files using this version of IDL?
Thanks!
Re: NetCDF4 problem [message #92996 is a reply to message #92995] Thu, 07 April 2016 07:36 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
On 04/07/16 09:52, deathknight wrote:
> Hi,
>
> I'm using IDL 7.1. How can I read the NetCDF4 files using this version of IDL?

NetCDF4 support wasn't added until v8.0 so the best (only?) way is to
upgrade your IDL install.

Similarly, HDF5 support wasn't added until v8.3 (?) so that route is a
no go.

I'm sure there are attempts that could be made, e.g. separately build
the zlib/HDF5/netCDF4 libraries into DLLs[*] and then link it into IDL
in some fashion. Insert picture of me wildly waving my arms about
because I really have no idea how to do that in IDL...but I know others
who read this newsgroup do. Whether or not any current advice will apply
to an old IDL version is the kicker.

Simplest, and maybe even least expensive (in terms of time-$$), is an
upgrade.

Not much help, I know.

cheers,

paulv

[*] FWIW, building the zlib/HDF5/netCDF4 libraries is ridiculously easy.
The instructions at the UCAR netCDF website are simple to follow.
Re: NetCDF4 problem [message #92997 is a reply to message #92996] Thu, 07 April 2016 10:03 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 4/7/16 8:36 am, Paul van Delst wrote:
> On 04/07/16 09:52, deathknight wrote:
>> Hi,
>>
>> I'm using IDL 7.1. How can I read the NetCDF4 files using this version
>> of IDL?
>
> NetCDF4 support wasn't added until v8.0 so the best (only?) way is to
> upgrade your IDL install.

I think that is correct.

> Similarly, HDF5 support wasn't added until v8.3 (?) so that route is a
> no go.

HDF5 support has been in IDL since 5.6:

http://harrisgeospatial.com/docs/H5_OPEN.html

I would read the NetCDF 4 file using the HDF 5 routines. If you want
simpler routines than the low level interface, check out my HDF 5 routines:

https://github.com/mgalloy/mglib/tree/master/src/hdf5

The routine to use is MG_H5_GETDATA. You will need the files in that
directory (plus at least objects/idl_object__define.pro to run on IDL 7.1).

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Re: NetCDF4 problem [message #92998 is a reply to message #92997] Thu, 07 April 2016 10:45 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
On 04/07/16 13:03, Michael Galloy wrote:
> On 4/7/16 8:36 am, Paul van Delst wrote:
>> On 04/07/16 09:52, deathknight wrote:
>>> Hi,
>>>
>>> I'm using IDL 7.1. How can I read the NetCDF4 files using this version
>>> of IDL?
>>
>> NetCDF4 support wasn't added until v8.0 so the best (only?) way is to
>> upgrade your IDL install.
>
> I think that is correct.
>
>> Similarly, HDF5 support wasn't added until v8.3 (?) so that route is a
>> no go.
>
> HDF5 support has been in IDL since 5.6:

Oops! I was going by the version of addition of the H5_LIST() procedure
in the documentation.

(I often use H5_PARSE() to read random netCDF4 files that I want to have
a lookee at and...checking the docs....yep, it was introduced in v5.6.
Embarrassed cough...)

Thanks for the correction.

> http://harrisgeospatial.com/docs/H5_OPEN.html
>
> I would read the NetCDF 4 file using the HDF 5 routines. If you want
> simpler routines than the low level interface, check out my HDF 5 routines:
>
> https://github.com/mgalloy/mglib/tree/master/src/hdf5
>
> The routine to use is MG_H5_GETDATA. You will need the files in that
> directory (plus at least objects/idl_object__define.pro to run on IDL 7.1).

Apologies to the OP for the incorrect info regarding HDF5 support in IDL
v7.1.

cheers,

paulv
Re: NetCDF4 problem [message #93002 is a reply to message #92996] Fri, 08 April 2016 05:32 Go to previous messageGo to next message
DK is currently offline  DK
Messages: 12
Registered: June 2015
Junior Member
在 2016年4月7日星期四 UTC+8下午10:37:04,Paul van Delst写道:
> On 04/07/16 09:52, deathknight wrote:
>> Hi,
>>
>> I'm using IDL 7.1. How can I read the NetCDF4 files using this version of IDL?
>
> NetCDF4 support wasn't added until v8.0 so the best (only?) way is to
> upgrade your IDL install.

That's what I think, too...hoping I was wrong.. Thank you for your explanation!
Re: NetCDF4 problem [message #93003 is a reply to message #92997] Fri, 08 April 2016 05:37 Go to previous messageGo to next message
DK is currently offline  DK
Messages: 12
Registered: June 2015
Junior Member
在 2016年4月8日星期五 UTC+8上午1:03:28,Mike Galloy写道:
> On 4/7/16 8:36 am, Paul van Delst wrote:
>> On 04/07/16 09:52, deathknight wrote:
>>> Hi,
>>>
>>> I'm using IDL 7.1. How can I read the NetCDF4 files using this version
>>> of IDL?
>>
>> NetCDF4 support wasn't added until v8.0 so the best (only?) way is to
>> upgrade your IDL install.
>
> I think that is correct.
>
>> Similarly, HDF5 support wasn't added until v8.3 (?) so that route is a
>> no go.
>
> HDF5 support has been in IDL since 5.6:
>
> http://harrisgeospatial.com/docs/H5_OPEN.html
>
> I would read the NetCDF 4 file using the HDF 5 routines. If you want
> simpler routines than the low level interface, check out my HDF 5 routines:
>
> https://github.com/mgalloy/mglib/tree/master/src/hdf5
>
> The routine to use is MG_H5_GETDATA. You will need the files in that
> directory (plus at least objects/idl_object__define.pro to run on IDL 7.1).
>

Could you please show me more about how to use these routines on IDL 7.1?
I added all the .pro files from your website into the /lib and run:
IDL> result=mg_h5_getdata('E:\netcdf4.nc')
and I got the error: MG_H5_GETDATA: no variable requested

Thank you very much!
Re: NetCDF4 problem [message #93007 is a reply to message #93003] Fri, 08 April 2016 08:22 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 4/8/16 6:37 AM, deathknight wrote:
> 在 2016年4月8日星期五 UTC+8上午1:03:28,Mike Galloy写道:
>> On 4/7/16 8:36 am, Paul van Delst wrote:
>>> On 04/07/16 09:52, deathknight wrote:
>>>> Hi,
>>>>
>>>> I'm using IDL 7.1. How can I read the NetCDF4 files using this version
>>>> of IDL?
>>>
>>> NetCDF4 support wasn't added until v8.0 so the best (only?) way is to
>>> upgrade your IDL install.
>>
>> I think that is correct.
>>
>>> Similarly, HDF5 support wasn't added until v8.3 (?) so that route is a
>>> no go.
>>
>> HDF5 support has been in IDL since 5.6:
>>
>> http://harrisgeospatial.com/docs/H5_OPEN.html
>>
>> I would read the NetCDF 4 file using the HDF 5 routines. If you want
>> simpler routines than the low level interface, check out my HDF 5 routines:
>>
>> https://github.com/mgalloy/mglib/tree/master/src/hdf5
>>
>> The routine to use is MG_H5_GETDATA. You will need the files in that
>> directory (plus at least objects/idl_object__define.pro to run on IDL 7.1).
>>
>
> Could you please show me more about how to use these routines on IDL 7.1?
> I added all the .pro files from your website into the /lib and run:
> IDL> result=mg_h5_getdata('E:\netcdf4.nc')
> and I got the error: MG_H5_GETDATA: no variable requested
>
> Thank you very much!
>

Yes, you have to specify the variable/attribute that you want:

IDL> var = mg_h5_getdata('E:\netcdf4.nc', 'group/myvar')
IDL> attr = mg_h5_getdata('E:\netcdf4.nc', 'group/myvar.attr')

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Re: NetCDF4 problem [message #93008 is a reply to message #92998] Fri, 08 April 2016 08:24 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 4/7/16 11:45 AM, Paul van Delst wrote:
> On 04/07/16 13:03, Michael Galloy wrote:
>> On 4/7/16 8:36 am, Paul van Delst wrote:
>>> On 04/07/16 09:52, deathknight wrote:
>>>> Hi,
>>>>
>>>> I'm using IDL 7.1. How can I read the NetCDF4 files using this version
>>>> of IDL?
>>>
>>> NetCDF4 support wasn't added until v8.0 so the best (only?) way is to
>>> upgrade your IDL install.
>>
>> I think that is correct.
>>
>>> Similarly, HDF5 support wasn't added until v8.3 (?) so that route is a
>>> no go.
>>
>> HDF5 support has been in IDL since 5.6:
>
> Oops! I was going by the version of addition of the H5_LIST() procedure
> in the documentation.

In IDL 8.3, they added some top level routines like H5_LIST, H5_GETDATA,
and H5_PUTDATA, but the low-level routines (plus H5_BROWSER and
H5_PARSE) have been there for a long time.

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Re: NetCDF4 problem [message #93015 is a reply to message #93007] Sun, 10 April 2016 05:50 Go to previous messageGo to next message
DK is currently offline  DK
Messages: 12
Registered: June 2015
Junior Member
> Yes, you have to specify the variable/attribute that you want:
>
> IDL> var = mg_h5_getdata('E:\netcdf4.nc', 'group/myvar')
> IDL> attr = mg_h5_getdata('E:\netcdf4.nc', 'group/myvar.attr')
>

Hi,

I tried, but still got error like this:

IDL> result=mg_h5_getdata('E:\netcdf4.nc', 'varname')
% H5F_OPEN: unable to open file: Object Name:"E:\netcdf4.nc"
% Error occurred at: MG_H5_GETDATA 446 D:\Program Files (x86)\ITT\IDL71\lib\hdf5\mg_h5_getdata.pro
% $MAIN$
% Execution halted at: $MAIN$

Where did I go wrong?

Thank you very much!
Re: NetCDF4 problem [message #93024 is a reply to message #93015] Mon, 11 April 2016 16:06 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 4/10/16 6:50 AM, deathknight wrote:
>
>> Yes, you have to specify the variable/attribute that you want:
>>
>> IDL> var = mg_h5_getdata('E:\netcdf4.nc', 'group/myvar')
>> IDL> attr = mg_h5_getdata('E:\netcdf4.nc', 'group/myvar.attr')
>>
>
> Hi,
>
> I tried, but still got error like this:
>
> IDL> result=mg_h5_getdata('E:\netcdf4.nc', 'varname')
> % H5F_OPEN: unable to open file: Object Name:"E:\netcdf4.nc"
> % Error occurred at: MG_H5_GETDATA 446 D:\Program Files (x86)\ITT\IDL71\lib\hdf5\mg_h5_getdata.pro
> % $MAIN$
> % Execution halted at: $MAIN$
>
> Where did I go wrong?
>
> Thank you very much!
>

Just to check, could you do:

IDL> filename = 'E:\netcdf4.nc'
IDL> print, file_test(filename)
IDL> file_id = h5f_open(filename)
IDL> help, file_id

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Re: NetCDF4 problem [message #93097 is a reply to message #93024] Tue, 26 April 2016 20:00 Go to previous messageGo to next message
DK is currently offline  DK
Messages: 12
Registered: June 2015
Junior Member
> Just to check, could you do:
>
> IDL> filename = 'E:\netcdf4.nc'
> IDL> print, file_test(filename)
> IDL> file_id = h5f_open(filename)
> IDL> help, file_id
>

Sorry for not getting back to you earlier. The results are as follows:

IDL> filename='E:\netcdf4.nc'
IDL> print, file_test(filename)
1
IDL> file_id=h5f_open(filename)
% Loaded DLM: HDF5.
% H5F_OPEN: unable to open file: Object Name:"E:\netcdf4.nc"
% Execution halted at: $MAIN$
IDL> help, file_id
FILE_ID UNDEFINED = <Undefined>

Is that the problem of my IDL version? Thanks!
Re: NetCDF4 problem [message #93114 is a reply to message #93097] Thu, 28 April 2016 13:41 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 4/26/16 9:00 PM, deathknight wrote:
>
>> Just to check, could you do:
>>
>> IDL> filename = 'E:\netcdf4.nc'
>> IDL> print, file_test(filename)
>> IDL> file_id = h5f_open(filename)
>> IDL> help, file_id
>>
>
> Sorry for not getting back to you earlier. The results are as follows:
>
> IDL> filename='E:\netcdf4.nc'
> IDL> print, file_test(filename)
> 1
> IDL> file_id=h5f_open(filename)
> % Loaded DLM: HDF5.
> % H5F_OPEN: unable to open file: Object Name:"E:\netcdf4.nc"
> % Execution halted at: $MAIN$
> IDL> help, file_id
> FILE_ID UNDEFINED = <Undefined>
>
> Is that the problem of my IDL version? Thanks!
>

This indicates the file does exist (yeah!), but can't be opened by the
HDF 5 library. Perhaps is a classic netCDF file? i.e., version < 4. Can
you open it using the standard netCDF library?

IDL> filename = 'E:\netcdf4.nc'
IDL> file_id = ncdf_open(filename)
IDL> help, file_id

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Re: NetCDF4 problem [message #93119 is a reply to message #93114] Thu, 28 April 2016 23:40 Go to previous messageGo to next message
DK is currently offline  DK
Messages: 12
Registered: June 2015
Junior Member
> This indicates the file does exist (yeah!), but can't be opened by the
> HDF 5 library. Perhaps is a classic netCDF file? i.e., version < 4. Can
> you open it using the standard netCDF library?
>
> IDL> filename = 'E:\netcdf4.nc'
> IDL> file_id = ncdf_open(filename)
> IDL> help, file_id
>

Hi Mike, the file I tried was download from the NECP website ( http://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanalys is.html) resently, and it said that "We have transitioned the data files from netCDF3 to netCDF4-classic format on Monday Oct 20th, 2014." on this webpage. So I am sure the file is not a classic netCDF3 file.

I also tried the old way and got the error "NC_ERROR=-51"

IDL> filename='E:\netcdf4.nc'
IDL> cdfid=ncdf_open(filename)
% Loaded DLM: NCDF.
% NCDF_OPEN: Unable to open the file "E:\netcdf4.nc". (NC_ERROR=-51)
% Execution halted at: $MAIN$

Really appreciate your kindly help and patience.
Re: NetCDF4 problem [message #93123 is a reply to message #93119] Fri, 29 April 2016 04:27 Go to previous messageGo to next message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Have you followed these instructions: http://www.harrisgeospatial.com/Support/HelpArticles/TabId/1 85/ArtMID/800/ArticleID/4352/4352.aspx

On Friday, April 29, 2016 at 2:41:02 AM UTC-4, deathknight wrote:
>> This indicates the file does exist (yeah!), but can't be opened by the
>> HDF 5 library. Perhaps is a classic netCDF file? i.e., version < 4. Can
>> you open it using the standard netCDF library?
>>
>> IDL> filename = 'E:\netcdf4.nc'
>> IDL> file_id = ncdf_open(filename)
>> IDL> help, file_id
>>
>
> Hi Mike, the file I tried was download from the NECP website ( http://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanalys is.html) resently, and it said that "We have transitioned the data files from netCDF3 to netCDF4-classic format on Monday Oct 20th, 2014." on this webpage. So I am sure the file is not a classic netCDF3 file.
>
> I also tried the old way and got the error "NC_ERROR=-51"
>
> IDL> filename='E:\netcdf4.nc'
> IDL> cdfid=ncdf_open(filename)
> % Loaded DLM: NCDF.
> % NCDF_OPEN: Unable to open the file "E:\netcdf4.nc". (NC_ERROR=-51)
> % Execution halted at: $MAIN$
>
> Really appreciate your kindly help and patience.
Re: NetCDF4 problem [message #93139 is a reply to message #93123] Sun, 01 May 2016 07:23 Go to previous message
DK is currently offline  DK
Messages: 12
Registered: June 2015
Junior Member
在 2016年4月29日星期五 UTC+8下午7:27:57,Haje Korth写道:
> Have you followed these instructions: http://www.harrisgeospatial.com/Support/HelpArticles/TabId/1 85/ArtMID/800/ArticleID/4352/4352.aspx

Great tip! It seems that NC_ERROR=-51 means "not a NetCDF file" according to the instructions... Many thanks.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: READ array from a file
Next Topic: Re: Problems on the Savitzky-Golay smoothing filter

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:22:28 PDT 2025

Total time taken to generate the page: 0.00574 seconds