61 lines
1.9 KiB
Python
61 lines
1.9 KiB
Python
from django.core.management.base import BaseCommand, CommandError
|
|
from django.db.models import F, Q
|
|
|
|
from datetime import date
|
|
import datetime
|
|
from django.utils import timezone
|
|
import astropy
|
|
from astropy.io import ascii
|
|
import pandas as pd
|
|
import pymysql
|
|
import numpy as np
|
|
from sqlalchemy import create_engine
|
|
from astropy import units as u
|
|
from astropy.coordinates import SkyCoord
|
|
from astropy.coordinates import ICRS, Galactic, FK5
|
|
from astropy_healpix import HEALPix, neighbours
|
|
|
|
from heasarc.models import HeasarcBase
|
|
from artsurvey.models import ArtSurveySource, ArtSurvey, EnergyBand, MetaSource, Catalog
|
|
from astrobasis.models import GAIADR2
|
|
from srglib.utils import find_counterparts
|
|
from srglib.utils import crossmatch
|
|
from srglib.utils import transfer
|
|
from heasarc.models import NSIDE_SOURCES, ORDER
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = 'Initiates data dase'
|
|
|
|
# def add_arguments(self, parser):
|
|
# parser.add_argument('poll_id', nargs='+', type=int)
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
srcs = MetaSource.objects.all()
|
|
print("Check for empty MetaSource")
|
|
for src in srcs:
|
|
count = src.artsurveysource_set.all().count()
|
|
if (count==0):
|
|
print("Empty MetaSource {} paper={}".format(src,src.catalog))
|
|
|
|
self.stdout.write(self.style.SUCCESS('Done'))
|
|
|
|
print("Check for empty Paper reference")
|
|
|
|
for src in srcs:
|
|
if not src.catalog:
|
|
continue
|
|
|
|
asrcs = src.artsurveysource_set.all()
|
|
count=0
|
|
for a in asrcs:
|
|
if not (a.catalog.all().count()):
|
|
continue
|
|
if(src.catalog in a.catalog.all()):
|
|
count=count+1
|
|
if (count==0):
|
|
print("Empty MetaSource {} paper={}".format(src,src.catalog))
|
|
|
|
self.stdout.write(self.style.SUCCESS('Done'))
|