analyze

package module
v0.0.0-...-13d6b0f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2021 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterPoints

func FilterPoints(
	rs []RingBuffer, levels int, h float64,
) (pxs, pys [][]float64, ok bool)

FilterPoints applies the filtering algorithm from section 2.2.3 of Mansfield, Kravtsov, & Diemer (2016) to the points contained in each of a collection of RingBuffers.

This function is mostly just a wrapper around functions from kde.go.

func GaussianKDE

func GaussianKDE(xs []float64, h, low, high float64, n int) *intr.Spline

GaussianKDE calculates a gaussian KDE from the points in the array xs, which kernel widths of h. This is done by evaluating the KDE at n uniformly-spaced points between low and high and then returning a cubic Spline fit through these points.

func PennaCoeffs

func PennaCoeffs(xs, ys, zs []float64, I, J, K int) []float64

PennaCoeffs calculates the Penna-Dines coefficients corresponding to the parameters I, J, and K for a set of input points.

func Smooth

func Smooth(
	xs, ys []float64, window int, opts ...SmoothOption,
) (vals, derivs []float64, ok bool)

Smooth returns a smoothed 1D series as well as the derivative of that series using a Savitzky-Golay filter of the given size. It also takes optional arguments which allow the smoothing to be done in-place.

func SplashbackRadius

func SplashbackRadius(
	rs, rhos, derivs []float64, opts ...SplashbackRadiusOption,
) (r float64, ok bool)

SplashbackRadius returns the point of steepest slope for a density profile. It also allows for optional callbacks.

Types

type KDETree

type KDETree struct {
	// contains filtered or unexported fields
}

KDETree is a data structure that maintains all the state required for the recursive KDE-based filtering used by Shellfish.

func NewKDETree

func NewKDETree(
	rs, phis []float64, splits int, h float64,
) (*KDETree, bool)

NewKDETree performs filtering fo points using the recursive KDE-based filtering described in section 2.2.3 of Mansfield, Kravtsov, Diemer (2016).

splits is the number of levels of recursion minus one.

func (*KDETree) FilterNearby

func (kt *KDETree) FilterNearby(
	rs, ths []float64, level int, dr float64,
) (fRs, fThs []float64, idxs []int)

FilterNearby returns all the points which are within dr of the filtering curve at the specified level of recursion.

func (*KDETree) GetConnMaxes

func (kt *KDETree) GetConnMaxes(level int) (rs, ths []float64)

GetConMaxes returns the location of the anchor points at a given level of recursion.

func (*KDETree) GetRFunc

func (kt *KDETree) GetRFunc(level int, rt RFuncType) func(float64) float64

GetRFunc returns the filtering curve at a particular level of recursion. rt should always be set to Cartesian unless you know exactly what you're doing and why you're doing it.

func (*KDETree) H

func (kt *KDETree) H() float64

H Returns the smoothing scale of the KDE tree.

func (*KDETree) PlotLevel

func (kt *KDETree) PlotLevel(level, spIdx int, opts ...interface{})

PlotLevel plots the KDEs found at a particular level of a KDETree using the pyplot options, opts. It is used purely for debugging purposed.

type RFuncType

type RFuncType int

Don't worry about this type, just always set it to Cartesian 100% of the time.

const (
	Radial RFuncType = iota
	Cartesian
)

type RingBuffer

type RingBuffer struct {
	PlaneXs, PlaneYs []float64 // x and y coords in the plane of the ring.
	Xs, Ys, Zs       []float64 // Cartesian coords in the simulation box.
	Rs, Phis         []float64 // r and phi coords in the plane of the ring.
	Oks              []bool    // Corresponds to a valid splashback point.

	N, Bins int
	// contains filtered or unexported fields
}

RingBuffer contains the locations of candidate splashback radii for a single ring of a LOS profiles. They are stored in multiple forms: x and y within the plane of the ring, x, y, and z in the coordinate system of the simulation, and r and phi within the plane of the ring. It also contains a bunch of buffers to prevent useless allocations in various operations.

func (*RingBuffer) Clear

func (r *RingBuffer) Clear()

Clear clears all the values contained within a RingBuffer.

func (*RingBuffer) Init

func (r *RingBuffer) Init(n, bins int)

Init initializes

func (*RingBuffer) OkPlaneCoords

func (r *RingBuffer) OkPlaneCoords(xs, ys []float64) (okXs, okYs []float64)

