-
Notifications
You must be signed in to change notification settings - Fork 183
Closed
Labels
Description
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