58 lines
1.7 KiB
Python
58 lines
1.7 KiB
Python
from django.core.management.base import BaseCommand, CommandError
|
|
|
|
import astropy
|
|
|
|
from artsurvey.models import ArtSurveySource, ArtSurvey, EnergyBand
|
|
|
|
|
|
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):
|
|
|
|
|
|
try:
|
|
band = EnergyBand.objects.get(slug='E0')
|
|
except EnergyBand.DoesNotExist:
|
|
print("EnergyBand bot found")
|
|
return
|
|
|
|
|
|
try:
|
|
survey = ArtSurvey.objects.get(version=12.5)
|
|
print("use ArtSurvey {}".format(survey))
|
|
except ArtSurvey.DoesNotExist:
|
|
print("ArtSurvey {} not found".format(survey_version))
|
|
return
|
|
|
|
|
|
filename='/export/django/srg/data/artsurvey_notes_revised_paper1.tex'
|
|
data = astropy.table.Table.read(filename,format='ascii.csv',delimiter='|')
|
|
print(data.info)
|
|
|
|
|
|
|
|
for item in data:
|
|
name=item[0]
|
|
notes=item[1]
|
|
print()
|
|
print("[new] {} --> {}".format(item[0],item[1]))
|
|
try:
|
|
srcs=ArtSurveySource.objects.filter(name__exact=name).filter(survey=survey).filter(band=band)
|
|
except Exception as e:
|
|
print(e)
|
|
continue
|
|
if(srcs.count()>1):
|
|
print("More than one source found!")
|
|
return
|
|
for src in srcs:
|
|
print("[old] {} --> {}".format(src.name,src.notes_paper))
|
|
#src.notes_paper=notes
|
|
#src.save()
|
|
|
|
self.stdout.write(self.style.SUCCESS('Done'))
|
|
|