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

refactor ingest_spectral_types function #539

Merged
Merged
Show file tree
Hide file tree
Changes from 16 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
9 changes: 6 additions & 3 deletions documentation/SpectralTypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ Columns marked with an asterisk (*) may not be empty.
| Column Name | Description | Unit | Data Type | Key Type |
|---|---|---|---|---|
| *source | Unique identifier for the source | | String(100) | primary and foreign: Sources.source |
| spectral_type_string | Spectral type string | | String(10) | |
| spectral_type_string | Spectral type string | | String(20) | |
| *spectral_type_code | Numeric code corresponding to spectral type | | Float | primary |
| spectral_type_error | Uncertainty of spectral type | | Float | |
| regime | Regime for spectral type value | | | primary and foreign:Regimes.regime |
| *regime | Regime for spectral type value | | | primary and foreign:Regimes.regime |
| adopted | Flag indicating if this is the adopted measurement | | Boolean | |
| photometric | Flag indicating if this is a photometric spectral type | | Boolean | |
| comments | Free form comments | | String(1000) | |
| *reference | Reference | | String(30) | primary and foreign: Publications.name |

Expand All @@ -20,4 +21,6 @@ Spectral Type Codes:
- 69 = M9
- 70 = L0
- 80 = T0
- 90 = Y0
- 90 = Y0

Regime is required and is constrained by the [Regimes table](/data/Regimes.json). However, `regime = "unknown"` can be used when the regime is unknown.
10 changes: 8 additions & 2 deletions simple/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,23 +300,29 @@ class SpectralTypes(Base):
nullable=False,
primary_key=True,
)
spectral_type_string = Column(String(10), nullable=False, primary_key=True)
spectral_type_string = Column(String(20), nullable=False, primary_key=True)
spectral_type_code = Column(Float, nullable=False, primary_key=True)
spectral_type_error = Column(Float)
regime = Column(
String(30),
ForeignKey("Regimes.regime", ondelete="cascade", onupdate="cascade"),
nullable=True,
primary_key=True,
)
adopted = Column(Boolean)
photometric = Column(Boolean)
comments = Column(String(1000))
reference = Column(
String(30),
ForeignKey("Publications.reference", onupdate="cascade"),
primary_key=True,
)

@validates("source", "spectral_type_code", "regime", "reference")
def validate_required(self, key, value):
if value is None:
raise ValueError(f"Value required for {key}")
return value


class Gravities(Base):
# Table to store gravity measurements
Expand Down
Loading