netcdf

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package netcdf is a Go binding for the netCDF C library.

This package supports netCDF version 3, and 4 if netCDF 4 support is enabled in the C library. The C library interface used is documented here: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c/

Example
package main

import (
	"fmt"
	"log"

	"github.com/CrapsJeroen/go-netcdf/netcdf"
)

// CreateExampleFile creates an example NetCDF file containing only one variable.
func CreateExampleFile(filename string) error {
	// Create a new NetCDF 4 file. The dataset is returned.
	ds, err := netcdf.CreateFile("gopher.nc", netcdf.CLOBBER|netcdf.NETCDF4)
	if err != nil {
		return err
	}
	defer ds.Close()

	// Add the dimensions for our data to the dataset
	dims := make([]netcdf.Dim, 2)
	ht, wd := 5, 4
	dims[0], err = ds.AddDim("height", uint64(ht))
	if err != nil {
		return err
	}
	dims[1], err = ds.AddDim("width", uint64(wd))
	if err != nil {
		return err
	}

	// Add the variable to the dataset that will store our data
	v, err := ds.AddVar("gopher", netcdf.UBYTE, dims)
	if err != nil {
		return err
	}

	// Add a _FillValue to the variable's attributes
	// From C++ netCDF documentation:
	//   With netCDF-4 files, nc_put_att will notice if you are writing a _FillValue attribute,
	//   and will tell the HDF5 layer to use the specified fill value for that variable. With
	//   either classic or netCDF-4 files, a _FillValue attribute will be checked for validity,
	//   to make sure it has only one value and that its type matches the type of the associated
	//   variable.
	if err := v.Attr("_FillValue").WriteUint8s([]uint8{255}); err != nil {
		return err
	}

	// Add an attribute to the variable
	if err := v.Attr("year").WriteInt32s([]int32{2012}); err != nil {
		return err
	}

	// Create the data with the above dimensions and write it to the file.
	gopher := make([]uint8, ht*wd)
	i := 0
	for y := 0; y < ht; y++ {
		for x := 0; x < wd; x++ {
			gopher[i] = uint8(x + y)
			i++
		}
	}
	return v.WriteUint8s(gopher)
}

// ReadExampleFile reads the data in NetCDF file at filename and prints it out.
func ReadExampleFile(filename string) error {
	// Open example file in read-only mode. The dataset is returned.
	ds, err := netcdf.OpenFile(filename, netcdf.NOWRITE)
	if err != nil {
		return err
	}
	defer ds.Close()

	// Get the variable containing our data and read the data from the variable.
	v, err := ds.Var("gopher")
	if err != nil {
		return err
	}

	// Print variable attribute
	year, err := netcdf.GetInt32s(v.Attr("year"))
	if err != nil {
		return err
	}
	fmt.Printf("year = %v\n", year[0])

	// Read data from variable
	gopher, err := netcdf.GetUint8s(v)
	if err != nil {
		return err
	}

	// Get the length of the dimensions of the data.
	dims, err := v.LenDims()
	if err != nil {
		return err
	}

	// Print out the data
	i := 0
	for y := 0; y < int(dims[0]); y++ {
		for x := 0; x < int(dims[1]); x++ {
			fmt.Printf(" %d", gopher[i])
			i++
		}
		fmt.Printf("\n")
	}
	return nil
}

func main() {
	// Create example file
	filename := "gopher.nc"
	if err := CreateExampleFile(filename); err != nil {
		log.Fatalf("creating example file failed: %v\n", err)
	}

	// Open and read example file
	if err := ReadExampleFile(filename); err != nil {
		log.Fatalf("reading example file failed: %v\n", err)
	}

}
Output:

 year = 2012
 0 1 2 3
 1 2 3 4
 2 3 4 5
 3 4 5 6
 4 5 6 7

Index

Examples

Constants

View Source
const (
	NC_UNLIMITED uint64 = C.NC_UNLIMITED
)

Unlimited size for dimension

Variables

This section is empty.

Functions

func GetBytes

func GetBytes(r BytesReader) (data []byte, err error)

GetBytes reads the entire data in r and returns it.

func GetFloat32s

func GetFloat32s(r Float32sReader) (data []float32, err error)

