Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make template measurements table #44

Merged
merged 3 commits into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 62 additions & 1 deletion schema/schema_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import enum

from astrodbkit2.astrodb import Base
from sqlalchemy import Column, DateTime, Float, ForeignKey, Integer, String
from sqlalchemy import Column, DateTime, Float, ForeignKey, Integer, String, Boolean
from sqlalchemy.orm import validates

# Globals
Expand Down Expand Up @@ -338,4 +338,65 @@ def validate_comments(self, key, value):
check_string_length(value, DESCRIPTION_STRING_LENGTH, key)
return value

class Parallax(Base):
# This is an example of a measurement table (see below, commented-out table as another example)

__tablename__ = 'Parallax'
source = Column(
String(100),
ForeignKey("Sources.source", ondelete="cascade", onupdate="cascade"),
nullable=False,
primary_key=True,
)

# always note units, following the practices of Chen et al. 2022.
parallax_mas = Column(Float, nullable=False)

parallax_error = Column(Float) # todo: make asymmetric errors
adopted = Column(Boolean) # flag for indicating if this is the adopted
comments = Column(String(1000))
reference = Column(
String(30),
ForeignKey("Publications.reference", onupdate="cascade"),
primary_key=True,
)

@validates("comment")
def validate_comment_length(self, key, value):
check_string_length(value, 1000, key)
return value

# class Measurement(Base):
# # This is a template table that you can fill in with your own measurement.
# . This is a placeholder for a table that would store measurements such as parallax.
#
# __tablename__ = 'Measurement'
# source = Column(
# String(100),
# ForeignKey("Sources.source", ondelete="cascade", onupdate="cascade"),
# nullable=False,
# primary_key=True,
# )
#
# # units should be included in the column name.
# # e.g., for parallax measured in milliarcseconds, this would read parallax_mas
# measurement = Column(Float, nullable=False)
#
# measurement_error = Column(Float) # todo: make asymmetric errors
# adopted = Column(Boolean) # flag for indicating if this is the adopted
# comments = Column(String(1000))
# reference = Column(
# String(30),
# ForeignKey("Publications.reference", onupdate="cascade"),
# primary_key=True,
# )
#
# @validates("comment")
# def validate_comment_length(self, key, value):
# check_string_length(value, 1000, key)
# return value





Loading