Note
Go to the end to download the full example code.
Make a phase curve GIF#
This example turns a phase curve into a gif.
from pathlib import Path
import os
import numpy as np
import matplotlib.pyplot as plt
from astropy import units as u
from imageio.v2 import imread, mimsave
from cartopy import crs as ccrs
import libpypsg
from libpypsg.globes import PyGCM
from VSPEC import ObservationModel,PhaseAnalyzer
from VSPEC.geometry import SystemGeometry
try:
CONFIG_PATH = Path(__file__).parent / 'phase_gif.yaml'
except NameError:
CONFIG_PATH = Path('phase_gif.yaml')
libpypsg.docker.set_url_and_run()
Saved settings to /home/runner/.libpypsg/settings.json
Reloading settings...
Load in the configuration#
It is stored in a YAML file.
model = ObservationModel.from_yaml(CONFIG_PATH)
model.build_planet()
model.build_spectra()
Starting at phase 0.0 deg, observe for 10.0 d in 120 steps
Phases = [ 0. 3. 6. 9. 12. 15. 18. 21. 24. 27. 30. 33. 36. 39.
42. 45. 48. 51. 54. 57. 60. 63. 66. 69. 72. 75. 78. 81.
84. 87. 90. 93. 96. 99. 102. 105. 108. 111. 114. 117. 120. 123.
126. 129. 132. 135. 138. 141. 144. 147. 150. 153. 156. 159. 162. 165.
168. 171. 174. 177. 180. 183. 186. 189. 192. 195. 198. 201. 204. 207.
210. 213. 216. 219. 222. 225. 228. 231. 234. 237. 240. 243. 246. 249.
252. 255. 258. 261. 264. 267. 270. 273. 276. 279. 282. 285. 288. 291.
294. 297. 300. 303. 306. 309. 312. 315. 318. 321. 324. 327. 330. 333.
336. 339. 342. 345. 348. 351. 354. 357. 0.] deg
Build Planet: 0%| | 0/121 [00:00<?, ?it/s]
Build Planet: 1%| | 1/121 [00:01<02:00, 1.00s/it]
Build Planet: 2%|▏ | 2/121 [00:01<01:58, 1.00it/s]
Build Planet: 2%|▏ | 3/121 [00:02<01:56, 1.01it/s]
Build Planet: 3%|▎ | 4/121 [00:03<01:55, 1.02it/s]
Build Planet: 4%|▍ | 5/121 [00:04<01:54, 1.01it/s]
Build Planet: 5%|▍ | 6/121 [00:05<01:53, 1.01it/s]
Build Planet: 6%|▌ | 7/121 [00:06<01:52, 1.01it/s]
Build Planet: 7%|▋ | 8/121 [00:07<01:52, 1.00it/s]
Build Planet: 7%|▋ | 9/121 [00:08<01:50, 1.01it/s]
Build Planet: 8%|▊ | 10/121 [00:09<01:50, 1.01it/s]
Build Planet: 9%|▉ | 11/121 [00:10<01:48, 1.01it/s]
Build Planet: 10%|▉ | 12/121 [00:11<01:47, 1.01it/s]
Build Planet: 11%|█ | 13/121 [00:12<01:47, 1.01it/s]
Build Planet: 12%|█▏ | 14/121 [00:13<01:46, 1.00it/s]
Build Planet: 12%|█▏ | 15/121 [00:14<01:45, 1.01it/s]
Build Planet: 13%|█▎ | 16/121 [00:15<01:43, 1.01it/s]
Build Planet: 14%|█▍ | 17/121 [00:16<01:42, 1.01it/s]
Build Planet: 15%|█▍ | 18/121 [00:17<01:42, 1.01it/s]
Build Planet: 16%|█▌ | 19/121 [00:18<01:40, 1.01it/s]
Build Planet: 17%|█▋ | 20/121 [00:19<01:40, 1.01it/s]
Build Planet: 17%|█▋ | 21/121 [00:20<01:39, 1.00it/s]
Build Planet: 18%|█▊ | 22/121 [00:21<01:37, 1.01it/s]
Build Planet: 19%|█▉ | 23/121 [00:22<01:37, 1.01it/s]
Build Planet: 20%|█▉ | 24/121 [00:23<01:35, 1.01it/s]
Build Planet: 21%|██ | 25/121 [00:24<01:34, 1.01it/s]
Build Planet: 21%|██▏ | 26/121 [00:25<01:33, 1.01it/s]
Build Planet: 22%|██▏ | 27/121 [00:26<01:33, 1.01it/s]
Build Planet: 23%|██▎ | 28/121 [00:27<01:31, 1.01it/s]
Build Planet: 24%|██▍ | 29/121 [00:28<01:30, 1.01it/s]
Build Planet: 25%|██▍ | 30/121 [00:29<01:29, 1.02it/s]
Build Planet: 26%|██▌ | 31/121 [00:30<01:28, 1.02it/s]
Build Planet: 26%|██▋ | 32/121 [00:31<01:27, 1.02it/s]
Build Planet: 27%|██▋ | 33/121 [00:32<01:26, 1.01it/s]
Build Planet: 28%|██▊ | 34/121 [00:33<01:26, 1.01it/s]
Build Planet: 29%|██▉ | 35/121 [00:34<01:24, 1.02it/s]
Build Planet: 30%|██▉ | 36/121 [00:35<01:23, 1.01it/s]
Build Planet: 31%|███ | 37/121 [00:36<01:22, 1.02it/s]
Build Planet: 31%|███▏ | 38/121 [00:37<01:21, 1.02it/s]
Build Planet: 32%|███▏ | 39/121 [00:38<01:20, 1.02it/s]
Build Planet: 33%|███▎ | 40/121 [00:39<01:19, 1.01it/s]
Build Planet: 34%|███▍ | 41/121 [00:40<01:18, 1.01it/s]
Build Planet: 35%|███▍ | 42/121 [00:41<01:17, 1.01it/s]
Build Planet: 36%|███▌ | 43/121 [00:42<01:16, 1.02it/s]
Build Planet: 36%|███▋ | 44/121 [00:43<01:16, 1.01it/s]
Build Planet: 37%|███▋ | 45/121 [00:44<01:14, 1.01it/s]
Build Planet: 38%|███▊ | 46/121 [00:45<01:14, 1.01it/s]
Build Planet: 39%|███▉ | 47/121 [00:46<01:13, 1.01it/s]
Build Planet: 40%|███▉ | 48/121 [00:47<01:11, 1.02it/s]
Build Planet: 40%|████ | 49/121 [00:48<01:10, 1.02it/s]
Build Planet: 41%|████▏ | 50/121 [00:49<01:09, 1.02it/s]
Build Planet: 42%|████▏ | 51/121 [00:50<01:08, 1.02it/s]
Build Planet: 43%|████▎ | 52/121 [00:51<01:07, 1.02it/s]
Build Planet: 44%|████▍ | 53/121 [00:52<01:07, 1.01it/s]
Build Planet: 45%|████▍ | 54/121 [00:53<01:05, 1.02it/s]
Build Planet: 45%|████▌ | 55/121 [00:54<01:04, 1.02it/s]
Build Planet: 46%|████▋ | 56/121 [00:55<01:03, 1.03it/s]
Build Planet: 47%|████▋ | 57/121 [00:56<01:02, 1.02it/s]
Build Planet: 48%|████▊ | 58/121 [00:57<01:01, 1.02it/s]
Build Planet: 49%|████▉ | 59/121 [00:58<01:01, 1.01it/s]
Build Planet: 50%|████▉ | 60/121 [00:59<01:00, 1.01it/s]
Build Planet: 50%|█████ | 61/121 [01:00<00:59, 1.01it/s]
Build Planet: 51%|█████ | 62/121 [01:01<00:58, 1.01it/s]
Build Planet: 52%|█████▏ | 63/121 [01:02<00:57, 1.01it/s]
Build Planet: 53%|█████▎ | 64/121 [01:03<00:56, 1.01it/s]
Build Planet: 54%|█████▎ | 65/121 [01:04<00:55, 1.01it/s]
Build Planet: 55%|█████▍ | 66/121 [01:05<00:54, 1.01it/s]
Build Planet: 55%|█████▌ | 67/121 [01:06<00:53, 1.01it/s]
Build Planet: 56%|█████▌ | 68/121 [01:07<00:52, 1.01it/s]
Build Planet: 57%|█████▋ | 69/121 [01:08<00:51, 1.02it/s]
Build Planet: 58%|█████▊ | 70/121 [01:09<00:50, 1.01it/s]
Build Planet: 59%|█████▊ | 71/121 [01:10<00:49, 1.02it/s]
Build Planet: 60%|█████▉ | 72/121 [01:11<00:48, 1.02it/s]
Build Planet: 60%|██████ | 73/121 [01:12<00:47, 1.01it/s]
Build Planet: 61%|██████ | 74/121 [01:13<00:46, 1.02it/s]
Build Planet: 62%|██████▏ | 75/121 [01:14<00:45, 1.01it/s]
Build Planet: 63%|██████▎ | 76/121 [01:15<00:44, 1.02it/s]
Build Planet: 64%|██████▎ | 77/121 [01:16<00:43, 1.01it/s]
Build Planet: 64%|██████▍ | 78/121 [01:17<00:42, 1.01it/s]
Build Planet: 65%|██████▌ | 79/121 [01:18<00:41, 1.01it/s]
Build Planet: 66%|██████▌ | 80/121 [01:19<00:40, 1.00it/s]
Build Planet: 67%|██████▋ | 81/121 [01:19<00:39, 1.01it/s]
Build Planet: 68%|██████▊ | 82/121 [01:20<00:38, 1.02it/s]
Build Planet: 69%|██████▊ | 83/121 [01:21<00:37, 1.01it/s]
Build Planet: 69%|██████▉ | 84/121 [01:22<00:36, 1.01it/s]
Build Planet: 70%|███████ | 85/121 [01:23<00:35, 1.01it/s]
Build Planet: 71%|███████ | 86/121 [01:24<00:34, 1.01it/s]
Build Planet: 72%|███████▏ | 87/121 [01:25<00:33, 1.01it/s]
Build Planet: 73%|███████▎ | 88/121 [01:26<00:32, 1.01it/s]
Build Planet: 74%|███████▎ | 89/121 [01:27<00:31, 1.02it/s]
Build Planet: 74%|███████▍ | 90/121 [01:29<00:32, 1.06s/it]
Build Planet: 75%|███████▌ | 91/121 [01:30<00:31, 1.04s/it]
Build Planet: 76%|███████▌ | 92/121 [01:31<00:29, 1.02s/it]
Build Planet: 77%|███████▋ | 93/121 [01:32<00:28, 1.01s/it]
Build Planet: 78%|███████▊ | 94/121 [01:33<00:27, 1.00s/it]
Build Planet: 79%|███████▊ | 95/121 [01:33<00:25, 1.01it/s]
Build Planet: 79%|███████▉ | 96/121 [01:35<00:24, 1.00it/s]
Build Planet: 80%|████████ | 97/121 [01:35<00:23, 1.01it/s]
Build Planet: 81%|████████ | 98/121 [01:36<00:22, 1.01it/s]
Build Planet: 82%|████████▏ | 99/121 [01:37<00:21, 1.01it/s]
Build Planet: 83%|████████▎ | 100/121 [01:38<00:20, 1.01it/s]
Build Planet: 83%|████████▎ | 101/121 [01:39<00:19, 1.02it/s]
Build Planet: 84%|████████▍ | 102/121 [01:40<00:18, 1.01it/s]
Build Planet: 85%|████████▌ | 103/121 [01:41<00:17, 1.01it/s]
Build Planet: 86%|████████▌ | 104/121 [01:42<00:16, 1.01it/s]
Build Planet: 87%|████████▋ | 105/121 [01:43<00:15, 1.00it/s]
Build Planet: 88%|████████▊ | 106/121 [01:45<00:15, 1.05s/it]
Build Planet: 88%|████████▊ | 107/121 [01:46<00:14, 1.03s/it]
Build Planet: 89%|████████▉ | 108/121 [01:47<00:13, 1.04s/it]
Build Planet: 90%|█████████ | 109/121 [01:48<00:12, 1.03s/it]
Build Planet: 91%|█████████ | 110/121 [01:49<00:11, 1.03s/it]
Build Planet: 92%|█████████▏| 111/121 [01:50<00:10, 1.02s/it]
Build Planet: 93%|█████████▎| 112/121 [01:51<00:09, 1.03s/it]
Build Planet: 93%|█████████▎| 113/121 [01:52<00:08, 1.03s/it]
Build Planet: 94%|█████████▍| 114/121 [01:53<00:07, 1.03s/it]
Build Planet: 95%|█████████▌| 115/121 [01:54<00:06, 1.04s/it]
Build Planet: 96%|█████████▌| 116/121 [01:55<00:05, 1.02s/it]
Build Planet: 97%|█████████▋| 117/121 [01:56<00:04, 1.05s/it]
Build Planet: 98%|█████████▊| 118/121 [01:57<00:03, 1.03s/it]
Build Planet: 98%|█████████▊| 119/121 [01:58<00:02, 1.02s/it]
Build Planet: 99%|█████████▉| 120/121 [01:59<00:01, 1.01s/it]
Build Planet: 100%|██████████| 121/121 [02:00<00:00, 1.01s/it]
Build Planet: 100%|██████████| 121/121 [02:00<00:00, 1.00it/s]
Creating interpolators:
thermal
thermal, combined
thermal, combined, stellar
thermal, combined, stellar, photon noise
thermal, combined, stellar, photon noise, detector noise
thermal, combined, stellar, photon noise, detector noise, telescope noise
thermal, combined, stellar, photon noise, detector noise, telescope noise, background noise
thermal, combined, stellar, photon noise, detector noise, telescope noise, background noise, transit
Finished!
Build Spectra: 0%| | 0/120 [00:00<?, ?it/s]
Loading Spectra: 0%| | 0/3 [00:00<?, ?it/s]
Loading Spectra: 33%|███▎ | 1/3 [00:00<00:00, 3.29it/s]
Loading Spectra: 67%|██████▋ | 2/3 [00:00<00:00, 3.27it/s]
Loading Spectra: 100%|██████████| 3/3 [00:00<00:00, 3.27it/s]
Loading Spectra: 100%|██████████| 3/3 [00:00<00:00, 3.27it/s]
Build Spectra: 1%| | 1/120 [00:01<02:33, 1.29s/it]
Build Spectra: 2%|▏ | 2/120 [00:01<01:27, 1.35it/s]
Build Spectra: 2%|▎ | 3/120 [00:02<01:06, 1.77it/s]
Build Spectra: 3%|▎ | 4/120 [00:02<00:56, 2.07it/s]
Build Spectra: 4%|▍ | 5/120 [00:02<00:50, 2.28it/s]
Build Spectra: 5%|▌ | 6/120 [00:03<00:46, 2.44it/s]
Build Spectra: 6%|▌ | 7/120 [00:03<00:44, 2.55it/s]
Build Spectra: 7%|▋ | 8/120 [00:03<00:42, 2.62it/s]
Build Spectra: 8%|▊ | 9/120 [00:04<00:41, 2.67it/s]
Build Spectra: 8%|▊ | 10/120 [00:04<00:40, 2.71it/s]
Build Spectra: 9%|▉ | 11/120 [00:04<00:39, 2.73it/s]
Build Spectra: 10%|█ | 12/120 [00:05<00:39, 2.75it/s]
Build Spectra: 11%|█ | 13/120 [00:05<00:38, 2.76it/s]
Build Spectra: 12%|█▏ | 14/120 [00:05<00:38, 2.77it/s]
Build Spectra: 12%|█▎ | 15/120 [00:06<00:37, 2.77it/s]
Build Spectra: 13%|█▎ | 16/120 [00:06<00:37, 2.75it/s]
Build Spectra: 14%|█▍ | 17/120 [00:07<00:37, 2.76it/s]
Build Spectra: 15%|█▌ | 18/120 [00:07<00:36, 2.76it/s]
Build Spectra: 16%|█▌ | 19/120 [00:07<00:36, 2.77it/s]
Build Spectra: 17%|█▋ | 20/120 [00:08<00:36, 2.75it/s]
Build Spectra: 18%|█▊ | 21/120 [00:08<00:35, 2.76it/s]
Build Spectra: 18%|█▊ | 22/120 [00:08<00:35, 2.76it/s]
Build Spectra: 19%|█▉ | 23/120 [00:09<00:35, 2.75it/s]
Build Spectra: 20%|██ | 24/120 [00:09<00:34, 2.75it/s]
Build Spectra: 21%|██ | 25/120 [00:09<00:34, 2.76it/s]
Build Spectra: 22%|██▏ | 26/120 [00:10<00:34, 2.76it/s]
Build Spectra: 22%|██▎ | 27/120 [00:10<00:33, 2.76it/s]
Build Spectra: 23%|██▎ | 28/120 [00:11<00:33, 2.75it/s]
Build Spectra: 24%|██▍ | 29/120 [00:11<00:33, 2.75it/s]
Build Spectra: 25%|██▌ | 30/120 [00:11<00:32, 2.74it/s]
Build Spectra: 26%|██▌ | 31/120 [00:12<00:32, 2.73it/s]
Build Spectra: 27%|██▋ | 32/120 [00:12<00:32, 2.73it/s]
Build Spectra: 28%|██▊ | 33/120 [00:12<00:31, 2.72it/s]
Build Spectra: 28%|██▊ | 34/120 [00:13<00:31, 2.73it/s]
Build Spectra: 29%|██▉ | 35/120 [00:13<00:31, 2.73it/s]
Build Spectra: 30%|███ | 36/120 [00:13<00:30, 2.74it/s]
Build Spectra: 31%|███ | 37/120 [00:14<00:30, 2.74it/s]
Build Spectra: 32%|███▏ | 38/120 [00:14<00:29, 2.75it/s]
Build Spectra: 32%|███▎ | 39/120 [00:15<00:29, 2.75it/s]
Build Spectra: 33%|███▎ | 40/120 [00:15<00:29, 2.74it/s]
Build Spectra: 34%|███▍ | 41/120 [00:15<00:28, 2.75it/s]
Build Spectra: 35%|███▌ | 42/120 [00:16<00:28, 2.75it/s]
Build Spectra: 36%|███▌ | 43/120 [00:16<00:28, 2.73it/s]
Build Spectra: 37%|███▋ | 44/120 [00:16<00:27, 2.73it/s]
Build Spectra: 38%|███▊ | 45/120 [00:17<00:27, 2.74it/s]
Build Spectra: 38%|███▊ | 46/120 [00:17<00:27, 2.74it/s]
Build Spectra: 39%|███▉ | 47/120 [00:17<00:26, 2.74it/s]
Build Spectra: 40%|████ | 48/120 [00:18<00:26, 2.74it/s]
Build Spectra: 41%|████ | 49/120 [00:18<00:25, 2.74it/s]
Build Spectra: 42%|████▏ | 50/120 [00:19<00:25, 2.74it/s]
Build Spectra: 42%|████▎ | 51/120 [00:19<00:25, 2.74it/s]
Build Spectra: 43%|████▎ | 52/120 [00:19<00:24, 2.73it/s]
Build Spectra: 44%|████▍ | 53/120 [00:20<00:24, 2.73it/s]
Build Spectra: 45%|████▌ | 54/120 [00:20<00:24, 2.72it/s]
Build Spectra: 46%|████▌ | 55/120 [00:20<00:23, 2.72it/s]
Build Spectra: 47%|████▋ | 56/120 [00:21<00:23, 2.72it/s]
Build Spectra: 48%|████▊ | 57/120 [00:21<00:23, 2.73it/s]
Build Spectra: 48%|████▊ | 58/120 [00:21<00:22, 2.73it/s]
Build Spectra: 49%|████▉ | 59/120 [00:22<00:22, 2.75it/s]
Build Spectra: 50%|█████ | 60/120 [00:22<00:21, 2.75it/s]
Build Spectra: 51%|█████ | 61/120 [00:23<00:21, 2.76it/s]
Build Spectra: 52%|█████▏ | 62/120 [00:23<00:20, 2.77it/s]
Build Spectra: 52%|█████▎ | 63/120 [00:23<00:20, 2.76it/s]
Build Spectra: 53%|█████▎ | 64/120 [00:24<00:20, 2.77it/s]
Build Spectra: 54%|█████▍ | 65/120 [00:24<00:19, 2.77it/s]
Build Spectra: 55%|█████▌ | 66/120 [00:24<00:19, 2.77it/s]
Build Spectra: 56%|█████▌ | 67/120 [00:25<00:19, 2.77it/s]
Build Spectra: 57%|█████▋ | 68/120 [00:25<00:18, 2.77it/s]
Build Spectra: 57%|█████▊ | 69/120 [00:25<00:18, 2.77it/s]
Build Spectra: 58%|█████▊ | 70/120 [00:26<00:18, 2.78it/s]
Build Spectra: 59%|█████▉ | 71/120 [00:26<00:17, 2.76it/s]
Build Spectra: 60%|██████ | 72/120 [00:27<00:17, 2.77it/s]
Build Spectra: 61%|██████ | 73/120 [00:27<00:16, 2.78it/s]
Build Spectra: 62%|██████▏ | 74/120 [00:27<00:16, 2.78it/s]
Build Spectra: 62%|██████▎ | 75/120 [00:28<00:17, 2.59it/s]
Build Spectra: 63%|██████▎ | 76/120 [00:28<00:16, 2.64it/s]
Build Spectra: 64%|██████▍ | 77/120 [00:28<00:16, 2.67it/s]
Build Spectra: 65%|██████▌ | 78/120 [00:29<00:15, 2.69it/s]
Build Spectra: 66%|██████▌ | 79/120 [00:29<00:15, 2.70it/s]
Build Spectra: 67%|██████▋ | 80/120 [00:30<00:14, 2.71it/s]
Build Spectra: 68%|██████▊ | 81/120 [00:30<00:14, 2.71it/s]
Build Spectra: 68%|██████▊ | 82/120 [00:30<00:14, 2.70it/s]
Build Spectra: 69%|██████▉ | 83/120 [00:31<00:13, 2.69it/s]
Build Spectra: 70%|███████ | 84/120 [00:31<00:13, 2.69it/s]
Build Spectra: 71%|███████ | 85/120 [00:31<00:12, 2.70it/s]
Build Spectra: 72%|███████▏ | 86/120 [00:32<00:12, 2.70it/s]
Build Spectra: 72%|███████▎ | 87/120 [00:32<00:12, 2.72it/s]
Build Spectra: 73%|███████▎ | 88/120 [00:32<00:11, 2.72it/s]
Build Spectra: 74%|███████▍ | 89/120 [00:33<00:11, 2.73it/s]
Build Spectra: 75%|███████▌ | 90/120 [00:33<00:10, 2.74it/s]
Build Spectra: 76%|███████▌ | 91/120 [00:34<00:10, 2.74it/s]
Build Spectra: 77%|███████▋ | 92/120 [00:34<00:10, 2.75it/s]
Build Spectra: 78%|███████▊ | 93/120 [00:34<00:09, 2.75it/s]
Build Spectra: 78%|███████▊ | 94/120 [00:35<00:09, 2.75it/s]
Build Spectra: 79%|███████▉ | 95/120 [00:35<00:09, 2.75it/s]
Build Spectra: 80%|████████ | 96/120 [00:35<00:08, 2.75it/s]
Build Spectra: 81%|████████ | 97/120 [00:36<00:08, 2.75it/s]
Build Spectra: 82%|████████▏ | 98/120 [00:36<00:07, 2.75it/s]
Build Spectra: 82%|████████▎ | 99/120 [00:36<00:07, 2.75it/s]
Build Spectra: 83%|████████▎ | 100/120 [00:37<00:07, 2.76it/s]
Build Spectra: 84%|████████▍ | 101/120 [00:37<00:06, 2.76it/s]
Build Spectra: 85%|████████▌ | 102/120 [00:38<00:06, 2.76it/s]
Build Spectra: 86%|████████▌ | 103/120 [00:38<00:06, 2.76it/s]
Build Spectra: 87%|████████▋ | 104/120 [00:38<00:05, 2.77it/s]
Build Spectra: 88%|████████▊ | 105/120 [00:39<00:05, 2.77it/s]
Build Spectra: 88%|████████▊ | 106/120 [00:39<00:05, 2.77it/s]
Build Spectra: 89%|████████▉ | 107/120 [00:39<00:04, 2.77it/s]
Build Spectra: 90%|█████████ | 108/120 [00:40<00:04, 2.77it/s]
Build Spectra: 91%|█████████ | 109/120 [00:40<00:03, 2.77it/s]
Build Spectra: 92%|█████████▏| 110/120 [00:40<00:03, 2.77it/s]
Build Spectra: 92%|█████████▎| 111/120 [00:41<00:03, 2.77it/s]
Build Spectra: 93%|█████████▎| 112/120 [00:41<00:02, 2.77it/s]
Build Spectra: 94%|█████████▍| 113/120 [00:42<00:02, 2.78it/s]
Build Spectra: 95%|█████████▌| 114/120 [00:42<00:02, 2.78it/s]
Build Spectra: 96%|█████████▌| 115/120 [00:42<00:01, 2.77it/s]
Build Spectra: 97%|█████████▋| 116/120 [00:43<00:01, 2.77it/s]
Build Spectra: 98%|█████████▊| 117/120 [00:43<00:01, 2.77it/s]
Build Spectra: 98%|█████████▊| 118/120 [00:43<00:00, 2.78it/s]
Build Spectra: 99%|█████████▉| 119/120 [00:44<00:00, 2.78it/s]
Build Spectra: 100%|██████████| 120/120 [00:44<00:00, 2.79it/s]
Build Spectra: 100%|██████████| 120/120 [00:44<00:00, 2.69it/s]
Write a figure making function#
So we can make a GIF later.
def make_fig(data:PhaseAnalyzer,geo:SystemGeometry,gcm:PyGCM,s:tuple):
"""
data is the simulation data
s is the phase index (start, stop)
"""
i = int(np.mean(s)) # int representation of s
p,q = s
fig = plt.figure(figsize=(10,5))
gs = fig.add_gridspec(1,2)
prof_ax = fig.add_subplot(gs[0,0])
pressure = np.mean(data.get_layer('Pressure')[p:q,:],axis=0)
temp = np.mean(data.get_layer('Temp')[p:q,:],axis=0)
prof_ax.plot(temp,pressure)
prof_ax.set_yscale('log')
prof_ax.set_xlabel('Temperature (K)')
prof_ax.set_ylabel('Pressure (bar)')
prof_ax.set_ylim(np.flip(prof_ax.get_ylim()))
prof_ax.set_xlim(-5,290)
phase = data.phase[i]
inax = prof_ax.inset_axes([0.5,0.5,0.4,0.4])
inax.set_aspect(1)
geo.get_system_visual(phase,ax=inax)
pl_spec = data.spectrum('thermal',s,noise=False)
star_spec = data.spectrum('star',s,noise=False)
noi_spec = data.spectrum('noise',s,noise=False)
wl = data.wavelength.to_value(u.um)
cont = ((pl_spec)/star_spec).to_value(u.dimensionless_unscaled)
contp = ((pl_spec+noi_spec)/star_spec).to_value(u.dimensionless_unscaled)
contm = ((pl_spec-noi_spec)/star_spec).to_value(u.dimensionless_unscaled)
spec_ax = fig.add_subplot(gs[0,1],projection=ccrs.PlateCarree())
spec_ax.plot(wl,cont*1e6,c='k')
spec_ax.fill_between(wl,contp*1e6,contm*1e6,color='k',alpha=0.2)
spec_ax.set_xlabel('Wavelength (um)')
spec_ax.set_ylabel('Thermal emission (ppm)')
spec_ax.set_aspect('auto')
spec_ax.tick_params(axis='both',which='major',direction='out')
spec_ax.set_xticks(np.arange(1,19,2))
spec_ax.set_yticks(np.arange(-1,10,2)*10)
lat = geo.get_pl_sub_obs_lat(phase)
time = data.time[i]
lon = geo.get_pl_sub_obs_lon(time,phase)
proj = ccrs.Orthographic(
central_latitude=lat.to_value(u.deg),
central_longitude=lon.to_value(u.deg)
)
mapax = spec_ax.inset_axes([0.05,0.5,0.4,0.4],projection=proj)
cbarax = spec_ax.inset_axes([0.5,0.5,0.1,0.4],projection=ccrs.PlateCarree())
cbarax.set_axis_off()
tsurf = gcm.tsurf.dat.to_value(u.K)
lats = gcm.lats
lons = gcm.lons
im = mapax.pcolormesh(lons,lats,tsurf.T,cmap='gist_heat',transform=ccrs.PlateCarree())
fig.colorbar(im,ax=cbarax,label='$T_{\\rm surf}$ (K)')
return fig
Get the data#
data = PhaseAnalyzer(model.directories['all_model'])
geometry = model.get_observation_parameters()
gcm = model.params.gcm.get_gcm()
# gcm = GCMdecoder.from_psg(model.params.gcm.content())
Display one frame#

Make a GIF#
def gif_image(i):
s = (max(0,i-10),min(data.n_images-1,i+10))
return make_fig(data,geometry,gcm,s)
images = []
fname='temp.png'
for i in range(data.n_images):
fig = gif_image(i)
fig.savefig(fname)
plt.close(fig)
images.append(imread(fname))
os.remove(fname)
filename = 'phase_curve.gif'
_=mimsave(filename, images,fps=20)
Total running time of the script: (4 minutes 5.625 seconds)