comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Add a variable to existing NetCDF file
items: Re: Add a variable to existing NetCDF file

Add a variable to existing NetCDF file
type: item
description: I know this topic was discussed previously, but the only solution given was to use Dave Fanning's suite of NetCDF tools. Seems like there should be an easier answer. I opened an existing NetCDF file using ncdf_open with the /write option. Then I set up all the information about a new variable (name, dimensions, etc.) I then tried to create the new variable in the NetCDF file using ncdf_vardef: newid = ncdf_vardef(id, 'swgup', [timeid,latid,lonid], /float) In response, I get the message % NCDF_VARDEF: Unable to define variable, not in define mode. However, the only way I can find to enter define mode in the Exelis documentation is to create a new file using ncdf_create. There must be another way. If not, why is there a /write option in ncdf_open in the first place? It seems silly to have to copy over the whole existing file just to add a variable. From what I can see, this would take hundreds of commands for my file. Maybe this question is only for the IDL developers, if using Dave's tools will work. I just don't understand why this should be so difficult. Laura H.
creator: laura.hike
date: 2015-01-09T20:39:26-00:00

Re: Add a variable to existing NetCDF file
type: item
description: laura.hike@gmail.com writes: > I know this topic was discussed previously, but the only solution given was to use Dave Fanning's suite of NetCDF tools. Seems like there should be an easier answer. Easier than what? Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ Sepore ma de ni thue. ("Perhaps thou speakest truth.")
creator: David Fanning
date: 2015-01-09T20:50:07-00:00

Re: Add a variable to existing NetCDF file
type: item
description: Ha, ha! :^) Something that can be done simply using basic IDL commands instead of having to download a whole library. It looks like all that's missing from the existing commands is a way to enter define mode. All the other commands you need are there. L. On Friday, January 9, 2015 at 12:50:06 PM UTC-8, David Fanning wrote: > laura.hike@gmail.com writes: > >> I know this topic was discussed previously, but the only solution given was to use Dave Fanning's suite of NetCDF tools. Seems like there should be an easier answer. > > Easier than what? > > Cheers, > > David > -- > David Fanning, Ph.D. > Fanning Software Consulting, Inc. > Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ > Sepore ma de ni thue. ("Perhaps thou speakest truth.")
creator: laura.hike
date: 2015-01-09T21:09:58-00:00

Re: Add a variable to existing NetCDF file
type: item
description: On Friday, January 9, 2015 at 10:10:00 PM UTC+1, laura...@gmail.com wrote: > Ha, ha! :^) Something that can be done simply using basic IDL commands instead of having to download a whole library. It looks like all that's missing from the existing commands is a way to enter define mode. All the other commands you need are there. NCDF_CONTROL, id, /redef regards, Lajos
creator: Lajos Foldy
date: 2015-01-09T21:32:45-00:00

Re: Add a variable to existing NetCDF file
type: item
description: laura.hike@gmail.com writes: > Ha, ha! :^) Something that can be done simply using basic IDL commands instead of having to download a whole library. It looks like all that's missing from the existing commands is a way to enter define mode. All the other commands you need are there. Maybe you are looking for this: NCDF_Control, fileID, /REDEF ; Put open file in DEFINE mode. Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ Sepore ma de ni thue. ("Perhaps thou speakest truth.")
creator: David Fanning
date: 2015-01-09T21:36:47-00:00

Re: Add a variable to existing NetCDF file
type: item
description: Oh, cool! Hidden in the generic NetCDF command, I see. All I want to do is add one variable to a file.... On Friday, January 9, 2015 at 1:36:47 PM UTC-8, David Fanning wrote: > laura.hike@gmail.com writes: > >> Ha, ha! :^) Something that can be done simply using basic IDL commands instead of having to download a whole library. It looks like all that's missing from the existing commands is a way to enter define mode. All the other commands you need are there. > > Maybe you are looking for this: > > NCDF_Control, fileID, /REDEF ; Put open file in DEFINE mode. > > Cheers, > > David > -- > David Fanning, Ph.D. > Fanning Software Consulting, Inc. > Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ > Sepore ma de ni thue. ("Perhaps thou speakest truth.")
creator: laura.hike
date: 2015-01-09T22:14:09-00:00

