NetCDF4 problem [message #92995] |
Thu, 07 April 2016 06:52  |
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   |
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 #93007 is a reply to message #93003] |
Fri, 08 April 2016 08:22   |
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   |
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 #93024 is a reply to message #93015] |
Mon, 11 April 2016 16:06   |
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 #93114 is a reply to message #93097] |
Thu, 28 April 2016 13:41   |
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 #93123 is a reply to message #93119] |
Fri, 29 April 2016 04:27   |
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.
|
|
|
|