50 lines
985 B
Python
50 lines
985 B
Python
# uplim/models.py
|
|
|
|
from django.db import models
|
|
from django.db.models import UniqueConstraint
|
|
|
|
|
|
|
|
|
|
class Survey(models.Model):
|
|
|
|
number = models.IntegerField(unique=True)
|
|
|
|
# nside = models.IntegerField(
|
|
# default=4096
|
|
# )
|
|
|
|
def __str__(self):
|
|
return f"Survey {self.number} of NSIDE {self.nside}"
|
|
|
|
|
|
|
|
|
|
|
|
class Pixel(models.Model):
|
|
|
|
id = models.AutoField(primary_key=True)
|
|
|
|
survey = models.ForeignKey(
|
|
Survey,
|
|
on_delete=models.CASCADE,
|
|
related_name='pixels',
|
|
default=0
|
|
)
|
|
|
|
hpid = models.IntegerField(db_index=True)
|
|
|
|
counts = models.IntegerField()
|
|
|
|
exposure = models.FloatField()
|
|
|
|
contaminated = models.BooleanField(default=False)
|
|
|
|
class Meta:
|
|
constraints = [
|
|
UniqueConstraint(fields=['survey', 'hpid'], name='unique_hpid_per_survey'),
|
|
]
|
|
|
|
def __str__(self):
|
|
return f"Pixel {self.id} (Survey {self.survey.number})"
|