Re: Adding new variable to existing NetCDF file

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue Oct 23 2012 - 12:15:25 MDT

I *think* NCL can do this via the "w" on addfile.

However, the most efficient method is to write a
netCDF file containing only the new variable(s)

    filo = "AddVar.nc"
    system("/bin/rm -f "+filo) ; rm any pre-existing file
    ncdf = addfile(filo ,"c") ; open output netCDF file
    filedimdef(ncdf,"time",-1,True)
    ncdf->VAR1 = T ; 4D
    ncdf->VAR2 = PS ; 3D

Then use ncks to merge the 2 files. Let orig.nc be the file
to which you want to add the new variables:

    NCKS = "ncks -A "+filo+" "+orig.nc ; A ==> append
    print("NCKS: "+NCKS)
    system(NCKS)

On 10/23/12 11:52 AM, Patrick C. Campbell wrote:
> Hello,
>
> Rather simple question that I haven't found many examples of.
>
> If I have calculated a new variable, does anyone have any information on
> how to add this variable using NCL, to an existing NetCDF file (same
> dimensions)?
>
> Regards,
>
> Patrick
>
>
> _______________________________________________
> 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 Tue Oct 23 12:15:44 2012

This archive was generated by hypermail 2.1.8 : Wed Oct 31 2012 - 09:14:12 MDT