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 src/scope/calc_quantities.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def calc_param_boilerplate(param, args, data, distance_unit):
],
data,
)
calc_snr("SNR", ["Kmag", "n_exposures", "P_rot", "phase_start", "phase_end"], data)

return data

Expand Down
7 changes: 4 additions & 3 deletions src/scope/input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#·······································:
Created: 2024-08-15
Author: Arjun Savel!
Planet name: WASP-166 b
Planet name: WASP-76 b

# Simulation setup

Expand All @@ -32,6 +32,7 @@ omega 0 # argument of periastron of the planet'
b DATABASE # impact parameter of the planet's orbit. [DB]
Rstar DATABASE # stellar radius, in solar radii. [DB]
Mstar DATABASE # stellar mass, in solar masses. [DB]
Kmag DATABASE # K-band magnitude of the star. [DB]
kp 128.1 # expected planetary orbital velocity assuming circular orbit, in km/s. input NULL if you'd like to calculate from orbital parameters.
v_sys 0.0 # systemic velocity, in km/s. [DB]
v_rot NULL # equatorial rotational velocity. input NULL if you'd like to calculate from orbital parameters.
Expand All @@ -58,10 +59,10 @@ vary_throughput True # whether to include throughput variations.
observation transmission # type of observation to perform. supported observations are ``emission`` and ``transmission``.
phase_start DATABASE # phase of the beginning of the observations. 0 is center of transit, 0.5 is secondary eclipse. If DATABASE, just the transit duration. [DB]
phase_end DATABASE # phase of the end of the observations. 0 is center of transit, 0.5 is secondary eclipse. If DATABASE, just the transit duration. [DB]
n_exposures 17 # number of exposures to simulate. sets the phases of the exposures. if set to 0, the minimum number of exposures that prevent pixel crossing for the provided instrument is used.
n_exposures -1 # number of exposures to simulate. sets the phases of the exposures. if set to 0, the minimum number of exposures that prevent pixel crossing for the provided instrument is used.
star True # whether to include the star in the simulation. In general, you'd like to!
telluric True # whether to include tellurics in the simulation. In general, you'd like to!
SNR 250 # signal-to-noise ratio of the observations, per pixel. I.e., what sets the photon counts at the detector.
SNR -1 # signal-to-noise ratio of the observations, per pixel. I.e., what sets the photon counts at the detector.

tell_type data-driven # type of telluric simulation. supported modes are ``ATRAN`` and ``data-driven``.
time_dep_tell False # whether the tellurics are time-dependent or not.
Expand Down
75 changes: 19 additions & 56 deletions src/scope/input_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,9 @@ def coerce_integers(data, key, value):


def coerce_database(data, key, value, astrophysical_params, planet_name, database_path):

if value == "DATABASE" and key in astrophysical_params:
data[key] = query_database(planet_name, key, database_path)

elif value == "DATABASE" and key in ["phase_start", "phase_end"]:
tdur = query_database(planet_name, "pl_trandur", database_path)
period = query_database(planet_name, "pl_orbper", database_path)
Expand Down Expand Up @@ -215,6 +214,7 @@ def parse_input_file(
"Mstar",
"Mp",
"peri",
"Kmag",
]

# Convert values to appropriate types
Expand Down Expand Up @@ -325,111 +325,74 @@ def parse_arguments():
parser.add_argument(
"--planet_spectrum_path", type=str, help="Path to planet spectrum"
)
parser.add_argument(
"--star_spectrum_path", type=str, help="Path to star spectrum"
)
parser.add_argument(
"--data_cube_path", type=str, help="Path to data cube"
)
parser.add_argument("--star_spectrum_path", type=str, help="Path to star spectrum")
parser.add_argument("--data_cube_path", type=str, help="Path to data cube")

