ljh

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: 9 Imported by: 0

Documentation

Overview

Package ljh provides classes that read or write from the LJH x-ray pulse data file format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Header struct {
	Frameperiod   float64   `json:"frameperiod"`
	Format        string    `json:"File Format"`
	FormatVersion string    `json:"File Format Version"`
	TDM           HeaderTDM `json:"TDM"`
}

Header is used to format the LJH3 json header

type HeaderTDM

type HeaderTDM struct {
	NumberOfRows      int
	NumberOfColumns   int
	SubframeDivisions int
	Row               int
	Column            int
	SubframeOffset    int
}

HeaderTDM contains info about TDM readout for placing in an LJH3 header

type PulseRecord

type PulseRecord struct {
	TimeCode      int64
	SubframeCount int64
	Pulse         []uint16
}

PulseRecord is the interface for individual pulse records

type Reader

type Reader struct {
	ChannelIndex    int
	Presamples      int
	Samples         int
	VersionNumber   VersionCode
	WordSize        int
	Timebase        float64
	TimestampOffset float64
	// contains filtered or unexported fields
}

Reader is the interface for reading an LJH file

func OpenReader

func OpenReader(fileName string) (r *Reader, err error)

OpenReader returns an active LJH file reader, or an error.

func (*Reader) Close

func (r *Reader) Close() error

Close closes the LJH file reader.

func (*Reader) NextPulse

func (r *Reader) NextPulse() (*PulseRecord, error)

NextPulse returns the next pulse from the open LJH file

type VersionCode

type VersionCode int

VersionCode enumerates the LJH file version numbers.

const (
	VersionInvalid VersionCode = iota
	Version2_1
	Version2_2
)

Enumeration for the LJH file version numbers

type Writer

type Writer struct {
	ChannelIndex              int
	Presamples                int
	Samples                   int
	FramesPerSample           int
	SubframeDivisions         int
	Timebase                  float64
	TimestampOffset           time.Time
	NumberOfRows              int
	NumberOfColumns           int
	NumberOfChans             int
	HeaderWritten             bool
	FileName                  string
	RecordsWritten            int
	DastardVersion            string
	GitHash                   string
	SourceName                string
	ChanName                  string
	ChannelNumberMatchingName int
	ColumnNum                 int
	RowNum                    int
	SubframeOffset            int
	PixelXPosition            int
	PixelYPosition            int
	PixelName                 string
	// contains filtered or unexported fields
}

Writer writes LJH2.2 files

func (Writer) Close

func (w Writer) Close()

Close closes the associated file, no more records can be written after this

func (*Writer) CreateFile

func (w *Writer) CreateFile() error

CreateFile creates a file with filename .FileName and assigns it to .file you can't write records without doing this

func (Writer) Flush

func (w Writer) Flush()

Flush flushes buffered data to disk

func (*Writer) WriteHeader

func (w *Writer) WriteHeader(firstRecord time.Time) error

WriteHeader writes a header to .file, returns err from WriteString

func (*Writer) WriteRecord

func (w *Writer) WriteRecord(framecount int64, timestamp int64, data []uint16) error

WriteRecord writes a single record to the files timestamp should be a posix timestamp in microseconds subframeCount is framecount*subframeDivisions + subframeOffset return error if data is wrong length (w.Samples is correct length)

type Writer3

type Writer3 struct {
	ChannelIndex               int
	ChannelName                string
	ChannelNumberMatchingIndex int
	Timebase                   float64
	NumberOfRows               int
	NumberOfColumns            int
	SubframeDivisions          int
	Row                        int
	Column                     int
	SubframeOffset             int
	HeaderWritten              bool
	FileName                   string
	RecordsWritten             int
	// contains filtered or unexported fields
}

Writer3 writes LJH3.0 files

func (Writer3) Close

func (w Writer3) Close()

Close closes the LJH3 file

func (*Writer3) CreateFile

func (w *Writer3) CreateFile() error

CreateFile opens the LJH3 file for writing, must be called before wring RecordSlice

func (Writer3) Flush

func (w Writer3) Flush()

Flush flushes buffered data to disk

func (*Writer3) WriteHeader

func (w *Writer3) WriteHeader() error

WriteHeader writes a header to the LJH3 file, return error if header already written

func (*Writer3) WriteRecord

func (w *Writer3) WriteRecord(firstRisingSample int32, framecount int64, timestamp int64, data []uint16) error

WriteRecord writes an LJH3 record firstRisingSample is the index in data of the sample after the pretrigger (zero or one indexed?) timestamp is posix timestamp in microseconds since epoch data can be variable length

Jump to

Keyboard shortcuts

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