Skip to main content

A Python interface for the Astrometry.net API.

Project description

Documentation Status Build & Tests Status

Introduction

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:

  1. Upload some file (UploadFile), which requires an API key & a login (Session)

  2. The upload creates a submission (Submission), unique for each upload. This has to do some general processing, even before the uploaded image is processed.

  3. When the submission is done preprocessing, and the system is ready to process the uploaded file, a job (Job) is spawned for each image.

  4. The job then takes some time to process, and when it is done it can either be successful or fail.

  5. 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):

 1  from astrometry_net_client import Session
 2  from astrometry_net_client import FileUpload
 3 
 4  s = Session(api_key='xxxxxxxxx')
 5  upl = FileUpload('some/file/name', session=s) # 1.
 6  submission = upl.submit()                     # 2.
 7  submission.until_done()                       # blocks until it is finished
 8  job = submission.jobs[0]                      # 3.
 9  job.until_done()                              # 4. (again blocks)
10  if job.success():
11      wcs = job.wcs_file()                      # 5. (only if successful)
12  print(job.info())                             # works even though the job failed

Or with the higher level Client :

1  from astrometry_net_client import Client
2 
3  c = Client(api_key='xxxxxxxxxx')
4 
5  # WARNING: this can take a while, as it blocks until the file is solved.
6  # wcs will be None if upload is not successful
7  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

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):

make install

Documentation

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:

make dependencies

then generate the documentation (using Sphinx) by:

make documentation

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:

firefox ./docs/_build/html/index.html

Examples

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

astrometry_net_client-0.2.10.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

astrometry_net_client-0.2.10-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file astrometry_net_client-0.2.10.tar.gz.

File metadata

  • Download URL: astrometry_net_client-0.2.10.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for astrometry_net_client-0.2.10.tar.gz
Algorithm Hash digest
SHA256 a3423b7c2fd72a58e36aaf15b93becd6549b0247a8da68e54bf398531ab193bf
MD5 74aad9624ec9387e65b350ac772b7d8a
BLAKE2b-256 ca50c0516e1427291570bf8968fb5b6f700c2da47aed7288cab3a08479592169

See more details on using hashes here.

File details

Details for the file astrometry_net_client-0.2.10-py3-none-any.whl.

File metadata

File hashes

Hashes for astrometry_net_client-0.2.10-py3-none-any.whl
Algorithm Hash digest
SHA256 976e3d104bc0711a779942e4f622140937eab1905a8815cc39dc9b209b4f5476
MD5 294938fc79b34dcdce60f7e42cf02f91
BLAKE2b-256 23e4f6a22952db6e739552ba35a4815ba0c4529639284706ddf103386a4158ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page