Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add (i *Indexer) GenerateStarsForPixel to indexer module in @observerly/skysolve #206

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions pkg/index/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,58 @@ func NewIndexer(

/*****************************************************************************************************************/

func (i *Indexer) GenerateStarsForPixel(pixel int) ([]star.Star, error) {
// Convert the pixel index to the pixel's equatorial coordinate:
eq := i.HealPIX.ConvertPixelIndexToEquatorial(pixel)

// Get the radial extent of the pixel:
radius := i.HealPIX.GetPixelRadialExtent(pixel)

// Get the sources within the pixel's radial extent:
sources, err := i.Catalog.PerformRadialSearch(eq, radius)

// If we encounter an error, return it:
if err != nil {
return nil, err
}

// Convert the sources to stars:
var stars []star.Star

for _, source := range sources {
// For each source, we just need to sense check that the source is within the pixel:
eq := astrometry.ICRSEquatorialCoordinate{
RA: source.RA,
Dec: source.Dec,
}

pixelIndex := i.HealPIX.ConvertEquatorialToPixelIndex(eq)

// If the source is not within the pixel, skip it:
if pixelIndex != pixel {
continue
}

stars = append(stars, star.Star{
Designation: source.Designation,
X: source.RA,
Y: source.Dec,
RA: source.RA,
Dec: source.Dec,
Intensity: source.PhotometricGMeanFlux,
})
}

// We should have at least 5 stars, if we have more just slice the first 5:
if len(stars) > 5 {
stars = stars[:5]
}

return stars, nil
}

/*****************************************************************************************************************/

func (i *Indexer) GenerateQuadsForPixel(pixel int) ([]quad.Quad, error) {
// Convert the pixel index to the pixel's equatorial coordinate:
eq := i.HealPIX.ConvertPixelIndexToEquatorial(pixel)
Expand Down