Class: Hdf5::H5Dataspace

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/hdf5.rb

Overview

Object for wrapping an HD5 dataspace, which contains information about the dimensions and size of the dataset

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ H5Dataspace

Create a new H5Dataspace object. id must be the id of a pre-existing HDF5 dataspace.



265
266
267
# File 'lib/hdf5.rb', line 265

def initialize(id)
  @id = id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



242
243
244
# File 'lib/hdf5.rb', line 242

def id
  @id
end

Class Method Details

.create_simple(current_dims, maximum_dims = nil) ⇒ Object

Create a new HDF5 dataspace with the given current and maximum dimensions. If maximum_dims is omitted it is set to current_dims. Returns an H5Dataspace object wrapping the dataspace

Raises:

  • (ArgumentError)


252
253
254
255
256
257
258
259
260
261
262
# File 'lib/hdf5.rb', line 252

def self.create_simple(current_dims, maximum_dims=nil)
  maximum_dims ||= current_dims
  raise ArgumentError.new("current_dims and maximum_dims must be the same size") unless current_dims.size == maximum_dims.size
  n = current_dims.size
  #basic_dims = FFI::MemoryPointer.new(H5Types.hsize_t, n)
  #basic_maxdims = FFI::MemoryPointer.new(H5Types.hsize_t, n)
  #basic_dims.write_array_of_type(:size_t, :put_size_t, current_dims)
  #basic_maxdims.write_array_of_type(:size_t, :put_size_t, maximum_dims)
  # Th
  new(basic_create_simple(n, current_dims.ffi_mem_pointer_hsize_t, maximum_dims.ffi_mem_pointer_hsize_t))
end

Instance Method Details

#dimsObject

Get the size of the dataspace



280
281
282
# File 'lib/hdf5.rb', line 280

def dims      
  basic_dims_maxdims[0].get_array_of_int64(0, ndims)
end

#maxdimsObject

Get the maximum size of the dataspace



284
285
286
# File 'lib/hdf5.rb', line 284

def maxdims      
  basic_dims_maxdims[1].get_array_of_int64(0, ndims)
end

#ndimsObject

Number of dimensions in the dataspace



269
270
271
# File 'lib/hdf5.rb', line 269

def ndims
  basic_get_simple_extent_ndims(@id)
end

#offset_simple(offsets) ⇒ Object

Set the offset of the dataspace. offsets should be an ndims-sized array of zero-based integer offsets.

Raises:

  • (ArgumentError)


289
290
291
292
# File 'lib/hdf5.rb', line 289

def offset_simple(offsets)
  raise ArgumentError.new("offsets should have ndims elements") unless offsets.size == ndims
  basic_offset_simple(@id, offsets.ffi_mem_pointer_hsize_t)
end