# Simple arithmetic and comparisons¶

Basic arithmetic and logical comparisons can be carried out using nctoolkit with the standard Python operators: `+`

, `-`

, `*`

, `/`

, `>`

, `<`

, `>=`

, `<=`

, `==`

, and `!=`

.

## Basic arithmetic using constants and datasets¶

Often you might want to subtract datasets from each other, or add or subtract a dataset by a constant. The former is potentially made complicated as datasets can take different forms. For example, you might want to subtract a dataset which contains annual means from a dataset that contains monthly values. In this case you want to subtract the annual mean from the relevant month in each year. To deal with this problem, nctoolkit offers the ability to use standard Python operations `+`

, `-`

,
`*`

and `/`

to carry out these operations, and in most use-cases it will be able to carry out an appropriate calculation.

Let’s illustrate this using a dataset of monthly sea surface temperature from 1850 to the present day. We will start by looking at the first time step:

```
[1]:
```

```
import nctoolkit as nc
ds = nc.open_data("sst.mon.mean.nc")
ds.subset(time = 0)
ds.plot()
```

```
nctoolkit is using Climate Data Operators version 2.1.0
```