From 73e813899f1a218a39717595f782ce28e348527c Mon Sep 17 00:00:00 2001 From: arjunsavel Date: Wed, 5 Mar 2025 13:58:52 -0500 Subject: [PATCH 1/2] actually call the etc when asked! --- src/scope/calc_quantities.py | 1 + src/scope/input.txt | 7 ++-- src/scope/input_output.py | 75 +++++++++------------------------- src/scope/scrape_igrins_etc.py | 7 ++++ 4 files changed, 31 insertions(+), 59 deletions(-) diff --git a/src/scope/calc_quantities.py b/src/scope/calc_quantities.py index b467cd4..7c4fb5a 100644 --- a/src/scope/calc_quantities.py +++ b/src/scope/calc_quantities.py @@ -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 diff --git a/src/scope/input.txt b/src/scope/input.txt index de242b5..487a52c 100644 --- a/src/scope/input.txt +++ b/src/scope/input.txt @@ -10,7 +10,7 @@ #·······································: Created: 2024-08-15 Author: Arjun Savel! -Planet name: WASP-166 b +Planet name: WASP-76 b # Simulation setup @@ -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. @@ -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. diff --git a/src/scope/input_output.py b/src/scope/input_output.py index 43d72c6..3f2d2f5 100644 --- a/src/scope/input_output.py +++ b/src/scope/input_output.py @@ -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) @@ -215,6 +214,7 @@ def parse_input_file( "Mstar", "Mp", "peri", + "Kmag", ] # Convert values to appropriate types @@ -325,32 +325,22 @@ 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" @@ -358,78 +348,51 @@ def parse_arguments(): 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() diff --git a/src/scope/scrape_igrins_etc.py b/src/scope/scrape_igrins_etc.py index 8ddf4a7..e92ad5a 100644 --- a/src/scope/scrape_igrins_etc.py +++ b/src/scope/scrape_igrins_etc.py @@ -41,6 +41,11 @@ def scrape_igrins_etc(kmag, exposure_time): float Exposure time in seconds. """ + pdb.set_trace() + 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 @@ -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 @@ -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.") + pdb.set_trace() return snr_value From 1a000a7385b4d18aab7a3e05fd4f8c8a84ec6258 Mon Sep 17 00:00:00 2001 From: arjunsavel Date: Wed, 5 Mar 2025 14:11:35 -0500 Subject: [PATCH 2/2] actually test the etc --- src/scope/scrape_igrins_etc.py | 4 ++-- src/scope/tests/test_io.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/scope/scrape_igrins_etc.py b/src/scope/scrape_igrins_etc.py index e92ad5a..e7c05f7 100644 --- a/src/scope/scrape_igrins_etc.py +++ b/src/scope/scrape_igrins_etc.py @@ -41,7 +41,7 @@ def scrape_igrins_etc(kmag, exposure_time): float Exposure time in seconds. """ - pdb.set_trace() + logger.debug( f"Scraping IGRINS SNR for Kmag={kmag} and exposure time={exposure_time}." ) @@ -96,7 +96,7 @@ def extract_snr_from_html(html_content): logger.info(f"Extracted SNR value: {snr_value}") else: logger.warning("SNR value not found.") - pdb.set_trace() + return snr_value diff --git a/src/scope/tests/test_io.py b/src/scope/tests/test_io.py index 89e6043..268f2ca 100644 --- a/src/scope/tests/test_io.py +++ b/src/scope/tests/test_io.py @@ -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 @@ -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. @@ -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. @@ -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``.