GetFloat32s reads the entire data in r and returns it.

func GetFloat64s

func GetFloat64s(r Float64sReader) (data []float64, err error)

GetFloat64s reads the entire data in r and returns it.

func GetInt16s

func GetInt16s(r Int16sReader) (data []int16, err error)

GetInt16s reads the entire data in r and returns it.

func GetInt32s

func GetInt32s(r Int32sReader) (data []int32, err error)

GetInt32s reads the entire data in r and returns it.

func GetInt64s

func GetInt64s(r Int64sReader) (data []int64, err error)

GetInt64s reads the entire data in r and returns it.

func GetInt8s

func GetInt8s(r Int8sReader) (data []int8, err error)

GetInt8s reads the entire data in r and returns it.

func GetUint16s

func GetUint16s(r Uint16sReader) (data []uint16, err error)

GetUint16s reads the entire data in r and returns it.

func GetUint32s

func GetUint32s(r Uint32sReader) (data []uint32, err error)

GetUint32s reads the entire data in r and returns it.

func GetUint64s

func GetUint64s(r Uint64sReader) (data []uint64, err error)

GetUint64s reads the entire data in r and returns it.

func GetUint8s

func GetUint8s(r Uint8sReader) (data []uint8, err error)

GetUint8s reads the entire data in r and returns it.

func UnravelIndex

func UnravelIndex(idx uint64, shape []uint64) ([]uint64, error)

UnravelIndex calculates coordinate position based on index

func Version

func Version() string

Version returns a string identifying the version of the netCDF library, and when it was built.

Types

type Attr

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

Attr represents an attribute associated with a variable.

func (Attr) Len

func (a Attr) Len() (n uint64, err error)

Len returns the length of the attribute value.

func (Attr) Name

func (a Attr) Name() string

Name returns the name of attribute a.

func (Attr) ReadBytes

func (a Attr) ReadBytes(val []byte) (err error)

ReadBytes reads the entire attribute value into val.

func (Attr) ReadFloat32s

func (a Attr) ReadFloat32s(val []float32) (err error)

ReadFloat32s reads the entire attribute value into val.

func (Attr) ReadFloat64s

func (a Attr) ReadFloat64s(val []float64) (err error)

ReadFloat64s reads the entire attribute value into val.

func (Attr) ReadInt16s

func (a Attr) ReadInt16s(val []int16) (err error)

ReadInt16s reads the entire attribute value into val.

func (Attr) ReadInt32s

func (a Attr) ReadInt32s(val []int32) (err error)

ReadInt32s reads the entire attribute value into val.

func (Attr) ReadInt64s

func (a Attr) ReadInt64s(val []int64) (err error)

ReadInt64s reads the entire attribute value into val.

func (Attr) ReadInt8s

func (a Attr) ReadInt8s(val []int8) (err error)

ReadInt8s reads the entire attribute value into val.

func (Attr) ReadUint16s

func (a Attr) ReadUint16s(val []uint16) (err error)

ReadUint16s reads the entire attribute value into val.

func (Attr) ReadUint32s

func (a Attr) ReadUint32s(val []uint32) (err error)

ReadUint32s reads the entire attribute value into val.

func (Attr) ReadUint64s

func (a Attr) ReadUint64s(val []uint64) (err error)

ReadUint64s reads the entire attribute value into val.

func (Attr) ReadUint8s

func (a Attr) ReadUint8s(val []uint8) (err error)

ReadUint8s reads the entire attribute value into val.

func (Attr) Type

func (a Attr) Type() (t Type, err error)

Type returns the data type of attribute a.

func (Attr) WriteBytes

func (a Attr) WriteBytes(val []byte) error

WriteBytes sets the value of attribute a to val.

func (Attr) WriteFloat32s

func (a Attr) WriteFloat32s(val []float32) error

WriteFloat32s sets the value of attribute a to val.

func (Attr) WriteFloat64s

func (a Attr) WriteFloat64s(val []float64) error

WriteFloat64s sets the value of attribute a to val.

func (Attr) WriteInt16s

func (a Attr) WriteInt16s(val []int16) error

WriteInt16s sets the value of attribute a to val.

func (Attr) WriteInt32s

func (a Attr) WriteInt32s(val []int32) error

