From 0456ae747b88d9ff85bb41de1f1cd81a1f218cbe Mon Sep 17 00:00:00 2001 From: arjunsavel Date: Tue, 7 May 2024 16:45:23 -0400 Subject: [PATCH 1/3] make template measurements table --- schema/schema_template.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/schema/schema_template.py b/schema/schema_template.py index bc0f80e..f71e8af 100644 --- a/schema/schema_template.py +++ b/schema/schema_template.py @@ -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 @@ -338,4 +338,38 @@ def validate_comments(self, key, value): check_string_length(value, DESCRIPTION_STRING_LENGTH, key) return value +class Measurement(Base): + # Template table. 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 replaced with the unit of measurement. + # e.g., for parallax measured in milliarcseconds, this would read parallax_mas + measurement_units = Column(Float, nullable=False) + + # units should be replaced with the unit of measurement. + # e.g., for parallax measured in milliarcseconds, this would read parallax_error_mas + measurement_error_units = 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 + + + + From 2d27e761acd5e36ab086815178d8d9234ece85d3 Mon Sep 17 00:00:00 2001 From: arjunsavel Date: Tue, 14 May 2024 16:05:39 -0400 Subject: [PATCH 2/3] add parallax table, comment out Measurements --- schema/schema_template.py | 45 +++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/schema/schema_template.py b/schema/schema_template.py index f71e8af..d0f589a 100644 --- a/schema/schema_template.py +++ b/schema/schema_template.py @@ -338,10 +338,10 @@ def validate_comments(self, key, value): check_string_length(value, DESCRIPTION_STRING_LENGTH, key) return value -class Measurement(Base): - # Template table. This is a placeholder for a table that would store measurements such as parallax. +class Parallax(Base): + # This is an example of a measurement table (see below, commented-out table as another example) - __tablename__ = 'Measurement' + __tablename__ = 'Parallax' source = Column( String(100), ForeignKey("Sources.source", ondelete="cascade", onupdate="cascade"), @@ -349,13 +349,10 @@ class Measurement(Base): primary_key=True, ) - # units should be replaced with the unit of measurement. - # e.g., for parallax measured in milliarcseconds, this would read parallax_mas - measurement_units = Column(Float, nullable=False) + # always note units, following the practices of Chen et al. 2022. + parallax_mas = Column(Float, nullable=False) - # units should be replaced with the unit of measurement. - # e.g., for parallax measured in milliarcseconds, this would read parallax_error_mas - measurement_error_units = Column(Float) # todo: make asymmetric errors + 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( @@ -369,6 +366,36 @@ 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 replaced with the unit of measurement. +# # e.g., for parallax measured in milliarcseconds, this would read parallax_mas +# measurement_units = 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 + From 0889b0c03b26077345eb4246a9a13d0d3c9f6e66 Mon Sep 17 00:00:00 2001 From: arjunsavel Date: Tue, 14 May 2024 16:07:10 -0400 Subject: [PATCH 3/3] make it not seem like we have a column just for unit name in Measurements --- schema/schema_template.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schema/schema_template.py b/schema/schema_template.py index d0f589a..8b635ff 100644 --- a/schema/schema_template.py +++ b/schema/schema_template.py @@ -378,9 +378,9 @@ def validate_comment_length(self, key, value): # primary_key=True, # ) # -# # units should be replaced with the unit of measurement. +# # units should be included in the column name. # # e.g., for parallax measured in milliarcseconds, this would read parallax_mas -# measurement_units = Column(Float, nullable=False) +# measurement = Column(Float, nullable=False) # # measurement_error = Column(Float) # todo: make asymmetric errors # adopted = Column(Boolean) # flag for indicating if this is the adopted