NCKS(1) | General Commands Manual | NCKS(1) |
ncks - netCDF Kitchen Sink
ncks [-3] [-4] [-5] [-6] [-7] [-A] [-a] [--area_wgt] [-b bnr_fl] [--bfr sz_byt] [-C] [-c] [--cal] [--cdl] [--chk_map] [--chk_nan] [--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]]] [-F] [--fl_fmt=fmt] [--fix_rec_dmn dim] [--fmt_val fmt] [-G gpe_dsc] [-g grp[,...]] [--glb att_name= att_val]] [--grp_xtr_var_xcl] [-H] [-h] [--hdn] [--hdr_pad sz_byt] [--hpss_try] [--json] [--jsn_fmt lvl] [-l path] [-M] [-m] [--map map-file] [--md5] [--mk_rec_dmn dim] [--msa] [--no_blank] [--no_cll_msr] [--no_frm_trm] [--no_tmp_fl] [-O] [-o output-file] [-P] [-p path] [--ppc var1[, var2[,...]]= prc]] [--prn_fl print-file] [-Q] [-q] [-R] [-r] [--rad] [--ram_all] [--rgr key= val] [--rnr wgt] [-s format] [-t thr_nbr] [-u] [--uio] [--unn] [-V] [-v var[,...]] [--vrt_fl vrt_crd] [-X box] [-x] [--xml] input-file [ output-file]
ncks combines every feature we could think of, except the kitchen sink, into one versatile utility to manipulate netCDF files. ncks extracts a subset of the data from input-file and either prints it as ASCII text to stdout, or writes (or pastes) it to output-file, or both.
ncks will print netCDF data in ASCII format to stdout, like ncdump, but with these differences: ncks prints data in a tabular format intended to be easy to search for the data you want, one datum per screen line, with all dimension subscripts and coordinate values (if any) preceding the datum. Option -s allows the user the format the data using C-style format strings.
Options -a, -F, -H, -M, -m, -Q, -q, -s, -u, and -V control the formatted appearance of the data.
ncks will extract (and optionally create a new netCDF file comprised of) only selected variable from the input file, like ncextr but with these differences: Only variables and coordinates may be specifically included or excluded---all global attributes and any attribute associated with an extracted variable will be copied to the screen and/or output netCDF file. Options -c, -C, -v, and -x control which variables are extracted.
ncks will extract hyperslabs from the specified variables. In fact ncks implements the nccut specification exactly. Option -d controls the hyperslab specification.
Input dimensions that are not associated with any output variable will not appear in the output netCDF. This feature removes superfluous dimensions from a netCDF file.
ncks will append variables and attributes from the input-file to output-file if output-file is a pre-existing netCDF file whose relevant dimensions conform to dimension sizes of input-file. The append features of ncks are intended to provide a rudimentary means of adding data from one netCDF file to another, conforming, netCDF file. When naming conflicts exists between the two files, data in output-file is usually overwritten by the corresponding data from input-file. Thus it is recommended that the user backup output-file in case valuable data is accidentally overwritten.
If output-file exists, the user will be queried whether to overwrite, append, or exit the ncks call completely. Choosing overwrite destroys the existing output-file and create an entirely new one from the output of the ncks call. Append has differing effects depending on the uniqueness of the variables and attributes output by ncks: If a variable or attribute extracted from input-file does not have a name conflict with the members of output-file then it will be added to output-file without overwriting any of the existing contents of output-file. In this case the relevant dimensions must agree (conform) between the two files; new dimensions are created in output-file as required. When a name conflict occurs, a global attribute from input-file will overwrite the corresponding global attribute from output-file. If the name conflict occurs for a non-record variable, then the dimensions and type of the variable (and of its coordinate dimensions, if any) must agree (conform) in both files. Then the variable values (and any coordinate dimension values) from input-file will overwrite the corresponding variable values (and coordinate dimension values, if any) in output-file
Since there can only be one record dimension in a file, the record dimension must have the same name (but not necessarily the same size) in both files if a record dimension variable is to be appended. If the record dimensions are of differing sizes, the record dimension of output-file will become the greater of the two record dimension sizes, the record variable from input-file will overwrite any counterpart in output-file and fill values will be written to any gaps left in the rest of the record variables (I think). In all cases variable attributes in output-file are superseded by attributes of the same name from input-file, and left alone if there is no name conflict.
Some users may wish to avoid interactive ncks queries about whether to overwrite existing data. For example, batch scripts will fail if ncks does not receive responses to its queries. Options -O and -A are available to force overwriting existing files and variables, respectively.
Options specific to ncks
The following list provides a short summary of the features unique to ncks.
View all data in netCDF in.nc, printed with Fortran indexing conventions:
Copy the netCDF file in.nc to file out.nc.
Print variable three_dmn_var from file in.nc with default notations. Next print three_dmn_var as an un-annotated text column. Then print three_dmn_var signed with very high precision. Finally, print three_dmn_var as a comma-separated list.
One dimensional arrays of characters stored as netCDF variables are automatically printed as strings, whether or not they are NUL-terminated, e.g.,
Create netCDF out.nc containing all variables, and any associated coordinates, except variable time, from netCDF in.nc:
Extract variables time and pressure from netCDF in.nc. If out.nc does not exist it will be created. Otherwise the you will be prompted whether to append to or to overwrite out.nc:
Create netCDF out.nc containing all variables from file in.nc. Restrict the dimensions of these variables to a hyperslab. Print (with -H) the hyperslabs to the screen for good measure. The specified hyperslab is: the sixth value in dimension time; the half-open range lat <= 0.0 in coordinate lat; the half-open range lon >= 330.0 in coordinate lon; the closed interval 0.3 <= band <= 0.5 in coordinate band; and cross-section closest to 1000.0 in coordinate lev. Note that limits applied to coordinate values are specified with a decimal point, and limits applied to dimension indices do not have a decimal point.
Assume the domain of the monotonically increasing longitude coordinate lon is 0 < lon < 360. Here, lon is an example of a wrapped coordinate. ncks will extract a hyperslab which crosses the Greenwich meridian simply by specifying the westernmost longitude as min and the easternmost longitude as max, as follows:
NCO manual pages written by Charlie Zender and originally formatted by Brian Mays.
Report bugs to <http://sf.net/bugs/?group_id=3331>.
Copyright © 1995-2018 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.
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 <http://nco.sf.net/nco.pdf>, <http://nco.sf.net/nco.dvi>, and <http://nco.sf.net/nco.ps>, respectively. 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
should give you access to the complete manual, except for the TeX-intensive portions.
ncap(1), ncap2(1), ncatted(1), ncbo(1), ncclimo(1), nces(1), ncecat(1), ncflint(1), ncks(1), nco(1), ncpdq(1), ncra(1), ncrcat(1), ncremap(1), ncrename(1), ncwa(1)
The NCO homepage at <http://nco.sf.net> contains more information.