Skip to content
Merged
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
29 changes: 12 additions & 17 deletions src/scope/run_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
calculating the log likelihood and cross-correlation function of the data given the model parameters.
"""

import os

import numpy as np
from tqdm import tqdm

from scope.broadening import *
from scope.ccf import *
from scope.input_output import parse_input_file, write_input_file, parse_arguments
from scope.input_output import *
from scope.noise import *
from scope.tellurics import *
from scope.utils import *
Expand Down Expand Up @@ -92,7 +87,7 @@ def make_data(
rv_planet, rv_star = calc_rvs(
v_sys, v_sys_measured, Kp, rv_semiamp_orbit, phases
) # measured in m/s now

flux_cube = np.zeros(
(n_order, n_exposure, n_pixel)
) # will store planet and star signal
Expand Down Expand Up @@ -120,7 +115,7 @@ def make_data(
star,
observation,
)

throughput_baselines = np.loadtxt(abs_path + "/data/throughputs.txt")

flux_cube = detrend_cube(flux_cube, n_order, n_exposure)
Expand Down Expand Up @@ -275,7 +270,7 @@ def make_data(
) # returning CCF and logL values


#@njit
# @njit
def calc_log_likelihood(
v_sys,
Kp,
Expand Down Expand Up @@ -432,7 +427,7 @@ def simulate_observation(
lambda_misalign=0.0,
inc=90.0,
seed=42,
LD=True,
LD=True,
vary_throughput=True,
instrument="IGRINS",
snr_path=None,
Expand Down Expand Up @@ -502,7 +497,7 @@ def simulate_observation(
# instrument profile convolution
instrument_kernel = get_instrument_kernel(instrument)
Fp_conv = np.convolve(Fp_conv_rot, instrument_kernel, mode="same")
print('here spectrum')
print("here spectrum")
print(Fp_conv)
star_wave, star_flux = np.loadtxt(
star_spectrum_path
Expand Down Expand Up @@ -555,7 +550,7 @@ def simulate_observation(
instrument=instrument,
)

run_name = f"{n_princ_comp}_NPC_{blaze}_blaze_{star}_star_{telluric}_telluric_{SNR}_SNR_{tell_type}_{time_dep_tell}_{wav_error}_{order_dep_throughput}"
run_name = f"{n_princ_comp}_NPC_{blaze}_blaze_{star}_star_{telluric}_telluric_{SNR}_SNR_{tell_type}_{time_dep_tell}_{wav_error}_{order_dep_throughput}_{seed}"

save_data(outdir, run_name, flux_cube, flux_cube_nopca, A_noplanet, just_tellurics)

Expand Down Expand Up @@ -585,7 +580,7 @@ def simulate_observation(
star=star,
observation=observation,
v_sys_measured=v_sys,
LD=LD
LD=LD,
)
lls[l, k], ccfs[l, k] = res

Expand All @@ -596,17 +591,17 @@ def simulate_observation(
args = parse_arguments()
# First, parse the input file to get base parameters
inputs = parse_input_file(args.input_file)

# Then override with any command line arguments that were explicitly provided
args_dict = vars(args)
for key, value in args_dict.items():
# Skip the input_file parameter
if key == 'input_file':
if key == "input_file":
continue

# Only override if the argument was explicitly provided (not None)
if value is not None:
inputs[key] = value

# Call the simulation function with the merged parameters
simulate_observation(**inputs)
Loading