<p>While I'm not familiar with the package, a <a href="http://docs.astropy.org/en/stable/api/astropy.constants.Constant.html#astropy.constants.Constant">very quick look at the documentation</a> suggests that you want</p>

<pre><code>In [90]: c.M_sun.uncertainty
</code></pre>

<p>instead.  I've just checked and this appears to be correct.</p>

<pre><code>&gt; python -c "from astropy import constants as c ; print c.M_sun.uncertainty"

5e+25
</code></pre>

CC BY-SA 3.0
2015-09-11T06:57:30.627Z
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: https://astronomy.stackexchange.com/questions/11769/how-to-get-error-out-of-astropy-constants
astrofrog
CC BY-SA 3.0
2015-09-11T17:44:10.483Z
@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$.
David Hammen
CC BY-SA 3.0
2015-09-11T05:17:00.010Z
2015-09-11T05:17:00.010Z
Warrick
<p>How do I get the error value out of an astropy.constants quantity?</p>

<pre><code>In [87]: from astropy import constants as c

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

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

In [90]: c.M_sun.error
AttributeError: 'Constant' object has no 'error' member
</code></pre>

CC BY-SA 3.0
2015-09-11T05:18:42.477Z
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?
Warrick
<astropy><python>
How to get error out of astropy constants
equant
# How to get error out of astropy constants

(Asked by: username_0 on 2015-09-10)

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]: 

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

In [90]: c.M_sun.error
AttributeError: 'Constant' object has no 'error' member

**Tags:** astropy, python
> **Comments:**
> **username_1**: 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?  

---

## 1 answers

### Answer by username_1 on 2015-09-11. Score: 5 | Accepted answer

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

> **Comments:**
> **username_2**: 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: https://astronomy.stackexchange.com/questions/11769/how-to-get-error-out-of-astropy-constants  
> **username_3**: @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$.  

---

