Plot the lightcurve of a spotted star#

This example plots the lightcurve caused by a spotted photosphere.

from pathlib import Path
from astropy import units as u
import matplotlib.pyplot as plt
import pypsg

from VSPEC import ObservationModel,PhaseAnalyzer

try:
    CFG_PATH = Path(__file__).parent / 'spot_lightcurve.yaml'
except NameError:
    CFG_PATH = 'spot_lightcurve.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()
Starting at phase 0.0 deg, observe for 40.0 d in 10 steps
Phases = [  0. 144. 288.  72. 216.   0. 144. 288.  72. 216.   0.] deg

Build Planet:   0%|          | 0/10 [00:00<?, ?it/s]
Build Planet:  10%|█         | 1/10 [00:00<00:01,  7.49it/s]
Build Planet:  20%|██        | 2/10 [00:00<00:00,  8.08it/s]
Build Planet:  30%|███       | 3/10 [00:00<00:00,  8.18it/s]
Build Planet:  40%|████      | 4/10 [00:00<00:00,  8.00it/s]
Build Planet:  50%|█████     | 5/10 [00:00<00:00,  7.85it/s]
Build Planet:  60%|██████    | 6/10 [00:00<00:00,  7.91it/s]
Build Planet:  70%|███████   | 7/10 [00:00<00:00,  8.15it/s]
Build Planet:  80%|████████  | 8/10 [00:01<00:00,  7.80it/s]
Build Planet:  90%|█████████ | 9/10 [00:01<00:00,  8.01it/s]
Build Planet: 100%|██████████| 10/10 [00:01<00:00,  7.93it/s]
Build Planet: 11it [00:01,  7.87it/s]
Build Planet: 11it [00:01,  7.93it/s]
Generated 2 mature spots

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading Spectra: 100%|██████████| 17/17 [00:05<00:00,  3.29it/s]
Loading Spectra: 100%|██████████| 17/17 [00:05<00:00,  3.30it/s]

Build Spectra:   2%|▎         | 1/40 [02:26<1:35:10, 146.43s/it]
Build Spectra:   5%|▌         | 2/40 [02:26<38:17, 60.45s/it]
Build Spectra:   8%|▊         | 3/40 [02:26<20:19, 32.97s/it]
Build Spectra:  10%|█         | 4/40 [02:27<12:01, 20.05s/it]
Build Spectra:  12%|█▎        | 5/40 [02:27<07:31, 12.91s/it]
Build Spectra:  15%|█▌        | 6/40 [02:27<04:52,  8.61s/it]
Build Spectra:  18%|█▊        | 7/40 [02:27<03:13,  5.88s/it]
Build Spectra:  20%|██        | 8/40 [02:28<02:10,  4.09s/it]
Build Spectra:  22%|██▎       | 9/40 [02:28<01:29,  2.89s/it]
Build Spectra:  25%|██▌       | 10/40 [02:28<01:02,  2.08s/it]
Build Spectra:  28%|██▊       | 11/40 [02:29<00:44,  1.52s/it]
Build Spectra:  30%|███       | 12/40 [02:29<00:31,  1.14s/it]
Build Spectra:  32%|███▎      | 13/40 [02:29<00:23,  1.15it/s]
Build Spectra:  35%|███▌      | 14/40 [02:29<00:17,  1.46it/s]
Build Spectra:  38%|███▊      | 15/40 [02:30<00:13,  1.81it/s]
Build Spectra:  40%|████      | 16/40 [02:30<00:11,  2.16it/s]
Build Spectra:  42%|████▎     | 17/40 [02:30<00:09,  2.50it/s]
Build Spectra:  45%|████▌     | 18/40 [02:30<00:07,  2.81it/s]
Build Spectra:  48%|████▊     | 19/40 [02:31<00:06,  3.07it/s]
Build Spectra:  50%|█████     | 20/40 [02:31<00:06,  3.28it/s]
Build Spectra:  52%|█████▎    | 21/40 [02:31<00:05,  3.46it/s]
Build Spectra:  55%|█████▌    | 22/40 [02:31<00:05,  3.58it/s]
Build Spectra:  57%|█████▊    | 23/40 [02:32<00:04,  3.67it/s]
Build Spectra:  60%|██████    | 24/40 [02:32<00:04,  3.75it/s]
Build Spectra:  62%|██████▎   | 25/40 [02:32<00:03,  3.80it/s]
Build Spectra:  65%|██████▌   | 26/40 [02:32<00:03,  3.83it/s]
Build Spectra:  68%|██████▊   | 27/40 [02:33<00:03,  3.86it/s]
Build Spectra:  70%|███████   | 28/40 [02:33<00:03,  3.89it/s]
Build Spectra:  72%|███████▎  | 29/40 [02:33<00:02,  3.91it/s]
Build Spectra:  75%|███████▌  | 30/40 [02:33<00:02,  3.91it/s]
Build Spectra:  78%|███████▊  | 31/40 [02:34<00:02,  3.92it/s]
Build Spectra:  80%|████████  | 32/40 [02:34<00:02,  3.93it/s]
Build Spectra:  82%|████████▎ | 33/40 [02:34<00:01,  3.93it/s]
Build Spectra:  85%|████████▌ | 34/40 [02:34<00:01,  3.93it/s]
Build Spectra:  88%|████████▊ | 35/40 [02:35<00:01,  3.93it/s]
Build Spectra:  90%|█████████ | 36/40 [02:35<00:01,  3.93it/s]
Build Spectra:  92%|█████████▎| 37/40 [02:35<00:00,  3.93it/s]
Build Spectra:  95%|█████████▌| 38/40 [02:35<00:00,  3.92it/s]
Build Spectra:  98%|█████████▊| 39/40 [02:36<00:00,  3.92it/s]
Build Spectra: 100%|██████████| 40/40 [02:36<00:00,  3.92it/s]
Build Spectra: 100%|██████████| 40/40 [02:36<00:00,  3.91s/it]

Load in the data#

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

data = PhaseAnalyzer(model.directories['all_model'])
/home/ted/github/VSPEC/VSPEC/analysis.py:131: RuntimeWarning: No Layer info, maybe globes or molecular signatures are off
  warnings.warn(

Get the lightcurve#

We will look in a few different wavelengths.

wl_pixels = [0,300,500,700]
time = data.time.to(u.day)
for i in wl_pixels:
    wl = data.wavelength[i]
    lc = data.lightcurve(
        source='star',
        pixel=i,
        normalize=0
    )
    plt.plot(time,lc,label=f'{wl:.1f}')
plt.legend()
plt.xlabel(f'time ({time.unit})')
_=plt.ylabel('Flux (normalized)')
plot spot lightcurve

Total running time of the script: (2 minutes 39.478 seconds)

Gallery generated by Sphinx-Gallery