Skip to content

Instantly share code, notes, and snippets.

@asher-pembroke
Last active April 17, 2017 22:02
Show Gist options
  • Select an option

  • Save asher-pembroke/714e2b2a92ff8d91df9e375e25a9f9b2 to your computer and use it in GitHub Desktop.

Select an option

Save asher-pembroke/714e2b2a92ff8d91df9e375e25a9f9b2 to your computer and use it in GitHub Desktop.
from pint import quantity

import numpy as np

import pint
ureg = pint.UnitRegistry()

#shape of the galaxy
diameter = 1e5 * ureg.lightyear
thickness = 1000. * ureg.lightyear

volume = np.pi * pow(diameter/2,2) * thickness

# number of terrestrial like planets
planets = 1e6

planets_per_vol = planets/volume

planets_per_vol.to_compact()

127.323954474 1/kilolight_year3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment