55 lines
1.4 KiB
Python
55 lines
1.4 KiB
Python
from django.core.management.base import BaseCommand, CommandError
|
|
|
|
from datetime import date
|
|
from heasarc.models import INPUT_DATA_DIR
|
|
import datetime
|
|
from django.utils import timezone
|
|
import astropy
|
|
from astropy.io import ascii
|
|
import pandas as pd
|
|
import pymysql
|
|
from sqlalchemy import create_engine
|
|
import numpy.ma as ma
|
|
|
|
from astrobasis.models import GaiaSourceFileDR3, GAIADR3
|
|
|
|
from astropy_healpix import HEALPix
|
|
from astropy.coordinates import SkyCoord # High-level coordinates
|
|
from astropy.coordinates import ICRS, Galactic, FK4, FK5 # Low-level frames
|
|
from astropy.coordinates import Angle, Latitude, Longitude # Angles
|
|
import astropy.units as u
|
|
|
|
|
|
import os
|
|
import glob
|
|
import logging
|
|
|
|
def init_gaia(filepath):
|
|
|
|
filename_w_ext = os.path.basename(filepath)
|
|
filename, file_extension = os.path.splitext(filename_w_ext)
|
|
|
|
gaia = GaiaSourceFileDR3(filename=filename)
|
|
gaia.save()
|
|
|
|
# print('--> Successfully initiated "%s"' % filename)
|
|
pass
|
|
|
|
class Command(BaseCommand):
|
|
help = 'Initiates data dase'
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
gaia_all = GAIADR3.objects.all()
|
|
gaia_all.delete()
|
|
|
|
files = []
|
|
for file in glob.glob("/data/tmp/george/Gaia/gedr3/gaia_source/fits/fits/*.fits"):
|
|
files.append(file)
|
|
|
|
for file in files:
|
|
print(file)
|
|
init_gaia(file)
|
|
|
|
self.stdout.write(self.style.SUCCESS('Done'))
|