Maps in reflected light

class starry.Map

The reflected light starry map class.

This class handles light curves and phase curves of objects viewed in reflected light. It has all the same attributes and methods as starry.maps.YlmBase, with the additions and modifications listed below.

The spherical harmonic coefficients of a map in reflected light are an expansion of the object’s spherical albedo (instead of its emissivity, in the default case). The body is assumed to be a spherical, non-uniform Lambertian scatterer.

By default, the illumination source is assumed to be a point source for the purposes of computing the illumination profile on the surface of the body and as a spherical source of finite extent for the purposes of modeling occultations. The point source approximation can be relaxed by changing the source_npts keyword when instantiating the map. This may be important for modeling very short-period exoplanets.

The xs, ys, and zs parameters in several of the methods below specify the position of the illumination source in units of this body’s radius. The flux returned by the flux() method is normalized to that which would be measured from a perfect Lambertian sphere of unit radius illuminated by a source whose flux at the observer is unity.

The amp parameter controls the overall scaling of the body’s flux. The default value is unity, which corresponds to a perfect Lambertian sphere, for which q = 3 / 2, where q is the ratio of the body’s spherical albedo to its geometric albedo. Different values of q can be obtained by changing amp accordingly.

Note

Instantiate this class by calling starry.Map() with ydeg > 0 and reflected set to True.

property N

Total number of map coefficients. Read-only

This is equal to \(N_\mathrm{y} + N_\mathrm{u} + N_\mathrm{f}\).

property Nf

Number of spherical harmonic coefficients in the filter. Read-only

This is equal to \((f_\mathrm{deg} + 1)^2\).

property Nu

Number of limb darkening coefficients, including \(u_0\). Read-only

This is equal to \(u_\mathrm{deg} + 1\).

property Ny

Number of spherical harmonic coefficients. Read-only

This is equal to \((y_\mathrm{deg} + 1)^2\).

property amp

The overall amplitude of the map in arbitrary units. This factor multiplies the intensity and the flux and is thus proportional to the luminosity of the object. For multi-wavelength maps, this is a vector corresponding to the amplitude of each wavelength bin. For reflected light maps, this is the average spherical albedo of the body.

property angle_unit

An astropy.units quantity defining the angle unit for this map.

property deg

Total degree of the map. Read-only

This is equal to \(y_\mathrm{deg} + u_\mathrm{deg} + f_\mathrm{deg}\).

design_matrix(**kwargs)

Compute and return the light curve design matrix, \(A\).

This matrix is used to compute the flux \(f\) from a vector of spherical harmonic coefficients \(y\) and the map amplitude \(a\): \(f = a A y\).

Parameters
  • xs (scalar or vector, optional) – x coordinate of the illumination source relative to this body in units of this body’s radius.

  • ys (scalar or vector, optional) – y coordinate of the illumination source relative to this body in units of this body’s radius.

  • zs (scalar or vector, optional) – z coordinate of the illumination source relative to this body in units of this body’s radius.

  • rs (scalar, optional) – radius of the illumination source in units of this body’s radius.

  • xo (scalar or vector, optional) – x coordinate of the occultor relative to this body in units of this body’s radius.

  • yo (scalar or vector, optional) – y coordinate of the occultor relative to this body in units of this body’s radius.

  • zo (scalar or vector, optional) – z coordinate of the occultor relative to this body in units of this body’s radius.

  • ro (scalar, optional) – Radius of the occultor in units of this body’s radius.

  • theta (scalar or vector, optional) – Angular phase of the body in units of angle_unit.

draw()

Draw a map from the posterior distribution.

This method draws a random map from the posterior distribution and sets the y map vector and amp map amplitude accordingly. Users should call solve() to enable this attribute.

property fdeg

Degree of the multiplicative filter. Read-only

flux(**kwargs)

Compute and return the reflected flux from the map.

Parameters
  • xs (scalar or vector, optional) – x coordinate of the illumination source relative to this body in units of this body’s radius.

  • ys (scalar or vector, optional) – y coordinate of the illumination source relative to this body in units of this body’s radius.

  • zs (scalar or vector, optional) – z coordinate of the illumination source relative to this body in units of this body’s radius.

  • rs (scalar, optional) – radius of the illumination source in units of this body’s radius.

  • xo (scalar or vector, optional) – x coordinate of the occultor relative to this body in units of this body’s radius.

  • yo (scalar or vector, optional) – y coordinate of the occultor relative to this body in units of this body’s radius.

  • zo (scalar or vector, optional) – z coordinate of the occultor relative to this body in units of this body’s radius.

  • ro (scalar, optional) – Radius of the occultor in units of this body’s radius.

  • theta (scalar or vector, optional) – Angular phase of the body in units of angle_unit.

  • integrated (bool, optional) – If True, dots the flux with the amplitude. Default False, in which case this returns a 2d array (wavelength-dependent maps only).