WriteInt32s sets the value of attribute a to val.

func (Attr) WriteInt64s

func (a Attr) WriteInt64s(val []int64) error

WriteInt64s sets the value of attribute a to val.

func (Attr) WriteInt8s

func (a Attr) WriteInt8s(val []int8) error

WriteInt8s sets the value of attribute a to val.

func (Attr) WriteUint16s

func (a Attr) WriteUint16s(val []uint16) error

WriteUint16s sets the value of attribute a to val.

func (Attr) WriteUint32s

func (a Attr) WriteUint32s(val []uint32) error

WriteUint32s sets the value of attribute a to val.

func (Attr) WriteUint64s

func (a Attr) WriteUint64s(val []uint64) error

WriteUint64s sets the value of attribute a to val.

func (Attr) WriteUint8s

func (a Attr) WriteUint8s(val []uint8) error

WriteUint8s sets the value of attribute a to val.

type BytesReader

type BytesReader interface {
	Len() (n uint64, err error)
	ReadBytes(val []byte) (err error)
}

BytesReader is a interface that allows reading a sequence of values of fixed length.

type Dataset

type Dataset C.int

Dataset represents a netCDF dataset.

func CreateFile

func CreateFile(path string, mode FileMode) (ds Dataset, err error)

CreateFile creates a new netCDF dataset. Mode is a bitwise-or of FileMode values.

func OpenFile

func OpenFile(path string, mode FileMode) (ds Dataset, err error)

OpenFile opens an existing netCDF dataset file at path. Mode is a bitwise-or of FileMode values.

func (Dataset) AddDim

func (ds Dataset) AddDim(name string, len uint64) (d Dim, err error)

AddDim adds a new dimension named name of length len. The new dimension d is returned.

func (Dataset) AddVar

func (ds Dataset) AddVar(name string, t Type, dims []Dim) (v Var, err error)

AddVar adds a new a variable named name of type t and dimensions dims. The new variable v is returned.

func (Dataset) Attr

func (ds Dataset) Attr(name string) (a Attr)

Attr returns global attribute named name. If the attribute does not yet exist, it'll be created once it's written.

func (Dataset) AttrN

func (ds Dataset) AttrN(n int) (a Attr, err error)

AttrN returns global attribute for attribute number n.

func (Dataset) Close

func (ds Dataset) Close() (err error)

Close closes an open netCDF dataset.

func (Dataset) Dim

func (ds Dataset) Dim(name string) (d Dim, err error)

Dim returns the Dim for the dimension named name.

func (Dataset) EndDef

func (ds Dataset) EndDef() (err error)

EndDef leaves define mode and enters data mode, so variable data can be read or written. Calling this method is not required for netCDF-4 files.

func (Dataset) NAttrs

func (ds Dataset) NAttrs() (n int, err error)

NAttrs returns the number of global attributes defined for dataset f.

func (Dataset) NVars

func (ds Dataset) NVars() (n int, err error)

NVars returns the number of variables defined for dataset f.

func (Dataset) Sync

func (ds Dataset) Sync() error

Sync and flush the current dataset to file. Need to run in a mutex world

func (Dataset) Var

func (ds Dataset) Var(name string) (v Var, err error)

Var returns the Var for the variable named name.

func (Dataset) VarN

func (ds Dataset) VarN(id int) Var

VarN returns a new variable in File f with ID id.

type Dim

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

Dim represents a dimension.

func (Dim) Len

func (d Dim) Len() (n uint64, err error)

Len returns the length of dimension d.

func (Dim) Name

func (d Dim) Name() (name string, err error)

Name returns the name of dimension d.

type Error

type Error C.int

Error represents an error returned by netCDF C library.

func (Error) Error

func (e Error) Error() string

Error returns a string representation of Error e.

type FileMode

type FileMode C.int

FileMode represents a file's mode.

const (
	NOWRITE FileMode = C.NC_NOWRITE // set read-only access
	WRITE   FileMode = C.NC_WRITE   // set read-write access
)

File modes for Open

