Use the VSPEC PHOENIX grid#

This example shows how to use the VSPEC grid.

from astropy import units as u
import numpy as np
from jax import numpy as jnp
import matplotlib.pyplot as plt

from GridPolator import GridSpectra
from GridPolator import config

Load the PHOENIX grid#

Load the default VSPEC PHOENIX grid.

wave_short = 1*u.um
wave_long = 10*u.um
resolving_power = 100
teffs = [3000,3100,3200]

spec = GridSpectra.from_vspec(
    w1=wave_short,
    w2=wave_long,
    resolving_power=resolving_power,
    teffs=teffs
)
Loading Spectra:   0%|          | 0/3 [00:00<?, ?it/s]PHOENIX grid for 3000 not found. Downloading...


Downloading teff=3000:   0%|          | 0.00/33.8M [00:00<?, ?B/s]

Downloading teff=3000:   0%|          | 4.10k/33.8M [00:00<51:12, 11.0kB/s]

Downloading teff=3000:   0%|          | 41.0k/33.8M [00:00<06:16, 89.6kB/s]

Downloading teff=3000:   1%|          | 188k/33.8M [00:00<01:24, 397kB/s]

Downloading teff=3000:   1%|▏         | 500k/33.8M [00:00<00:34, 962kB/s]

Downloading teff=3000:   5%|▌         | 1.70M/33.8M [00:00<00:09, 3.35MB/s]

Downloading teff=3000:  12%|█▏        | 4.18M/33.8M [00:01<00:03, 7.75MB/s]

Downloading teff=3000:  25%|██▌       | 8.58M/33.8M [00:01<00:01, 15.3MB/s]

Downloading teff=3000:  38%|███▊      | 12.8M/33.8M [00:01<00:01, 19.9MB/s]

Downloading teff=3000:  51%|█████     | 17.3M/33.8M [00:01<00:00, 25.8MB/s]

Downloading teff=3000:  60%|██████    | 20.4M/33.8M [00:01<00:00, 25.5MB/s]

Downloading teff=3000:  73%|███████▎  | 24.7M/33.8M [00:01<00:00, 27.1MB/s]

Downloading teff=3000:  86%|████████▌ | 29.0M/33.8M [00:01<00:00, 31.1MB/s]

Downloading teff=3000:  96%|█████████▌| 32.3M/33.8M [00:01<00:00, 29.7MB/s]
Downloading teff=3000: 100%|██████████| 33.8M/33.8M [00:02<00:00, 16.7MB/s]

Loading Spectra:  33%|███▎      | 1/3 [00:05<00:10,  5.03s/it]PHOENIX grid for 3100 not found. Downloading...


Downloading teff=3100:   0%|          | 0.00/33.7M [00:00<?, ?B/s]

Downloading teff=3100:   0%|          | 4.10k/33.7M [00:00<53:45, 10.4kB/s]

Downloading teff=3100:   0%|          | 49.2k/33.7M [00:00<05:21, 105kB/s]

Downloading teff=3100:   1%|          | 254k/33.7M [00:00<01:10, 473kB/s]

Downloading teff=3100:   3%|▎         | 1.07M/33.7M [00:00<00:17, 1.84MB/s]

Downloading teff=3100:  11%|█         | 3.57M/33.7M [00:01<00:04, 6.71MB/s]

Downloading teff=3100:  20%|██        | 6.81M/33.7M [00:01<00:02, 10.8MB/s]

Downloading teff=3100:  31%|███       | 10.4M/33.7M [00:01<00:01, 16.2MB/s]

Downloading teff=3100:  41%|████      | 13.8M/33.7M [00:01<00:01, 17.4MB/s]

Downloading teff=3100:  51%|█████     | 17.2M/33.7M [00:01<00:00, 21.1MB/s]

Downloading teff=3100:  61%|██████    | 20.6M/33.7M [00:01<00:00, 20.6MB/s]

Downloading teff=3100:  72%|███████▏  | 24.2M/33.7M [00:01<00:00, 24.0MB/s]

Downloading teff=3100:  82%|████████▏ | 27.7M/33.7M [00:02<00:00, 22.6MB/s]

Downloading teff=3100:  93%|█████████▎| 31.2M/33.7M [00:02<00:00, 25.4MB/s]
Downloading teff=3100: 100%|██████████| 33.7M/33.7M [00:02<00:00, 15.1MB/s]

Loading Spectra:  67%|██████▋   | 2/3 [00:09<00:04,  4.98s/it]PHOENIX grid for 3200 not found. Downloading...


Downloading teff=3200:   0%|          | 0.00/33.6M [00:00<?, ?B/s]

Downloading teff=3200:   0%|          | 4.10k/33.6M [00:00<49:27, 11.3kB/s]

Downloading teff=3200:   0%|          | 45.1k/33.6M [00:00<04:45, 118kB/s]

Downloading teff=3200:   0%|          | 139k/33.6M [00:00<01:54, 294kB/s]

Downloading teff=3200:   1%|▏         | 492k/33.6M [00:00<00:31, 1.05MB/s]

Downloading teff=3200:   4%|▎         | 1.25M/33.6M [00:00<00:13, 2.32MB/s]

Downloading teff=3200:  10%|█         | 3.49M/33.6M [00:01<00:04, 7.10MB/s]

Downloading teff=3200:  20%|██        | 6.82M/33.6M [00:01<00:02, 13.3MB/s]

Downloading teff=3200:  31%|███       | 10.5M/33.6M [00:01<00:01, 19.3MB/s]

Downloading teff=3200:  40%|███▉      | 13.4M/33.6M [00:01<00:01, 20.2MB/s]

Downloading teff=3200:  50%|████▉     | 16.8M/33.6M [00:01<00:00, 23.8MB/s]

Downloading teff=3200:  59%|█████▉    | 19.9M/33.6M [00:01<00:00, 24.6MB/s]

Downloading teff=3200:  70%|███████   | 23.6M/33.6M [00:01<00:00, 28.0MB/s]

Downloading teff=3200:  80%|████████  | 27.0M/33.6M [00:01<00:00, 28.3MB/s]

Downloading teff=3200:  91%|█████████ | 30.7M/33.6M [00:01<00:00, 30.5MB/s]
Downloading teff=3200: 100%|██████████| 33.6M/33.6M [00:02<00:00, 16.8MB/s]

Loading Spectra: 100%|██████████| 3/3 [00:14<00:00,  4.88s/it]
Loading Spectra: 100%|██████████| 3/3 [00:14<00:00,  4.91s/it]

Recall a spectrum from the grid#

GridSpectra will resample the grid with your supplied wavelength array as well as interpolate between \(T_{eff}\) values.

new_wl:u.Quantity = np.linspace(2,5,40) * u.um
teff = 3050 * u.K

new_wl = jnp.array(new_wl.to_value(config.wl_unit))
teff = jnp.array([teff.to_value(config.teff_unit)])

flux = spec.evaluate((teff,), new_wl)[0]

plt.plot(new_wl, flux)
plt.xlabel(f'Wavelength ({config.wl_unit:latex})')
_=plt.ylabel(f'Flux ({config.flux_unit:latex})')
plot use vspec grid

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

Gallery generated by Sphinx-Gallery