# Optional parameters with their defaults matching your function
parser.add_argument(
"--phase_start",
type=float,

help="Start phase of the simulated observations",
)
parser.add_argument(
"--phase_end",
type=float,

help="End phase of the simulated observations",
)
parser.add_argument(
"--n_exposures", type=int, help="Number of exposures"
)
parser.add_argument(
"--observation", type=str, help="Observation type"
)
parser.add_argument("--n_exposures", type=int, help="Number of exposures")
parser.add_argument("--observation", type=str, help="Observation type")
parser.add_argument("--blaze", type=bool, help="Blaze flag")
parser.add_argument(
"--n_princ_comp", type=int, help="Number of principal components"
)
parser.add_argument("--star", type=bool, help="Star flag")
parser.add_argument("--SNR", type=float, help="Signal to noise ratio")
parser.add_argument("--telluric", type=bool, help="Telluric flag")
parser.add_argument(
"--tell_type", type=str, help="Telluric type"
)
parser.add_argument(
"--time_dep_tell", type=bool, help="Time dependent telluric"
)
parser.add_argument(
"--wav_error", type=bool, help="Wavelength error flag"
)
parser.add_argument("--tell_type", type=str, help="Telluric type")
parser.add_argument("--time_dep_tell", type=bool, help="Time dependent telluric")
parser.add_argument("--wav_error", type=bool, help="Wavelength error flag")
parser.add_argument(
"--rv_semiamp_orbit", type=float, help="RV semi-amplitude orbit"
)
parser.add_argument(
"--order_dep_throughput",
type=bool,

help="Order dependent throughput",
)
parser.add_argument(
"--Rp", type=float, help="Planet radius (Jupiter radii)"
)
parser.add_argument(
"--Rstar", type=float, help="Star radius (solar radii)"
)
parser.add_argument(
"--kp", type=float, help="Planetary orbital velocity (km/s)"
)
parser.add_argument("--Rp", type=float, help="Planet radius (Jupiter radii)")
parser.add_argument("--Rstar", type=float, help="Star radius (solar radii)")
parser.add_argument("--kp", type=float, help="Planetary orbital velocity (km/s)")
parser.add_argument("--v_rot", type=float, help="Rotation velocity")
parser.add_argument("--scale", type=float, help="Scale factor")
parser.add_argument("--v_sys", type=float, help="Systemic velocity")
parser.add_argument(
"--pca_rmeove", type=str, help="PCA removal scheme"
)
parser.add_argument(
"--modelname", type=str, help="Model name"
)
parser.add_argument("--pca_rmeove", type=str, help="PCA removal scheme")
parser.add_argument("--modelname", type=str, help="Model name")
parser.add_argument(
"--divide_out_of_transit",
type=bool,

help="Divide out of transit",
)
parser.add_argument(
"--out_of_transit_dur", type=float, help="Out of transit duration"
)
parser.add_argument(
"--include_rm", type=bool, help="Include RM effect"
)
parser.add_argument(
"--v_rot_star", type=float, help="Star rotation velocity"
)
parser.add_argument("--include_rm", type=bool, help="Include RM effect")
parser.add_argument("--v_rot_star", type=float, help="Star rotation velocity")
parser.add_argument("--a", type=float, help="Semi-major axis")
parser.add_argument(
"--lambda_misalign", type=float, help="Misalignment angle"
)
parser.add_argument("--lambda_misalign", type=float, help="Misalignment angle")
parser.add_argument("--inc", type=float, help="Inclination")
parser.add_argument("--seed", type=int, help="Random seed")
parser.add_argument("--LD", type=bool, help="Limb darkening")
parser.add_argument(
"--vary_throughput", type=bool, help="Vary throughput"
)
parser.add_argument("--vary_throughput", type=bool, help="Vary throughput")
parser.add_argument(
"--log_level",
type=str,

choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
help="Logging level (default: INFO)",
)

# For file input option
parser.add_argument(
"--input_file", type=str, default='input.txt',help="Input file with parameters"
"--input_file", type=str, default="input.txt", help="Input file with parameters"
)

return parser.parse_args()
Expand Down
7 changes: 7 additions & 0 deletions src/scope/scrape_igrins_etc.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ def scrape_igrins_etc(kmag, exposure_time):
float
Exposure time in seconds.
"""

logger.debug(
f"Scraping IGRINS SNR for Kmag={kmag} and exposure time={exposure_time}."
)
logger.handlers[0].flush()
options = Options()
options.add_argument("--headless") # Run in headless mode

Expand Down Expand Up @@ -73,6 +78,7 @@ def scrape_igrins_etc(kmag, exposure_time):
logger.error("Could not interact with IGRINS SNR website.")

snr_value = extract_snr_from_html(response_page)
logger.debug(f"Scraped SNR value: {snr_value}")

return snr_value

Expand All @@ -90,6 +96,7 @@ def extract_snr_from_html(html_content):
logger.info(f"Extracted SNR value: {snr_value}")
else:
logger.warning("SNR value not found.")

return snr_value


Expand Down
4 changes: 4 additions & 0 deletions src/scope/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def sample_files():
Rp_solar DATABASE
Rstar NULL
kp 150.0
Kmag 10
v_rot 5.0
v_sys 0.0

Expand All @@ -54,6 +55,7 @@ def sample_files():
phase_end 0.5
blaze True
star False
SNR 350
n_exposures 10
tell_type data-driven # type of telluric simulation. supported modes are ``ATRAN`` and ``data-driven``.
time_dep_tell False # whether the tellurics are time-dependent or not.
Expand Down Expand Up @@ -106,6 +108,7 @@ def sample_files_second():
v_rot 5.0
P_rot 1.0
v_sys 0.0
Kmag 10

# Instrument Parameters
blaze True # whether to include a blaze function or not.
Expand All @@ -118,6 +121,7 @@ def sample_files_second():
phase_end 0.5
blaze True
star False
SNR -1
instrument IGRINS
n_exposures -1
tell_type data-driven # type of telluric simulation. supported modes are ``ATRAN`` and ``data-driven``.
Expand Down
Loading