const (
	CLOBBER       FileMode = C.NC_CLOBBER       // destroy existing file
	NOCLOBBER     FileMode = C.NC_NOCLOBBER     // don't destroy existing file
	CLASSIC_MODEL FileMode = C.NC_CLASSIC_MODEL // enforce classic model
	NETCDF4       FileMode = C.NC_NETCDF4       // use netCDF-4/HDF5 format
	OFFSET_64BIT  FileMode = C.NC_64BIT_OFFSET  // use large (64-bit) file offsets
)

File modes for Create

const (
	SHARE FileMode = C.NC_SHARE // share updates, limit cacheing
)

File modes for Open or Create

type Float32sReader

type Float32sReader interface {
	Len() (n uint64, err error)
	ReadFloat32s(val []float32) (err error)
}

Float32sReader is a interface that allows reading a sequence of values of fixed length.

type Float64sReader

type Float64sReader interface {
	Len() (n uint64, err error)
	ReadFloat64s(val []float64) (err error)
}

Float64sReader is a interface that allows reading a sequence of values of fixed length.

type Int16sReader

type Int16sReader interface {
	Len() (n uint64, err error)
	ReadInt16s(val []int16) (err error)
}

Int16sReader is a interface that allows reading a sequence of values of fixed length.

type Int32sReader

type Int32sReader interface {
	Len() (n uint64, err error)
	ReadInt32s(val []int32) (err error)
}

Int32sReader is a interface that allows reading a sequence of values of fixed length.

type Int64sReader

type Int64sReader interface {
	Len() (n uint64, err error)
	ReadInt64s(val []int64) (err error)
}

Int64sReader is a interface that allows reading a sequence of values of fixed length.

type Int8sReader

type Int8sReader interface {
	Len() (n uint64, err error)
	ReadInt8s(val []int8) (err error)
}

Int8sReader is a interface that allows reading a sequence of values of fixed length.

type Type

type Type C.nc_type

Type is a netCDF external data type.

const (
	BYTE   Type = C.NC_BYTE   // signed 1 byte integer
	CHAR   Type = C.NC_CHAR   // ISO/ASCII character
	SHORT  Type = C.NC_SHORT  // signed 2 byte integer
	INT    Type = C.NC_INT    // signed 4 byte integer
	LONG   Type = C.NC_LONG   // deprecated, but required for backward compatibility.
	FLOAT  Type = C.NC_FLOAT  // single precision floating point number
	DOUBLE Type = C.NC_DOUBLE // double precision floating point number
	UBYTE  Type = C.NC_UBYTE  // unsigned 1 byte int
	USHORT Type = C.NC_USHORT // unsigned 2-byte int
	UINT   Type = C.NC_UINT   // unsigned 4-byte int
	INT64  Type = C.NC_INT64  // signed 8-byte int
	UINT64 Type = C.NC_UINT64 // unsigned 8-byte int
	STRING Type = C.NC_STRING // string
)

Type declarations according to C standards

func (Type) String

func (t Type) String() string

String converts a Type to its string representation.

type Uint16sReader

type Uint16sReader interface {
	Len() (n uint64, err error)
	ReadUint16s(val []uint16) (err error)
}

Uint16sReader is a interface that allows reading a sequence of values of fixed length.

type Uint32sReader

type Uint32sReader interface {
	Len() (n uint64, err error)
	ReadUint32s(val []uint32) (err error)
}

Uint32sReader is a interface that allows reading a sequence of values of fixed length.

type Uint64sReader

type Uint64sReader interface {
	Len() (n uint64, err error)
	ReadUint64s(val []uint64) (err error)
}

Uint64sReader is a interface that allows reading a sequence of values of fixed length.

type Uint8sReader

type Uint8sReader interface {
	Len() (n uint64, err error)
	ReadUint8s(val []uint8) (err error)
}

Uint8sReader is a interface that allows reading a sequence of values of fixed length.

type Var

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

Var represents a variable.

func (Var) Attr

func (v Var) Attr(name string) (a Attr)

Attr returns attribute named name. If the attribute does not yet exist, it'll be created once it's written.

func (Var) AttrN

func (v Var) AttrN(n int) (a Attr, err error)

AttrN returns attribute for attribute number n.

func (Var) Compression

func (v Var) Compression() (shuffle, deflate bool, deflateLevel int, err error)

Compression returns the deflate settings for a variable in a NetCDF-4 file.

