ncmem

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

Documentation

Overview

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

NetCDF version 4.6.2 or later is required.

In-memory support is documented here: https://www.unidata.ucar.edu/software/netcdf/docs/md__Volumes_Workspace_releases_netcdf-c-4_87_84_netcdf-c_docs_inmemory.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bytes

type Bytes struct {
	Data []byte
	// contains filtered or unexported fields
}

Bytes provides a view into C allocated data. It's Free method method must be called to release the memory.

func (*Bytes) Free

func (b *Bytes) Free()

Free releases the underlying data. All references to Data are invalid after calling.

type Dataset

type Dataset struct {
	netcdf.Dataset
}

Dataset wraps netcdf.Dataset, adding methods specific to in-memory datasets.

Must be closed via one of the added Close, CloseBytes, or CloseCopyBytes methods to properly release memory.

func Create

func Create(path string, mode netcdf.FileMode, initialSize int) (ds Dataset, err error)

Create creates a new in-memory dataset. Path sets the dataset name. Mode is a bitwise-or of netcdf.FileMode values. InitialSize is a hint for the initial amount of memory to allocate for the dataset.

func Open

func Open(path string, mode netcdf.FileMode, flags Flags, data []byte) (ds Dataset, err error)

Open opens an existing netCDF dataset from a copy of the provided data. Path sets the dataset name. Mode is a bitwise-or of netcdf.FileMode values. Flags is a bitwise-or of Flags values.

func OpenReader

func OpenReader(path string, mode netcdf.FileMode, flags Flags, r io.Reader) (ds Dataset, err error)

OpenReader reads and opens an existing netCDF dataset from r. Path sets the dataset name. Mode is a bitwise-or of netcdf.FileMode values. Flags is a bitwise-or of Flags values.

If r fulfills LenReader, it's Len method will be used to determine how much memory to allocate.

func (Dataset) Close

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

Close closes and releases the memory of the dataset.

Use CloseMem to retrieve the in-memory data.

func (Dataset) CloseBytes

func (ds Dataset) CloseBytes() (*Bytes, error)

CloseBytes closes the dataset and returns a reference to C allocated memory.

func (Dataset) CloseCopyBytes

func (ds Dataset) CloseCopyBytes() (data []byte, err error)

CloseCopyBytes closes the dataset and returns a copy of the in-memory data.

type Flags

type Flags C.int

Flags define how the netCDF library should manage memory.

const (
	MEMIO_LOCKED Flags = C.NC_MEMIO_LOCKED
)

Flags for Open.

type LenReader

type LenReader interface {
	io.Reader
	Len() int
}

LenReader is an io.Reader which can provide it's unread length.

Jump to

Keyboard shortcuts

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