rodluger / starry

Tools for mapping stars and planets.
https://starry.readthedocs.io
MIT License
138 stars 32 forks source link

Model spectrum is wrong at very small velocities #296

Closed rodluger closed 2 years ago

rodluger commented 2 years ago

When vsini << vsini_max, the convolution kernel is too narrow and we run into discretization error. This example shows what's going on: below about 100 m/s, we get pretty bad edge effects; the central portion of the spectrum is also compromised.

We might either want to add a vsini_min check (raise an error/warning if vsini is too small) or re-sample the convolution kernel at low vsini (a bit more work to do).

import starry
import numpy as np
import matplotlib.pyplot as plt

# Instantiate
map = starry.DopplerMap(ydeg=15, nt=1, inc=60, vsin_max=100000, lazy=False)

# A dark circular spot at 30 deg lat with radius 20 deg
lat = np.linspace(-90, 90, 300)
lon = np.linspace(-180, 180, 600)
image = np.ones((len(lat), len(lon)))
y = lat.reshape(-1, 1)
x = lon.reshape(1, -1)
image[x ** 2 + (y - 30) ** 2 < 20 ** 2] = 0

# A single absorption line at the central wavelength
spectrum = 1.0 - 0.75 * np.exp(-0.5 * (map.wav0 - 643.0) ** 2 / 0.0085 ** 2)

# Ingest into the starry map
map.load(maps=image, spectra=spectrum)

# Visualize
map.veq = 0
plt.plot(map.flux().reshape(-1), label="v=0")
map.veq = 50
plt.plot(map.flux().reshape(-1), label="v=50")
map.veq = 100
plt.plot(map.flux().reshape(-1), label="v=100")
plt.legend()
plt.show()

image