How to get error out of astropy constants

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

• 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? Sep 11 '15 at 5:18

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"

5e+25

• 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/… Sep 11 '15 at 6:57
• @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$. Sep 11 '15 at 17:44