API

class starry_process.StarryProcess(r=20.0, dr=None, c=0.1, n=10.0, tau=None, temporal_kernel=<function Matern32Kernel>, marginalize_over_inclination=True, normalized=True, covpts=300, **kwargs)

An interpretable Gaussian process for stellar light curves.

Parameters
  • r (scalar, optional) – The mean star spot radius in degrees. Default is 20.0. Care should be taken when modeling very small spots, as the spherical harmonic expansion can typically only model features with radius on the order of 180 / ydeg or larger. For the default spherical harmonic degree, the minimum radius is about 10 degrees. Values below this will typically lead to poor approximations, although the process will in general still be valid and numerically stable.

  • dr (scalar, optional) – The half-width of the uniform prior on the spot radius in degrees. Default is None. If this value is zero, a delta-function prior centered at r is assumed.

  • a (scalar, optional) – Shape parameter of the spot latitude distribution. This is equal to the log of the alpha parameter characterizing the Beta distribution in the cosine of the latitude, scaled to the range [0, 1]. Default is 0.4. Cannot be set if mu and sigma are provided.

  • b (scalar, optional) – Shape parameter of the spot latitude distribution. This is equal to the log of the beta parameter characterizing the Beta distribution in the cosine of the latitude, scaled to the range [0, 1]. Default is 0.27. Cannot be set if mu and sigma are provided.

  • mu (scalar, optional) – Mode of the spot latitude distribution in degrees. Default is None. If this parameter is set, sigma must also be set, and a and b cannot be provided.

  • sigma (scalar, optional) – Standard deviation of the spot latitude distribution in degrees. Default is None. If this parameter is set, mu must also be set, and a and b cannot be provided.

  • c (scalar, optional) – The mean spot contrast as a fraction of the photospheric intensity. Default is 0.1.

  • n (scalar, optional) – The total number of spots (does not have to be an integer). Note that since a StarryProcess does not model spots as discrete features, this parameter will not generally have the expected behavior when sampling from the prior. In other words, it is unlikely that a draw with n=10 will have ten distinct spots when visualizing the corresponding stellar surface, nor will it necessarily have more spots than a draw with (say) n=5. However, this parameter does behave correctly in an inference setting: the posterior over n when doing inference on an ensemble of light curves is meaningful and should have a mean (on average) equal to the true number of spots (assuming all other model assumptions are valid). Default is 10.0.

  • tau (scalar, optional) – The spot evolution timescale. This is the timescale of the kernel defined by temporal_kernel to model temporal variability of the stellar surface. In the case of no time evolution, set this to None. Default is None.

  • temporal_kernel (callable, optional) – The kernel function used to model temporal variability. This must be a callable of the form f(t1, t2, tau) where t1 and t2 are tensors (scalar or vector-valued) representing the input times and tau is a tensor representing the timescale hyperparameter, and it must return a tensor covariance matrix of shape (len(t1), len(t2)). Recommended kernels are implemented in the starry_process.temporal module. Default is Matern32Kernel.

  • marginalize_over_inclination (bool, optional) – Whether or not to marginalize over the inclination under the assumption of an isotropic prior. Recommended if there are no constraints on the inclination of the object. If this is set to True, the value of the i keyword to several of the methods in this class will be ignored. Default is True.

  • normalized (bool, optional) – Whether or not the flux observations (passed in calls to log_likelihood and sample_ylm_conditional) are normalized. Usually, the true baseline in stellar photometry is unknown, as it requires knowledge of how bright the star would be in the absence of star spots. If the baseline is unknown (which is almost certainly the case), we recommend setting this keyword to True and make sure observations are mean- (or median-) normalized. Alternatively, particularly when the amplitude of variability is large, you may set this to False and explicitly model the unknown baseline with a latent parameter for each star when doing inference. Default is True.

  • covpts (int, optional) – The number of grid points on which to compute the kernel when marginalize_over_inclination is set to True. Since the full covariance is expensive to compute, StarryProcess instead computes it on a uniform grid in phase lag and performs a cubic spline interpolation to obtain the covariance matrix. Increasing this number will improve the accuracy of the computation at the expense of greater runtime. Default is 300.

The following under-the-hood keyword arguments are also accepted, although changing them is not recommended unless you really understand what you are doing:

Parameters
  • ydeg (int, optional) – The spherical harmonic degree of the process. Default is 15. Decreasing this value will speed up computations but decrease the ability to model small features on the surface. Increasing this above the default value is not recommended, as it can lead to numerical instabilities.

  • udeg (int, optional) – The degree of limb darkening. Default is 2. Changing this is currently supported, but it is likely that future releases will deprecate this in favor of always using quadratic limb darkening, which can be analytically marginalized over.

  • normalization_order (int, optional) – Order of the series expansion for the normalized covariance. Default is 20.

  • normalization_zmax (float, optional) – Maximum value of the expansion parameter z when computing the normalized covariance. Values above this threshold will result in infinite variance and a log probability of -np.inf. Default is 0.023.

  • log_alpha_max (float, optional) – The maximum value of log(alpha). Default is 10.

  • log_beta_max (float, optional) – The maximum value of log(beta). Default is 10.

  • sigma_max (float, optional) – The maximum value of the latitude standard deviation in degrees. The latitude distribution becomes extremely non-gaussian for high values of sigma. This value is used to penalize such distributions when computing the jacobian of the transformation. Default is 45.0.

  • compile_args (list, optional) – Additional arguments to be passed to the C compiler when compiling the ops for this class. Each entry in the list should be a tuple of (name, value) pairs. For possible options, see the macros under USER CONSTANTS in the header file starry_process/ops/include/constants.h.

  • epsy (float, optional) – A small number added to the diagonal of the spherical harmonic covariance matrix for stability. Default is 1e-12.

  • epsy15 (float, optional) – A small number added to terms in the diagonal of the spherical harmonic covariance matrix above degree 15, which become particularly unstable. Default is 1e-09.

  • mx (int, optional) – x resolution of Mollweide grid (for map visualizations). Default is 300.

  • my (int, optional) – y resolution of Mollweide grid (for map visualizations). Default is 150.

property cho_cov_ylm

The lower Cholesky factorization of the spherical harmonic covariance.

cov(t, i=60.0, p=1.0, u=array([0.0, 0.0]))

The GP flux covariance matrix.

Parameters
  • t (vector) – The time array in arbitrary units.

  • i (scalar, optional) – The inclination of the star in degrees. Default is 60.0. If marginalize_over_inclination is set, this argument is ignored.

  • p (scalar, optional) – The rotational period of the star in the same units as t. Default is 1.0.

  • u (vector, optional) – The limb darkening coefficients for the star. Default is [0. 0.].

cov_pix(latlon)

The covariance of the process in latitude-longitude pixel space.

Parameters

latlon (ndarray) – The latitude(s) and longitude(s) at which to evaluate the covariance in degrees. This must be a numerical quantity (tensor inputs are not supported) of shape (..., 2), where the last dimension corresponds to a tuple of latitude-longitude values.

Returns

The tensor-valued covariance evaluated at the flattened vector of input coordinates. This will have shape (N, N) where N is the number of input lat-lon coordinates.

property cov_ylm

The spherical harmonic covariance matrix.

property covpts

The number of interpolation points for the covariance matrix when marginalize_over_inclination is True.

flux(y, t, i=60.0, p=1.0, u=array([0.0, 0.0]))

Return the light curve corresponding to a spherical harmonic representation of a surface y.

Parameters
  • y (vector or matrix) – The spherical harmonic coefficients. This can be an ndarray or tensor of any number of dimensions provided the last dimension has length equal to the number of spherical harmonic coefficients of the map. If time variability is enabled, the next to last dimension should be equal to the number of time points. The output from methods such as sample_ylm can thus be directly passed to this method.

  • t (vector) – The time array in arbitrary units.

  • i (scalar, optional) – The inclination of the star in degrees. Default is 60.0. This option is accepted even if marginalize_over_inclination is True.

  • p (scalar, optional) – The rotational period of the star in the same units as t. Default is 1.0.

  • u (vector, optional) – The limb darkening coefficients for the star. Default is [0. 0.].

