Re: plotting missing values [message #86798 is a reply to message #86797] |
Wed, 04 December 2013 07:45   |
Fabzi
Messages: 305 Registered: July 2010
|
Senior Member |
|
|
Hi David,
On 04.12.2013 16:41, David Fanning wrote:
> Does anyone know if there is a simple test I can perform in IDL
> to tell if the file is a netCDF3 as opposed to a netCDF4 file?
I had a support request on this a couple of months ago. It will be
included in IDL 8.3, I've been told. In the mean time they gave me
following code, which works:
;+
; :Description:
; Checks the format of a NCDF file without opening it
; (CLASSIC, 64BIT or NETCDF4)
;
; :Returns:
; A string::
; - 'FORMAT_CLASSIC'
; - 'FORMAT_64BIT'
; - 'FORMAT_NETCDF4'
; - 'Unknown'
;
; :Params:
; filename: in, string
; the path to the file to check
;
; :Author: Anonymous Developer from Exelis
;-
function w_ncdf_format, filename
ON_ERROR, 2
openr, unit, filename, /get_lun
data = bytarr(4)
readu, unit, data
free_lun, unit
case string(data) of
string([67b, 68b, 70b, 1b]): return, 'FORMAT_CLASSIC'
string([67b, 68b, 70b, 2b]): return, 'FORMAT_64BIT'
string([137b, 72b, 68b, 70b]): return, 'FORMAT_NETCDF4'
else: return, 'UNKNOWN'
endcase
end
|
|
|