Sum all values over several dimensions of a netCDF variable

This post was originally published here

NCO:ncap2 and .total

ncap2 -s 'summed_variable=variable_to_sum.total($lat,$lon)' in.nc out.nc

Make sure to use single quotes.

If your in.nc==out.cnc then adding -A will save you from having to specify “overwrite” (see this).

ncap2 -A -s 'summed_variable=variable_to_sum.total($lat,$lon)' in.nc out.nc

Leave a Reply

Your email address will not be published. Required fields are marked *