io

package
v0.0.0-...-b5d641a Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: MIT Imports: 14 Imported by: 13

Documentation

Index

Constants

View Source
const (
	ExampleConvertSnapshotFile = `` /* 1999-byte string literal not displayed */

	ExampleRenderFile = `` /* 2850-byte string literal not displayed */

	ExampleBoxFile = `` /* 554-byte string literal not displayed */

	ExampleBallFile = `` /* 514-byte string literal not displayed */

	ExampleTetraHistFile = `` /* 652-byte string literal not displayed */

)
View Source
const (
	// Endianness used by default when writing catalogs. Catalogs of any
	// endianness can be read.
	DefaultEndiannessFlag int32 = -1
)
View Source
const (
	Version = uint64(2)
)

Variables

This section is empty.

Functions

func EndiannessVersionFlag

func EndiannessVersionFlag(end binary.ByteOrder) uint64

func ReadGadgetParticlesAt

func ReadGadgetParticlesAt(
	path string,
	order binary.ByteOrder,
	xs, vs []geom.Vec,
	ids []int64,
	idSize int,
	variant string,
)

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.

func ReadGrid

func ReadGrid(fname string) ([]float64, error)

func ReadSheetHeaderAt

func ReadSheetHeaderAt(file string, hdBuf *SheetHeader) error

ReadHeaderAt reads the header in the given file into the target Header.

func ReadSheetPositionsAt

func ReadSheetPositionsAt(file string, xsBuf []geom.Vec) error

ReadPositionsAt reads the velocities in the given file into a buffer.

func ReadSheetVelocitiesAt

func ReadSheetVelocitiesAt(file string, vsBuf []geom.Vec) error

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

func (*BallConfig) CheckInit

func (ball *BallConfig) CheckInit(name string, totalWidth float64) error

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 ReadBoundsConfig(fname string, totalWidth float64) ([]BoxConfig, error)

func (*BoxConfig) CheckInit

func (box *BoxConfig) CheckInit(name string, totalWidth float64) error

func (*BoxConfig) IsProjection

func (box *BoxConfig) IsProjection() bool

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. This serves as a standardized version of the different header formats.

func ReadGadget

func ReadGadget(
	path string, order binary.ByteOrder, idSize int, variant string,
) (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, variant string) *CatalogHeader

ReadGadgetHeader reads a Gadget catalog and returns a standardized gotetra containing its information. variant is a string that specifies which of the Gadget-2 variants is being used. Currently supported: "LGadget-2" and "Arepo-type-2".

type ConvertSnapshotConfig

type ConvertSnapshotConfig struct {
	SharedConfig
	// Required
	Cells         int
	Gadget2IDSize int
	InputFormat   string

	// Optional
	IteratedInput, IteratedOutput string
	IterationStart, IterationEnd  int
	XUnits, VUnits, MUnits        float64
}

func (*ConvertSnapshotConfig) ValidCells

func (con *ConvertSnapshotConfig) ValidCells() bool

func (*ConvertSnapshotConfig) ValidGadget2IDSize

func (con *ConvertSnapshotConfig) ValidGadget2IDSize() 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

func NewCosmoInfo(H0, omegaM, omegaL, z, boxWidth float64) CosmoInfo

type CosmologyHeader

type CosmologyHeader struct {
	Z      float64
	OmegaM float64
	OmegaL float64
	H100   float64
}

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 IntVector

type IntVector [3]int64

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 {
	SharedConfig

	// 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 {
	// Required
	Input, Output string
	// Optional
	LogFile, ProfileFile string
}

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

CellBounds returns the bounds of a given sheet aligned to the boundaries of the voxels with a given granularity.

type TetraHistConfig

type TetraHistConfig struct {
	SharedConfig

	Quantity string

	HistMin, HistMax float64
	HistBins         int
	HistScale        string

	Particles int

	SubsampleLength int

	GridFile                string
	AppendName, PrependName string
}

func (*TetraHistConfig) ValidGridFile

func (con *TetraHistConfig) ValidGridFile() bool

func (*TetraHistConfig) ValidHistBins

func (con *TetraHistConfig) ValidHistBins() bool

func (*TetraHistConfig) ValidHistMax

func (con *TetraHistConfig) ValidHistMax() bool

func (*TetraHistConfig) ValidHistMin

func (con *TetraHistConfig) ValidHistMin() bool

func (*TetraHistConfig) ValidHistScale

func (con *TetraHistConfig) ValidHistScale() bool

func (*TetraHistConfig) ValidInput

func (con *TetraHistConfig) ValidInput() bool

func (*TetraHistConfig) ValidOutput

func (con *TetraHistConfig) ValidOutput() bool

func (*TetraHistConfig) ValidQuantity

func (con *TetraHistConfig) ValidQuantity() bool

func (*TetraHistConfig) ValidSubsampleLength

func (con *TetraHistConfig) ValidSubsampleLength() bool

type TetraHistWrapper

type TetraHistWrapper struct {
	TetraHist TetraHistConfig
}

func DefaultTetraHistWrapper

func DefaultTetraHistWrapper() *TetraHistWrapper

type TypeInfo

type TypeInfo struct {
	HeaderSize   int64
	GridType     int64
	IsVectorGrid int64
}

type Vector

type Vector [3]float64

Jump to

Keyboard shortcuts

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