sphere_halo

package
v0.0.0-...-e3578a0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

package sphere_halo is essentially a redo of the implementation of HaloProfiles found in the los package but with a different internal geometry kernel. I've learned a few lessons since then about the right way to structure this stuff and I'm going to try applying those lessons here.

Operating on a SphereHalo is relatively simple:

 hs := make([]SphereHalo, workers)
 h := &hs[0]
 h.Init(norms, origin, rMin, rMax, bins, n)

 // Read particle positions from disk. (Probably in a loop.)
 vecs := Read()

 h.Transform(vecs)
 intr := make([]bool, len(vecs))
 h.Intersect(vecs, intr)

 // Split the halo up into thread-specific workplaces.
 h.Split(hs)

// Split into multiple thread here

for i, vec := range vecs {
    if intr[i] { h.Insert(vec, ptRadius) }
 }

 // Do synchronization here

 h.Join(hs)

Index

Constants

This section is empty.

Variables

View Source
var (
	OneCountProf []int
	TwoCountProf []int
	OneCount     int
	TwoCount     int
)

Functions

This section is empty.

Types

type SphereHalo

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

Type SphereHalo represents a halo which can have spheres inserted into it.

func (*SphereHalo) GetRhos

func (h *SphereHalo) GetRhos(ring, losIdx int, buf []float64)

GetRhos writes the density of the LoS at a given ring and LoS profile into buf.

func (*SphereHalo) GetRs

func (h *SphereHalo) GetRs(buf []float64)

GetRs writes the radial values of each bin into a a buffer.

func (*SphereHalo) Init

func (h *SphereHalo) Init(
	norms []geom.Vec, origin [3]float64,
	rMin, rMax float64, bins, n int,
	defaultRho float64,
)

Init initializes a halo centered at origin with minimum and maximum radii given by rMin, and rMax. It will consist of a family of rings whose normals are given by the slice of vectors, norms. Each ring will consists of n lines of sight and will have bins radial bins.

func (*SphereHalo) Insert

func (h *SphereHalo) Insert(vec geom.Vec, radius, rho float64)

Insert insreats a sphere with the given center and radius to all the rings of the halo.

func (*SphereHalo) Intersect

func (h *SphereHalo) Intersect(vecs []rgeom.Vec, r float64, intr []bool)

Intersect treats all the given vectors as spheres of radius r, and tests them for intersection with the halo. The results are written to the buffer intr.

Intersect must be called after Transform is called on the vectors.

func (*SphereHalo) Join

func (h *SphereHalo) Join(hs []SphereHalo)

Join joins h and all the halos in hs together into h. The mass stored in h at the end is equal to the total mass intially in h and all the halos in hs.

Used for parallelization. But very expensive.

func (*SphereHalo) LineSegment

func (h *SphereHalo) LineSegment(ring, losIdx int, out *geom.LineSegment)

LineSegment calculates a line segment corresponding to a given profile and writes it to out.

func (*SphereHalo) MeanProfile

func (h *SphereHalo) MeanProfile() []float64

MeanProfile computes the mean value of all the halo's LoS profiles.

func (*SphereHalo) MedianProfile

func (h *SphereHalo) MedianProfile() []float64

MedianProfile computes the median value of all the halo's LoS profiles.

func (*SphereHalo) Phi

func (h *SphereHalo) Phi(losIdx int) float64

Phi returns the angle corresponding to the given LoS index.

func (*SphereHalo) PlaneToVolume

func (h *SphereHalo) PlaneToVolume(ring int, px, py float64) (x, y, z float64)

func (*SphereHalo) RMax

func (h *SphereHalo) RMax() float64

func (*SphereHalo) SheetIntersect

func (h *SphereHalo) SheetIntersect(hd *io.SheetHeader) bool

SheetIntersect returns true if the given halo and sheet intersect one another and false otherwise.

func (*SphereHalo) Split

func (h *SphereHalo) Split(hs []SphereHalo)

Split splits the halo h into copies and stores those copies in hs. The total mass stored in h and all those copies is equal to the total mass stored in h.

Used for parallelization. But very expensive.

func (*SphereHalo) Transform

func (h *SphereHalo) Transform(vecs []rgeom.Vec, totalWidth float64)

Transform translates all the given vectors so that they are in the local coordinate system of the halo.

Jump to

Keyboard shortcuts

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