Re: NCDF_IS_NCDF [message #92613 is a reply to message #92612] |
Fri, 22 January 2016 12:04   |
khyde
Messages: 21 Registered: November 2013
|
Junior Member |
|
|
On Friday, January 22, 2016 at 2:48:38 PM UTC-5, Mike Galloy wrote:
> On 1/22/16 12:26 PM, kimberly.hyde@noaa.gov wrote:
>> On Friday, January 22, 2016 at 2:20:25 PM UTC-5, kimber...@noaa.gov
>> wrote:
>>> On Thursday, January 21, 2016 at 10:26:36 PM UTC-5, Michael Galloy
>>> wrote:
>>>> On 1/21/16 1:21 PM, KH wrote:
>>>> > Hello,
>>>> >
>>>> > Is there a netcdf equivalent to HDF_ISHDF? I am basically
>>>> > looking for a way to test if a file is a netcdf file before
>>>> > trying to open the file (and the having the program crash
>>>> > because it isn't actually a netcdf file).
>>>>
>>>> Yes, I would normally recommend just trying to open the file and
>>>> catching the error if it fails, but, as you noted, it actually
>>>> crashes IDL:
>>>>
>>>> IDL> id = ncdf_open(filename) Assertion failed: (0), function
>>>> NC4_open, file nc4file.c, line 2696. Abort trap: 6
>>>>
>>>> Are your files netCDF 4 files? You can use H5F_IS_HDF5 if you
>>>> don't want pre-4 netCDF files:
>>>>
>>>> IDL> help, h5f_is_hdf5(file_which('ncgroup.nc')) <Expression>
>>>> LONG = 1 IDL> help,
>>>> h5f_is_hdf5(file_which('sample.nc')) <Expression> LONG =
>>>> 0
>>>>
>>>>
>>>> Mike -- Michael Galloy www.michaelgalloy.com Modern IDL: A Guide
>>>> to IDL Programming (http://modernidl.idldev.com)
>>>
>>> These particular files are netcdf4 so I can use the H5f program,
>>> but not all of my files are netcdf4 so I was hoping to find a way
>>> to automatically test what type of files they are. Thanks for your
>>> assistance, Kim
>>
>>
>> In the end, I am mainly trying to quickly determine if the netcdf
>> files I downloaded are corrupt or incomplete. That way if they are
>> bad, I can remove them so that they don't crash during subsequent
>> processing. Currently I am opening the file and then using
>> NCDF_INQUIRE to get the basic structure information, but if there is
>> an easier way to check the file, I am open for ideas.
>>
>> Kim
>>
>
> I have a routine, MG_NC_ISNCDF, in my library mglib (at
> github.com/mgalloy/mglib). You have to build the library to get the
> routine (and, of course, put the location of where the DLM is installed
> into your IDL DLM path). You will need the netCDF, HDF5, curl, libsz,
> and libz libraries installed. Change the paths to the proper locations,
> but something like the following should work for your system:
>
> mkdir build
> cd build
>
> cmake \
> -DCMAKE_INSTALL_PREFIX:PATH=~/software/mglib \
> -DNETCDF_INCLUDE_DIR:PATH=/usr/local/include \
> -DNETCDF_LIBRARY:PATH=/usr/local/lib/libnetcdf.a \
> -DHDF5_LIBRARY:PATH=/usr/local/lib/libhdf5.a \
> -DHDF5_LA_LIBRARY:PATH=/usr/local/lib/libhdf5_hl.a \
> -DCURL_LIBRARY:PATH=/usr/lib/libcurl.dylib \
> -DSZ_LIBRARY:PATH=/usr/local/lib/libsz.a \
> -DZ_LIBRARY:PATH=/usr/lib/libz.dylib \
> ..
>
> Mike
> --
> Michael Galloy
> www.michaelgalloy.com
> Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Hello Mike,
Is this a C program or IDL? It definitely isn't clear to me how to implement this. All I really know is basic IDL and the code in the program doesn't look familiar to me.
Kim
|
|
|