Documentation ¶
Index ¶
- Constants
- func EndiannessVersionFlag(end binary.ByteOrder) uint64
- func ReadGadgetParticlesAt(path string, order binary.ByteOrder, xs, vs []geom.Vec, ids []int64)
- func ReadGrid(fname string) ([]float64, error)
- func ReadSheetHeaderAt(file string, hdBuf *SheetHeader) error
- func ReadSheetPositionsAt(file string, xsBuf []geom.Vec) error
- func ReadSheetVelocitiesAt(file string, vsBuf []geom.Vec) error
- func WriteBuffer(buf density.Buffer, cosmo CosmoInfo, render RenderInfo, loc LocationInfo, ...)
- func WriteSheet(file string, h *SheetHeader, xs, vs []geom.Vec)
- type BallConfig
- type BoundsConfig
- type BoxConfig
- type CatalogHeader
- type ConvertSnapshotConfig
- func (con *ConvertSnapshotConfig) ValidCells() bool
- func (con *ConvertSnapshotConfig) ValidInputFormat() bool
- func (con *ConvertSnapshotConfig) ValidIteratedInput() bool
- func (con *ConvertSnapshotConfig) ValidIteratedOutput() bool
- func (con *ConvertSnapshotConfig) ValidIterationEnd() bool
- func (con *ConvertSnapshotConfig) ValidIterationStart() bool
- type ConvertSnapshotWrapper
- type CosmoInfo
- type CosmologyHeader
- type GridHeader
- type IntVector
- type LocationInfo
- type Particle
- type ParticleBuffer
- type RenderConfig
- type RenderInfo
- type RenderWrapper
- type SharedConfig
- type SheetHeader
- type TypeInfo
- type Vector
Constants ¶
const ( ExampleConvertSnapshotFile = `` /* 630-byte string literal not displayed */ ExampleRenderFile = `` /* 1477-byte string literal not displayed */ ExampleBoundsFile = `` /* 602-byte string literal not displayed */ )
const ( // Endianness used by default when writing catalogs. Catalogs of any // endianness can be read. DefaultEndiannessFlag int32 = -1 )
const (
Version = uint64(2)
)
Variables ¶
This section is empty.
Functions ¶
func EndiannessVersionFlag ¶
func ReadGadgetParticlesAt ¶
ReadGadgetParticlesAt reads a Gadget file and writes all the particles within it to the given particle buffer, ps. floatBuf and intBuf are used internally. The length of all three buffers must be equal to the number of particles in the catalog.
This call signature, and espeically the Particle type are all a consequence of soem shockingly poor early design decisions.
func ReadSheetHeaderAt ¶
func ReadSheetHeaderAt(file string, hdBuf *SheetHeader) error
ReadHeaderAt reads the header in the given file into the target Header.
func ReadSheetPositionsAt ¶
ReadPositionsAt reads the velocities in the given file into a buffer.
func ReadSheetVelocitiesAt ¶
ReadVelocitiesAt reads the velocities in the given file into a buffer.
func WriteBuffer ¶
func WriteBuffer( buf density.Buffer, cosmo CosmoInfo, render RenderInfo, loc LocationInfo, wr io.Writer, )
func WriteSheet ¶
func WriteSheet(file string, h *SheetHeader, xs, vs []geom.Vec)
Write writes a grid of position and velocity vectors to a file, defined by the given header.
Types ¶
type BallConfig ¶
type BallConfig struct {
// Required
X, Y, Z, Radius float64
// Optional
RadiusMultiplier float64
Name string
}
func (*BallConfig) Box ¶
func (ball *BallConfig) Box(totalWidth float64) *BoxConfig
type BoundsConfig ¶
type BoundsConfig struct { Ball map[string]*BallConfig Box map[string]*BoxConfig }
type BoxConfig ¶
type BoxConfig struct { // Required X, Y, Z float64 XWidth, YWidth, ZWidth float64 // Optional ProjectionAxis string // Optional, "undocumented" Name string }
func ReadBoundsConfig ¶
func (*BoxConfig) IsProjection ¶
type CatalogHeader ¶
type CatalogHeader struct { Cosmo CosmologyHeader Mass float64 // Mass of one particle Count int64 // Number of particles in catalog TotalCount int64 // Number of particles in all catalogs CountWidth int64 // Number of particles "on one side": TotalCount^(1/3) Idx int64 // Index of catalog: x-major ordering is used GridWidth int64 // Number of gird cells "on one side" Width float64 // Width of the catalog's bounding box TotalWidth float64 // Width of the sim's bounding box }
CatalogHeader describes meta-information about the current catalog.
func ReadGadget ¶
func ReadGadget( path string, order binary.ByteOrder, ) (hd *CatalogHeader, xs, vs []geom.Vec, ids []int64)
ReadGadget reads the gadget particle catalog located at the given location and written with the given endianness. Its header and particle sequence are returned in a standardized format.
func ReadGadgetHeader ¶
func ReadGadgetHeader(path string, order binary.ByteOrder) *CatalogHeader
ReadGadgetHeader reads a Gadget catalog and returns a standardized gotetra containing its information.
type ConvertSnapshotConfig ¶
type ConvertSnapshotConfig struct { // Required Cells int InputFormat string // Optional IteratedInput, IteratedOutput string IterationStart, IterationEnd int }
func (*ConvertSnapshotConfig) ValidCells ¶
func (con *ConvertSnapshotConfig) ValidCells() bool
func (*ConvertSnapshotConfig) ValidInputFormat ¶
func (con *ConvertSnapshotConfig) ValidInputFormat() bool
func (*ConvertSnapshotConfig) ValidIteratedInput ¶
func (con *ConvertSnapshotConfig) ValidIteratedInput() bool
func (*ConvertSnapshotConfig) ValidIteratedOutput ¶
func (con *ConvertSnapshotConfig) ValidIteratedOutput() bool
func (*ConvertSnapshotConfig) ValidIterationEnd ¶
func (con *ConvertSnapshotConfig) ValidIterationEnd() bool
func (*ConvertSnapshotConfig) ValidIterationStart ¶
func (con *ConvertSnapshotConfig) ValidIterationStart() bool
type ConvertSnapshotWrapper ¶
type ConvertSnapshotWrapper struct {
ConvertSnapshot ConvertSnapshotConfig
}
func DefaultConvertSnapshotWrapper ¶
func DefaultConvertSnapshotWrapper() *ConvertSnapshotWrapper
type CosmoInfo ¶
type CosmoInfo struct {
Redshift, ScaleFactor float64
OmegaM, OmegaL, Hubble float64
RhoMean, RhoCritical float64
BoxWidth float64
}
func NewCosmoInfo ¶
type CosmologyHeader ¶
CosmologyHeader contains information describing the cosmological context in which the simulation was run.
type GridHeader ¶
type GridHeader struct { EndiannessVersion uint64 Type TypeInfo Cosmo CosmoInfo Render RenderInfo Loc LocationInfo Vel LocationInfo }
func ReadGridHeader ¶
func ReadGridHeader(fname string) (*GridHeader, error)
type LocationInfo ¶
type LocationInfo struct {
Origin, Span Vector
PixelOrigin, PixelSpan IntVector
PixelWidth float64
}
func NewLocationInfo ¶
func NewLocationInfo(origin, span [3]int, cellWidth float64) LocationInfo
type ParticleBuffer ¶
type ParticleBuffer struct {
// contains filtered or unexported fields
}
ParticleBuffer is a wrapper around catalog files which allows floats to be appended to files on the fly without much overhead from I/O or without excessive memory usage/reallocating.
func NewParticleBuffer ¶
func NewParticleBuffer(xs, vs []geom.Vec, bufSize int) *ParticleBuffer
NewParticleBuffer creates a ParticleBuffer associated with the given file.
func (*ParticleBuffer) Append ¶
func (pb *ParticleBuffer) Append(xBuf, vBuf []geom.Vec, idBuf []int64)
Append adds a value to the float buffer, which will eventually be written to the target file.
func (*ParticleBuffer) Flush ¶
func (pb *ParticleBuffer) Flush()
Flush writes the contents of the buffer to its target file. This will be called automatically whenever the buffer fills.
type RenderConfig ¶
type RenderConfig struct { // Required Quantity string TotalPixels, Particles int // Optional AutoParticles bool ImagePixels, ProjectionDepth int SubsampleLength int AppendName, PrependName string }
func (*RenderConfig) ValidImagePixels ¶
func (con *RenderConfig) ValidImagePixels() bool
func (*RenderConfig) ValidParticles ¶
func (con *RenderConfig) ValidParticles() bool
func (*RenderConfig) ValidProjectionDepth ¶
func (con *RenderConfig) ValidProjectionDepth() bool
func (*RenderConfig) ValidQuantity ¶
func (b *RenderConfig) ValidQuantity() bool
func (*RenderConfig) ValidSubsampleLength ¶
func (con *RenderConfig) ValidSubsampleLength() bool
func (*RenderConfig) ValidTotalPixels ¶
func (con *RenderConfig) ValidTotalPixels() bool
type RenderInfo ¶
type RenderInfo struct { Particles int64 TotalPixels int64 SubsampleLength int64 MinProjectionDepth int64 ProjectionAxis int64 }
func NewRenderInfo ¶
func NewRenderInfo(particles, totalCells, skip int, axisStr string) RenderInfo
type RenderWrapper ¶
type RenderWrapper struct {
Render RenderConfig
}
func DefaultRenderWrapper ¶
func DefaultRenderWrapper() *RenderWrapper
type SharedConfig ¶
type SharedConfig struct {
func (*SharedConfig) ValidInput ¶
func (con *SharedConfig) ValidInput() bool
func (*SharedConfig) ValidLogFile ¶
func (con *SharedConfig) ValidLogFile() bool
func (*SharedConfig) ValidOutput ¶
func (con *SharedConfig) ValidOutput() bool
func (*SharedConfig) ValidProfileFile ¶
func (con *SharedConfig) ValidProfileFile() bool
type SheetHeader ¶
type SheetHeader struct { Cosmo CosmologyHeader Count, CountWidth int64 SegmentWidth, GridWidth, GridCount int64 // GridWidth = SegmentWidth + 1 Idx, Cells int64 Mass float64 TotalWidth float64 Origin, Width geom.Vec VelocityOrigin, VelocityWidth geom.Vec }
The binary format used for phase sheets is as follows:
|-- 1 --||-- 2 --||-- ... 3 ... --||-- ... 4 ... --||-- ... 5 ... --| 1 - (int32) Flag indicating the endianness of the file. 0 indicates a big endian byte ordering and -1 indicates a little endian byte order. 2 - (int32) Size of a Header struct. Should be checked for consistency. 3 - (sheet.Header) Header file containing meta-information about the sheet fragment. 4 - ([][3]float32) Contiguous block of x, y, z coordinates. Given in Mpc. 5 - ([][3]float32) Contiguous block of v_x, v_y, v_z coordinates.
func (*SheetHeader) CellBounds ¶
func (hd *SheetHeader) CellBounds(cells int) *geom.CellBounds