In [1]:

```
from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
```

As always with Colossus, we need to set a cosmology:

In [2]:

```
from colossus.cosmology import cosmology
cosmology.setCosmology('planck15');
```

In [3]:

```
from colossus.halo import mass_so
```

In [4]:

```
z = np.linspace(0.0, 3.0, 40)
plt.figure()
plt.yscale('log')
plt.xlabel('z')
plt.ylabel('density (Msun h2 / kpc3)')
plt.plot(z, mass_so.densityThreshold(z, 'vir'), label = 'vir');
plt.plot(z, mass_so.densityThreshold(z, '180m'), label = '180m');
plt.plot(z, mass_so.densityThreshold(z, '180c'), label = '180c');
plt.legend();
```

`2467m`

or `155c`

. We can convert mass and radius into each other, for example, let's get the virial radius of a halo of virial mass $10^{12}M_{\odot}/h$ at $z = 0.5$, and convert it back:

In [5]:

```
R = mass_so.M_to_R(1E12, 0.5, 'vir')
print(R)
M2 = mass_so.R_to_M(R, 0.5, 'vir')
print(M2)
```

`mass_defs`

and `mass_adv`

modules.

In [6]:

```
from colossus.halo import mass_defs
from colossus.halo import mass_adv
```

`200c`

. Internally, this function makes an assumption about the density profile of the halo, by default an NFW profile. Thus, we need to pass a concentration as well as a mass:

In [7]:

```
Mvir = 1E12
cvir = 7.0
M200c, R200c, c200c = mass_defs.changeMassDefinition(Mvir, cvir, 0.5, 'vir', '200c')
print(M200c / Mvir)
print(c200c / cvir)
```

In [8]:

```
M200c, R200c, c200c = mass_adv.changeMassDefinitionCModel(Mvir, 0.5, 'vir', '200c')
print(M200c / Mvir)
print(c200c / cvir)
```

`changeMassDefinition()`

function is a wrapper around a more general function called `evolveSO()`

which finds spherical overdensity radii and masses under the assumption that a profile is static. The name refers to pseudo-evolution, the change in mass and radius over time due to the changing mass definition (see, e.g., Diemer et al. 2013). Let's see how much a halo pseudo-evolves between $z = 1$ and $z = 0$ if it's profile doesn't change at all:

In [9]:

```
Mvir_z1 = 1E12
cvir_z1 = 7.0
Mvir_z0, Rvir_z0, cvir_z0 = mass_defs.pseudoEvolve(Mvir_z1, cvir_z1, 'vir', 1.0, 0.0)
print(Mvir_z0 / Mvir_z1)
```