Dimensions and World Coordinates
AstroImages are based on Dimensional Data. Each axis is assigned a dimension name and the indices are tracked.
World Coordinates
FITS files with world coordinate system (WCS) headers contain all the information necessary to map a pixel location into celestial coordinates & back.
Let's see how this works with a 2D image with RA & DEC coordinates.
using AstroImages
using Plots
# Download a Hubble image of the Eagle nebula
download(
"http://www.astro.uvic.ca/~wthompson/astroimages/fits/656nmos.fits",
"eagle-656nmos.fits"
);
eagle = load("eagle-656nmos.fits")
This image contains world coordinate system headers. AstroImages.jl uses WCS.jl (and wcslib under the hood) to parse these headers. We can generate a WCSTransform object to inspect:
wcs(eagle, 1) # specify which coordinate system
WCSTransform(naxis=2,cdelt=[1.0, 1.0],crval=[274.71149247724, -13.816384007184],crpix=[386.5, 396.0])
Note that we specify with an index which coordinate system we'd like to use. Most images just contain one, but some contain multiple systems.
We can lookup a coordinate from the image:
world = pix_to_world(eagle, [1, 1]) # Bottom left corner
2-element Vector{Float64}:
274.712299241082
-13.801135972688115
Or convert back from world coordinates to pixel coordinates: We can lookup a coordinate from the image:
world_to_pix(eagle, world) # Bottom left corner
2-element Vector{Float64}:
1.000000000336172
0.9999999992196535
These pixel coordinates do not necessarily have to lie within the bounds of the original image, and in general lie at a fractional pixel position.
If an image contains WCS headers, we can visualize them using implot
:
implot(eagle)