Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies = [
"exoplanet-core",
"pymc>=4",
"schwimmbad",
"astroquery"
]
dynamic = ["version"]

Expand Down
23 changes: 23 additions & 0 deletions src/scope/input_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
from datetime import datetime

import pandas as pd
from astroquery.ipac.nexsci.nasa_exoplanet_archive import NasaExoplanetArchive

from scope.calc_quantities import *
from scope.logger import *

logger = get_logger()

data_dir = os.path.join(os.path.dirname(__file__), "./data")


class ScopeConfigError(Exception):
def __init__(self, message="scope input file error:"):
Expand Down Expand Up @@ -423,3 +426,23 @@ def parse_arguments():
)

return parser.parse_args()


def refresh_db():
"""
Refresh the database with the latest exoplanet data.
"""
# Download the latest exoplanet data
# Update the database file

table = NasaExoplanetArchive.query_criteria(
table="pscomppars", select="*", where="pl_name is not null"
)

# Convert to Pandas DataFrame for easier handling
df = table.to_pandas()

# Save to CSV
filepath = os.path.join(data_dir, "default_params_exoplanet_archive.csv")
df.to_csv(filepath, index=False)
return df
9 changes: 9 additions & 0 deletions src/scope/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
write_input_file,
ScopeConfigError,
parameter_mapping,
refresh_db,
)

test_data_path = os.path.join(os.path.dirname(__file__), "../data")
Expand Down Expand Up @@ -210,3 +211,11 @@ def test_database_columns():

for value in parameter_mapping.values():
assert value in db.columns


def test_refresh_db():
"""
just test that a reasonable db comes back
"""
df = refresh_db()
assert len(df) > 0 and "pl_name" in df.columns
Loading