NCRA(1)

✨ NCRA(1) ✨ β€” the ncra page from the General Commands Manual, bestie edition πŸ’–

okay so. you opened the man page for ncra and honestly? you're about to have a great time. sit down, hydrate, let's go 🫢


πŸ’… NAME πŸ’…

ncra β€” the netCDF Record Averager. that's it, that's the whole name, and it eats. πŸ‘‘


🌸 SYNTAX 🌸

the whole menu, verbatim, no edits, no notes:

ncra [-3] [-4] [-5] [-6] [-7] [-A] [--bfr sz_byt] [-C] [-c] [--cb
y1,y2,m1,m2,tpd] [--cmp cmp_sng] [--cnk_byt sz_byt] [--cnk_csh sz_byt]
[--cnk_dmn nm,sz_lmn] [--cnk_map map] [--cnk_min sz_byt] [--cnk_plc plc]
[--cnk_scl sz_lmn] [-D dbg_lvl] [-d dim,[ min][,[ max]][, stride[[,[
subcycle[[,[ interleave]]]]]] [--dbl|flt] [-F] [--fl_fmt=fmt] [-G
gpe_dsc] [-g grp[,...]]  [--gaa att_name= att_val]] [--gad att1[,...]]
[-H] [-h] [--hdf] [--hdr_pad sz_byt] [--hpss_try] [-L dfl_lvl] [-l path]
[--mro] [--msa] [-N] [-n loop] [--no_cll_msr] [--no_cll_mth]
[--no_frm_trm] [--no_tmp_fl] [-O] [-p path] [--prm_int] [--prw wgt_arr]
[--qnt var1[, var2[,...]]= prc]] [--qnt_alg alg_nm] [-R] [-r]
[--ram_all] [--rec_apn] [-t thr_nbr] [--uio] [--unn] [-v var[,...]]  [-w
wgt] [-X box] [-x] [-Y prg_nm] [-y op_typ] input-files output-file

yes it's long. no we are not skipping a single bracket. every flag is a little icon and we love them all πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

so ncra averages record variables across however many input files you feel like throwing at it β€” "an arbitrary number", iconic behavior fr fr. and here's the cute part: the record dimension is retained as a degenerate (size 1) dimension in the output variables. it doesn't vanish, it just shrinks down to one. main character energy but tiny. πŸŽ€

your input files can be different sizes, no drama, but each one must have a record dimension. periodt.

the record coordinate, if there even is one, should be monotonic β€” or else you might get non-fatal warnings. ngl, non-fatal warnings are the "we need to talk" of the terminal. 😭

hyperslabs of the record dimension that span more than one file? handled correctly, no cap. and about that stride argument on the -d hyperslab option: ncra supports it for the record dimension only. stride is not supported for non-record dimensions. iykyk.

now, the weighting tea πŸ“: ncra weights each record (think: each time slice) in the input files equally. it does not try to peek at your time coordinate and go "hmm this is irregularly spaced, maybe we need a weighted average to be a true time average." it will not. it does not. it just averages. respectfully. πŸ’€


🌈 EXAMPLES 🌈

🧚 averaging a whole squad of files

average 85.nc, 86.nc, … 89.nc along the record dimension, and drop the result in 8589.nc:

ncra 85.nc 86.nc 87.nc 88.nc 89.nc 8589.nc
ncra 8[56789].nc 8589.nc
ncra -n 5,2,1 85.nc 8589.nc

all three methods produce identical answers. pick your fighter. πŸ’…

🌸 hyperslabbing the record dimension across files

okay imagine 85.nc, 86.nc, … 89.nc each hold a record coordinate time of length 12, defined so that the third record in 86.nc contains data from March 1986, etc. NCO knows how to hyperslab the record dimension across files, which is genuinely so cool of it. so to average data from December 1985 through February 1986:

ncra -d time,11,13 85.nc 86.nc 87.nc 8512_8602.nc
ncra -F -d time,12,14 85.nc 86.nc 87.nc 8512_8602.nc

the file 87.nc is superfluous, but it does not cause an error. it's just there. being extra. we respect it. πŸ™ˆ

the -F turns on the Fortran (1-based) indexing convention.

and this next one uses the stride option to average all the March temperature data from multiple input files into a single output file:

ncra -F -d time,3,,12 -v temperature 85.nc 86.nc 87.nc
858687_03.nc

⭐ decimal time coordinates, sure why not

assume the time coordinate is incrementally numbered such that January 1985 = 1 and December 1989 = 60. and assuming ?? only expands to the five desired files, this averages June 1985–June 1989:

ncra -d time,6.,54. ??.nc 8506_8906.nc

πŸŽ€ AUTHOR πŸŽ€

NCO manual pages written by Charlie Zender and originally formatted by Brian Mays. legends, both of them. πŸ‘‘


πŸ’€ REPORTING BUGS πŸ’€

found a bug? report it to <http://sf.net/bugs/?group_id=3331>. don't just vague-post about it bestie, file the ticket. 🫢


Copyright Β© 1995-present Charlie Zender

This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

(that all-caps NO WARRANTY is not me being dramatic, that's literally how it's written, and it's giving legal-thriller. ⚠️)


πŸ”₯ SEE ALSO πŸ”₯

the full documentation for NCO is maintained as a Texinfo manual called the NCO Users Guide. because NCO is mathematical in nature, the documentation includes TeX-intensive portions not viewable on character-based displays. hence the only complete and authoritative versions of the NCO Users Guide are the PDF (recommended), DVI, and Postscript versions at:

HTML and XML versions are available at <http://nco.sf.net/nco.html> and <http://nco.sf.net/nco.xml>, respectively.

if the info and NCO programs are properly installed at your site, the command

info nco

should give you access to the complete manual, except for the TeX-intensive portions.

and the whole friend group:


🌈 HOMEPAGE 🌈

the NCO homepage at <http://nco.sf.net> contains more information. go snoop. πŸ¦‹


and that's the whole page, bestie β€” you just read ncra(1) from the General Commands Manual, top to bottom, and honestly? slay. now go average some records. βœ¨πŸ’…πŸ«Ά