intensity(lat=0, lon=0, xs=0, ys=0, zs=1, rs=0, on94_exact=False, illuminate=True, **kwargs)

Compute and return the intensity of the map.

Parameters
  • lat (scalar or vector, optional) – latitude at which to evaluate the intensity in units of angle_unit.

  • lon (scalar or vector, optional) – longitude at which to evaluate the intensity in units of angle_unit.

  • xs (scalar or vector, optional) – x coordinate of the illumination source relative to this body in units of this body’s radius.

  • ys (scalar or vector, optional) – y coordinate of the illumination source relative to this body in units of this body’s radius.

  • zs (scalar or vector, optional) – z coordinate of the illumination source relative to this body in units of this body’s radius.

  • rs (scalar, optional) – radius of the illumination source in units of this body’s radius.

  • theta (scalar, optional) – For differentially rotating maps only, the angular phase at which to evaluate the intensity. Default 0.

  • limbdarken (bool, optional) – Apply limb darkening (only if udeg > 0)? Default True.

limbdark_is_physical()

Check whether the limb darkening profile (if any) is physical.

This method uses Sturm’s theorem to ensure that the limb darkening intensity is positive everywhere and decreases monotonically toward the limb.

Returns

Whether or not the limb darkening profile is physical.

Return type

bool

lnlike(*, design_matrix=None, woodbury=True, **kwargs)

Returns the log marginal likelihood of the data given a design matrix.

This method computes the marginal likelihood (marginalized over the spherical harmonic coefficients) given a light curve and its covariance (set via the set_data() method) and a Gaussian prior on the spherical harmonic coefficients (set via the set_prior() method).

Parameters
  • design_matrix (matrix, optional) – The flux design matrix, the quantity returned by design_matrix(). Default is None, in which case this is computed based on kwargs.

  • woodbury (bool, optional) – Solve the linear problem using the Woodbury identity? Default is True. The Woodbury identity is used to speed up matrix operations in the case that the number of data points is much larger than the number of spherical harmonic coefficients. In this limit, it can speed up the code by more than an order of magnitude. Keep in mind that the numerical stability of the Woodbury identity is not great, so if you’re getting strange results try disabling this. It’s also a good idea to disable this in the limit of few data points and large spherical harmonic degree.

  • kwargs (optional) – Keyword arguments to be passed directly to design_matrix(), if a design matrix is not provided.

Returns

The log marginal likelihood, a scalar.

property nw

Number of wavelength bins. Read-only

remove_prior()

Remove the prior on the map coefficients.

render(res=300, projection='ortho', illuminate=True, theta=0.0, xs=0, ys=0, zs=1, rs=0, on94_exact=False)

Compute and return the intensity of the map on a grid.

Returns an image of shape (res, res), unless theta is a vector, in which case returns an array of shape (nframes, res, res), where nframes is the number of values of theta. However, if this is a spectral map, nframes is the number of wavelength bins and theta must be a scalar.

Parameters
  • res (int, optional) – The resolution of the map in pixels on a side. Defaults to 300.

  • projection (string, optional) – The map projection. Accepted values are ortho, corresponding to an orthographic projection (as seen on the sky), rect, corresponding to an equirectangular latitude-longitude projection, and moll, corresponding to a Mollweide equal-area projection. Defaults to ortho.

  • illuminate (bool, optional) – Illuminate the map? Default is True.

  • theta (scalar or vector, optional) – The map rotation phase in units of angle_unit. If this is a vector, an animation is generated. Defaults to 0.0.

  • xs (scalar or vector, optional) – x coordinate of the illumination source relative to this body in units of this body’s radius.

  • ys (scalar or vector, optional) – y coordinate of the illumination source relative to this body in units of this body’s radius.

  • zs (scalar or vector, optional) – z coordinate of the illumination source relative to this body in units of this body’s radius.

  • rs (scalar, optional) – radius of the illumination source in units of this body’s radius.

reset(**kwargs)

Reset all map coefficients and attributes.

Note

Does not reset custom unit settings.

property roughness

The Oren-Nayar (1994) surface roughness parameter, sigma, in units of angle_unit.

set_data(flux, C=None, cho_C=None)

Set the data vector and covariance matrix.

This method is required by the solve() method, which analytically computes the posterior over surface maps given a dataset and a prior, provided both are described as multivariate Gaussians.

Parameters
  • flux (vector) – The observed 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.

set_prior(*, mu=None, L=None, cho_L=None)

Set the prior mean and covariance of the spherical harmonic coefficients.

This method is required by the solve() method, which analytically computes the posterior over surface maps given a dataset and a prior, provided both are described as multivariate Gaussians.

