how do I split one .nc file into two

From: Erik Noble <enoble_at_nyahnyahspammersnyahnyah>
Date: Tue, 31 Jul 2007 21:53:21 -0400

Hi.
Simple question:
How do I split in half a necdf file with one varible and write out 2
separate files?
The variable has 1460 time steps
time = UNLIMITED ; // (1460 currently)
hgt(time, level, lat, lon)

What do I need to change here? Is this too much? :

begin
;***********************************************
;read in netcdf file
;***********************************************
   a = addfile("./hgt.2006.nc","r")
   ncdf_out = addfile("hgt.2006-1.nc" ,"c") ; create output netCDF file
   ncdf_out2 = addfile("hgt.2006-2.nc" ,"c") ; create 2nd output
netCDF file
  names = getfilevarnames(a)

   time = getvarnames(time)
   ntimes = dimsizes(time)
   Split = (ntimes-1)/2

   do i=0. Split
     ncdf_out->$names(i)$ = a->$names(i)$
   end do

   do i=Split, ntimes-1
     ncdf_out2->$names(i)$ = a->$names(i)$
   end do
end

Thank you ahead of time.
Sincerely,
Erik
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jul 31 2007 - 19:53:21 MDT

This archive was generated by hypermail 2.2.0 : Mon Aug 06 2007 - 08:08:45 MDT