<p>While what you wrote is technically correct, the <code>astropy.units</code> package is designed to solve your problem in the following way</p>
<pre><code># use the &lt;&lt; operator here instead of * to avoid copying the image
image = image_in_Jy_per_sr &lt;&lt; (u.Jy / u.sr)

pixel_scale = 0.05 * (u.arcsec / u.pix)

image = image / pixel_scale ** 2

image_in_Jy_per_pix = image.to_value(u.Jy / u.pix ** 2)
</code></pre>
<p>Doing it this way allows <code>astropy.units</code> to work better, since it allows checking if the result is dimensionally-compatible with Jy/pix.</p>

CC BY-SA 4.0
2023-04-20T10:34:42.703Z
Thank you for your answer!
Sketos
CC BY-SA 4.0
2023-04-19T17:00:31.477Z
2023-04-19T17:00:31.477Z
Roy Smart
<p>I want to convert the units of an image from Jy/sr (Janskys per steradian) to Jy/pix and I know the pixel scale in arcsec. The way I do this, in python, is the following:</p>
<pre><code>from astropy import units

pixel_scale = 0.05 # NOTE: in arcsec

conversion_factor = 1.0 / (units.steradian.to(units.arcsec**2.0) / pixel_scale**2.0)

image_in_Jy_per_pix = image_in_Jy_per_sr * conversion_factor
</code></pre>
<p>Is this correct?</p>

<observational-astronomy><data-analysis>
Convert image from Jy/sr to Jy/pix
Sketos
# Convert image from Jy/sr to Jy/pix

(Asked by: username_0 on 2023-04-18)

I want to convert the units of an image from Jy/sr (Janskys per steradian) to Jy/pix and I know the pixel scale in arcsec. The way I do this, in python, is the following:

```
from astropy import units

pixel_scale = 0.05 # NOTE: in arcsec

conversion_factor = 1.0 / (units.steradian.to(units.arcsec**2.0) / pixel_scale**2.0)

image_in_Jy_per_pix = image_in_Jy_per_sr * conversion_factor

```

Is this correct?

**Tags:** observational-astronomy, data-analysis


---

## 1 answers

### Answer by username_1 on 2023-04-19. Score: 3

While what you wrote is technically correct, the `astropy.units` package is designed to solve your problem in the following way

```
# use the << operator here instead of * to avoid copying the image
image = image_in_Jy_per_sr << (u.Jy / u.sr)

pixel_scale = 0.05 * (u.arcsec / u.pix)

image = image / pixel_scale ** 2

image_in_Jy_per_pix = image.to_value(u.Jy / u.pix ** 2)

```

Doing it this way allows `astropy.units` to work better, since it allows checking if the result is dimensionally-compatible with Jy/pix.

> **Comments:**
> **username_0**: Thank you for your answer!  

---

