Skip to content
Open
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
6 changes: 5 additions & 1 deletion src/scope/input_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,11 @@ def parse_input_file(

data = calculate_derived_parameters(data)

if data["tell_type"] == "data-driven" and data["blaze"] == False:
if (
data["tell_type"] == "data-driven"
and data["blaze"] == False
and data["telluric"] == True
):
raise ScopeConfigError("Data-driven tellurics requires blaze set to True.")

return data
Expand Down
9 changes: 8 additions & 1 deletion src/scope/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
"""
import numpy as np

from scope.logger import get_logger
from scope.utils import *

logger = get_logger()

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


Expand Down Expand Up @@ -92,7 +95,8 @@ def add_quadratic_noise(flux_cube_model, wl_grid, SNR, IGRINS=False, **kwargs):

else:
raise NotImplementedError("Only IGRINS data is currently supported.")

logger.debug("Added quadratic IGRINS noise to the flux cube model.")
logger.debug("mean noisy flux: {}".format(np.mean(noisy_flux)))
return noisy_flux


Expand Down Expand Up @@ -130,6 +134,9 @@ def add_crires_plus_noise(flux_cube_model, wl_grid, SNR):
# a few quick checks to make sure that nothing has gone wrong with adding noise
noisy_flux[order][exposure][noisy_flux[order][exposure] < 0.0] = 0.0
noisy_flux[order][exposure][~np.isfinite(noisy_flux[order][exposure])] = 0.0
logger.debug("Added CRIRES+ noise to the flux cube model.")
logger.debug("mean SNR: {}".format(np.mean(SNR)))
logger.debug("mean noisy flux: {}".format(np.mean(noisy_flux)))
return noisy_flux


Expand Down
12 changes: 8 additions & 4 deletions src/scope/run_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def make_data(

np.random.seed(seed)
logger.info(f"Seed set to {seed}")
logger.debug(f"Mean stellar flux: {np.mean(Fstar_conv)}")

rv_planet, rv_star = calc_rvs(
v_sys, v_sys_measured, Kp, rv_semiamp_orbit, phases
Expand Down Expand Up @@ -143,7 +144,7 @@ def make_data(
flux_cube[:, i, :], 90
)
flux_cube[:, i, :] *= throughput_factor

logger.debug(f"Mean flux post-throughput variation: {np.mean(flux_cube)}")
if tellurics:
if instrument != "IGRINS":
raise NotImplementedError(
Expand Down Expand Up @@ -174,8 +175,11 @@ def make_data(
just_tellurics[just_tellurics < 0.0] = 0.0
flux_cube = detrend_cube(flux_cube, n_order, n_exposure)
if blaze:
flux_cube = add_blaze_function(wlgrid, flux_cube, n_order, n_exposure)
flux_cube = add_blaze_function(
wlgrid, flux_cube, n_order, n_exposure, instrument=instrument
)
flux_cube[flux_cube < 0.0] = 0.0
logger.debug(f"Mean flux post-blaze: {np.mean(flux_cube)}")
flux_cube[np.isnan(flux_cube)] = 0.0

flux_cube = detrend_cube(flux_cube, n_order, n_exposure)
Expand Down Expand Up @@ -255,13 +259,14 @@ def make_data(
flux_cube /= median_out_of_transit # todo: check axes work out

if do_pca:
logger.debug("mean flux pre-pca: ", np.mean(flux_cube))
for j in range(n_order):
flux_cube[j] -= np.mean(flux_cube[j])
flux_cube[j] /= np.std(flux_cube[j])
flux_cube[j], pca_noise_matrix[j] = perform_pca(
flux_cube[j], n_princ_comp, pca_removal=pca_removal
)

logger.debug("mean flux post-pca: ", np.mean(flux_cube))
else:
for j in range(n_order):
for i in range(n_exposure):
Expand Down Expand Up @@ -523,7 +528,6 @@ def simulate_observation(
star_flux, star_wave, v_rot_star, phases, Rstar, inc, lambda_misalign, a, Rp
)

# todo: swap out
Fstar_conv = get_star_spline(
star_wave, star_flux, wl_model, instrument_kernel, smooth=False
)
Expand Down
6 changes: 6 additions & 0 deletions src/scope/tellurics.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import pandas as pd
from scipy import interpolate

from scope.logger import get_logger

logger = get_logger()

abs_path = os.path.dirname(__file__)


Expand Down Expand Up @@ -230,4 +234,6 @@ def add_tellurics(
flux_cube_model = add_tellurics_atran(
wl_cube_model, flux_cube_model, n_order, n_exp, vary_airmass=vary_airmass
)
logger.debug("Tellurics added.")
logger.debug("mean flux post-tellurics: ", np.mean(flux_cube_model))
return flux_cube_model
5 changes: 0 additions & 5 deletions src/scope/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,6 @@ def calc_limb_darkening(u1, u2, a, b, Rstar, ph, LD):
return I


# todo: download atran scripts
# todo: fit wavelength solution stuff
# todo: plot the maps


@njit
def perform_pca(input_matrix, n_princ_comp, pca_removal="subtract"):
"""
Expand Down
Loading