A Python interface for the Astrometry.net API.
This package is meant to be a simple but extensible interface for the Astrometry.net API. A higher level interface is offered through the Client class, combining most functionality. However, if you want more control over the requests (e.g. by manually checking the responses), you can also use the Job, Submission and UploadFile classes 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):
<small class="ln"> 1 </small>
from astrometry_net_client import Session<small class="ln"> 2 </small>
from astrometry_net_client import FileUpload<small class="ln"> 3 </small>
<small class="ln"> 4 </small>
s = Session(api_key='xxxxxxxxx')<small class="ln"> 5 </small>
upl = FileUpload('some/file/name', session=s) # 1.<small class="ln"> 6 </small>
submission = upl.submit() # 2.<small class="ln"> 7 </small>
submission.until_done() # blocks until it is finished<small class="ln"> 8 </small>
job = submission.jobs # 3.<small class="ln"> 9 </small>
job.until_done() # 4. (again blocks)<small class="ln">10 </small>
if job.success():<small class="ln">11 </small>
wcs = job.wcs_file() # 5. (only if successful)<small class="ln">12 </small>
print(job.info()) # works even though the job failed
Or with the higher level Client :
<small class="ln">1 </small>
from astrometry_net_client import Client<small class="ln">2 </small>
<small class="ln">3 </small>
c = Client(api_key='xxxxxxxxxx')<small class="ln">4 </small>
<small class="ln">5 </small>
# WARNING: this can take a while, as it blocks until the file is solved.<small class="ln">6 </small>
# wcs will be None if upload is not successful<small class="ln">7 </small>
wcs = 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 following initialize & send pattern:
r = Request(url) # initialize (request not yet sent) response = r.make() # send the request
Similarely, retrieving files like the WCS file (after a successful Job) will be done once and cached thereafter:
wcs = job.wcs_file() # first call makes the actual request wcs_2 = job.wcs_file() # second call uses previously obtained result
Installation required python version 3.8 or greater.
Simpy install the package usng PyPi:
pip install astrometry-net-client
Note that the development and testing of this package is done on Linux, so it may not work on a different platform.
Installing From Source
Installing 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:
make virt-env source .env/bin/activate pip install wheel
Then build & install the package with (does not install development dependencies):
Documentation is available at Readthedocs
There is a local documentation available (defined by docstrings). To access it, first install the package and the development dependencies:
then generate the documentation (using Sphinx) by:
The main page can then be found at (assuming you are in the project root) ./docs/_build/html/index.html. Open this (for example) with:
Some example files/scripts are found at the examples entry of the documentation.
Some elaborate examples can be found in the examples directory. For more specific usage, refer to the documentation.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for astrometry_net_client-0.2.7.tar.gz
Hashes for astrometry_net_client-0.2.7-py3-none-any.whl