nctoolkit.DataSet.multiply

DataSet.multiply(self, x=None, var=None)

Multiply a dataset This will multiply a 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 multiply the dataset by. If multiplying by a dataset or single file there must only be a single variable in it, unless var is supplied. The grids must be the same.

  • var (str) – A variable in the x to multiply the dataset by

Examples

If you wanted to multiply variables in a dataset by 10, you would do the following:

>>> ds.multiply(10)

To multiply the values in a dataset by the values of variables in dataset ds2, you would do the following:

>>> ds1.multiply(ds2)

Grids in the datasets must match. Multiplication 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 multiply the data in all timesteps in ds1.

Multiplying a dataset by the data from another netCDF file will work in the same way:

>>> ds.multiply("example.nc")