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

Home » Public Forums » archive » Add a new variable to netCDF file?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Add a new variable to netCDF file? [message #78073] Mon, 24 October 2011 16:44 Go to next message
Ashley Berg is currently offline  Ashley Berg
Messages: 14
Registered: February 2011
Junior Member
So, I know how to overwrite a variable in a netCDF file, but how do I
add a new one?

I have a netCDF file with about 30 variables and I want to add two new
ones. It would be a pain to have to copy over all 30 vars plus the
new ones into a new file, so is there a way to add variables using the
netCDF operators? I've been experimenting but haven't been able to
find a way to do it (when I try to write a new variable to the file,
it complains that it can't find the variable, which implies it's
looking to overwrite an existing one rather than tack on the new one).

Thanks!
Re: Add a new variable to netCDF file? [message #78148 is a reply to message #78073] Tue, 25 October 2011 13:50 Go to previous messageGo to next message
Ashley Berg is currently offline  Ashley Berg
Messages: 14
Registered: February 2011
Junior Member
On Oct 25, 12:46 pm, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:

> Did you define it first (per Paul's list of steps)?
>
> Ken Bowman

Yes, I followed each one of his steps. If someone has been able to
get it to work, I would appreciate seeing some sample code in case I
made some error... but since I have now successfully used NCL to add
my variables to the file, figuring out how to do it in IDL is not a
priority for me anymore (though others may still be interested).
Re: Add a new variable to netCDF file? [message #78149 is a reply to message #78073] Tue, 25 October 2011 11:46 Go to previous messageGo to next message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article
<8b005a34-1e1e-4d98-9a61-a16a994fe5dc@j36g2000prh.googlegroups.com>,
Ashley Berg <ashley.berg@gmail.com> wrote:

> Hello all,
>
> Paul's suggestion actually did not work for me (in IDL). The problem
> still seems to be that the variable I want to put into the netCDF file
> doesn't already exist in the file:
>
> % NCDF_VARPUT: Variable "TEST_VAR" not found.
> % NCDF_VARPUT: Variable Inquiry failed, -1 is not a valid variable id.
>
> However, I believe I can use NCL (NCAR Command Language) to add a new
> variable to an existing netCDF file, so I will try that next.

Did you define it first (per Paul's list of steps)?

Ken Bowman
Re: Add a new variable to netCDF file? [message #78150 is a reply to message #78073] Tue, 25 October 2011 11:17 Go to previous messageGo to next message
Ashley Berg is currently offline  Ashley Berg
Messages: 14
Registered: February 2011
Junior Member
Hello all,

Paul's suggestion actually did not work for me (in IDL). The problem
still seems to be that the variable I want to put into the netCDF file
doesn't already exist in the file:

% NCDF_VARPUT: Variable "TEST_VAR" not found.
% NCDF_VARPUT: Variable Inquiry failed, -1 is not a valid variable id.

However, I believe I can use NCL (NCAR Command Language) to add a new
variable to an existing netCDF file, so I will try that next.
Re: Add a new variable to netCDF file? [message #86933 is a reply to message #78073] Sun, 15 December 2013 04:49 Go to previous messageGo to next message
fereshtehkomijani is currently offline  fereshtehkomijani
Messages: 1
Registered: December 2013
Junior Member
On Tuesday, October 25, 2011 3:14:29 AM UTC+3:30, Ashley Berg wrote:
> So, I know how to overwrite a variable in a netCDF file, but how do I
>
> add a new one?
>
>
>
> I have a netCDF file with about 30 variables and I want to add two new
>
> ones. It would be a pain to have to copy over all 30 vars plus the
>
> new ones into a new file, so is there a way to add variables using the
>
> netCDF operators? I've been experimenting but haven't been able to
>
> find a way to do it (when I try to write a new variable to the file,
>
> it complains that it can't find the variable, which implies it's
>
> looking to overwrite an existing one rather than tack on the new one).
>
>
>
> Thanks!

dear
i am newbie with netcdf files manipulate. my aim is same as Ashley Berg to add 3 variables which all of them are in 3 different netcdf files with fourth netcdf file. all of them have same time step, longitude and latitude. but i cant fine way to do that. is it possible to do that with MATLAB? if it is, would you please tell me how.
cheers
fereshte
Re: Add a new variable to netCDF file? [message #86934 is a reply to message #86933] Sun, 15 December 2013 14:37 Go to previous message
Andy Sayer is currently offline  Andy Sayer
Messages: 127
Registered: February 2009
Senior Member
You might have better luck posting in a Matlab group (this one is for IDL). I don't know how many of us use Matlab (I don't). Good luck!

>
> dear
>
> i am newbie with netcdf files manipulate. my aim is same as Ashley Berg to add 3 variables which all of them are in 3 different netcdf files with fourth netcdf file. all of them have same time step, longitude and latitude. but i cant fine way to do that. is it possible to do that with MATLAB? if it is, would you please tell me how.
>
> cheers
>
> fereshte
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to identify outliers or short fluctuation signal data from an array of data?
Next Topic: join two .csv files

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

Current Time: Wed Oct 08 11:35:08 PDT 2025

Total time taken to generate the page: 0.00574 seconds