func (Var) Dims

func (v Var) Dims() (dims []Dim, err error)

Dims returns the dimensions of variable v.

func (Var) Len

func (v Var) Len() (uint64, error)

Len returns the total number of values in the variable v.

func (Var) LenDims

func (v Var) LenDims() ([]uint64, error)

LenDims returns the length of the dimensions of variable v.

func (Var) NAttrs

func (v Var) NAttrs() (n int, err error)

NAttrs returns the number of attributes assigned to variable v.

func (Var) Name

func (v Var) Name() (name string, err error)

Name returns the name of the variable.

func (Var) ReadBytes

func (v Var) ReadBytes(data []byte) error

ReadBytes reads the entire variable v into data, which must have enough space for all the values (i.e. len(data) must be at least v.Len()).

func (Var) ReadBytesAt

func (v Var) ReadBytesAt(idx []uint64) (val byte, err error)

ReadBytesAt returns a value via index position

func (Var) ReadBytesSlice

func (v Var) ReadBytesSlice(data []byte, start, count []uint64) error

ReadBytesSlice reads a slice of variable v into data, which must have enough space for all the values. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadBytesStridedSlice

func (v Var) ReadBytesStridedSlice(data []byte, start, count []uint64, stride []int64) error

ReadBytesStridedSlice reads a strided slice of variable v into data, which must have enough space for all the values. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadFloat32At

func (v Var) ReadFloat32At(idx []uint64) (val float32, err error)

ReadFloat32At returns a value via index position

func (Var) ReadFloat32Slice

func (v Var) ReadFloat32Slice(data []float32, start, count []uint64) error

ReadFloat32Slice reads a slice of variable v into data, which must have enough space for all the values. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadFloat32StridedSlice

func (v Var) ReadFloat32StridedSlice(data []float32, start, count []uint64, stride []int64) error

ReadFloat32StridedSlice reads a strided slice of variable v into data, which must have enough space for all the values. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadFloat32s

func (v Var) ReadFloat32s(data []float32) error

ReadFloat32s reads the entire variable v into data, which must have enough space for all the values (i.e. len(data) must be at least v.Len()).

func (Var) ReadFloat64At

func (v Var) ReadFloat64At(idx []uint64) (val float64, err error)

ReadFloat64At returns a value via index position

func (Var) ReadFloat64Slice

func (v Var) ReadFloat64Slice(data []float64, start, count []uint64) error

ReadFloat64Slice reads a slice of variable v into data, which must have enough space for all the values. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadFloat64StridedSlice

func (v Var) ReadFloat64StridedSlice(data []float64, start, count []uint64, stride []int64) error

ReadFloat64StridedSlice reads a strided slice of variable v into data, which must have enough space for all the values. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadFloat64s

func (v Var) ReadFloat64s(data []float64) error

ReadFloat64s reads the entire variable v into data, which must have enough space for all the values (i.e. len(data) must be at least v.Len()).

func (Var) ReadInt16At

func (v Var) ReadInt16At(idx []uint64) (val int16, err error)

ReadInt16At returns a value via index position

func (Var) ReadInt16Slice

func (v Var) ReadInt16Slice(data []int16, start, count []uint64) error

ReadInt16Slice reads a slice of variable v into data, which must have enough space for all the values. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadInt16StridedSlice

func (v Var) ReadInt16StridedSlice(data []int16, start, count []uint64, stride []int64) error

ReadInt16StridedSlice reads a strided slice of variable v into data, which must have enough space for all the values. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadInt16s

func (v Var) ReadInt16s(data []int16) error

ReadInt16s reads the entire variable v into data, which must have enough space for all the values (i.e. len(data) must be at least v.Len()).

func (Var) ReadInt32At

func (v Var) ReadInt32At(idx []uint64) (val int32, err error)

ReadInt32At returns a value via index position

func (Var) ReadInt32Slice

func (v Var) ReadInt32Slice(data []int32, start, count []uint64) error

ReadInt32Slice reads a slice of variable v into data, which must have enough space for all the values. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadInt32StridedSlice

func (v Var) ReadInt32StridedSlice(data []int32, start, count []uint64, stride []int64) error

ReadInt32StridedSlice reads a strided slice of variable v into data, which must have enough space for all the values. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadInt32s

func (v Var) ReadInt32s(data []int32) error

ReadInt32s reads the entire variable v into data, which must have enough space for all the values (i.e. len(data) must be at least v.Len()).

func (Var) ReadInt64At

func (v Var) ReadInt64At(idx []uint64) (val int64, err error)

ReadInt64At returns a value via index position

func (Var) ReadInt64Slice

func (v Var) ReadInt64Slice(data []int64, start, count []uint64) error

ReadInt64Slice reads a slice of variable v into data, which must have enough space for all the values. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadInt64StridedSlice

func (v Var) ReadInt64StridedSlice(data []int64, start, count []uint64, stride []int64) error

ReadInt64StridedSlice reads a strided slice of variable v into data, which must have enough space for all the values. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadInt64s

func (v Var) ReadInt64s(data []int64) error

ReadInt64s reads the entire variable v into data, which must have enough space for all the values (i.e. len(data) must be at least v.Len()).

func (Var) ReadInt8At

func (v Var) ReadInt8At(idx []uint64) (val int8, err error)

ReadInt8At returns a value via index position

func (Var) ReadInt8Slice

func (v Var) ReadInt8Slice(data []int8, start, count []uint64) error

ReadInt8Slice reads a slice of variable v into data, which must have enough space for all the values. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadInt8StridedSlice

func (v Var) ReadInt8StridedSlice(data []int8, start, count []uint64, stride []int64) error

ReadInt8StridedSlice reads a strided slice of variable v into data, which must have enough space for all the values. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadInt8s

func (v Var) ReadInt8s(data []int8) error

ReadInt8s reads the entire variable v into data, which must have enough space for all the values (i.e. len(data) must be at least v.Len()).

func (Var) ReadUint16At

func (v Var) ReadUint16At(idx []uint64) (val uint16, err error)

ReadUint16At returns a value via index position

func (Var) ReadUint16Slice

func (v Var) ReadUint16Slice(data []uint16, start, count []uint64) error

ReadUint16Slice reads a slice of variable v into data, which must have enough space for all the values. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadUint16StridedSlice

func (v Var) ReadUint16StridedSlice(data []uint16, start, count []uint64, stride []int64) error

ReadUint16StridedSlice reads a strided slice of variable v into data, which must have enough space for all the values. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadUint16s

func (v Var) ReadUint16s(data []uint16) error

ReadUint16s reads the entire variable v into data, which must have enough space for all the values (i.e. len(data) must be at least v.Len()).

func (Var) ReadUint32At

func (v Var) ReadUint32At(idx []uint64) (val uint32, err error)

ReadUint32At returns a value via index position

func (Var) ReadUint32Slice

func (v Var) ReadUint32Slice(data []uint32, start, count []uint64) error

ReadUint32Slice reads a slice of variable v into data, which must have enough space for all the values. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadUint32StridedSlice

func (v Var) ReadUint32StridedSlice(data []uint32, start, count []uint64, stride []int64) error

ReadUint32StridedSlice reads a strided slice of variable v into data, which must have enough space for all the values. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadUint32s

func (v Var) ReadUint32s(data []uint32) error

ReadUint32s reads the entire variable v into data, which must have enough space for all the values (i.e. len(data) must be at least v.Len()).

func (Var) ReadUint64At

func (v Var) ReadUint64At(idx []uint64) (val uint64, err error)

ReadUint64At returns a value via index position

func (Var) ReadUint64Slice

func (v Var) ReadUint64Slice(data []uint64, start, count []uint64) error

ReadUint64Slice reads a slice of variable v into data, which must have enough space for all the values. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadUint64StridedSlice

func (v Var) ReadUint64StridedSlice(data []uint64, start, count []uint64, stride []int64) error

ReadUint64StridedSlice reads a strided slice of variable v into data, which must have enough space for all the values. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadUint64s

func (v Var) ReadUint64s(data []uint64) error

ReadUint64s reads the entire variable v into data, which must have enough space for all the values (i.e. len(data) must be at least v.Len()).

func (Var) ReadUint8At

func (v Var) ReadUint8At(idx []uint64) (val uint8, err error)

