[MITgcm-support] How to join two nc files?
Baylor Fox-Kemper
baylor at MIT.EDU
Thu Jun 8 09:47:10 EDT 2006
Hi David,
I like your script so much that I have checked it in to the
repository. I hope that's OK with you; please let me know if not.
Cheers,
-Baylor
On Jun 7, 2006, at 2:47 PM, David Wang wrote:
> I wrote a simple matlab script based on mnc_assembly.m. It's a
> quick and dirty way to join multi-tile mnc output. - d.
>
> Ed Hill wrote:
>> On Tue, 2006-06-06 at 09:44 -0400, Baylor Fox-Kemper wrote:
>>> One can also use ferret to open multiple tiles using ferret.
>>> Here is
>>> an example.
>> Hi Baylor,
>> Thanks for the matlab and ferret examples. There are at least four
>> other ways of reading (and potentially "joining") multiple netcdf
>> files
>> and they are:
>> MITgcm/utils/matlab/mnc_assembly.m
>> This is a matlab script that will assemble both exch1 and exch2
>> domains. It reads a collection of per-tile MITgcm netcdf output
>> files and writes a collection of per-face netcdf files.
>> MITgcm/utils/matlab/rdmnc.m
>> This is meant to be a "netcdf version of rdmds". It reads
>> and spatially assembles multiple MITgcm netcdf output files.
>> MITgcm/utils/matlab/gmt/rdnctiles.m
>> This is another "netcdf version of rdmds". Its newer than
>> rdmnc and has more flexibility. It can perform "assembly"
>> of exch1-style XY arrays, exch2-style cubes, and can also
>> return matlab structures with per-tile information that can
>> handle completely general tile/face topologies.
>> NCO: http://nco.sourceforge.net/
>> NCO is a suite of netcdf tools that can be used to perform
>> all sorts of helpful pre- and post-processing. With the NCO
>> utilities its relatively easy to extract hyper-slabs,
>> concatenate along various dimensions, etc.
>> Ed
>> NOTE: All of the above MatLAB scripts rely upon Chuck Denham's
>> MexCDF (aka "mexcdf53") toolbox.
> function foo = gluemnc(diags,nIter0)
> % gluemnc.m
> % written by david wang, ldeo
> %
> % purpose: use mnc_assembly.m to glue the multi-tile *.*.nc mnc output
> % into a single "global" nc file, which is subject to further
> % manipulation (e.g., adding/modifying coordiates/attributes)
> % if necessary.
> %
> % diags: diagnostics name
> % nIter0: 10-digit iterate #
> % EXAMPLE:
> % foo = gluemnc('state','0000000000');
>
> if nargin ~= 2, error('there have to be two input arguments!'); end
>
> nc_in = [diags,'.',nIter0,'.t%03d.nc'];
> nc_inone = [diags,'.',nIter0,'.t001.nc'];
> nc_inall = [diags,'.',nIter0,'.t*.nc'];
> nc_out = [diags,'_',nIter0,'.nc'];
>
> varlist = ncload(nc_inone);
> nvars = length(varlist);
> vars = struct([]);
>
> for i = 1:nvars,
> vars(i).name = char(varlist(i));
> end
>
> [nt,nf] = mnc_assembly(nc_in, vars, nc_out);
>
> reply = input('delete the original tiled files? [y/n] ','s');
> if isempty(reply), reply = 'y'; end
> if strcmpi(reply,'y'), delete(nc_inall); end
>
> return
>
> _______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org
> http://mitgcm.org/mailman/listinfo/mitgcm-support
More information about the MITgcm-support
mailing list