Closed fbartolic closed 4 years ago
I'll look into it. Thanks!
@fbartolic Quick update: I fixed the issue but found a new instability in this limit. Working on resolving that, should have this working by tomorrow morning.
OK I fixed the instability, I think.
xo = np.linspace(29.03953239062832, 33.03953239062832, 1000)
yo, zo, ro = 23.892679948795926, 1.0, 39.10406741663172
xs, ys, zs = -0.1023801975400136, 0.02539410349374292, 5.423840491698775
map = starry.Map(ydeg=6, reflected=True)
map[1:, :] = 1
plt.plot(xo, map.flux(xo=xo, yo=yo, zo=zo, ro=ro, xs=xs, ys=ys, zs=zs))
plt.show()
@fbartolic Let me know if this works. There is still an instability when the sub-stellar point gets very close to the center of the disk -- I'm going to tackle that tomorrow.
@fbartolic
OK, it looks like I've fixed all the instabilities I'm aware of. Below is a (really unrealistic) mock example of the Earth in occultation, where the radius ratio is the same as that of Jupiter/Io. I made the orbital, rotational, and illumination periods all different to break most of the degeneracies in the problem and verify that we recover the truth when doing inference (and it works!) In the bottom plot, left is truth and right is a posterior draw.
So, do play around with this when you get a chance and let me know if you run into trouble. Thanks!
import starry
import numpy as np
import matplotlib.pyplot as plt
starry.config.lazy = False
np.random.seed(3)
# Orbital/geometric parameters
npts = 50000
t = np.linspace(0, 1, npts)
porb = 0.19
prot = 0.12
rorb = 50
ro = 38.0
yo = np.sin(2 * np.pi / porb * t + 0.5)
xo = np.cos(2 * np.pi / porb * t)
zo = np.sin(2 * np.pi / porb * t)
amp = rorb / np.sqrt(xo ** 2 + yo ** 2 + zo ** 2)
xo *= amp
yo *= amp
zo *= amp
theta = 360.0 / prot * t
xs = np.sin(7 * np.pi * t)
ys = np.cos(5 * np.pi * t)
zs = 5
kwargs = dict(xs=xs, ys=ys, zs=zs, theta=theta, xo=xo, yo=yo, zo=zo, ro=ro)
# Generate a synthetic dataset
map = starry.Map(ydeg=10, reflected=True)
map.load("earth")
img0 = map.render(projection="rect", illuminate=False)
flux0 = map.flux(**kwargs)
err = 3e-4
flux = flux0 + np.random.randn(npts) * err
# Solve the linear problem & draw a sample
map.set_data(flux, C=err ** 2)
map.set_prior(L=1e-4)
map.solve(**kwargs)
map.draw()
model = map.flux(**kwargs)
img = map.render(projection="rect", illuminate=False)
# Plot the light curve model
plt.plot(t, flux)
plt.plot(t, model)
# Plot the posterior draw for the map
fig, ax = plt.subplots(1, 2)
vmin = img0.min()
vmax = img0.max()
ax[0].imshow(
img0,
origin="lower",
cmap="plasma",
extent=(-180, 180, -90, 90),
vmin=vmin,
vmax=vmax,
)
ax[1].imshow(
img,
origin="lower",
cmap="plasma",
extent=(-180, 180, -90, 90),
vmin=vmin,
vmax=vmax,
)
plt.show()
I'm getting an error when calling
map.design_matrix
for a reflected light occultation. Here's a reproducible example:Traceback:
Starry version is
'1.0.1.dev14+gf585d6a0'