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

Home » Public Forums » archive » Re: NetCDF and empty variables
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: NetCDF and empty variables [message #66134 is a reply to message #66129] Fri, 17 April 2009 12:34 Go to previous messageGo to previous message
renaud.dussurget is currently offline  renaud.dussurget
Messages: 8
Registered: April 2008
Junior Member
On 17 avr, 17:55, liamgum...@gmail.com wrote:
> On Apr 17, 8:18 am, renaud.dussur...@gmail.com wrote:
>
>
>
>> IDL>ncid = NCDF_OPEN('myFile.nc')
>> IDL>varId = NCDF_VARID(ncid,'HISTORY_INSTITUTION')
>> IDL>out=NCDF_VARINQ(ncid, VarId)
>> IDL>help, out, /str
>> ** Structure <a9c098>, 5 tags, length=56, data length=52, refs=1:
>> NAME STRING 'HISTORY_INSTITUTION'
>> DATATYPE STRING 'CHAR'
>> NDIMS LONG 3
>> NATTS LONG 3
>> DIM LONG Array[3]
>
>> IDL>print, out.dim
>> 6 8 12
>
>> IDL>NCDF_VARGET, ncid, varId, data, COUNT=cnt
>> % Array dimensions must be greater than 0.
>
> Where is the array CNT defined?
>
> Have you tried something like this?
>
> PRO TEST
> ncid = ncdf_open('myfile.nc')
> varid = ncdf_varid(ncid, 'HISTORY_INSTITUTION')
> if (varid eq -1) then message, 'Variable does not exist'
> ncdf_varget, ncid, varid, value
> help, value
> END
>
> If the code gets past the check for (varid eq -1) and it still
> crashes, then something very odd is going on, and I think you have a
> reason to contact ITTVIS technical support.
>
> Liam.
> Practical IDL Programminghttp://www.gumley.com/

Hello

Well, as I've said, it is much nastier than this.
varid returned by NCDF_VARID is correct (the variable exists in the
netcdf file and this is its ID)
The return of NCDF_VARINQ also suppose that this variable should have
3 dimensions (as, I think,the creator of this file intended it...)
But there is simply NO DATA within this variable, and there is no way
to check this before trying to get the data from the file.

When I do a ncdump of this file I get this

netcdf 69003_prof {
dimensions:
DATE_TIME = 14 ;
STRING256 = 256 ;
STRING64 = 64 ;
STRING32 = 32 ;
STRING16 = 16 ;
STRING8 = 8 ;
STRING4 = 4 ;
STRING2 = 2 ;
N_PROF = 16 ;
N_PARAM = 2 ;
N_LEVELS = 94 ;
N_CALIB = 1 ;
N_HISTORY = UNLIMITED ; // (0 currently)
variables:
[...]
char HISTORY_INSTITUTION(N_HISTORY, N_PROF, STRING4) ;
HISTORY_INSTITUTION:long_name = "Institution which
performed action" ;
HISTORY_INSTITUTION:conventions = "Argo reference
table 4" ;
HISTORY_INSTITUTION:_FillValue = " " ;
[...]
data:
}

-> so there is no data within this variable.
It seems that all "HISTORY_*" variables within this file have been
forgotten... We cannot think that NetCDF file will always be perfectly
defined as they should be, so here is our problem...

If I repeat this operation with Matlab, using the ncload command, I
have this:
>> ncload 'myFile.nc'
>> whos
[...]
HISTORY_INSTITUTION 0x0 0 double
[...]
So Matlab is able to detect that the variable exists,even if it is
empty, and does not crash reading it.

But, anyway, the EXECUTE() trick works well, as I've been able to read
my whole data set without any problem.

I think I'll write a mail to ITT tech support to work around this bug.

Bye
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Computing needs, here's free root account on Solaris10
Next Topic: DEM Volume (voxel_proj)

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

Current Time: Sat Oct 11 14:07:30 PDT 2025

Total time taken to generate the page: 0.96264 seconds