data_representation

package
v0.4.14 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntFromBytes added in v0.4.0

func IntFromBytes(b []byte) int

IntFromBytes converts an arbitrary length byte slice into an int using sign-and-magnitude encoding.

func UintFromBytes added in v0.4.0

func UintFromBytes(b []byte) int

UintFromBytes converts an arbitrary length byte slice into an unsigned integer.

Types

type BitStream added in v0.4.0

type BitStream struct {
	// contains filtered or unexported fields
}

BitStream is used for reading bits from a byte slice and decoding them into values.

func NewBitStream added in v0.4.0

func NewBitStream(data []byte) *BitStream

NewBitStream instantiates a new BitStream for the given byte slice.

func (*BitStream) Pos added in v0.4.0

func (b *BitStream) Pos() int

Pos returns the current bit position in the stream.

func (*BitStream) ReadBits added in v0.4.0

func (b *BitStream) ReadBits(n int) uint64

ReadBits reads n bits from the stream and returns them as a uint64.

func (*BitStream) ReadSignedBits added in v0.4.0

func (b *BitStream) ReadSignedBits(n int) int64

ReadSignedBits reads n bits from the stream and returns them as an int64.

type BitmapReader added in v0.2.3

type BitmapReader struct {
	// contains filtered or unexported fields
}

BitmapReader is used to read the bitmap section of a GRIB record. The bitmap section is used to determine which values are missing.

func NewBitmapReader added in v0.2.3

func NewBitmapReader(rec record.Record) *BitmapReader

NewBitmapReader instantiates a new BitmapReader from the given record.

func (*BitmapReader) IsMissing added in v0.4.0

func (r *BitmapReader) IsMissing(index int) bool

IsMissing returns true if the value at the given index is missing.

type ComplexParams added in v0.4.0

type ComplexParams struct {
	TotalPoints              int
	DataPoints               int
	Order                    int
	SpatialOctets            int
	NG                       int
	BitsPerGroup             int
	BitsPerGroupWidth        int
	BitsPerScaledGroupLength int
	GroupWidthReference      int
	GroupLengthReference     int
	GroupLengthIncrement     int
	LastGroupLength          int
	Ref                      float64
	BinaryScale              int
	DecimalScale             int
	MissingValueManagement   int
	PrimaryMissingValue      float64
	SecondaryMissingValue    float64
	Bitmap                   *BitmapReader
}

ComplexParams contains the parameters needed for unpacking complex data, including spatially processed complex data.

func (*ComplexParams) UnpackComplex added in v0.4.0

func (p *ComplexParams) UnpackComplex(packedData []byte) ([]float64, error)

UnpackComplex unpacks the provided byte slice into a slice of float64 values.

Note: the wgrib2 C codebase on GitHub was especially useful in compiling the logic, in addition to the GRIB2 reference documents hosted by NCEP and the regulations hosted by ECWMF.

func (*ComplexParams) UnpackComplexIterator added in v0.4.9

func (p *ComplexParams) UnpackComplexIterator(packedData []byte) (iter.Seq2[int, float64], error)

type Template0

type Template0 struct {
	ReferenceValue     float64
	BinaryScaleFactor  int
	DecimalScaleFactor int
	BitsPerValue       int
	OriginalFieldType  int
}

Template0 contains the fields for Grid Point Data - Simple Packing

func (Template0) DecimalScale added in v0.4.1

func (t Template0) DecimalScale() int

DecimalScale returns the decimal scale factor of the record. The decimal scale factor is used to shift the decimal point of a decoded value to the correct position.

func (Template0) GetValues

func (t Template0) GetValues(rec record.Record) ([]float64, error)

GetValues unpacks the record's data into the original values

func (Template0) Parse

Parse fills in the template from the provided section

func (Template0) ValuesIterator added in v0.4.9

func (t Template0) ValuesIterator(rec record.Record) (iter.Seq2[int, float64], error)

type Template2 added in v0.4.0

type Template2 struct {
	ReferenceValue                 float64
	BinaryScaleFactor              int
	DecimalScaleFactor             int
	BitsPerGroup                   int
	OriginalFieldType              int
	GroupSplittingMethod           int
	MissingValueManagement         int
	PrimaryMissingValue            int
	SecondaryMissingValue          int
	TotalGroups                    int
	GroupWidthReference            int
	BitsUsedForGroupWidths         int
	GroupLengthReference           int
	LengthIncrementForGroupLengths int
	LastGroupLength                int
	BitsUsedForScaledGroupLengths  int
}

Template2 contains the fields for Grid Point Data - Complex Packing

func (Template2) DecimalScale added in v0.4.1

