nctoolkit.DataSet.divide#
- DataSet.divide(x=None, var=None)#
divide: Divide the data.
This will divide the dataset by a constant, another dataset or a netCDF file.
- Parameters:
x (int, float, DataSet or netCDF file) – An int, float, single file dataset or netCDF file to divide the dataset by. If a dataset or netCDF file is supplied, this must have only one variable, unless var is provided. The grids must be the same.
var (str) – A variable in the x to use for the operation
Examples
If you wanted to divide all variables in a dataset by 20, you would do the following:
>>> ds.divide(10)
Or, you could use standard python division syntax:
>>> ds / 10
To divide values in a dataset by those in the dataset ds2 from a dataset ds1, you would do the following:
>>> ds1.divide(ds2)
Or, you could use standard python division syntax:
>>> ds1 / ds2
Grids in the datasets must match. Division will occur in matching timesteps in ds1 and ds2. If there is only 1 timestep in ds2, then the data from that timestep in ds2 will divided the data in all ds1 time steps.