[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netCDF #XID-711290]: How to joins together netCDF files???
- Subject: [netCDF #XID-711290]: How to joins together netCDF files???
- Date: Thu, 03 May 2007 10:10:35 -0600
Hi Alessandro,
Thanks for telling me about IOIPSL, I had not heard about that. If it already
has a solution, it might be easiest to try to solve the problem with IOIPSL and
get that to work. For that, you would have to send us more details and maybe
some test data, and it might take us some weeks to figure out the problem with
someone else's software.
Another possibility is to use the freely available NCO (netCDF operators)
package, briefly described here:
http://www.unidata.ucar.edu/software/netcdf/software.html#NCO
From the NCO Users' Guide, there is a description of using the "ncpdq" program
to do something like what you need:
ncpdq makes it possible to concatenate files along any dimension, not just the
record dimension. First, use ncpdq to convert the dimension to be concatenated
(i.e., extended with data from other files) into the record dimension. Second,
use ncrcat to concatenate these files. Finally, if desirable, use ncpdq to
revert to the original dimensionality. As a concrete example, say that files
x_01.nc, x_02.nc, ... x_10.nc contain time-evolving datasets from spatially
adjacent regions. The time and spatial coordinates are time and x,
respectively. Initially the record dimension is time. Our goal is to create a
single file that contains joins all the spatially adjacent regions into one
single time-evolving dataset.
for idx in 01 02 03 04 05 06 07 08 09 10; do # Bourne Shell
ncpdq -a x,time x_${idx}.nc foo_${idx}.nc # Make x record dimension
done
ncrcat foo_??.nc out.nc # Concatenate along x
ncpdq -a time,x out.nc out.nc # Revert to time as record dimension
---------------------------------
Another possibility is to write a small program in C, Fortran, C++, or Java or
perhaps in a scripting language such as perl, python, or ruby, that reads in
the data fields and stitches them together one longitude at a time, writing the
merged result fields to the output file. Depending on programming skills, this
might only take a day or two.
The psuedocode would be something like
open the 4 files
create an empty output file, fileout, with all the desired variables
for each variable
for each longitude
read slice1 from file1
read slice2 from file2
read slice3 from file3
read slice4 from file4
merge slices 1 through 4 into slice_global
write out slice_global to fileout
end for
end for
You could even create the output file using the "ncgen" tool, so you wouldn't
have to write a program for that.
--Russ
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu
Ticket Details
===================
Ticket ID: XID-711290
Department: Support netCDF
Priority: Normal
Status: Closed