Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from django.db import models
from composite_field import CompositeField
# Create your models here.
IMAGE_CATEGORY = (
'SCIENCE',
'CALIBRATION',
'SIMULATION'
)
IMAGE_FIRST_GROUP = (
'OBJECT',
'STD',
'BIAS',
'DARK',
'FLAT',
'LINEARITY',
'OTHER'
)
IMAGE_SECOND_GROUP = (
'SKY',
'LAMP',
'DOME',
'OTHER'
)
class ImageType(CompositeField):
category = models.CharField(
max_length=20,
choices=[(d, d) for d in IMAGE_CATEGORY]
)
firstType = models.CharField(
max_length=20,
choices=[(d,d) for d in IMAGE_FIRST_GROUP]
)
secondType = models.CharField(
max_length=20,
choices=[(d,d) for d in IMAGE_SECOND_GROUP]
)
class ImageStatistics(models.Model):
min = models.FloatField()
max = models.FloatField()
mean = models.FloatField()
stddev = models.FloatField()
median = models.FloatField()
class ImageBaseFrame(models.Model):
exposureTime = models.FloatField()
imgNumber = models.PositiveSmallIntegerField()
naxis1 = models.PositiveIntegerField()
naxis2 = models.PositiveIntegerField()
imageType = ImageType()
stats = models.OneToOneField(
ImageStatistics,
models.SET_NULL,
blank=True,
null=True,
)
class Meta:
abstract = True
class Instrument(models.Model):
instrumentName = models.CharField(max_length=100)
telescopeName = models.CharField(max_length=100)
class Meta:
unique_together = (('instrumentName', 'telescopeName'))
class Pointing(CompositeField):
rightAscension = models.FloatField()
declination = models.FloatField()
class ImageSpaceFrame(ImageBaseFrame):
observationDateTime = models.DateTimeField()
observationId = models.PositiveIntegerField()
ditherNumber = models.PositiveSmallIntegerField()
instrument = models.ForeignKey(Instrument,
on_delete=models.CASCADE,
related_name='+')
commandedPointing = Pointing()
class Meta:
abstract = True
NISP_DETECTOR_ID = (
'11','12','13','14',
'21','22','23','24',
'31','32','33','34',
'41','42','43','44'
)
class NispDetector(models.Model):
detectorId = models.CharField(
max_length=2,
choices = [(d,d) for d in NISP_DETECTOR_ID]
)
gain = models.FloatField()
readoutNoise = models.FloatField()
rawFrame = models.ForeignKey('NispRawFrame',
related_name='detectors',
on_delete=models.CASCADE)
class Meta:
unique_together = (('detectorId', 'rawFrame'))
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
WCS_COORDINATE_TYPE = (
'RA',
'DEC',
'GLON',
'GLAT',
'ELON',
'ELAT'
)
WCS_PROJECTION_TYPE = (
'LOG',
'TAN',
'SIN'
)
class CtypeWcs(CompositeField):
coordinateType = models.CharField(
max_length=4,
choices = [(d,d) for d in WCS_COORDINATE_TYPE]
)
projectionType = models.CharField(
max_length=3,
choices = [(d,d) for d in WCS_PROJECTION_TYPE]
)
class Astrometry(models.Model):
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
ctype2 = CtypeWcs()
crval1 = models.FloatField()
crval2 = models.FloatField()
crpix1 = models.FloatField()
crpix2 = models.FloatField()
cd1_1 = models.FloatField()
cd1_2 = models.FloatField()
cd2_1 = models.FloatField()
cd2_2 = models.FloatField()
detector = models.OneToOneField(NispDetector,
related_name='astrometry',
blank=True,
null=True,
on_delete=models.CASCADE)
NISP_FILTER_WHEEL = (
'Y',
'J',
'H',
'OPEN',
'CLOSE'
)
NISP_GRISM_WHEEL = (
'BLUE0',
'RED0',
'RED90',
'RED180'
'OPEN'
'CLOSE'
)
class DataContainer(models.Model):
fileFormat = models.CharField(
max_length=10
)
formatIdentifier = models.CharField(
max_length=20
)
formatVersion = models.CharField(
max_length=20
)
url = models.URLField()
class NispRawFrame(ImageSpaceFrame):
filterWheelPosition = models.CharField(
max_length=15,
choices = [(d,d) for d in NISP_FILTER_WHEEL]
)
grismWheelPosition = models.CharField(
max_length=15,
choices = [(d,d) for d in NISP_GRISM_WHEEL]
)
frameFile = models.OneToOneField(DataContainer,
on_delete=models.CASCADE)