Documentation
¶
Overview ¶
Package ljh provides classes that read or write from the LJH x-ray pulse data file format.
Index ¶
Constants ¶
const BUFIOSIZE = 65536
The buffer size (bytes) of the bufio.Writer that buffers disk output
const FLUSHINTERVAL = 3 * time.Second
Flush the ouputfile regularly at this interval
const WRITECHANCAPACITY = 1000
The capacity of unprocessed pulse records before even the "asynchronous" writes will block.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Header ¶
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 ¶
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 ¶
OpenReader returns an active LJH file reader, or an error.
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 ¶
CreateFile creates a file with filename .FileName and assigns it to .file you can't write records without doing this
func (*Writer) WriteHeader ¶
WriteHeader writes a header to .file, returns err from WriteString
func (*Writer) WriteRecord ¶
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) CreateFile ¶
CreateFile opens the LJH3 file for writing, must be called before wring RecordSlice
func (*Writer3) WriteHeader ¶
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