示例#1
0
// Creates a new simple dataspace and opens it for access.
// hid_t H5Screate_simple( int rank, const hsize_t * current_dims, const hsize_t * maximum_dims )
func CreateSimpleDataSpace(dims, maximum_dims []int) (*DataSpace, error) {

	var c_dims *C.hsize_t = nil
	var c_maxdims *C.hsize_t = nil

	rank := C.int(0)
	if dims != nil {
		rank = C.int(len(dims))
		// FIXME: size of C.hsize_t and go.int !!
		c_dims = (*C.hsize_t)(unsafe.Pointer(&dims[0]))

	}
	if maximum_dims != nil {
		rank = C.int(len(maximum_dims))
		// FIXME: size of C.hsize_t and go.int !!
		c_maxdims = (*C.hsize_t)(unsafe.Pointer(&maximum_dims[0]))

	}
	if len(dims) != len(maximum_dims) && (dims != nil && maximum_dims != nil) {
		return nil, errors.New("sizes of 'dims' and 'maximum_dims' dont match")
	}

	hid := C.H5Screate_simple(rank, c_dims, c_maxdims)
	err := togo_err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	ds := new_dataspace(hid)
	return ds, err
}
示例#2
0
文件: h5t.go 项目: kisielk/go-hdf5
// copyDatatype should be called by any function wishing to return
// an existing Datatype from a Dataset or Attribute.
func copyDatatype(id C.hid_t) (*Datatype, error) {
	hid := C.H5Tcopy(id)
	err := h5err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	return NewDatatype(hid), nil
}
示例#3
0
文件: h5f.go 项目: pauh/go-hdf5
// Returns a new identifier for a previously-opened HDF5 file.
func (self *File) ReOpen() (*File, error) {
	hid := C.H5Freopen(self.id)
	err := h5err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	return newFile(hid), nil
}
示例#4
0
文件: h5pt.go 项目: kisielk/go-hdf5
// Type returns an identifier for a copy of the datatype for a dataset.
func (t *Table) Type() (*Datatype, error) {
	hid := C.H5Dget_type(t.id)
	err := h5err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	return copyDatatype(hid)
}
示例#5
0
文件: h5t.go 项目: kisielk/go-hdf5
// MemberType returns the datatype of the specified member.
func (t *CompoundType) MemberType(mbr_idx int) (*Datatype, error) {
	hid := C.H5Tget_member_type(t.id, C.uint(mbr_idx))
	err := h5err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	return copyDatatype(hid)
}
示例#6
0
文件: h5s.go 项目: simleb/go-hdf5
// Copy creates an exact copy of a dataspace.
func (s *Dataspace) Copy() (*Dataspace, error) {
	hid := C.H5Scopy(s.id)
	err := h5err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	o := newDataspace(hid)
	return o, err
}
示例#7
0
文件: h5s.go 项目: simleb/go-hdf5
// CreateDataspace creates a new dataspace of a specified type.
func CreateDataspace(class SpaceClass) (*Dataspace, error) {
	hid := C.H5Screate(C.H5S_class_t(class))
	err := h5err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	ds := newDataspace(hid)
	return ds, nil
}
示例#8
0
文件: h5t.go 项目: pauh/go-hdf5
// Copies an existing datatype.
func (t *Datatype) Copy() (*Datatype, error) {
	hid := C.H5Tcopy(t.id)
	err := h5err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	o := NewDatatype(hid, t.rt)
	return o, err
}
示例#9
0
文件: h5p.go 项目: pauh/go-hdf5
// Creates a new property as an instance of a property list class.
// hid_t H5Pcreate(hid_t cls_id )
func NewPropList(cls_id PropType) (*PropList, error) {
	hid := C.H5Pcreate(C.hid_t(cls_id))
	err := h5err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	p := new_proplist(hid)
	return p, err
}
示例#10
0
文件: h5d.go 项目: pauh/go-hdf5
// Returns an identifier for a copy of the datatype for a dataset.
// hid_t H5Dget_type(hid_t dataset_id )
func (s *Dataset) Type() (*Datatype, error) {
	hid := C.H5Dget_type(s.id)
	err := h5err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	dt := NewDatatype(hid, nil)
	return dt, err
}
示例#11
0
文件: h5d.go 项目: simleb/go-hdf5
func createDataset(id C.hid_t, name string, dtype *Datatype, dspace *Dataspace, dcpl *PropList) (*Dataset, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))
	hid := C.H5Dcreate2(id, c_name, dtype.id, dspace.id, P_DEFAULT.id, dcpl.id, P_DEFAULT.id)
	if err := h5err(C.herr_t(int(hid))); err != nil {
		return nil, err
	}
	return newDataset(hid), nil
}
示例#12
0
// Copies an existing datatype.
// hid_t H5Tcopy( hid_t dtype_id )
func (t *DataType) Copy() (*DataType, error) {
	hid := C.H5Tcopy(t.id)
	err := togo_err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	o := new_dtype(hid, t.rt)
	return o, err
}
示例#13
0
// Returns an identifier for a copy of the datatype for a dataset.
// hid_t H5Dget_type(hid_t dataset_id )
func (t *Table) Type() (*DataType, error) {
	hid := C.H5Dget_type(t.id)
	err := togo_err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	dt := new_dtype(hid, nil)
	return dt, err
}
示例#14
0
func NewVarLenType(base_type *DataType) (*VarLenType, error) {
	hid := C.H5Tvlen_create(base_type.id)
	err := togo_err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	dt := new_vltype(hid)
	return dt, err
}
示例#15
0
// Returns the datatype of the specified member.
// hid_t H5Tget_member_type( hid_t dtype_id, unsigned field_idx )
func (t *CompType) MemberType(mbr_idx int) (*DataType, error) {
	hid := C.H5Tget_member_type(t.id, C.uint(mbr_idx))
	err := togo_err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	dt := new_dtype(hid, t.rt.Field(mbr_idx).Type)
	return dt, nil
}
示例#16
0
文件: h5p.go 项目: simleb/go-hdf5
// Copy copies an existing PropList to create a new PropList.
func (p *PropList) Copy() (*PropList, error) {
	hid := C.H5Pcopy(p.id)
	err := h5err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	o := newPropList(hid)
	return o, err
}
示例#17
0
文件: h5a.go 项目: simleb/go-hdf5
func openAttribute(id C.hid_t, name string) (*Attribute, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	hid := C.H5Aopen(id, c_name, P_DEFAULT.id)
	if err := h5err(C.herr_t(int(hid))); err != nil {
		return nil, err
	}
	return newAttribute(hid), nil
}
示例#18
0
文件: h5d.go 项目: simleb/go-hdf5
func openDataset(id C.hid_t, name string) (*Dataset, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	hid := C.H5Dopen2(id, c_name, P_DEFAULT.id)
	if err := h5err(C.herr_t(int(hid))); err != nil {
		return nil, err
	}
	return newDataset(hid), nil
}
示例#19
0
文件: h5t.go 项目: kisielk/go-hdf5
// NewVarLenType creates a new VarLenType.
// base_type specifies the element type of the VarLenType.
func NewVarLenType(base_type *Datatype) (*VarLenType, error) {
	id := C.H5Tvlen_create(base_type.id)
	err := h5err(C.herr_t(int(id)))
	if err != nil {
		return nil, err
	}
	t := &VarLenType{Datatype{Location{Identifier{id}}}}
	runtime.SetFinalizer(t, (*VarLenType).finalizer)
	return t, err
}
示例#20
0
文件: h5s.go 项目: jonlawlor/go-hdf5
// SimpleExtentDims returns dataspace dimension size and maximum size.
func (s *Dataspace) SimpleExtentDims() (dims, maxdims []uint, err error) {
	rank := s.SimpleExtentNDims()
	dims = make([]uint, rank)
	maxdims = make([]uint, rank)

	c_dims := (*C.hsize_t)(unsafe.Pointer(&dims[0]))
	c_maxdims := (*C.hsize_t)(unsafe.Pointer(&maxdims[0]))
	rc := C.H5Sget_simple_extent_dims(s.id, c_dims, c_maxdims)
	err = h5err(C.herr_t(rc))
	return
}
示例#21
0
// Creates a new dataset at this location.
// hid_t H5Dcreate2( hid_t loc_id, const char *name, hid_t dtype_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id )
func (f *File) CreateDataSet(name string, dtype *DataType, dspace *DataSpace, dcpl *PropList) (*DataSet, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))
	hid := C.H5Dcreate2(f.id, c_name, dtype.id, dspace.id, P_DEFAULT.id, dcpl.id, P_DEFAULT.id)
	err := togo_err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	dset := new_dataset(hid)
	return dset, err
}
示例#22
0
文件: h5g.go 项目: simleb/go-hdf5
func openGroup(id C.hid_t, name string, gapl_flag C.hid_t) (*Group, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	hid := C.H5Gopen2(id, c_name, gapl_flag)
	if err := h5err(C.herr_t(int(hid))); err != nil {
		return nil, err
	}
	g := &Group{Location{hid}}
	runtime.SetFinalizer(g, (*Group).finalizer)
	return g, nil
}
示例#23
0
文件: h5g.go 项目: simleb/go-hdf5
func createGroup(id C.hid_t, name string, link_flags, grp_c_flags, grp_a_flags int) (*Group, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	hid := C.H5Gcreate2(id, c_name, C.hid_t(link_flags), C.hid_t(grp_c_flags), P_DEFAULT.id)
	if err := h5err(C.herr_t(int(hid))); err != nil {
		return nil, err
	}
	g := &Group{Location{hid}}
	runtime.SetFinalizer(g, (*Group).finalizer)
	return g, nil
}
示例#24
0
文件: h5g.go 项目: kisielk/go-hdf5
// OpenGroup opens an existing child group from this Group.
func (g *CommonFG) OpenGroup(name string) (*Group, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	hid := C.H5Gopen2(g.id, c_name, P_DEFAULT.id)
	if err := h5err(C.herr_t(int(hid))); err != nil {
		return nil, err
	}
	group := &Group{CommonFG{Location{Identifier{hid}}}}
	runtime.SetFinalizer(group, (*Group).finalizer)
	return group, nil
}
示例#25
0
文件: h5pt.go 项目: simleb/go-hdf5
func openTable(id C.hid_t, name string) (*Table, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	hid := C.H5PTopen(id, c_name)
	err := h5err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	table := newPacketTable(hid)
	return table, err
}
示例#26
0
func NewArrayType(base_type *DataType, dims []int) (*ArrayType, error) {
	ndims := C.uint(len(dims))
	c_dims := (*C.hsize_t)(unsafe.Pointer(&dims[0]))

	hid := C.H5Tarray_create2(base_type.id, ndims, c_dims)
	err := togo_err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	t := new_array_type(hid)
	return t, err
}
示例#27
0
// Returns a new identifier for a previously-opened HDF5 file.
func (self *File) ReOpen() (f *File, err error) {
	f = nil
	err = nil

	hid := C.H5Freopen(self.id)
	err = togo_err(C.herr_t(int(hid)))
	if err != nil {
		return
	}
	f = new_file(hid)
	return
}
示例#28
0
// Creates a new datatype.
// hid_t H5Tcreate( H5T_class_t class, size_tsize )
func CreateDataType(class TypeClass, size int) (t *DataType, err error) {
	t = nil
	err = nil

	hid := C.H5Tcreate(C.H5T_class_t(class), C.size_t(size))
	err = togo_err(C.herr_t(int(hid)))
	if err != nil {
		return
	}
	t = new_dtype(hid, _type_cls_to_go_type[class])
	return
}
示例#29
0
文件: h5f.go 项目: pauh/go-hdf5
// Opens an existing HDF5 file.
func OpenFile(name string, flags int) (*File, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	// FIXME: file props
	hid := C.H5Fopen(c_name, C.uint(flags), P_DEFAULT.id)
	err := h5err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	return newFile(hid), nil
}
示例#30
0
// Opens an existing dataset.
// hid_t H5Dopen( hid_t loc_id, const char *name, hid_t dapl_id )
func (f *File) OpenDataSet(name string) (*DataSet, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	hid := C.H5Dopen2(f.id, c_name, P_DEFAULT.id)
	err := togo_err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	dset := new_dataset(hid)
	return dset, err
}