Returns

The flux timeseries. This will in general have shape (…, nsamples, ntimes).

log_jac()

The log of the absolute value of the determinant of the Jacobian matrix.

The spot latitude is Beta-distributed with shape parameters a and b, equal to the log of the traditional alpha and beta parameters of the Beta distribution, normalized and scaled to the range [0, 1]. From Bayes’ theorem, the joint posterior in these two quantities is

\[p\big(a, b \big| data\big) \sim p\big(data \big| a, b\big) \times p(a, b)\]

However, this is a rather awkward parametrization, since it’s hard to visualize how exactly a and b (or alpha and beta) determine quantities we actually care about, such as the mean mu and standard deviation sigma of the distribution. This parameterization is especially clumsy when it comes to specifying the prior p(a, b), since any prior on these quantities will imply a very different prior on mu and sigma. In most cases, we probably want to place a prior on mu and sigma directly. We can do this by noting that

\[p(a, b) = p(\mu, \sigma) \times J\]

where

\[J = \bigg| \frac{\partial{\mu}}{\partial{a}} \times \frac{\partial{\sigma}}{\partial{b}} - \frac{\partial{\mu}}{\partial{b}} \times \frac{\partial{\sigma}}{\partial{a}} \bigg|\]

is the absolute value of the determinant of the Jacobian matrix.

Thus, to enforce a uniform prior on mu and sigma, sample in a and b with a uniform prior in the range [0, 1] and multiply the PDF by J. Since we’re in log space, you’ll want to add log J (the value returned by this function) to the log likelihood.

log_likelihood(t, flux, data_cov, i=60.0, p=1.0, u=array([0.0, 0.0]), baseline_mean=0.0, baseline_var=0.0)

Compute the log marginal likelihood of a light curve.

Parameters
  • t (vector) – The time array in arbitrary units.

  • flux (vector or matrix) –

    The array of observed flux values in arbitrary units. In general, the flux should be either mean- or median-normalized with zero baseline. If the raw photometry is measured in counts, users should compute the flux from

    flux = counts / np.mean(counts) - 1
    

    If the baseline is something else (such as unity), users may alternatively set the baseline_mean parameter to reflect that. Note that if the normalized keyword passed to this class is False, then the flux should instead be normalized to the true baseline (i.e., the counts one would measure if the star had no spots). This quantity is typically not known, so it should be treated as a latent variable of the model. Note, finally, that flux may also be a matrix, in which case each of its M rows is assumed to be the light curve of a different star whose periods, limb darkening coefficients, inclinations (if marginalize_over_inclination is False) and data uncertainty are all the same. This is probably not very useful for real data, for which all of these are bound to be different even for “similar” stars, but it is very useful for testing and dealing with synthetic data. If that’s your use case, it’s much faster to pass in a batch of light curves than to call this function M times. Future versions of this code will (likely) provide the option to marginalize over period and limb darkening coefficients, in which case this feature will be far more useful!

  • data_cov (scalar, vector, or matrix) – The data covariance matrix. This may be a scalar equal to the (homoscedastic) variance of the data, a vector equal to the variance of each observation, or a matrix equal to the full covariance of the dataset.

  • i (scalar, optional) – The inclination of the star in degrees. Default is 60.0. If marginalize_over_inclination is set, this argument is ignored.

  • p (scalar, optional) – The rotational period of the star in the same units as t. Default is 1.0.

  • u (vector, optional) – The limb darkening coefficients for the star. Default is [0. 0.].

  • baseline_mean (scalar or vector, optional) – The flux baseline to subtract when computing the GP likelihood. Default is 0.0.

  • baseline_var (scalar or matrix) – The variance (square of the uncertainty) on the true value of the baseline. This is added to every element of the GP covariance matrix in order to marginalize over the baseline uncertainty. This may also be a matrix specifying the covariance due to additional correlated noise unrelated to star spot variability. Default is 0.0.

Returns

The log marginal likelihood of the flux vector conditioned on the current properties of the model. This is the likelihood marginalized over all possible spherical harmonic vectors.

property marginalize_over_inclination

Whether or not the process marginalizes over inclination under an isotropic prior.

mean(t, i=60.0, p=1.0, u=array([0.0, 0.0]))

The GP flux mean vector.

Note that this mean is defined relative to a baseline of zero. If normalized is True, this method always returns zero. If normalized is False, this method returns the mean flux deficit. In these units, a star with no spots on it has zero flux. To get light curves measured relative to a unit baseline, simply add 1.

Parameters
  • t (vector) – The time array in arbitrary units.

  • i (scalar, optional) – The inclination of the star in degrees. Default is 60.0. If marginalize_over_inclination is set, this argument is ignored.

  • p (scalar, optional) – The rotational period of the star in the same units as t. Default is 1.0.

  • u (vector, optional) – The limb darkening coefficients for the star. Default is [0. 0.].

mean_pix(latlon)

The mean of the process in latitude-longitude pixel space.

Parameters

latlon (ndarray) – The latitude(s) and longitude(s) at which to evaluate the mean in degrees. This must be a numerical quantity (tensor inputs are not supported) of shape (..., 2), where the last dimension corresponds to a tuple of latitude-longitude values.

Returns

The tensor-valued mean evaluated at the flattened vector of input coordinates. This will have shape (N,) where N is the number of input lat-lon coordinates.

property mean_ylm

The mean spherical harmonic coefficient vector.

mollweide(y, unit_background=True)

Return the Mollweide projection of a spherical harmonic representation of a surface y.

Parameters
  • y (vector or matrix) – The spherical harmonic coefficients. This can be an ndarray or tensor of any number of dimensions provided the last dimension has length equal to the number of spherical harmonic coefficients of the map. The output from methods such as sample_ylm can thus be directly passed to this method.

  • unit_background (bool, optional) – If True (default), the returned image is shifted so that the unspotted surface has unit intensity; otherwise, the baseline is set to zero.

Returns

A matrix of dimension one greater than y, where the last two dimensions have shape (my, mx), corresponding to the number of pixels along the vertical and horizontal axes of the rendered image. These parameters can be passed as kewyords when instantiating this class; their default values are 150 and 300, respectively.

property normalized

Whether or not the process is modeling light curves that have been normalized to the (sample) mean (or median).

predict(t, flux, data_cov, t_sample=None, i=60.0, p=1.0, u=array([0.0, 0.0]), baseline_mean=0.0, baseline_var=0.0)

Return the mean and covariance of the distribution over light curves conditioned on observed flux values.

Parameters
  • t (vector) – The time array in arbitrary units at which the flux is measured.

  • flux (vector) –

    The array of observed flux values in arbitrary units. In general, the flux should be either mean- or median-normalized with zero baseline. If the raw photometry is measured in counts, users should compute the flux from

    flux = counts / np.mean(counts) - 1
    

    If the baseline is something else (such as unity), users may alternatively set the baseline_mean parameter to reflect that. Note that if the normalized keyword passed to this class is False, then the flux should instead be normalized to the true baseline (i.e., the counts one would measure if the star had no spots). This is usually not known, so it should be modeled as a latent variable.

  • data_cov (scalar, vector, or matrix) – The data covariance matrix. This may be a scalar equal to the (homoscedastic) variance of the data, a vector equal to the variance of each observation, or a matrix equal to the full covariance of the dataset.

  • t_sample (vector, optional) – The time array on which to compute the flux distribution. If None (default), evaluates the mean and covariance on the input time array t.

  • i (scalar, optional) – The inclination of the star in degrees. Default is 60.0. If marginalize_over_inclination is set, this argument is ignored.

  • p (scalar, optional) – The rotational period of the star in the same units as t. Default is 1.0.

  • u (vector, optional) – The limb darkening coefficients for the star. Default is [0. 0.].

  • baseline_mean (scalar or vector, optional) – The flux baseline to subtract when computing the GP likelihood. Default is 0.0.

  • baseline_var (scalar or matrix) – The variance (square of the uncertainty) on the true value of the baseline. This is added to every element of the GP covariance matrix in order to marginalize over the baseline uncertainty. This may also be a matrix specifying the covariance due to additional correlated noise unrelated to star spot variability. Default is 0.0.

Returns

The mean vector and covariance matrix of the flux distribution conditioned on the observations.

Note

This method is not yet implemented for normalized light curves. We recommend not normalizing the light curve and instead fitting for a latent amplitude with normalize = False.

sample(t, i=60.0, p=1.0, u=array([0.0, 0.0]), nsamples=1, eps=1e-08)

Draw samples from the prior distribution over light curves.

Parameters
  • t (vector) – The time array in arbitrary units.

  • i (scalar, optional) – The inclination of the star in degrees. Default is 60.0. If marginalize_over_inclination is set, this argument is ignored.

  • p (scalar, optional) – The rotational period of the star in the same units as t. Default is 1.0.

  • u (vector, optional) – The limb darkening coefficients for the star. Default is [0. 0.].

  • nsamples (int, optional) – The number of samples to draw. Default 1.

  • eps (float, optional) – A small number added to the diagonal of the flux covariance matrix when marginalizing over inclination for extra stability. If this method returns NaN values, try increasing this value. Default is 1e-08.

Returns

An array of samples of shape (nsamples, ntimes).

sample_conditional(t, flux, data_cov, t_sample=None, i=60.0, p=1.0, u=array([0.0, 0.0]), baseline_mean=0.0, baseline_var=0.0, nsamples=1, eps=1e-08)

Draw samples from the distribution over light curves conditioned on observed flux values.

Parameters
  • t (vector) – The time array in arbitrary units at which the flux is measured.

  • flux (vector) –

    The array of observed flux values in arbitrary units. In general, the flux should be either mean- or median-normalized with zero baseline. If the raw photometry is measured in counts, users should compute the flux from

    flux = counts / np.mean(counts) - 1
    

    If the baseline is something else (such as unity), users may alternatively set the baseline_mean parameter to reflect that. Note that if the normalized keyword passed to this class is False, then the flux should instead be normalized to the true baseline (i.e., the counts one would measure if the star had no spots). This is usually not known, so it should be modeled as a latent variable.

  • data_cov (scalar, vector, or matrix) – The data covariance matrix. This may be a scalar equal to the (homoscedastic) variance of the data, a vector equal to the variance of each observation, or a matrix equal to the full covariance of the dataset.

  • t_sample (vector, optional) – The time array on which to sample the flux distribution. If None (default), returns samples evaluated on the input time array t.

  • i (scalar, optional) – The inclination of the star in degrees. Default is 60.0. If marginalize_over_inclination is set, this argument is ignored.

  • p (scalar, optional) – The rotational period of the star in the same units as t. Default is 1.0.

  • u (vector, optional) – The limb darkening coefficients for the star. Default is [0. 0.].

  • baseline_mean (scalar or vector, optional) – The flux baseline to subtract when computing the GP likelihood. Default is 0.0.

  • baseline_var (scalar or matrix) – The variance (square of the uncertainty) on the true value of the baseline. This is added to every element of the GP covariance matrix in order to marginalize over the baseline uncertainty. This may also be a matrix specifying the covariance due to additional correlated noise unrelated to star spot variability. Default is 0.0.

  • nsamples (int, optional) – The number of samples to draw. Default 1.

  • eps (float, optional) – A small number added to the diagonal of the flux covariance matrix for extra stability. If this method returns NaN values, try increasing this value. Default is 1e-08.

Returns

An array of samples of shape (nsamples, ntimes).

Note

This method is not yet implemented for normalized light curves. We recommend not normalizing the light curve and instead fitting for a latent amplitude with normalize = False.

sample_ylm(t=None, nsamples=1)

Draw samples from the prior.

