1NCBO(1)                     General Commands Manual                    NCBO(1)
2
3
4

NAME

6       ncbo - netCDF Binary Operator
7

SYNTAX

9       ncbo  [-3]  [-4]  [-5]  [-6]  [-7]  [-A]  [--bfr sz_byt][-C][-c] [--cmp
10       cmp_sng]  [--cnk_byt  sz_byt][--cnk_csh  sz_byt][--cnk_dmn   nm,sz_lmn]
11       [--cnk_map   map]   [--cnk_min   sz_byt]   [--cnk_plc  plc]  [--cnk_scl
12       sz_lmn][-D dbg_lvl] [-d dim,[ min][,[ max]]]  [-F]  [--fl_fmt=fmt]  [-G
13       gpe_dsc]  [-g  grp[,...]]   [--glb  att_name=  att_val]]  [-h]  [--hdf]
14       [--hdr_pad  sz_byt][--hpss_try]  [-L   dfl_lvl]   [-l   path]   [--msa]
15       [--no_cll_msr]  [--no_frm_trm]  [--no_tmp_fl]  [-O] [-p path] [-R] [-r]
16       [--ram_all] [-t thr_nbr] [--uio] [--unn] [-v var[,...]]  [-X box]  [-x]
17       file_1 file_2 file_3
18

DESCRIPTION

20       ncbo  subtracts  variables  in  file_2 from the corresponding variables
21       (those with the same name) in file_1 and stores the results in  file_3.
22       Variables in file_2 are broadcast to conform to the corresponding vari‐
23       able in file_1 if necessary.  Broadcasting a  variable  means  creating
24       data  in  non-existing dimensions from the data in existing dimensions.
25       For example, a two dimensional variable in  file_2  can  be  subtracted
26       from  a  four, three, or two (but not one or zero) dimensional variable
27       (of the same name) in file_1.  This functionality allows  the  user  to
28       compute anomalies from the mean.  Note that variables in file_1 are not
29       broadcast to conform to the dimensions in file_2.  Thus, ncbo, the num‐
30       ber of dimensions, or rank, of any processed variable in file_1 must be
31       greater than or equal to the rank of the same variable in file_2.  Fur‐
32       thermore,  the  size of all dimensions common to both file_1 and file_2
33       must be equal.
34
35       When computing anomalies from the mean it is often the case that file_2
36       was  created  by applying an averaging operator to a file with the same
37       dimensions as file_1, if not file_1 itself.  In these  cases,  creating
38       file_2  with  ncra  rather  than  ncwa will cause the ncbo operation to
39       fail.  For concreteness say the record dimension in file_1 is time.  If
40       file_2  were  created  by averaging file_1 over the time dimension with
41       the ncra operator rather than with the ncwa operator, then file_2  will
42       have a time dimension of size 1 rather than having no time dimension at
43       all In this case the input files to ncbo, file_1 and file_2, will  have
44       unequally  sized time dimensions which causes ncbo to fail.  To prevent
45       this from occurring, use ncwa to remove the time dimension from file_2.
46       An example is given below.
47
48       ncbo  will  never  difference coordinate variables or variables of type
49       NC_CHAR or NC_BYTE.  This ensures that coordinates like (e.g., latitude
50       and  longitude)  are  physically meaningful in the output file, file_3.
51       This behavior is hardcoded.  ncbo applies special rules  to  some  NCAR
52       CSM  fields  (e.g.,  ORO).  See NCAR CSM Conventions for a complete de‐
53       scription.  Finally, we note that ncflint (ncflint netCDF File Interpo‐
54       lator)  can be also perform file subtraction (as well as addition, mul‐
55       tiplication and interpolation).
56

EXAMPLES

