You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add to WCS tutorial: How to place a scale bar on an image with WCS #443
A colleague of mine asked me this simple question, and I thought it would make a good addition to the WCS tutorial. He ended up finding a solution in the source code for AplPy, but I'm certain we could make it simpler. (i.e., we don't need to the if statements to know if our inputs are an Astropy Quantity versus a Unit)
## Scale length from my colleague is calculated for a cosmology case
#a2261 is at z = 0.22331. For Omega_M = 0.3, Omega_Lambda = 0.7, this corresponds to 1 arcsec = 3.593 kpc
scale_length = 100.0 / 3.593 * u.arcsec # = 100 kpc
## This code plots that scale length on the image
# The following is taken from AplPy overlays
if isinstance(scale_length, u.Quantity):
barlength = scale_length.to(u.degree).value
elif isinstance(scale_length, u.Unit):
barlength = length.to(u.degree)
if wcs.is_celestial:
pix_scale = wcsutils.proj_plane_pixel_scales(wcs)
else:
print("you can't do that in this coordinate system")
pix_scale = [1.0, 1.0]
degrees_per_pixel = np.sqrt(pix_scale[0] * pix_scale[1])
barlength = barlength / degrees_per_pixel
Have used matplotlib's axes.arrow for the plotting of a scale bar on an image in the Celestial Coordinates 1 (or celestial-coords1) notebook on Google Colab, with a wcs transform thrown in so that I can directly enter the degrees for the attributes for plotting. Maybe this simplified version would be more suitable for our purposes.
There is an implementation of a scale bar in Section 3 of Working with Celestial Coords with WCS I. So, as far as I'm concerned, from a Tutorial perspective, this is addressed.
If you want to propose to add it to core -- which makes total sense -- I assume you'd want to open that issue/PR in a different repo.
Activity
kakirastern commentedon Apr 14, 2020
@eblur Yeah, I agree that it would be a good idea!
kakirastern commentedon Apr 28, 2020
Have used
matplotlib'saxes.arrowfor the plotting of a scale bar on an image in the Celestial Coordinates 1 (orcelestial-coords1) notebook on Google Colab, with awcstransform thrown in so that I can directly enter the degrees for the attributes for plotting. Maybe this simplified version would be more suitable for our purposes.keflavich commentedon Jul 6, 2021
Even though this was closed... I don't see this material in the tutorials. This is the snippet I use. Should we consider adding to core?
kelle commentedon Jul 8, 2021
There is an implementation of a scale bar in Section 3 of Working with Celestial Coords with WCS I. So, as far as I'm concerned, from a Tutorial perspective, this is addressed.
If you want to propose to add it to core -- which makes total sense -- I assume you'd want to open that issue/PR in a different repo.