PotentialSampler

class discO.PotentialSampler(potential: Any, *, total_mass: Quantity | None = None, representation_type: BaseRepresentation | str | None | ellipsis = None, key: module | str | None = None, **other)[source]

Bases: CommonBase

Sample a Potential.

Parameters:
potentialPotentialWrapper

The potential object. Must have a frame.

total_massQuantity or None (optional)

The total mass of the potential. Necessary if the mass is divergent, must be None otherwise.

representation_type: |Representation| or None (optional, keyword-only)

The coordinate representation in which to return samples. If None (default) uses representation type from potential.

**defaults

default arguments for sampling parameters. In run, parameters with default None will draw from these defaults.

Returns:
PotentialSampler or subclass

If key is not None, returns subclass.

Other Parameters:
keyModuleType or str or None (optional, keyword-only)

The key to which the potential belongs. If not provided (None, default) tries to infer from potential.

Raises:
ValueError
  • If directly instantiating a PotentialSampler (not subclass) and cannot find the appropriate subclass, identified using key.

  • If the total mass of the potential is divergent and total_mass is None.

TypeError

If potential is not PotentialWrapper

Attributes Summary

frame

The frame of the data.

potential

The potential, wrapped.

representation_type

The representation type of the data.

Methods Summary

__call__([n, representation_type, random])

Sample.

run([n, iterations, representation_type, ...])

Iteratively sample the potential.

Attributes Documentation

frame

The frame of the data. Can be None.

potential

The potential, wrapped.

representation_type

The representation type of the data. Can be None.

Methods Documentation

abstract __call__(n: int = 1, *, representation_type: BaseRepresentation | str | None | ellipsis = None, random: int | RandomState | None = None, **kwargs) SkyCoord[source]

Sample.

Parameters:
nint (optional)

number of samples

representation_type: |Representation| or None (optional, keyword-only)

The coordinate representation.

randomint or RandomState or None (optional, keyword-only)

Random state.

**kwargs

passed to underlying instance

Returns:
SkyCoord
run(n: int = 1, iterations: int = 1, *, representation_type: BaseRepresentation | str | None | ellipsis = None, random: int | RandomState | None = None, batch: bool = False, progress: bool = True, **kwargs) SkyCoord[source]

Iteratively sample the potential.

Parameters:
nint (optional)

Number of sample points.

iterationsint (optional)

Number of iterations. Must be > 0.

representation_type: |Representation| or None (optional, keyword-only)

The coordinate representation.

randomint or RandomState or None (optional, keyword-only)

Random state or seed.

progressbool (optional, keyword-only)

If True, a progress bar will be shown as the sampler progresses. If a string, will select a specific tqdm progress bar - most notable is ‘notebook’, which shows a progress bar suitable for Jupyter notebooks. If False, no progress bar will be shown.

**kwargs

Passed to underlying instance

Yields:
SkyCoord

If sequential is False. The shape of the SkyCoord is (n, niter) where a scalar n has length 1.

Raises:
ValueError

If number if iterations not greater than 0.