Re: Adding a new variable to existing netCDF file?

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Tue Sep 20 2011 - 23:56:01 MDT

It can be as simple as:

f = addfile("your_file_name.nc","w") ; open the file for writing -- it really means for modification.
f->your_new_variable = your_new_variable

The caveat is that if you want to use dimensions that already exist in the file then you need to make sure that "your_variable" has dimension names and sizes that are compatible. If your file is large this operation can be slow, because metadata about the new variable has to be placed at the beginning of the file, and everything following the metadata section must be moved to make room. See the setfileoption procedure under "HeaderReserveSpace" if you are going to be doing this on a regular basis.
  -dave

On Sep 20, 2011, at 11:32 PM, Ashley Berg wrote:

> Is there a way to add a new variable to an already existing netCDF file using NCL? I know how to replace a variable in an existing file, but I'd like to add a new variable onto the end of a netCDF file that already contains about 60 other variables. I couldn't find anything on how to do this, so maybe the only way is to read in and write out all 60 variables plus the new variable to a new netCDF file... but that would be a pain!
>
> Thanks.
> -Ashley
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Sep 21 01:56:12 2011

This archive was generated by hypermail 2.1.8 : Thu Sep 22 2011 - 17:12:44 MDT