SQLAlchemy extensions for HEALPix spatially indexed astronomy data
Project description
HEALPix Alchemy
The healpix_alchemy
Python package extends SQLAlchemy will provide spatial
indexing for astronomical sky coordinates, regions, and raster images (e.g.
LIGO/Virgo and Fermi probability sky maps) in a relational database. It does
not rely on any database extensions.
This package is a work in progress. Initially, healpix_alchemy
focuses on
spatial indexing of point clouds while we work out the SQLAlchemy abstraction
design. Once this is mature, we will incorporate the raster indexing strategies
from https://github.com/growth-astro/healpix-intersection-example.
Installation
You can install healpix_alchemy
the Python Package Index:
$ pip install healpix-alchemy
Usage
from healpix_alchemy.point import HasPoint, Point
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
# Create two tables Catalog1 and Catalog2 that both have spherical coordinates.
class Catalog1(HasPoint, Base):
__tablename__ = 'catalog1'
id = Column(Integer, primary_key=True)
class Catalog2(HasPoint, Base):
__tablename__ = 'catalog2'
id = Column(Integer, primary_key=True)
...
# Populate Catalog1 and Catalog2 tables with some sample data...
session.add(Catalog1(id=0, point=Point(ra=320.5, dec=-23.5)))
...
session.add(Catalog2(id=0, point=Point(ra=18.1, dec=18.3)))
...
session.commit()
# Cross-match the two tables.
separation = 1 # separation in degrees
query = session.query(
Catalog1.id, Catalog2.id
).join(
Catalog2,
Catalog1.point.within(Catalog2.point, separation)
).order_by(
Catalog1.id, Catalog2.id
)
for row in query:
... # do something with the query results
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for healpix_alchemy-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 351a31ad113d40b6083e443710de0b66e48f5284ce4d80d296e4a921033d3cf8 |
|
MD5 | f996684636a041ae5087e081a14918e4 |
|
BLAKE2b-256 | 53d2071644b2bf0ed40209f537c1db1ecadac9553fd8e4d242da98e95e3d1e0f |