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?
 
TL;DR Summary: In 3 years, the Square Kilometre Array (SKA) telescope (or rather, a system of telescopes) should be put into operation. In case of failure to detect alien signals, it will further expand the radius of the so-called silence (or rather, radio silence) of the Universe. Is there any sense in this or is blissful ignorance better? In 3 years, the Square Kilometre Array (SKA) telescope (or rather, a system of telescopes) should be put into operation. In case of failure to detect...
Thread 'Could gamma-ray bursts have an intragalactic origin?'
This is indirectly evidenced by a map of the distribution of gamma-ray bursts in the night sky, made in the form of an elongated globe. And also the weakening of gamma radiation by the disk and the center of the Milky Way, which leads to anisotropy in the possibilities of observing gamma-ray bursts. My line of reasoning is as follows: 1. Gamma radiation should be absorbed to some extent by dust and other components of the interstellar medium. As a result, with an extragalactic origin, fewer...
This thread is dedicated to the beauty and awesomeness of our Universe. If you feel like it, please share video clips and photos (or nice animations) of space and objects in space in this thread. Your posts, clips and photos may by all means include scientific information; that does not make it less beautiful to me (n.b. the posts must of course comply with the PF guidelines, i.e. regarding science, only mainstream science is allowed, fringe/pseudoscience is not allowed). n.b. I start this...
Back
Top