ReadUint8At returns a value via index position

func (Var) ReadUint8Slice

func (v Var) ReadUint8Slice(data []uint8, start, count []uint64) error

ReadUint8Slice reads a slice of variable v into data, which must have enough space for all the values. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadUint8StridedSlice

func (v Var) ReadUint8StridedSlice(data []uint8, start, count []uint64, stride []int64) error

ReadUint8StridedSlice reads a strided slice of variable v into data, which must have enough space for all the values. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) ReadUint8s

func (v Var) ReadUint8s(data []uint8) error

ReadUint8s reads the entire variable v into data, which must have enough space for all the values (i.e. len(data) must be at least v.Len()).

func (Var) SetCompression

func (v Var) SetCompression(shuffle, deflate bool, deflateLevel int) error

SetCompression sets the deflate parameters for a variable in a NetCDF-4 file.

func (Var) Type

func (v Var) Type() (t Type, err error)

Type returns the data type of variable v.

func (Var) WriteBytes

func (v Var) WriteBytes(data []byte) error

WriteBytes writes data as the entire data for variable v.

func (Var) WriteBytesAt

func (v Var) WriteBytesAt(idx []uint64, val byte) (err error)

WriteBytesAt sets a value via its index position

func (Var) WriteBytesSlice

func (v Var) WriteBytesSlice(data []byte, start, count []uint64) error

WriteBytesSlice writes data as a slice of variable v. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteBytesStridedSlice

func (v Var) WriteBytesStridedSlice(data []byte, start, count []uint64, stride []int64) error

WriteBytesStridedSlice writes data as a slice of variable v. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteFloat32At

func (v Var) WriteFloat32At(idx []uint64, val float32) (err error)

WriteFloat32At sets a value via its index position

func (Var) WriteFloat32Slice

func (v Var) WriteFloat32Slice(data []float32, start, count []uint64) error

WriteFloat32Slice writes data as a slice of variable v. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteFloat32StridedSlice

func (v Var) WriteFloat32StridedSlice(data []float32, start, count []uint64, stride []int64) error

WriteFloat32StridedSlice writes data as a slice of variable v. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteFloat32s

func (v Var) WriteFloat32s(data []float32) error

WriteFloat32s writes data as the entire data for variable v.

func (Var) WriteFloat64At

func (v Var) WriteFloat64At(idx []uint64, val float64) (err error)

WriteFloat64At sets a value via its index position

func (Var) WriteFloat64Slice

func (v Var) WriteFloat64Slice(data []float64, start, count []uint64) error

WriteFloat64Slice writes data as a slice of variable v. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteFloat64StridedSlice

func (v Var) WriteFloat64StridedSlice(data []float64, start, count []uint64, stride []int64) error

WriteFloat64StridedSlice writes data as a slice of variable v. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteFloat64s

func (v Var) WriteFloat64s(data []float64) error

WriteFloat64s writes data as the entire data for variable v.

func (Var) WriteInt16At

func (v Var) WriteInt16At(idx []uint64, val int16) (err error)

WriteInt16At sets a value via its index position

func (Var) WriteInt16Slice

func (v Var) WriteInt16Slice(data []int16, start, count []uint64) error

WriteInt16Slice writes data as a slice of variable v. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteInt16StridedSlice

func (v Var) WriteInt16StridedSlice(data []int16, start, count []uint64, stride []int64) error

WriteInt16StridedSlice writes data as a slice of variable v. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteInt16s

func (v Var) WriteInt16s(data []int16) error

WriteInt16s writes data as the entire data for variable v.

func (Var) WriteInt32At

func (v Var) WriteInt32At(idx []uint64, val int32) (err error)

WriteInt32At sets a value via its index position

func (Var) WriteInt32Slice

func (v Var) WriteInt32Slice(data []int32, start, count []uint64) error

WriteInt32Slice writes data as a slice of variable v. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteInt32StridedSlice

func (v Var) WriteInt32StridedSlice(data []int32, start, count []uint64, stride []int64) error

WriteInt32StridedSlice writes data as a slice of variable v. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteInt32s

func (v Var) WriteInt32s(data []int32) error

WriteInt32s writes data as the entire data for variable v.

func (Var) WriteInt64At

