How do I get the error value out of an astropy.constants quantity?

In [87]: from astropy import constants as c

In [88]: c.M_sun
Out[88]: <Constant name='Solar mass' value=1.9891e+30 error=5e+25 units='kg' reference="Allen's Astrophysical Quantities 4th Ed.">

In [89]: c.M_sun.value
Out[89]: 1.9891e+30

In [90]: c.M_sun.error
AttributeError: 'Constant' object has no 'error' member
  • $\begingroup$ I've added an answer, but I would ordinarily vote to close because of a lack of effort on your part. Are you using IPython? Did you try hitting tab at c.M_sun. to see what the available functions and variables are? $\endgroup$
    – Warrick
    Commented Sep 11, 2015 at 5:18

1 Answer 1


While I'm not familiar with the package, a very quick look at the documentation suggests that you want

In [90]: c.M_sun.uncertainty

instead. I've just checked and this appears to be correct.

> python -c "from astropy import constants as c ; print c.M_sun.uncertainty"

  • 3
    $\begingroup$ This is correct. I've opened an issue to make sure we update the representation of the constant to say 'uncertainty' instead of 'error' and 'unit' instead of 'units', to match the attributes: astronomy.stackexchange.com/questions/11769/… $\endgroup$
    – astrofrog
    Commented Sep 11, 2015 at 6:57
  • $\begingroup$ @astrofrog - If you're associated with that product, you should be using the Sun's gravitational parameter rather than the Sun's mass. Conceptually, $\mu_{\odot} = GM_{\odot}$, but in practice, $M_{\odot}$ is computed: $M_{\odot}=\mu{\odot}/G$. This computation uses the observed (and very precise) value of $\mu_{\odot}$ and the observed (but rather imprecise) value of $G$. Almost all of the uncertainty in $M_{\odot}$ results from the uncertainty in $G$. $\endgroup$ Commented Sep 11, 2015 at 17:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .