off

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: NIST-PD-fallback Imports: 8 Imported by: 0

Documentation

Overview

Package off provides classes that write OFF files OFF files store TES pulses projected into a linear basis OFF files have a JSON header followed by a single newline after the header records are written sequentially in little endian format bytes type meaning 0-3 int32 recordSamples (could be calculated from nearest neighbor pulses in princple) 4-7 int32 recordPreSamples (could be calculated from nearest neighbor pulses in princple) 8-15 int64 framecount 16-23 int64 timestamp from time.Time.UnixNano() 24-27 float32 pretriggerMean (from raw data, not from modeled pulse, really shouldn't be neccesary, just in case for now!) 28-31 float32 residualStdDev (in raw data space, not Mahalanobis distance) 32-Z float32 the NumberOfBases model coefficients of the pulse projected in to the model Z = 31+4*NumberOfBases

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayJsoner

type ArrayJsoner struct {
	Rows    int
	Cols    int
	SavedAs string
}

ArrayJsoner aids in formatting arrays for writing to JSON

func NewArrayJsoner

func NewArrayJsoner(array *mat.Dense) *ArrayJsoner

NewArrayJsoner creates an ArrayJsoner from a mat.Dense

type CreationInfo

type CreationInfo struct {
	DastardVersion string
	GitHash        string
	SourceName     string
	CreationTime   time.Time
}

CreationInfo stores info related to file creation for printing to the file header, aids with json formatting

type ModelInfo

type ModelInfo struct {
	Projectors ArrayJsoner

	Basis ArrayJsoner

	Description string
	// contains filtered or unexported fields
}

ModelInfo stores info related to the model (aka basis, aka projectors) for printing to the file header, aids with json formatting

type PixelInfo

type PixelInfo struct {
	XPosition int
	YPosition int
	Name      string
}

type TimeDivisionMultiplexingInfo

type TimeDivisionMultiplexingInfo struct {
	NumberOfRows      int
	NumberOfColumns   int
	NumberOfChans     int
	SubframeDivisions int
	ColumnNum         int
	RowNum            int
	SubframeOffset    int
}

TimeDivisionMultiplexingInfo stores info related to tdm readout for printing to the file header, aids with json formatting

type Writer

type Writer struct {
	ChannelIndex              int
	ChannelName               string
	ChannelNumberMatchingName int
	MaxPresamples             int
	MaxSamples                int
	FramePeriodSeconds        float64
	FileFormat                string
	FileFormatVersion         string
	NumberOfBases             int
	ModelInfo                 ModelInfo
	CreationInfo              CreationInfo
	ReadoutInfo               TimeDivisionMultiplexingInfo
	PixelInfo                 PixelInfo
	// contains filtered or unexported fields
}

Writer writes OFF files

func NewWriter

func NewWriter(fileName string, ChannelIndex int, ChannelName string, ChannelNumberMatchingName int,
	MaxPresamples int, MaxSamples int, FramePeriodSeconds float64,
	Projectors *mat.Dense, Basis *mat.Dense, ModelDescription string,
	DastardVersion string, GitHash string, SourceName string,
	ReadoutInfo TimeDivisionMultiplexingInfo, pixelInfo PixelInfo) *Writer

NewWriter creates a new OFF writer. No file is created until the first call to WriteRecord

func (Writer) Close

func (w Writer) Close()

Close closes the file, it flushes the bufio.Writer first

func (*Writer) CreateFile

func (w *Writer) CreateFile() error

CreateFile creates a file at w.FileName must be called before WriteHeader or WriteRecord

func (Writer) Flush

func (w Writer) Flush()

Flush flushes the write buffer

func (*Writer) HeaderWritten

func (w *Writer) HeaderWritten() bool

HeaderWritten returns true if header has been written.

func (*Writer) RecordsWritten

func (w *Writer) RecordsWritten() int

RecordsWritten return the nunber of records written.

func (*Writer) WriteHeader

func (w *Writer) WriteHeader() error

WriteHeader writes a header to the file

func (*Writer) WriteRecord

func (w *Writer) WriteRecord(recordSamples int32, recordPreSamples int32, framecount int64,
	timestamp int64, pretriggerMean float32, pretriggerDelta float32, residualStdDev float32, data []float32) error

WriteRecord writes a record to the file

Jump to

Keyboard shortcuts

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