Microlensing

Lens properties

class moana.lens.Microlens(sep=1.0, q=0.001, frame=None, **kwargs)[source]

Define a binary lens.

Parameters:
  • sep (float) – separation between primary and secondary, in units of the Einstein radius.

  • q (float) – planet-to-host star mass ratio.

  • frame (LensReferenceFrame | None)

Keyword Arguments:
  • s (float) – alias for sep.

  • eps1 (float) – planet-to-host star mass fraction.

class moana.lens.ResonantCaustic(sep=1.0, q=0.001, **kwargs)[source]

Sample a resonant caustic.

Parameters:
  • sep (float) – separation between primary and secondary, in units of the Einstein radius.

  • q (float) – planet-to-host star mass ratio.

Keyword Arguments:
  • s (float) – alias for sep.

  • eps1 (float) – planet-to-host star mass fraction.

moana.lens.close_limit_2l(q)[source]

Compute the limit between resonant and close-separation caustics.

Parameters:

q (ndarray) – list of lens mass ratios.

Returns:

limit as a function of q.

Return type:

ndarray

moana.lens.critic_2l(s, q, phi)[source]

Cumpute solution of the Witt equation.

To sample critic curves, use the convention: - the heaviest body (mass m1) is the origin; - the lightest body (mass m2) is at (-s, 0).

Parameters:
  • s (float) – separation

  • q (float) – the lens mass ratio q = m2/m1.

  • phi (float) – the angle parameter in [0,2*pi].

Returns:

numpy array of the complex roots.

moana.lens.lens_equation_2l(xcoords, eps, z)[source]

Apply the binary-lens equation to an affix.

Conventions: - the heaviest body (mass m1) is the origin; - the lightest body (mass m2) is at (-s, 0).

Parameters:
  • s – separation

  • q – the lens mass ratio q = m2/m1.

  • z (complex) – complex number in the lens plane.

  • xcoords (float)

  • eps (float)

Returns:

numpy array of the corresponding position in the source plane

moana.lens.shape(s, q)[source]

Compute the limit between resonant and close-separation caustics.

Parameters:
  • s (ndarray) – list of separation values.

  • q (ndarray) – list of lens mass ratios.

Returns:

list of str, where ‘c’ means close, ‘r’ means ‘resonant’, and ‘w’ means

wide’.

Return type:

ndarray

moana.lens.wide_limit_2l(q)[source]

Compute the limit between resonant and wide-separation caustics.

Parameters:

q (ndarray) – list of lens mass ratios.

Returns:

limit as a function of q.

Return type:

ndarray

moana.lens.wk(z, affix, mass_fraction, k)[source]

Evaluate the function W_k(z) (see Cassan, 2017).

The complex function W_k(z) is used to compute the lens equation, the caustics and many other microlensing quantities, such as derivatives. The definition used does not depend on the reference frame, nor the number of point lenses. Let’s assume that we have N point lenses in what follows.

Parameters:
  • z (complex) – affix of the point where W_k(z) is evaluated.

  • affix (ndarray) – array (shape: N, type: complex) of the affix of each point lenses.

  • mass_fraction (ndarray) – array (shape N, type: float) with the corresponding mass fractions.

  • k (int) – order of the function W_k(z).

Reference frames

class moana.frames.LensReferenceFrame(center='barycenter', x_axis='12')[source]

Reference frame where x-axis is a lens symmetry axis.

Parameters:
  • center (hint_frame) – origin of the frame.

  • x_axis (hint_dir) – direction of the x-axis. The primary (secondary) is ‘1’ (‘2’), so ‘12’ means: ‘from the primary, to the secondary’.

to_frame(z, new_frame, **kwargs)[source]

Compute positions in a new reference frame.

Parameters:
  • z (ndarray) – position in old reference frame.

  • new_frame (LensReferenceFrame) – new reference frame.

Keyword Arguments:
  • sep (float) – separation in Einstein units.

  • gl1 (float) – distance from the barycenter to the primary, in Einstein units

Statistics

class moana.estimators.SampledPosterior(sample, labels, limit=None, weights=None)[source]

Class to derive statistical properties from a sample.

Parameters:
  • sample (DataFrame) – sample for 1+ parameters.

  • labels (list) – labels of columns to include in statistics.

  • weights (str) – this str indicates which column is used to weight the samples.

sample

pandas.DataFrame of the parameters.

cdf

dict and for each label, cdf[label] is a numpy.array with sorted values in cdf[label][0] and the cumulative function in cdf[label][1].

build_cdf(label, weights=None)[source]

Build the cumulative distribution function.

Parameters:
  • label (str) – this str indicates which column is used.

  • weights (str) – this str indicates which column is used to weight the samples.

Returns:

Array of the sorted values (column 0) and the cumulative function

(column 1).

Return type:

array

find_limits(label, limit)[source]

Determine the parameter values based on a given probability.

Parameters:
  • label (str) – this str indicates which column is used.

  • limit (list) – list of probability values.

  • weights – this str indicates which column is used to weight the samples.

Returns:

Array of the corresponding values of the parameter.

Return type:

array

scatter_plot_scaling(width=6.614173228346457, optimize=True)[source]

Compute size of scatter plots and margins

Parameters:
  • width (float) – Size of the plot.

  • optimize (bool) – If True, the function will reduce each subplot so that the total plot size is the value of width. If False, then the margins will enlarge a little bit the plot, and the total size will be slightly larger than the given width parameter.

Returns:

List of float with with – - the total size of the plot; - the bottom and left margins; - the top and right margins; - the interplot spacing.

Return type:

list