Parameters
  • t (vector, optional) – If provided, return the samples evaluated at these points in time. This is only useful if the surface variability timescale tau is set. Default is None.

  • nsamples (int, optional) – The number of samples to draw. Default 1.

Returns

An array of samples of shape (nsamples, ntimes, nylm) (if a vector of times is provided) or (nsamples, nylm) if not.

sample_ylm_conditional(t, flux, data_cov, i=60.0, p=1.0, u=array([0.0, 0.0]), baseline_mean=0.0, baseline_var=0.0, nsamples=1)

Draw samples from the process conditioned on observed flux values.

Parameters
  • t (vector) – The time array in arbitrary units.

  • flux (vector) –

    The array of observed flux values in arbitrary units. In general, the flux should be either mean- or median-normalized with zero baseline. If the raw photometry is measured in counts, users should compute the flux from

    flux = counts / np.mean(counts) - 1
    

    If the baseline is something else (such as unity), users may alternatively set the baseline_mean parameter to reflect that. Note that if the normalized keyword passed to this class is False, then the flux should instead be normalized to the true baseline (i.e., the counts one would measure if the star had no spots). This is usually not known, so it should be modeled as a latent variable.

  • data_cov (scalar, vector, or matrix) – The data covariance matrix. This may be a scalar equal to the (homoscedastic) variance of the data, a vector equal to the variance of each observation, or a matrix equal to the full covariance of the dataset.

  • i (scalar, optional) –

    The inclination of the star in degrees. Default is 60.0. This option is accepted even if marginalize_over_inclination is True. If the inclination is not known, draw it from an isotropic prior by running, e.g.,

    i = np.arccos(np.random.random()) * 180 / np.pi
    

  • p (scalar, optional) – The rotational period of the star in the same units as t. Default is 1.0.

  • u (vector, optional) – The limb darkening coefficients for the star. Default is [0. 0.].

  • baseline_mean (scalar or vector, optional) – The flux baseline to subtract when computing the GP likelihood. Default is 0.0.

  • baseline_var (scalar or matrix) – The variance (square of the uncertainty) on the true value of the baseline. This is added to every element of the GP covariance matrix in order to marginalize over the baseline uncertainty. This may also be a matrix specifying the covariance due to additional correlated noise unrelated to star spot variability. Default is 0.0.

  • nsamples (int, optional) – The number of samples to draw. Default 1.

Returns

An array of samples of shape (nsamples, nylm).

Note

This method is not implemented for normalized or time-variable light curves. In the former case, the transformation between spherical harmonic coefficients and flux is nonlinear, so sampling from the distribution over surfaces must be done numerically. The latter case may be implemented in the future.

visualize(y=None, unit_background=True, **kwargs)

Visualize the Mollweide projection of a spherical harmonic representation of a surface y using matplotlib.

Parameters
  • y (vector or matrix, optional) – The spherical harmonic coefficients. This can be an ndarray or tensor of any number of dimensions provided the last dimension has length equal to the number of spherical harmonic coefficients of the map and the next to last dimension is the number of frames in the animation. The output from methods such as sample_ylm can thus be directly passed to this method. If more than 2d, all but the last two dimensions are ignored. If not provided, y will be computed from a call to sample_ylm().

  • unit_background (bool, optional) – If True (default), the returned image is shifted so that the unspotted surface has unit intensity; otherwise, the baseline is set to zero.

  • ax (optional) – A matplotlib axis instance to use. Default is to create a new figure.

  • cmap (string or colormap instance, optional) – The matplotlib colormap to use. Defaults to plasma.

  • figsize (tuple, optional) – Figure size in inches. Default is (7, 3.5).

  • colorbar (bool, optional) – Display a colorbar? Default is False.

  • grid (bool, optional) – Show latitude/longitude grid lines? Defaults to True.

  • interval (int, optional) – Interval between frames in milliseconds (animated maps only). Defaults to 75.

  • file (string, optional) – The file name (including the extension) to save the figure or animation to. Defaults to None.

  • html5_video (bool, optional) – If rendering in a Jupyter notebook, display as an HTML5 video? Default is True. If False, displays the animation using Javascript (file size will be larger.)

  • dpi (int, optional) – Image resolution in dots per square inch. Defaults to the value defined in matplotlib.rcParams.

  • bitrate (int, optional) – Bitrate in kbps (animations only). Defaults to the value defined in matplotlib.rcParams.

  • vmin (float, optional) – The lower bound of the colormap.

  • vmax (float, optional) – The upper bound of the colormap.

