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

Home » Public Forums » archive » netCDF adding variable to an existing file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
netCDF adding variable to an existing file [message #83958] Tue, 16 April 2013 12:51 Go to previous message
armor.uah is currently offline  armor.uah
Messages: 4
Registered: April 2013
Junior Member
All,
I have been attempting to use some of the information I have gathered in this group (From Paul V. on 10/25/2011) to add a couple of variables to my netCDF file (it is a CFradial format, if that matters). I'm running into problems, and I believe the root of it all are the dimensions -- getting them and adding one more. So, this file is open:

;1) Put the netcdf file in DEFINE mode (NCDF_CONTROL)
NCDF_CONTROL, netid, /REDEF

;2) If required, define new dimensions (NCDF_DIMDEF)
;This is the only dimension that is not already defined:
three_el_dim=NCDF_DIMDEF(netid, 'three', three_elev_ang)
;PROBLEM #1: I cannot define this new dimension: "% NCDF_DIMDEF: Unable to create dimension, name in use by another dimension (three)."
;The name "three" was not used anywhere else in my script, tried several other random string here and it breaks there every time.

;Problem #2: I cannot use the dimensions that already exist. I have tried using the outputs from NCDF_DIMINQ and would get errors in the "NCDF_VARDEF" telling me "% NCDF_VARDEF: Unable to define variable, bad dimension id ." so I decided to create new dimensions (I would rather not, but will if I have to!). These are the same size as the existing dimensions:
t_dim=NCDF_DIMDEF(netid,'times', time_dim)
r_dim=NCDF_DIMDEF(netid,'ranges', range_dim)
The error here is the same as above: "% NCDF_DIMDEF: Unable to create dimension, name in use by another dimension"

;For the sake of completeness, here are the other things I'm doing:

;3) Define the new variable (NCDF_VARDEF)
;Trying to use the dimensions that are already defined in the file but failed, these are here with the dimensions I tried to create:
LWCid = NCDF_VARDEF(netid, 'LWC',[t_dim, r_dim])
;errors: "% NCDF_VARDEF: Unable to define variable, name in use by another variable (LWC)." I thought: Sure, that's the name of my variable, so I changed 'LWC' to 'aLWC' and now am getting a different error: "% NCDF_VARDEF: Unable to define variable, bad dimension id ." ... maybe this means that when I get my dimensions issues figured out this error will fix itself??

;This variable has the new dimension I tried to define but failed:
Rid = NCDF_VARDEF(netid, 'Rain_rate', [three_el_dim, R_DIM])


;4) Repeat 2-3 as necessary for multiple dimensions/variables.
;5) Put the netcdf in DATA mode (NCDF_CONTROL)
NCDF_CONTROL, netid, /ENDEF

;6) Write the new variable data to the file (NCDF_VARPUT)
NCDF_VARPUT, netid, LWCid, LWC
NCDF_VARPUT, netid, Rid, R
;error: % NCDF_VARPUT: Variable Inquiry failed, -1 is not a valid variable id.

;7) Repeat 6 as necessary for multiple variables.
;8) Close the file (NCDF_CLOSE)
NCDF_CLOSE, netid


Any help would be appreciated!
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: netCDF adding variable to an existing file
Next Topic: IDL 8.2.2 released

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

Current Time: Fri Oct 10 06:10:26 PDT 2025

Total time taken to generate the page: 0.04639 seconds