import distl
import astropy.units as u

Create Distribution With Units

Units can be attached to a distribution either by passing unit to the creation function, or multiplying a Distribution object by a unit object.

g = distl.gaussian(10, 2, unit=u.km)
g = distl.gaussian(10, 2) * u.km
g
<distl.gaussian loc=10.0 scale=2.0 unit=km>
out = g.plot(show=True)

png

Sample/Plot in Different Units

g.sample(unit=u.m)
8380.071695942237
out = g.plot(unit=u.m, show=True)

png

Translate Units

g_meters = g.to(u.m)
g_meters
<distl.gaussian loc=10000.0 scale=2000.0 unit=m>
out = g_meters.plot(show=True)

png

there are also shortcut methods for to_size or to_solar

out = g.to_solar().plot(show=True)

png

out = g.to_si().plot(show=True)

png