initial commit

This commit is contained in:
2024-09-10 12:28:01 +03:00
parent 92a8174bdf
commit db126af85a
19 changed files with 655 additions and 0 deletions

0
sample_app/__init__.py Normal file
View File

3
sample_app/admin.py Normal file
View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
sample_app/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class SampleAppConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'sample_app'

View File

@@ -0,0 +1,48 @@
# Generated by Django 5.1.1 on 2024-09-09 12:01
import django.db.models.deletion
import uuid
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='CatalogFile',
fields=[
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('name', models.CharField(max_length=32)),
('status', models.CharField(choices=[('PENDING', 'Pending'), ('INGESTED', 'Ingested'), ('INDEXED', 'Indexed')], default='PENDING', max_length=10)),
],
),
migrations.CreateModel(
name='GaiaSource',
fields=[
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('solution_id', models.CharField(blank=True, default='', max_length=19)),
('designation', models.CharField(blank=True, default='', max_length=30)),
('source_id', models.CharField(blank=True, default='', max_length=19)),
('ref_epoch', models.FloatField(default=0.0, null=True)),
('ra', models.FloatField(default=0.0, null=True)),
('ra_error', models.FloatField(default=0.0, null=True)),
('dec', models.FloatField(default=0.0, null=True)),
('dec_error', models.FloatField(default=0.0, null=True)),
('parallax', models.FloatField(default=0.0, null=True)),
('parallax_error', models.FloatField(default=0.0, null=True)),
('pmra', models.FloatField(default=0.0, null=True)),
('pmra_error', models.FloatField(default=0.0, null=True)),
('pmdec', models.FloatField(default=0.0, null=True)),
('pmdec_error', models.FloatField(default=0.0, null=True)),
('phot_g_mean_mag', models.FloatField(default=0.0, null=True)),
('phot_bp_mean_mag', models.FloatField(default=0.0, null=True)),
('phot_rp_mean_mag', models.FloatField(default=0.0, null=True)),
('catalog_file', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='sources', to='sample_app.catalogfile')),
],
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.1.1 on 2024-09-09 14:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sample_app', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='catalogfile',
name='status',
field=models.CharField(choices=[('PENDING', 'Pending'), ('IN_PROGRESS', 'In Progress'), ('INGESTED', 'Ingested'), ('INDEXED', 'Indexed')], default='PENDING', max_length=11),
),
]

View File

74
sample_app/models.py Normal file
View File

@@ -0,0 +1,74 @@
from django.db import models
import uuid
class CatalogFile(models.Model):
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=32)
STATUS_CHOICES = [
('PENDING', 'Pending'),
('IN_PROGRESS', 'In Progress'),
('INGESTED', 'Ingested'),
('INDEXED', 'Indexed')
]
status = models.CharField(max_length=11, choices=STATUS_CHOICES, default='PENDING')
class GaiaSource(models.Model):
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
catalog_file = models.ForeignKey(
CatalogFile, on_delete=models.CASCADE,
related_name='sources', null=True
)
solution_id = models.CharField(blank=True, default='', max_length=19)
#solution identifier
#why charfield and not integerfield?
designation = models.CharField(max_length=30, blank=True, default='')
#unique source designation across all DR
source_id = models.CharField(max_length=19, blank=True, default='')
#unique id within DR again why not integer
ref_epoch = models.FloatField(default=0.0, null=True)
#reference epoch julian years
ra = models.FloatField(default=0.0, null=True)
ra_error = models.FloatField(default=0.0, null=True)
#barycentric ra in icrs at ref epoch
#error in mas
dec = models.FloatField(default=0.0, null=True)
dec_error = models.FloatField(default=0.0, null=True)
#barycentric dec in icrs at ref epoch
#error in mas
parallax = models.FloatField(default=0.0, null=True)
parallax_error = models.FloatField(default=0.0, null=True)
#parallax and error at ref epoch in mas
pmra = models.FloatField(default=0.0, null=True)
pmra_error = models.FloatField(default=0.0, null=True)
#proper motion over ra mas/yr
pmdec = models.FloatField(default=0.0, null=True)
pmdec_error = models.FloatField(default=0.0, null=True)
#proper motion over dec mas/yr
phot_g_mean_mag = models.FloatField(default=0.0, null=True)
#mean g band magnitude, vega scale
phot_bp_mean_mag = models.FloatField(default=0.0, null=True)
#mean bp magnitude, vega scale
phot_rp_mean_mag = models.FloatField(default=0.0, null=True)
#mean rp magnitude, vega scale

View File

@@ -0,0 +1,7 @@
from rest_framework import serializers
from .models import GaiaSource
class GaiaSourceSerializer(serializers.ModelSerializer):
class Meta:
model = GaiaSource
fields = '__all__'

3
sample_app/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

7
sample_app/urls.py Normal file
View File

@@ -0,0 +1,7 @@
from django.urls import path
from .views import GaiaSourceListCreate, GaiaSourceDetail
urlpatterns = [
path('GaiaSource/', GaiaSourceListCreate.as_view(), name='GaiaSource-list-create'),
path('GaiaSource/<int:pk>/', GaiaSourceDetail.as_view(), name='GaiaSource-detail'),
]

13
sample_app/views.py Normal file
View File

@@ -0,0 +1,13 @@
from django.shortcuts import render
from rest_framework import generics
from .models import GaiaSource
from .serializers import GaiaSourceSerializer
class GaiaSourceListCreate(generics.ListCreateAPIView):
queryset = GaiaSource.objects.all()
serializer_class = GaiaSourceSerializer
class GaiaSourceDetail(generics.RetrieveUpdateDestroyAPIView):
queryset = GaiaSource.objects.all()
serializer_class = GaiaSourceSerializer