Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def inc(self, value):
self._inc = math.cast(value * self._angle_factor)
"""
# TODO: Implement for spectral maps?
self._no_spectral()
# Check that the data is set
if self._flux is None or self._C is None:
raise ValueError("Please provide a dataset with `set_data()`.")
# Get the full design matrix
if design_matrix is None:
assert t is not None, "Please provide a time vector `t`."
design_matrix = self.design_matrix(t)
X = math.cast(design_matrix)
# Get the data vector
f = math.cast(self._flux)
# Check for bodies whose priors are set
self._solved_bodies = []
inds = []
dense_L = False
for k, body in enumerate(self._bodies):
if body.map._mu is None or body.map._L is None:
# Subtract out this term from the data vector,
# since it is fixed
f -= body.map.amp * math.dot(X[:, self._inds[k]], body.map.y)
else:
# Add to our list of indices/bodies to solve for
"""
# TODO: Implement for spectral maps?
self._no_spectral()
# Check that the data is set
if self._flux is None or self._C is None:
raise ValueError("Please provide a dataset with `set_data()`.")
# Get the full design matrix
if design_matrix is None:
assert t is not None, "Please provide a time vector `t`."
design_matrix = self.design_matrix(t)
X = math.cast(design_matrix)
# Get the data vector
f = math.cast(self._flux)
# Check for bodies whose priors are set
self._solved_bodies = []
inds = []
dense_L = False
for k, body in enumerate(self._bodies):
if body.map._mu is None or body.map._L is None:
# Subtract out this term from the data vector,
# since it is fixed
f -= body.map.amp * math.dot(X[:, self._inds[k]], body.map.y)
else:
# Add to our list of indices/bodies to solve for
if not dense_L:
# We can just concatenate vectors
LInv = math.concatenate(
[
body.map._L.inverse * math.ones(body.map.Ny)
for body in self._solved_bodies
]
)
else:
LInv = math.block_diag(
*[
body.map._L.inverse * math.eye(body.map.Ny)
for body in self._solved_bodies
]
)
lndetL = math.cast(
[body.map._L.lndet for body in self._solved_bodies]
)
return linalg.lnlike_woodbury(
X, f, self._C.inverse, mu, LInv, self._C.lndet, lndetL
)
else:
if not dense_L:
# We can just concatenate vectors
L = math.concatenate(
[
body.map._L.value * math.ones(body.map.Ny)
for body in self._solved_bodies
]
)
else:
L = math.block_diag(
def m(self, value):
self._m = math.cast(value * self._mass_factor)
def theta0(self, value):
self._theta0 = math.cast(value * self._angle_factor)
in the system given a dataset and a prior, provided both are described
as multivariate Gaussians.
Args:
flux (vector): The observed system light curve.
C (scalar, vector, or matrix): The data covariance. This may be
a scalar, in which case the noise is assumed to be
homoscedastic, a vector, in which case the covariance
is assumed to be diagonal, or a matrix specifying the full
covariance of the dataset. Default is None. Either `C` or
`cho_C` must be provided.
cho_C (matrix): The lower Cholesky factorization of the data
covariance matrix. Defaults to None. Either `C` or
`cho_C` must be provided.
"""
self._flux = math.cast(flux)
self._C = linalg.Covariance(C=C, cho_C=cho_C, N=self._flux.shape[0])
def t0(self, value):
self._t0 = math.cast(value * self._time_factor)
def draw(self):
"""
Draw a map from the posterior distribution and set
the :py:attr:`y` map vector of each body.
Users should call :py:meth:`solve` to enable this attribute.
"""
if self._solution is None:
raise ValueError("Please call `solve()` first.")
# Number of coefficients
N = np.sum([body.map.Ny for body in self._solved_bodies])
# Fast multivariate sampling using the Cholesky factorization
yhat, cho_ycov = self._solution
u = math.cast(np.random.randn(N))
x = yhat + math.dot(cho_ycov, u)
# Set all the map vectors
n = 0
for body in self._solved_bodies:
inds = slice(n, n + body.map.Ny)
body.map.amp = x[inds][0]
body.map[1:, :] = x[inds][1:] / body.map.amp
n += body.map.Ny
def w(self, value):
self._w = math.cast(value * self._angle_factor)