跳转到主要内容

用于天体目录中索引锥形搜索的SQLAlchemy扩展

项目描述

PyPI Status GitHub Workflow Status codecov

Cone Search Alchemy

conesearch_alchemy Python包增强了SQLAlchemy,以提供使用PostgreSQL数据库在恒星目录上执行快速、索引化锥形搜索的功能。它不依赖于任何数据库扩展。

安装

您可以从Python包索引安装conesearch_alchemy

$ pip install conesearch-alchemy

使用方法

from conesearch_alchemy.point import Point
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()


# Create two tables Catalog1 and Catalog2 that both have spherical coordinates.

class Catalog1(Point, Base):
    __tablename__ = 'catalog1'
    id = Column(Integer, primary_key=True)


class Catalog2(Point, Base):
    __tablename__ = 'catalog2'
    id = Column(Integer, primary_key=True)


...

# Populate Catalog1 and Catalog2 tables with some sample data...
session.add(Catalog1(id=0, ra=320.5, dec=-23.5))
...
session.add(Catalog2(id=0, 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.within(point, separation)
).order_by(
    Catalog1.id, Catalog2.id
)
for row in query:
    ...  # do something with the query results


# Do a cone search around literal ra, dec values.
separation = 1  # separation in degrees
point = Point(ra=212.5, dec=-33.2)
query = session.query(
    Catalog1.id
).filter(
    Catalog1.within(point, separation)
).order_by(
    Catalog1.id
)
for row in query:
    ...  # do something with the query results

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

conesearch_alchemy-1.1.0.tar.gz (4.4 kB 查看哈希值)

上传时间:

构建分布

conesearch_alchemy-1.1.0-py3-none-any.whl (5.5 kB 查看哈希值)

上传时间: Python 3

由以下支持