Plot the spectrum of a transiting planet#

This example runs VSPEC with a transiting planet scenario.

from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt
import pypsg

from VSPEC import ObservationModel,PhaseAnalyzer

try:
    CFG_PATH = Path(__file__).parent / 'transit_spectrum.yaml'
except NameError:
    CFG_PATH = Path('transit_spectrum.yaml')

pypsg.docker.set_url_and_run()
Saved settings to /home/ted/.pypsg/settings.json
Reloading settings...

Initialize the VSPEC run#

We read in the config file and run the model.

model = ObservationModel.from_yaml(CFG_PATH)
model.build_planet()
model.build_spectra()
/home/ted/github/VSPEC/VSPEC/gcm/heat_transfer.py:538: RuntimeWarning: Energy balance off by -9.6 %. eps = 6.0, T0 = 0.7
  warnings.warn(msg, RuntimeWarning)
Starting at phase 178.8 deg, observe for 1.5 h in 18 steps
Phases = [178.8  178.92 179.05 179.18 179.3  179.42 179.55 179.68 179.8  179.92
 180.05 180.17 180.3  180.42 180.55 180.67 180.8  180.92 181.05] deg

Build Planet:   0%|          | 0/18 [00:00<?, ?it/s]
Build Planet:   6%|▌         | 1/18 [00:00<00:11,  1.43it/s]
Build Planet:  11%|█         | 2/18 [00:00<00:07,  2.24it/s]
Build Planet:  17%|█▋        | 3/18 [00:01<00:05,  2.73it/s]
Build Planet:  22%|██▏       | 4/18 [00:01<00:05,  2.70it/s]
Build Planet:  28%|██▊       | 5/18 [00:01<00:04,  2.70it/s]
Build Planet:  33%|███▎      | 6/18 [00:02<00:04,  2.70it/s]
Build Planet:  39%|███▉      | 7/18 [00:02<00:04,  2.71it/s]
Build Planet:  44%|████▍     | 8/18 [00:03<00:03,  2.71it/s]
Build Planet:  50%|█████     | 9/18 [00:03<00:03,  2.69it/s]
Build Planet:  56%|█████▌    | 10/18 [00:03<00:02,  2.67it/s]
Build Planet:  61%|██████    | 11/18 [00:04<00:02,  2.66it/s]
Build Planet:  67%|██████▋   | 12/18 [00:04<00:02,  2.65it/s]
Build Planet:  72%|███████▏  | 13/18 [00:04<00:01,  2.64it/s]
Build Planet:  78%|███████▊  | 14/18 [00:05<00:01,  2.64it/s]
Build Planet:  83%|████████▎ | 15/18 [00:05<00:01,  2.58it/s]
Build Planet:  89%|████████▉ | 16/18 [00:06<00:00,  2.58it/s]
Build Planet:  94%|█████████▍| 17/18 [00:06<00:00,  2.57it/s]
Build Planet: 100%|██████████| 18/18 [00:06<00:00,  2.81it/s]
Build Planet: 19it [00:07,  3.01it/s]
Build Planet: 19it [00:07,  2.67it/s]

Build Spectra:   0%|          | 0/18 [00:00<?, ?it/s]

Loading Spectra:   0%|          | 0/17 [00:00<?, ?it/s]

Loading Spectra:   6%|▌         | 1/17 [00:00<00:04,  3.52it/s]

Loading Spectra:  12%|█▏        | 2/17 [00:00<00:04,  3.47it/s]

Loading Spectra:  18%|█▊        | 3/17 [00:00<00:04,  3.46it/s]

Loading Spectra:  24%|██▎       | 4/17 [00:01<00:03,  3.48it/s]

Loading Spectra:  29%|██▉       | 5/17 [00:01<00:03,  3.48it/s]

Loading Spectra:  35%|███▌      | 6/17 [00:01<00:03,  3.49it/s]

Loading Spectra:  41%|████      | 7/17 [00:02<00:02,  3.50it/s]

Loading Spectra:  47%|████▋     | 8/17 [00:02<00:02,  3.51it/s]

Loading Spectra:  53%|█████▎    | 9/17 [00:02<00:02,  3.50it/s]

Loading Spectra:  59%|█████▉    | 10/17 [00:02<00:01,  3.51it/s]

Loading Spectra:  65%|██████▍   | 11/17 [00:03<00:01,  3.51it/s]

Loading Spectra:  71%|███████   | 12/17 [00:03<00:01,  3.52it/s]

Loading Spectra:  76%|███████▋  | 13/17 [00:03<00:01,  3.52it/s]

Loading Spectra:  82%|████████▏ | 14/17 [00:03<00:00,  3.53it/s]

Loading Spectra:  88%|████████▊ | 15/17 [00:04<00:00,  3.53it/s]

Loading Spectra:  94%|█████████▍| 16/17 [00:04<00:00,  3.53it/s]

Loading Spectra: 100%|██████████| 17/17 [00:04<00:00,  3.54it/s]
Loading Spectra: 100%|██████████| 17/17 [00:04<00:00,  3.51it/s]

Build Spectra:   6%|▌         | 1/18 [00:05<01:27,  5.15s/it]
Build Spectra:  11%|█         | 2/18 [00:05<00:36,  2.29s/it]
Build Spectra:  17%|█▋        | 3/18 [00:05<00:20,  1.38s/it]
Build Spectra:  22%|██▏       | 4/18 [00:06<00:13,  1.01it/s]
Build Spectra:  28%|██▊       | 5/18 [00:06<00:10,  1.28it/s]
Build Spectra:  33%|███▎      | 6/18 [00:06<00:07,  1.53it/s]
Build Spectra:  39%|███▉      | 7/18 [00:07<00:06,  1.74it/s]
Build Spectra:  44%|████▍     | 8/18 [00:07<00:05,  1.92it/s]
Build Spectra:  50%|█████     | 9/18 [00:08<00:04,  2.06it/s]
Build Spectra:  56%|█████▌    | 10/18 [00:08<00:03,  2.16it/s]
Build Spectra:  61%|██████    | 11/18 [00:08<00:03,  2.24it/s]
Build Spectra:  67%|██████▋   | 12/18 [00:09<00:02,  2.30it/s]
Build Spectra:  72%|███████▏  | 13/18 [00:09<00:02,  2.34it/s]
Build Spectra:  78%|███████▊  | 14/18 [00:10<00:01,  2.37it/s]
Build Spectra:  83%|████████▎ | 15/18 [00:10<00:01,  2.39it/s]
Build Spectra:  89%|████████▉ | 16/18 [00:11<00:00,  2.41it/s]
Build Spectra:  94%|█████████▍| 17/18 [00:11<00:00,  2.44it/s]
Build Spectra: 100%|██████████| 18/18 [00:11<00:00,  2.66it/s]
Build Spectra: 100%|██████████| 18/18 [00:11<00:00,  1.53it/s]

Load in the data#

We can use VSPEC to read in the synthetic data we just created.

data = PhaseAnalyzer(model.directories['all_model'])

Calculate the transit depth#

Since this star model has no limb darkeing, no spots, and no noise, we don’t need to fit a model to our data to extract the transit depth.

plot transit spectrum
Text(16.222222222222214, 0.5, '$\\frac{R_p}{R_*}$ (%)')

Total running time of the script: (0 minutes 21.443 seconds)

Gallery generated by Sphinx-Gallery