Re: Add a variable to existing NetCDF file
type: item
description: laura.hike@gmail.com writes: > Oh, cool! Hidden in the generic NetCDF command, I see. All I want to do is add one variable to a file.... Because this seems like an awfully easy and common thing to do, I've added an example of how to add a new variable to an already existing netCDF file in the file ncdf_file_examples.pro. You can find the new version of the file here: http://www.idlcoyote.com/programs/ncdf_file_examples.pro Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ Sepore ma de ni thue. ("Perhaps thou speakest truth.")
creator: David Fanning
date: 2015-01-09T22:29:53-00:00

Re: Add a variable to existing NetCDF file
type: item
description: But it still won't work. Now I get a generic "Unable to define variable" error. Maybe I'll give up, write a tiny new file, and append it to the other using NCL or NCO. On Friday, January 9, 2015 at 2:14:12 PM UTC-8, laura...@gmail.com wrote: > Oh, cool! Hidden in the generic NetCDF command, I see. All I want to do is add one variable to a file.... > > > > On Friday, January 9, 2015 at 1:36:47 PM UTC-8, David Fanning wrote: >> laura.hike@gmail.com writes: >> >>> Ha, ha! :^) Something that can be done simply using basic IDL commands instead of having to download a whole library. It looks like all that's missing from the existing commands is a way to enter define mode. All the other commands you need are there. >> >> Maybe you are looking for this: >> >> NCDF_Control, fileID, /REDEF ; Put open file in DEFINE mode. >> >> Cheers, >> >> David >> -- >> David Fanning, Ph.D. >> Fanning Software Consulting, Inc. >> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ >> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
creator: laura.hike
date: 2015-01-09T22:34:49-00:00

Re: Add a variable to existing NetCDF file
type: item
description: Note: I hadn't seen your last message before writing that last one. I'll check your example. On Friday, January 9, 2015 at 2:34:53 PM UTC-8, laura...@gmail.com wrote: > But it still won't work. Now I get a generic "Unable to define variable" error. Maybe I'll give up, write a tiny new file, and append it to the other using NCL or NCO. > > > On Friday, January 9, 2015 at 2:14:12 PM UTC-8, laura...@gmail.com wrote: >> Oh, cool! Hidden in the generic NetCDF command, I see. All I want to do is add one variable to a file.... >> >> >> >> On Friday, January 9, 2015 at 1:36:47 PM UTC-8, David Fanning wrote: >>> laura.hike@gmail.com writes: >>> >>>> Ha, ha! :^) Something that can be done simply using basic IDL commands instead of having to download a whole library. It looks like all that's missing from the existing commands is a way to enter define mode. All the other commands you need are there. >>> >>> Maybe you are looking for this: >>> >>> NCDF_Control, fileID, /REDEF ; Put open file in DEFINE mode. >>> >>> Cheers, >>> >>> David >>> -- >>> David Fanning, Ph.D. >>> Fanning Software Consulting, Inc. >>> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ >>> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
creator: laura.hike
date: 2015-01-09T22:35:58-00:00

Re: Add a variable to existing NetCDF file
type: item
description: Ah, a degenerate dimension was eliminated, changing the variable array size. Got it now. On Friday, January 9, 2015 at 2:34:53 PM UTC-8, laura...@gmail.com wrote: > But it still won't work. Now I get a generic "Unable to define variable" error. Maybe I'll give up, write a tiny new file, and append it to the other using NCL or NCO. > > > On Friday, January 9, 2015 at 2:14:12 PM UTC-8, laura...@gmail.com wrote: >> Oh, cool! Hidden in the generic NetCDF command, I see. All I want to do is add one variable to a file.... >> >> >> >> On Friday, January 9, 2015 at 1:36:47 PM UTC-8, David Fanning wrote: >>> laura.hike@gmail.com writes: >>> >>>> Ha, ha! :^) Something that can be done simply using basic IDL commands instead of having to download a whole library. It looks like all that's missing from the existing commands is a way to enter define mode. All the other commands you need are there. >>> >>> Maybe you are looking for this: >>> >>> NCDF_Control, fileID, /REDEF ; Put open file in DEFINE mode. >>> >>> Cheers, >>> >>> David >>> -- >>> David Fanning, Ph.D. >>> Fanning Software Consulting, Inc. >>> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ >>> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
creator: laura.hike
date: 2015-01-09T23:02:11-00:00