A Efficient cone searches with Healpix-alchemy

  • A
  • Thread starter Thread starter BOAS
  • Start date Start date
  • Tags Tags
    Cone Python
AI Thread Summary
The discussion focuses on optimizing a cone search implementation using the HEALPix-alchemy package. The user has set up models for Field, FieldTile, and Source to manage HEALPix data. They are currently querying to check if each source is contained within a FieldTile, which is inefficient. The user seeks advice on modifying their approach to check each tile and return the contained sources more effectively. Suggestions for improving the query performance and structure are needed to enhance efficiency.
BOAS
Messages
546
Reaction score
19
TL;DR Summary
Implementation of a more efficient cone search using healpix-alchemy
I am trying to implement a cone search for a catalog with the HEALPix-alchemy package. I have the following models set up, based on the examples here: https://arxiv.org/pdf/2112.06947


Python:
class Field(Base):
        """
        Represents a collection of FieldTiles making up the area of interest.
        """
        id = Column(Integer, primary_key=True, autoincrement=True)
        tiles = relationship(lambda: FieldTile, order_by="FieldTile.id")


class FieldTile(Base):
    """
    A HEALPix tile that is a component of the Field being selected.
    """
    id = Column(ForeignKey(Field.id), primary_key=True)
    hpx = Column(Tile, index=True)
    pk = Column(Integer, primary_key=True, autoincrement=True)


class Source(Base):
    """
    Represents a source and its location.
    """
   
    id = mapped_column(Integer, primary_key=True, index=True, autoincrement=True)
    name = Column(String, unique=True)
    Heal_Pix_Position = Column(Point, index=True, nullable=False)


I am then using CDSHealpix to get the HEALPix cells contained within a specified cone.

I construct the Multi Order Coverage map from the HEALPix cells using MOCpy and extract the HEALPix tiles using HEALPix-alchemy.

I then populate the Field table with this collection of tiles.

Finally, I perform the following query:

Python:
query = db.query(Source).filter(FieldTile.hpx.contains(Source.Heal_Pix_Position)).all()

However, this is very inefficient as I am effectively checking each source in my catalog to see if it is contained within a FieldTile.

How can I modify my approach so that I am checking each tile and returning the sources that it contains?
 
Is a homemade radio telescope realistic? There seems to be a confluence of multiple technologies that makes the situation better than when I was a wee lad: software-defined radio (SDR), the easy availability of satellite dishes, surveillance drives, and fast CPUs. Let's take a step back - it is trivial to see the sun in radio. An old analog TV, a set of "rabbit ears" antenna, and you're good to go. Point the antenna at the sun (i.e. the ears are perpendicular to it) and there is...
3I/ATLAS, also known as C/2025 N1 (ATLAS) and formerly designated as A11pl3Z, is an iinterstellar comet. It was discovered by the Asteroid Terrestrial-impact Last Alert System (ATLAS) station at Río Hurtado, Chile on 1 July 2025. Note: it was mentioned (as A11pl3Z) by DaveE in a new member's introductory thread. https://www.physicsforums.com/threads/brian-cox-lead-me-here.1081670/post-7274146 https://earthsky.org/space/new-interstellar-object-candidate-heading-toward-the-sun-a11pl3z/ One...
Back
Top