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

Ingest Roth24 Spectral types #482

Merged
merged 23 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dab5afc
first commit
rothermichaustin Mar 8, 2024
4eab56c
start of ingest script
rothermichaustin May 10, 2024
e0fa464
Merge branch 'main' of github.com:SIMPLE-AstroDB/SIMPLE-db into Roth2…
rothermichaustin May 10, 2024
d6adf75
refactor ingest_spectral_types function
Exu-112 Jul 16, 2024
0371ac9
Merge branch 'main' into refactor_ingest_spectral_types_function
kelle Jul 23, 2024
ff07a4e
trying to get tests to pass
kelle Jul 23, 2024
bf379cc
getting tests to pass
kelle Jul 23, 2024
64dbb2e
add photometric column, updating docs
kelle Jul 23, 2024
a0898a6
refactor ingest_spectral_type function
kelle Jul 23, 2024
5e0c867
Merge branch 'refactor_ingest_spectral_types_function' of github.com:…
rothermichaustin Jul 23, 2024
ccd9140
add raise_error keyword
kelle Jul 23, 2024
dd5ddaf
Merge branch 'refactor_ingest_spectral_types_function' of github.com:…
rothermichaustin Jul 23, 2024
2f1d7ed
improve error handling
kelle Jul 23, 2024
570f0e3
error handling
kelle Jul 23, 2024
1104535
Merge branch 'refactor_ingest_spectral_types_function' of github.com:…
rothermichaustin Jul 23, 2024
680ac25
Updated working script and tests
rothermichaustin Jul 23, 2024
34af275
Merge branch 'main' into Roth24-sptypes
kelle Jul 25, 2024
406cb1c
Extra prints commented out
rothermichaustin Jul 26, 2024
5aad6ff
completed ingest script
rothermichaustin Jul 26, 2024
43080a0
JSON files and test
rothermichaustin Jul 26, 2024
27099d1
Deleted notebook
rothermichaustin Jul 26, 2024
9a2839f
Updated Versions.json
rothermichaustin Jul 26, 2024
50507b8
Fixed error in Versions.json
rothermichaustin Jul 26, 2024
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
.pytest_cache
.ds_store
*.code-workspace
.ipynb_checkpoints


53 changes: 53 additions & 0 deletions scripts/ingests/BYW_SpT2024.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from astrodb_utils import load_astrodb
from simple.schema import *

SAVE_DB = False # save the data files in addition to modifying the .db file
RECREATE_DB = True # recreates the .db file from the data files
# LOAD THE DATABASE
db = load_astrodb("SIMPLE.db", recreatedb=RECREATE_DB)

# Load Google sheet
sheet_id = "1JFa8F4Ngzp3qAW8NOBurkz4bMKo9zXYeF6N1vMtqDZs"
link = f"https://docs.google.com/spreadsheets/d/{sheet_id}/export?format=csv"

# read the csv data into an astropy table
# ascii.read attempts to read data from local files rather from URLs so using a library like requests helps get data and create object that can be passed to ascii.read
byw_table = ascii.read(
link,
format="csv",
data_start=1,
header_start=0,
guess=False,
fast_reader=False,
delimiter=",",
)

# print result astropy table
print(byw_table.info)

# Loop through each row in byw table and print data: source name ra, dec.
def ingest_all_source_spt(db):
for row in byw_table[1:90]: # skip the header row - [1:10]runs only first 10 rows
# Print byw source information
print("BYW Source SpT Information:")


for col_name in row.colnames:
print(f"{col_name}: {row[col_name]}")

ingest_spectral_types(
db,
source=row["Source"],
spectral_type_string=row["spectral_type_string"],
spectral_type_code=row["spectral_type_code"],
spectral_type_error=row["spectral_type_error"],
regime=row["regime"],
adopted=row["adopted"],
comments=row["comments"],
reference=row["Reference"]
raise_error=True,
search_db=True,
)

# Add a separator between rows for better readability
print("-" * 20)
kelle marked this conversation as resolved.
Show resolved Hide resolved
55 changes: 55 additions & 0 deletions scripts/ingests/Roth24/Spectral_types.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "0c8363db",
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'simple'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-5a30dd9fcc35>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0msimple\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mutils\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mspectral_types\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mingest_spectral_types\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mconvert_spt_string_to_code\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'simple'"
]
}
],
"source": [
"from simple.utils.spectral_types import ingest_spectral_types, convert_spt_string_to_code"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a2c0fa5b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}