func (v Var) WriteInt64At(idx []uint64, val int64) (err error)

WriteInt64At sets a value via its index position

func (Var) WriteInt64Slice

func (v Var) WriteInt64Slice(data []int64, start, count []uint64) error

WriteInt64Slice writes data as a slice of variable v. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteInt64StridedSlice

func (v Var) WriteInt64StridedSlice(data []int64, start, count []uint64, stride []int64) error

WriteInt64StridedSlice writes data as a slice of variable v. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteInt64s

func (v Var) WriteInt64s(data []int64) error

WriteInt64s writes data as the entire data for variable v.

func (Var) WriteInt8At

func (v Var) WriteInt8At(idx []uint64, val int8) (err error)

WriteInt8At sets a value via its index position

func (Var) WriteInt8Slice

func (v Var) WriteInt8Slice(data []int8, start, count []uint64) error

WriteInt8Slice writes data as a slice of variable v. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteInt8StridedSlice

func (v Var) WriteInt8StridedSlice(data []int8, start, count []uint64, stride []int64) error

WriteInt8StridedSlice writes data as a slice of variable v. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteInt8s

func (v Var) WriteInt8s(data []int8) error

WriteInt8s writes data as the entire data for variable v.

func (Var) WriteUint16At

func (v Var) WriteUint16At(idx []uint64, val uint16) (err error)

WriteUint16At sets a value via its index position

func (Var) WriteUint16Slice

func (v Var) WriteUint16Slice(data []uint16, start, count []uint64) error

WriteUint16Slice writes data as a slice of variable v. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteUint16StridedSlice

func (v Var) WriteUint16StridedSlice(data []uint16, start, count []uint64, stride []int64) error

WriteUint16StridedSlice writes data as a slice of variable v. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteUint16s

func (v Var) WriteUint16s(data []uint16) error

WriteUint16s writes data as the entire data for variable v.

func (Var) WriteUint32At

func (v Var) WriteUint32At(idx []uint64, val uint32) (err error)

WriteUint32At sets a value via its index position

func (Var) WriteUint32Slice

func (v Var) WriteUint32Slice(data []uint32, start, count []uint64) error

WriteUint32Slice writes data as a slice of variable v. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteUint32StridedSlice

func (v Var) WriteUint32StridedSlice(data []uint32, start, count []uint64, stride []int64) error

WriteUint32StridedSlice writes data as a slice of variable v. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteUint32s

func (v Var) WriteUint32s(data []uint32) error

WriteUint32s writes data as the entire data for variable v.

func (Var) WriteUint64At

func (v Var) WriteUint64At(idx []uint64, val uint64) (err error)

WriteUint64At sets a value via its index position

func (Var) WriteUint64Slice

func (v Var) WriteUint64Slice(data []uint64, start, count []uint64) error

WriteUint64Slice writes data as a slice of variable v. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteUint64StridedSlice

func (v Var) WriteUint64StridedSlice(data []uint64, start, count []uint64, stride []int64) error

WriteUint64StridedSlice writes data as a slice of variable v. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteUint64s

func (v Var) WriteUint64s(data []uint64) error

WriteUint64s writes data as the entire data for variable v.

func (Var) WriteUint8At

func (v Var) WriteUint8At(idx []uint64, val uint8) (err error)

WriteUint8At sets a value via its index position

func (Var) WriteUint8Slice

func (v Var) WriteUint8Slice(data []uint8, start, count []uint64) error

WriteUint8Slice writes data as a slice of variable v. The slice is specified by start and count: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteUint8StridedSlice

func (v Var) WriteUint8StridedSlice(data []uint8, start, count []uint64, stride []int64) error

WriteUint8StridedSlice writes data as a slice of variable v. The slice is specified by start, count and stride: https://www.unidata.ucar.edu/software/netcdf/docs/programming_notes.html#specify_hyperslab.

func (Var) WriteUint8s

func (v Var) WriteUint8s(data []uint8) error

WriteUint8s writes data as the entire data for variable v.

Directories

Path Synopsis
Package ncmem is a Go binding for the netCDF C library's in-memory operations.
Package ncmem is a Go binding for the netCDF C library's in-memory operations.

Jump to

Keyboard shortcuts

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