Note that the prior is placed on the amplitude-weighted coefficients, i.e., the quantity x = map.amp * map.y. Because the first spherical harmonic coefficient is fixed at unity, x[0] is the amplitude of the map. The actual spherical harmonic coefficients are given by x / map.amp.

This convention allows one to linearly fit for an arbitrary map normalization at the same time as the spherical harmonic coefficients, while ensuring the starry requirement that the coefficient of the \(Y_{0,0}\) harmonic is always unity.

Parameters
  • mu (scalar or vector) – The prior mean on the amplitude-weighted spherical harmonic coefficients. Default is 1.0 for the first term and zero for the remaining terms. If this is a vector, it must have length equal to Ny.

  • L (scalar, vector, or matrix) – The prior covariance. This may be a scalar, in which case the covariance is assumed to be homoscedastic, a vector, in which case the covariance is assumed to be diagonal, or a matrix specifying the full prior covariance. Default is None. Either L or cho_L must be provided.

  • cho_L (matrix) – The lower Cholesky factorization of the prior covariance matrix. Defaults to None. Either L or cho_L must be provided.

show(**kwargs)

Display an image of the map, with optional animation. See the docstring of render() for more details and additional keywords accepted by this method.

Parameters
  • 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 (3, 3) for orthographic maps and (7, 3.5) for rectangular maps.

  • projection (string, optional) – The map projection. Accepted values are ortho, corresponding to an orthographic projection (as seen on the sky), rect, corresponding to an equirectangular latitude-longitude projection, and moll, corresponding to a Mollweide equal-area projection. Defaults to ortho.

  • 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.

  • norm (optional) – The color normalization passed to matplotlib.pyplot.imshow, an instance of matplotlib.colors.Normalize. Can be used to pass in minimum and maximum values. Default is None.

  • illuminate (bool, optional) – Illuminate the map (reflected light maps only)? Default True. If False, shows the albedo surface map.

  • screen (bool, optional) – Apply the illumination as a black-and-white alpha screen (reflected light maps only)? Default True. If False, a single colormap is used to plot the visible intensity.

Note

Pure limb-darkened maps do not accept a projection keyword.

Note

If calling this method on an instance of Map created within a pymc3.Model(), you may specify a point keyword with the model point at which to evaluate the map. This method also accepts a model keyword, although this is inferred automatically if called from within a pymc3.Model() context. If no point is provided, attempts to evaluate the map at model.test_point and raises a warning.

property solution

The posterior probability distribution for the map.

This is a tuple containing the mean and lower Cholesky factorization of the covariance of the amplitude-weighted spherical harmonic coefficient vector, obtained by solving the regularized least-squares problem via the solve() method.

Note that to obtain the actual covariance matrix from the lower Cholesky factorization \(L\), simply compute \(L L^\top\).

Note also that this is the posterior for the amplitude-weighted map vector. Under this convention, the map amplitude is equal to the first term of the vector and the spherical harmonic coefficients are equal to the vector normalized by the first term.

solve(*, design_matrix=None, **kwargs)

Solve the linear least-squares problem for the posterior over maps.

This method solves the generalized least squares problem given a light curve and its covariance (set via the set_data() method) and a Gaussian prior on the spherical harmonic coefficients (set via the set_prior() method). The map amplitude and coefficients are set to the maximum a posteriori (MAP) solution.

Parameters
  • design_matrix (matrix, optional) – The flux design matrix, the quantity returned by design_matrix(). Default is None, in which case this is computed based on kwargs.

  • kwargs (optional) – Keyword arguments to be passed directly to design_matrix(), if a design matrix is not provided.

Returns

A tuple containing the posterior mean for the amplitude-weighted spherical harmonic coefficients (a vector) and the Cholesky factorization of the posterior covariance (a lower triangular matrix).

Note

Users may call draw() to draw from the posterior after calling this method.

property source_npts

The number of points used when approximating finite illumination source size. This quantity must be set when instantiating the map.

property u

The vector of limb darkening coefficients. Read-only

To set this vector, index the map directly using one index: map[n] = ... where n is the degree of the limb darkening coefficient. This may be an integer or an array of integers. Slice notation may also be used.

property udeg

Limb darkening degree. Read-only

property wav

The wavelength(s) at which the flux is measured in units of wav_unit.

property wav_unit

An astropy.units quantity defining the angle unit for this map.

property y

The spherical harmonic coefficient vector. Read-only

To set this vector, index the map directly using two indices: map[l, m] = ... where l is the spherical harmonic degree and m is the spherical harmonic order. These may be integers or arrays of integers. Slice notation may also be used.

property ydeg

Spherical harmonic degree of the map. Read-only