OkPlaneCoords returns the within-plane x and y coordinates where r.Oks is true.

func (*RingBuffer) OkPolarCoords

func (r *RingBuffer) OkPolarCoords(rs, phis []float64) (okRs, okPhis []float64)

OkPlaneCoords returns the within-plane r and phi coordinates where r.Oks is true.

func (*RingBuffer) Splashback

func (r *RingBuffer) Splashback(
	h *los.Halo, ring int, window int, dLim float64,
)

Splashback calculates the candidate splashback radius for a given line of sight and stores the relevant information in the RingBuffer.

type Shell

type Shell func(phi, theta float64) float64

Shell is a function that returns the radius of a shell at a given set of angles.

Unless otherwise specified, all quantities are calculated through Monte Carlo solid angle sampling.

func PennaFunc

func PennaFunc(cs []float64, I, J, K int) Shell

PennaFunc returns a shell function correpsonding to a particular set of Penna-Dines coefficients.

func PennaVolumeFit

func PennaVolumeFit(
	xs, ys [][]float64, h *los.Halo, I, J int,
) (cs []float64, shell Shell)

PennaVolumeFit fits a Penna-Dines shell to a set of points constrained to a collection of planes belong to an los.Halo object.

This function is essentially just a wrapper around PennaCoeffs.

func (Shell) AngularFractionProfile

func (s Shell) AngularFractionProfile(
	samples, bins int, rMin, rMax float64,
) (rs, fs []float64)

AngularFractionProfile the percentage of lines of sight at a given radius which are inside the shell. (Note: it doesn't just perform the brute force Monte Carlo calculation at every radius, so don't worry about the number of bins having an effect on the performance.)

func (Shell) Axes

func (s Shell) Axes(samples int) (a, b, c float64, aVec [3]float64)

Axes calculates the moment of inertia-equivalent axes of a Shell as well as the direction of the major axis.

func (Shell) CartesianSampledVolume

func (s Shell) CartesianSampledVolume(samples int, rMax float64) float64

CartesianSampledVolume returns the volume of a Shell. The volume is calculated by Monte Carlo sampling of a sphere of radius rMax.

This is slower than Volume for most shell shapes.

func (Shell) Contains

func (s Shell) Contains(x, y, z float64) bool

Contains returns true if a Shell contains a point and false otherwise. The point must be in a coordinate system in which the Shell is at (0, 0, 0).

func (Shell) DiffVolume

func (s1 Shell) DiffVolume(s2 Shell, samples int) float64

DiffVolume returns the volume of the space between two Shells, s1 and s2.

func (Shell) MaxDiff

func (s1 Shell) MaxDiff(s2 Shell, samples int) float64

MaxDiff returns the maximum radial distance between two Shells along any line of sight.

func (Shell) MeanRadius

func (s Shell) MeanRadius(samples int) float64

MeanRadius returns the angle-weighted mean radius of a Shell.

func (Shell) MedianRadius

func (s Shell) MedianRadius(samples int) float64

MedianRadius returns the angle-weighted median radius of a Shell.

func (Shell) RadialRange

func (s Shell) RadialRange(samples int) (low, high float64)

RadialRange returns the maximum and minimum radius of a Shell.

func (Shell) RadiusHistogram

func (s Shell) RadiusHistogram(
	samples, bins int, rMin, rMax float64,
) (rs, ns []float64)

RadiusHistogram returns a normalized angle-weighted histogram of the radii of a Shell.

func (Shell) SurfaceArea

func (s Shell) SurfaceArea(samples int) float64

SurfaceArea returns the surface area of a shell.

func (Shell) Volume

func (s Shell) Volume(samples int) float64

Volume returns the volume of Shell.

type SmoothOption

type SmoothOption internalSmoothOption

SmoothOption is an abstract data type which allows for the customization of calls to Smooth without cluttering the call signature in the common case. This works similarly to kwargs in other languages.

func Derivs

func Derivs(derivs []float64) SmoothOption

Derivs supplies Smooth with a slice which smoothed derivatives can be written to.

func Vals

func Vals(vals []float64) SmoothOption

Vals supplies Smooth with a slice which smoothed values can be written to.

type SplashbackRadiusOption

type SplashbackRadiusOption internalSplashbackRadiusOption

func DLim

DLim sets limit for d ln(rho) / d ln(r) above which point cannot be the splashback radius.

Directories

Path Synopsis
ellipse_grid module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL