Package: twirl
twirlPython package for astrometric plate solvingtwirl is an astrometric plate solving package for Python. It is suited for cases where the Right Ascension and Declination (RA, dec) coordinates of the image center and the field of view is known, computing a World Coordinate System (WCS) based on GAIA reference stars.twirl compute a WCS following these steps:detection of stars in the image if not providedcatalog query using image known centerasterisms building and matchingimage recombination and wcs fit using astropy.wcsAstersisms are made of 3 or 4 points. 4 points asterisms are built following Lang et al. 2009 while 3 points asterims are based on an original algorithm.Installationtwirl can be installed using pip:pipinstalltwirlor using poetry:poetryaddtwirlExample Usagetwirlis designed to be complementary to theastropypackage. It is used to compute a WCS by matching an image detected stars with catalog stars. To query the catalog stars, the center coordinates of the image must be known, as well as the size of the field of view. If not available, the latter can be computed using the known pixel scale of the detector.Hence, the process starts by extracting the image RA-DEC center equatorial coordinate and compute the instrument field of viewimportnumpyasnpfromastropy.ioimportfitsfromastropyimportunitsasufromastropy.coordinatesimportSkyCoord# Open some FITS imagehdu=fits.open("...")[0]# get the center of the imagera,dec=hdu.header["RA"],hdu.header["DEC"]center=SkyCoord(ra,dec,unit=["deg","deg"])# and the size of its field of viewpixel=0.66*u.arcsec# known pixel scaleshape=hdu.data.shapefov=np.max(shape)*pixel.to(u.deg)We can then query the gaia stars in the field using this informationimporttwirlsky_coords=twirl.gaia_radecs(center,1.2*fov)[0:12]and match the queried stars to stars detected in the image# detect stars in the imagepixel_coords=twirl.find_peaks(hdu.data)[0:12]# compute the World Coordinate Systemwcs=twirl.compute_wcs(pixel_coords,sky_coords)leading to a World Coordinate System object.A more complete example is provided indocs/ipynb/wcs.ipynbDevelopmentProject RequirementsPython3.11.*Poetryfor Python package and environment management.Installing DependenciesThe twirl project manages Python package dependencies usingPoetry. You'll need to follow the instructions for installation there.Then you can start a shell session with the new environment with:$poetryshellN.B.For development with vscode you will need to run the following command:$poetryconfigvirtualenvs.in-projecttrueThis will installed the poetry.venvin the root of the project and allow vscode to setup the environment correctly for development.To start development, install all of the dependencies as:$poetryinstallN.B.Ensure that any dependency changes are committed to source control, so everyone has a consistenct package dependecy list.AcknowledgementsThis package has made use of the algorithm fromLang, D. et al. (2010).Astrometry.net: Blind Astrometric Calibration of Arbitrary Astronomical Images. The Astronomical Journal, 139(5), pp.1782–1800.doi:10.1088/0004-6256/139/5/1782.implemented inGarcia, L. J. et al. (2022). prose: a Python framework for modular astronomical images processing. MNRAS, vol. 509, no. 4, pp. 4817–4828, 2022.doi:10.1093/mnras/stab3113.See thisdocumentation pagefor the BibTeX entries.