property ydeg

The spherical harmonic degree of the surface map expansion.

class starry_process.MCMCInterface(model=None)

An interface for using a pymc3 model with a plain vanilla MCMC sampler.

Parameters

model (optional) – The pymc3 model. If None (default), uses the current model on the stack.

get_initial_state(nwalkers=30, var=None, check_finite=True, max_tries=100)

Generate random initial points for sampling.

If the optimize method was called beforehand, this method returns samples from a multidimensional Gaussian centered on the maximum a posteriori (MAP) solution with covariance equal to the inverse of the Hessian matrix at that point, unless var is provided, in which case that is used instead. If the optimizer was not called, this method returns samples from a Gaussian with mean equal to the model’s test point (model.test_point) and variance equal to var.

Parameters

var (float, array, or matrix, optional) – Variance of the multidimensional Gaussian used to draw samples. This quantity is optional if optimize was called beforehand, otherwise it must be provided. Default is None.

Returns

An array of shape (nwalkers, ndim) where ndim is the number of free model parameters.

logp(x)

Return the log probability evaluated at a point.

Parameters

x (array) – The array of parameter values.

Returns

The value of the log probability function evaluated at x.

optimize(**kwargs)

Maximize the log probability of a pymc3 model.

This routine wraps pymc3_ext.optimize, which in turn wraps the scipy.optimize.minimize function. This method accepts any of the keywords accepted by either of those two functions.

Returns

The array of parameter values at the optimum point.

transform(samples, varnames=None, progress=True)

Transform samples from the internal to the user parametrization.

Parameters
  • samples (array or matrix) – The set of points to transform.

  • varnames (list, optional) – The names of the parameters to transform to. These may either be strings or the actual pymc3 model variables. If None (default), these are determined automatically and may be accessed as the varnames attribute of this class.

  • progress (bool, optional) – Display a progress bar? Default True.

Returns

An array of shape (..., len(varnames)), where ... = samples.shape[:-1], containing the transformed samples.

starry_process.beta2gauss(a, b, log_alpha_max=10, log_beta_max=10)

Return the mode mu and standard deviation sigma of Laplace’s (Gaussian) approximation to the PDF of the latitude Beta distribution with shape parameters a and b.

Parameters
  • a (scalar or vector) – Shape parameter.

  • b (scalar or vector) – Shape parameter.

  • log_alpha_max (float, optional) – The maximum value of ln(alpha). Default is 10.

  • log_beta_max (float, optional) – The maximum value of ln(beta). Default is 10.

The shape parameters a and b are related to the shape parameters of the Beta distribution in cosine latitude via the transformations

Note

This is a utility function that can accept and return either numeric values or tensors. If both a and b are numeric quantities, the result will be a numeric quantity; otherwise it will be a tensor.

starry_process.gauss2beta(mu, sigma, log_alpha_max=10, log_beta_max=10)

Return the shape parameters a and b of the latitude Beta distribution closest to the Gaussian with mean mu and standard deviation sigma.

Parameters
  • mu (scalar or vector) – The mean latitude in degrees.

  • sigma (scalar or vector) – The latitude standard deviation in degrees.

  • log_alpha_max (float, optional) – The maximum value of ln(alpha). Default is 10.

  • log_beta_max (float, optional) – The maximum value of ln(beta). Default is 10.

The shape parameters a and b are related to the shape parameters of the Beta distribution in cosine latitude via the transformations

Note

This is a utility function that can accept and return either numeric values or tensors. If both mu and sigma are numeric quantities, the result will be a numeric quantity; otherwise it will be a tensor.