A Efficient cone searches with Healpix-alchemy

  • Thread starter Thread starter BOAS
  • Start date Start date
  • Tags Tags
    Cone Python
Click For 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
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?
 
"Pop III stars are thought to be composed entirely of helium and hydrogen with trace amounts of lithium, the ingredients left over after the Big Bang. They formed early on, around 200 million years after the universe began. These stars are extremely rare because they died out long ago, although scientists have hoped that the faint light from these distant, ancient objects would be detectable. Previous Population III candidates have been ruled out because they didn't meet the three main...

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 8 ·
Replies
8
Views
1K
Replies
4
Views
2K