func (t Template2) DecimalScale() int

DecimalScale returns the decimal scale factor of the record. The decimal scale factor is used to shift the decimal point of a decoded value to the correct position.

func (Template2) GetValues added in v0.4.0

func (t Template2) GetValues(rec record.Record) ([]float64, error)

GetValues unpacks the record's data into the original values

func (Template2) Parse added in v0.4.0

Parse fills in the template from the provided section

func (Template2) ValuesIterator added in v0.4.9

func (t Template2) ValuesIterator(rec record.Record) (iter.Seq2[int, float64], error)

type Template3

type Template3 struct {
	ReferenceValue                 float64
	BinaryScaleFactor              int
	DecimalScaleFactor             int
	BitsPerGroup                   int
	OriginalFieldType              int
	GroupSplittingMethod           int
	MissingValueManagement         int
	PrimaryMissingValue            int
	SecondaryMissingValue          int
	TotalGroups                    int
	GroupWidthReference            int
	BitsUsedForGroupWidths         int
	GroupLengthReference           int
	LengthIncrementForGroupLengths int
	LastGroupLength                int
	BitsUsedForScaledGroupLengths  int
	SpatialDifferenceOrder         int
	TotalSpatialDifferencingOctets int
}

Template3 contains the fields for Grid Point Data - Complex Packing and Spatial Differencing

func (Template3) DecimalScale added in v0.4.1

func (t Template3) DecimalScale() int

DecimalScale returns the decimal scale factor of the record. The decimal scale factor is used to shift the decimal point of a decoded value to the correct position.

func (Template3) GetValues

func (t Template3) GetValues(rec record.Record) ([]float64, error)

GetValues unpacks the record's data into the original values

func (Template3) Parse

Parse fills in the template from the provided section

func (Template3) ValuesIterator added in v0.4.9

func (t Template3) ValuesIterator(rec record.Record) (iter.Seq2[int, float64], error)

type Template4 added in v0.4.5

type Template4 struct {
	Precision int
}

Template4 contains the fields for Grid Point Data - IEEE Floating Point Data

func (Template4) DecimalScale added in v0.4.5

func (t Template4) DecimalScale() int

DecimalScale returns the decimal scale factor of the record. The decimal scale factor is used to shift the decimal point of a decoded value to the correct position.

func (Template4) GetValues added in v0.4.5

func (t Template4) GetValues(rec record.Record) ([]float64, error)

GetValues unpacks the record's data into the original values

func (Template4) Parse added in v0.4.5

Parse fills in the template from the provided section

func (Template4) ValuesIterator added in v0.4.9

func (t Template4) ValuesIterator(rec record.Record) (iter.Seq2[int, float64], error)

type Template40 added in v0.2.3

type Template40 struct {
	ReferenceValue         float32
	BinaryScaleFactor      int
	DecimalScaleFactor     int
	BitDepth               int
	OriginalFieldType      int
	CompressionType        int
	TargetCompressionRatio int
}

Template40 contains the fields for Grid point data - JPEG 2000 code stream format

func (Template40) DecimalScale added in v0.4.1

func (t Template40) DecimalScale() int

DecimalScale returns the decimal scale factor of the record. The decimal scale factor is used to shift the decimal point of a decoded value to the correct position.

func (Template40) GetValues added in v0.2.3

func (t Template40) GetValues(rec record.Record) ([]float64, error)

GetValues unpacks the record's data into the original values

func (Template40) Parse added in v0.2.3

Parse fills in the template from the provided section

func (Template40) ValuesIterator added in v0.4.9

func (t Template40) ValuesIterator(_ record.Record) (iter.Seq2[int, float64], error)

type Template41 added in v0.2.6

type Template41 struct {
	ReferenceValue     float64
	BinaryScaleFactor  int
	DecimalScaleFactor int
	BitDepth           int
	OriginalFieldType  int
}

Template41 contains the fields for Grid point data - Portable Network Graphics (PNG)

func (Template41) DecimalScale added in v0.4.1

func (t Template41) DecimalScale() int

DecimalScale returns the decimal scale factor of the record. The decimal scale factor is used to shift the decimal point of a decoded value to the correct position.

func (Template41) GetValues added in v0.2.6

func (t Template41) GetValues(rec record.Record) ([]float64, error)

GetValues unpacks the record's data into the original values

func (Template41) Parse added in v0.2.6

Parse fills in the template from the provided section

func (Template41) ValuesIterator added in v0.4.9

func (t Template41) ValuesIterator(rec record.Record) (iter.Seq2[int, float64], error)

Jump to

Keyboard shortcuts

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