prototype indexer implementation

This commit is contained in:
Никита Тырин 2024-09-11 15:06:47 +03:00
parent 6df8af77df
commit 5fe96c3b86
4 changed files with 56 additions and 1 deletions

1
.gitignore vendored
View File

@ -160,3 +160,4 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
tutorial.ipynb

View File

@ -1,9 +1,36 @@
from django.core.management.base import BaseCommand
from GaiaDBInterface.models import GaiaSource, CatalogFile
from astropy.coordinates import SkyCoord
import astropy_healpix as ah
import numpy as np
def healpix():
NSIDE=2048
ORDER='ring'
for catalog_file in CatalogFile.objects.all():
sources = list(catalog_file.sources.all())
ra_list = np.array([source.ra for source in sources])
dec_list = np.array([source.dec for source in sources])
skycoord = SkyCoord(ra=ra_list, dec=dec_list, unit='deg', frame="fk5")
healpix = ah.HEALPix(nside=NSIDE, order=ORDER)
healpix_indices = healpix.skycoord_to_healpix(skycoord)
for source, healpix_index in zip(sources, healpix_indices):
source.healpix_ring_index = healpix_index
GaiaSource.objects.bulk_update(sources, ['healpix_ring_index'])
class Command(BaseCommand):
help = 'Index sources using healpix.'
def handle(self, *args, **options):
healpix()

View File

@ -0,0 +1,23 @@
# Generated by Django 5.1.1 on 2024-09-11 11:13
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('GaiaDBInterface', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='gaiasource',
name='healpix_nested_index',
field=models.BigIntegerField(blank=True, null=True),
),
migrations.AddField(
model_name='gaiasource',
name='healpix_ring_index',
field=models.BigIntegerField(blank=True, null=True),
),
]

View File

@ -69,6 +69,10 @@ class GaiaSource(models.Model):
phot_rp_mean_mag = models.FloatField(default=0.0, null=True)
#mean rp magnitude, vega scale
healpix_ring_index = models.BigIntegerField(null=True, blank=True)
healpix_nested_index = models.BigIntegerField(null=True, blank=True)