Package: astrometry-net-client
NoteThe package is still in development, but it can already be used.
Do not hesitate to leave any feedback (positive or negative)!IntroductionThis package is meant to be a simple but extensible interface for theAstrometry.net API. A higher level interface is offered through theClientclass, combining most functionality. However, if you want more control over the requests (e.g. by manually checking the responses), you can also use theJob,SubmissionandUploadFileclasses directly.The structure of these classes tries to follow the pattern of the API itself, which is essentially:Upload some file (UploadFile), which requires an API key & a login (Session)The upload creates a submission (Submission), unique for each upload. This has to do some general processing, even before the uploaded image is processed.When the submission is done preprocessing, and the system is ready to process the uploaded file, a job (Job) is spawned for each image.The job then takes some time to process, and when it is done it can either be successful or fail.When successful, some information (e.g. found objects) and result files like the generated WCS header can be retrieved.Using this package, these steps are (note that this is not the ideal way to upload multiple files):1fromastrometry_net_clientimportSession2fromastrometry_net_clientimportFileUpload34s=Session(api_key='xxxxxxxxx')5upl=FileUpload('some/file/name',session=s)# 1.6submission=upl.submit()# 2.7submission.until_done()# blocks until it is finished8job=submission.jobs[0]# 3.9job.until_done()# 4. (again blocks)10ifjob.success():11wcs=job.wcs_file()# 5. (only if successful)12print(job.info())# works even though the job failedOr with the higher levelClient:1fromastrometry_net_clientimportClient23c=Client(api_key='xxxxxxxxxx')45# WARNING: this can take a while, as it blocks until the file is solved.6# wcs will be None if upload is not successful7wcs=c.calibrate_file_wcs(filename)One of the core ideas of this package is to try and make the minimal amount of requests possible and make them at a clear time. This is realized by the followinginitialize & sendpattern:r=Request(url)# initialize (request not yet sent)response=r.make()# send the requestSimilarely, retrieving files like the WCS file (after a successfulJob) will be done once and cached thereafter:wcs=job.wcs_file()# first call makes the actual requestwcs_2=job.wcs_file()# second call uses previously obtained resultInstallationInstallation required python version 3.8 or greater.Simpy install the package usng PyPi:pipinstallastrometry-net-clientNote that the development and testing of this package is done on Linux, so it
may not work on a different platform.Installing From SourceInstalling the package from source is made easy by the Makefile, once you have a local copy of the repository (e.g. by cloning, or downloading & extracting the repo ZIP).It is heavily recommended to use a virtual environment. Create and activate one by running:makevirt-envsource.env/bin/activatepipinstallwheelThen build & install the package with (does not install development dependencies):makeinstallDocumentationDocumentation is available atReadthedocsThere is a local documentation available (defined by docstrings). To access it, first  install the package and the development dependencies:makedependenciesthen generate the documentation (using Sphinx) by:makedocumentationThe main page can then be found at (assuming you are in the project root)./docs/_build/html/index.html. Open this (for example) with:firefox./docs/_build/html/index.htmlExamplesSome example files/scripts are found at theexamples entryof the documentation.Some elaborate examples can be found in theexamplesdirectory.
For more specific usage, refer to thedocumentation.