Skip to content

Commit

Permalink
updates to targetdb model classes, tested locally
Browse files Browse the repository at this point in the history
  • Loading branch information
johndonor3 committed Jan 29, 2021
1 parent 84bf078 commit ca75714
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 37 deletions.
1 change: 1 addition & 0 deletions python/sdssdb/peewee/sdss5db/catalogdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ class CantatGaudinTable1(CatalogdbModel):
# BigIntegerField is fine even though table column pkey
# is a bigserial column
pkey = BigIntegerField(primary_key=True)
cluster = TextField(null=True)

class Meta:
table_name = 'cantat_gaudin_table1'
Expand Down
75 changes: 38 additions & 37 deletions python/sdssdb/peewee/sdss5db/targetdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Meta:
database = database


AssignmentDeferred = DeferredThroughModel()
# AssignmentDeferred = DeferredThroughModel()
CartonToTargetDeferred = DeferredThroughModel()


Expand All @@ -39,12 +39,13 @@ class Meta:


class Cadence(TargetdbBase):
label = TextField(null=False)
nepochs = IntegerField(null=True)
delta = ArrayField(field_class=FloatField, null=True)
delta_max = ArrayField(field_class=FloatField, null=True)
delta_min = ArrayField(field_class=FloatField, null=True)
instrument_pk = ArrayField(field_class=IntegerField, null=True)
label = TextField(null=False)
nexposures = SmallIntegerField(null=True)
# instrument_pk = ArrayField(field_class=IntegerField, null=True)
nexp = ArrayField(field_class=SmallIntegerField, null=True)
pk = AutoField()
skybrightness = ArrayField(field_class=FloatField, null=True)
epoch_max_length = ArrayField(field_class=FloatField, null=True)
Expand All @@ -67,7 +68,7 @@ class Field(TargetdbBase):
racen = DoubleField(null=False)
deccen = DoubleField(null=False)
position_angle = FloatField(null=True)
slots_exposures = ArrayField(field_class=FloatField, null=True)
slots_exposures = ArrayField(field_class=IntegerField, null=True)
cadence = ForeignKeyField(column_name='cadence_pk',
field='pk',
model=Cadence,
Expand Down Expand Up @@ -185,43 +186,24 @@ class Target(TargetdbBase):
pmdec = FloatField(null=True)
pmra = FloatField(null=True)
ra = DoubleField(null=True)
designs = ManyToManyField(Design,
through_model=AssignmentDeferred,
backref='targets')
positioners = ManyToManyField(Positioner,
through_model=AssignmentDeferred,
backref='targets')
instruments = ManyToManyField(Instrument,
through_model=AssignmentDeferred,
backref='targets')
cadences = ManyToManyField(Cadence,
through_model=CartonToTargetDeferred,
backref='targets')
# designs = ManyToManyField(Design,
# through_model=AssignmentDeferred,
# backref='targets')
# positioners = ManyToManyField(Positioner,
# through_model=AssignmentDeferred,
# backref='targets')
# instruments = ManyToManyField(Instrument,
# through_model=AssignmentDeferred,
# backref='targets')
# cadences = ManyToManyField(Cadence,
# through_model=CartonToTargetDeferred,
# backref='targets')
parallax = FloatField(null=True)

class Meta:
table_name = 'target'


class Assignment(TargetdbBase):
design = ForeignKeyField(Design,
column_name='design_pk',
field='pk')
instrument = ForeignKeyField(Instrument,
column_name='instrument_pk',
field='pk')
pk = AutoField()
positioner = ForeignKeyField(Positioner,
column_name='positioner_pk',
field='pk')
carton_to_target = ForeignKeyField(CartonToTarget,
column_name='carton_to_target_pk',
field='pk')

class Meta:
table_name = 'assignment'


class CartonToTarget(TargetdbBase):
cadence = ForeignKeyField(Cadence,
column_name='cadence_pk',
Expand All @@ -242,6 +224,25 @@ class Meta:
table_name = 'carton_to_target'


class Assignment(TargetdbBase):
design = ForeignKeyField(Design,
column_name='design_pk',
field='pk')
instrument = ForeignKeyField(Instrument,
column_name='instrument_pk',
field='pk')
pk = AutoField()
positioner = ForeignKeyField(Positioner,
column_name='positioner_pk',
field='pk')
carton_to_target = ForeignKeyField(CartonToTarget,
column_name='carton_to_target_pk',
field='pk')

class Meta:
table_name = 'assignment'


class Magnitude(TargetdbBase):
bp = FloatField(null=True)
g = FloatField(null=True)
Expand All @@ -260,5 +261,5 @@ class Meta:
table_name = 'magnitude'


AssignmentDeferred.set_model(Assignment)
# AssignmentDeferred.set_model(Assignment)
CartonToTargetDeferred.set_model(CartonToTarget)

0 comments on commit ca75714

Please sign in to comment.