58       Say files 85_0112.nc and 86_0112.nc each contain  12  months  of  data.
59       Compute the change in the monthly averages from 1985 to 1986:
60              ncbo 86_0112.nc 85_0112.nc 86m85_0112.nc
61
62       The  following  examples  demonstrate the broadcasting feature of ncbo.
63       Say we wish to compute the monthly anomalies of T from the yearly aver‐
64       age  of T for the year 1985.  First we create the 1985 average from the
65       monthly data, which is stored with the record dimension time.
66              ncra 85_0112.nc 85.nc
67              ncwa -O -a time 85.nc 85.nc
68       The second command, ncwa, gets rid of the time dimension of size 1 that
69       ncra  left in 85.nc.  Now none of the variables in 85.nc has a time di‐
70       mension.  A quicker way to accomplish this is to use ncwa from the  be‐
71       ginning:
72              ncwa -a time 85_0112.nc 85.nc
73       We are now ready to use ncbo to compute the anomalies for 1985:
74              ncbo -v T 85_0112.nc 85.nc t_anm_85_0112.nc
75       Each of the 12 records in t_anm_85_0112.nc now contains the monthly de‐
76       viation of T from the annual mean of T for each gridpoint.
77
78       Say we wish to compute the monthly gridpoint anomalies from  the  zonal
79       annual  mean.   A  zonal mean is a quantity that has been averaged over
80       the longitudinal (or x) direction.  First we use ncwa to  average  over
81       longitudinal  direction  lon,  creating  xavg_85.nc,  the zonal mean of
82       85.nc.  Then we use ncbo to subtract the zonal annual  means  from  the
83       monthly gridpoint data:
84              ncwa -a lon 85.nc xavg_85.nc
85              ncbo 85_0112.nc xavg_85.nc tx_anm_85_0112.nc
86       Assuming  85_0112.nc  has  dimensions  time  and lon, this example only
87       works if xavg_85.nc has no time or lon dimension.
88
89       As a final example, say we have five years of monthly  data  (i.e.,  60
90       months)  stored in 8501_8912.nc and we wish to create a file which con‐
91       tains the twelve month seasonal cycle of the  average  monthly  anomaly
92       from the five-year mean of this data.  The following method is just one
93       permutation of many which will accomplish the same result.   First  use
94       ncwa to create the file containing the five-year mean:
95              ncwa -a time 8501_8912.nc 8589.nc
96       Next  use  ncbo  to  create  a  file  containing the difference of each
97       month's data from the five-year mean:
98              ncbo 8501_8912.nc 8589.nc t_anm_8501_8912.nc
99       Now use ncks to group the five January anomalies together in one  file,
100       and  use  ncra  to  create  the  average anomaly for all five Januarys.
101       These commands are embedded in a shell loop so they  are  repeated  for
102       all twelve months:
103              foreach idx (01 02 03 04 05 06 07 08 09 10 11 12)
104              ncks -F -d time,,,12 t_anm_8501_8912.nc foo.
105              ncra foo. t_anm_8589_.nc
106              end
107       Note  that ncra understands the stride argument so the two commands in‐
108       side the loop may be combined into the single command
109              ncra -F -d time,,,12 t_anm_8501_8912.nc foo.
110       Finally, use ncrcat to concatenate the 12 average monthly anomaly files
111       into one twelve-record file which contains the entire seasonal cycle of
112       the monthly anomalies:
113              ncrcat t_anm_8589_??.nc t_anm_8589_0112.nc
114
115

AUTHOR

117       NCO manual pages written by Charlie Zender and originally formatted  by
118       Brian Mays.
119
120

REPORTING BUGS

122       Report bugs to <http://sf.net/bugs/?group_id=3331>.
123
124
126       Copyright © 1995-present Charlie Zender
127       This is free software; see the source for copying conditions.  There is
128       NO warranty; not even for MERCHANTABILITY or FITNESS FOR  A  PARTICULAR
129       PURPOSE.
130
131

SEE ALSO

133       The full documentation for NCO is maintained as a Texinfo manual called
134       the NCO Users Guide.  Because NCO is mathematical in nature, the  docu‐
135       mentation  includes  TeX-intensive  portions not viewable on character-
136       based displays.  Hence the only complete and authoritative versions  of
137       the NCO Users Guide are the PDF (recommended), DVI, and Postscript ver‐
138       sions at <http://nco.sf.net/nco.pdf>, <http://nco.sf.net/nco.dvi>,  and
139       <http://nco.sf.net/nco.ps>,  respectively.   HTML  and XML versions are
140       available         at          <http://nco.sf.net/nco.html>          and
141       <http://nco.sf.net/nco.xml>, respectively.
142
143       If  the  info and NCO programs are properly installed at your site, the
144       command
145
146              info nco
147
148       should give you access to the complete manual, except for  the  TeX-in‐
149       tensive portions.
150
151

HOMEPAGE

153       The NCO homepage at <http://nco.sf.net> contains more information.
154
155
156
157                                                                       NCBO(1)
Impressum