Public Member Functions

Data< T, N_rank > Class Template Reference
[Classes of the ODIN data processing framework (odindata library)]

#include <data.h>

Inheritance diagram for Data< T, N_rank >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Data (const TinyVector< int, N_rank > &dimvec, const T &val=0)
 Data (const STD_string &filename, bool readonly, const TinyVector< int, N_rank > &shape, LONGEST_INT offset=0)
 Data (const Data< T, N_rank > &d)
 Data (const Array< T, N_rank > &a)
 Data (const tjarray< tjvector< T >, T > &a)
template<class T_expr >
 Data (BZ_ETPARM(_bz_ArrayExpr< T_expr >) expr)
 ~Data ()
Data< T, N_rank > & operator= (const Data< T, N_rank > &d)
Data< T, N_rank > & operator= (const Array< T, N_rank > &a)
Data< T, N_rank > & operator= (const T &val)
template<class T_expr >
Data< T, N_rank > & operator= (BZ_ETPARM(_bz_ArrayExpr< T_expr >) expr)
Data< T, N_rank > & operator= (const tjarray< tjvector< T >, T > &a)
int read (const STD_string &format, const STD_string &filename, LONGEST_INT offset=0)
template<typename T2 >
int read (const STD_string &filename, LONGEST_INT offset=0)
int write (const STD_string &format, const STD_string &filename, bool autoscale=true) const
template<typename T2 >
int write (const STD_string &filename, bool autoscale=true) const
int write (const STD_string &filename, fopenMode mode=overwriteMode) const
int write_asc_file (const STD_string &filename, const Array< T, N_rank > &pre=defaultArray, const Array< T, N_rank > &post=defaultArray) const
int read_asc_file (const STD_string &filename)
int autowrite (const STD_string &filename, const FileWriteOpts &opts=FileWriteOpts(), const Protocol *prot=0) const
int autoread (const STD_string &filename, const FileReadOpts &opts=FileReadOpts(), Protocol *prot=0, ProgressMeter *progmeter=0)
bool is_filemapped () const
 operator tjarray< tjvector< T >, T > () const
TinyVector< int, N_rank > create_index (unsigned long index) const
unsigned long create_linear_index (const TinyVector< int, N_rank > &indexvec) const
void shift (unsigned int shift_dim, int shift)
void congrid (const TinyVector< int, N_rank > &newshape, const TinyVector< float, N_rank > *subpixel_shift=0, bool left_to_right=false)
template<typename T2 , int N_rank2>
Data< T2, N_rank2 > & convert_to (Data< T2, N_rank2 > &dst, bool autoscale=true) const
T * c_array ()

Detailed Description

template<typename T, int N_rank>
class Data< T, N_rank >

This template class holds multidimensional data. In addition to functionality provided by the Blitz Array class, it offers methods to read/write raw data and and other file formats (nifti, vtk, ...) to/from a file. In addition, uing a special constructor, the array can be associated with a block of data on disk using the UNIX mmap functionality. In this case, any changes made to the array will be automatically tranfered to the file. Please note that any attempt to resize such an array will most likely cause a segmentation fault.

Definition at line 129 of file odindata/data.h.


Constructor & Destructor Documentation

template<typename T, int N_rank>
Data< T, N_rank >::Data ( const TinyVector< int, N_rank > &  dimvec,
const T &  val = 0 
) [inline]

Constructs an array with the given dimensionality and initial value

Definition at line 137 of file odindata/data.h.

template<typename T, int N_rank>
Data< T, N_rank >::Data ( const STD_string &  filename,
bool  readonly,
const TinyVector< int, N_rank > &  shape,
LONGEST_INT  offset = 0 
)

Maps the given file 'filename' into the newly created array via the the mmap function, see the mmap man page for details. The mapping is abolish when the array is destroyed (destructor). Other parameters:

  • readonly : If true, file can only be read. If false, the file will be created if it does not exist
  • shape : The extent in each dimension
  • offset : Skip first 'offset' bytes

Definition at line 457 of file odindata/data.h.

template<typename T, int N_rank>
Data< T, N_rank >::Data ( const Data< T, N_rank > &  d  )  [inline]

Copy constructor

Definition at line 166 of file odindata/data.h.

template<typename T, int N_rank>
Data< T, N_rank >::Data ( const Array< T, N_rank > &  a  )  [inline]

Copy constructor from Blitz::Array

Definition at line 171 of file odindata/data.h.

template<typename T, int N_rank>
Data< T, N_rank >::Data ( const tjarray< tjvector< T >, T > &  a  )  [inline]

Constructor from an equivalent tjarray (Arrays). If rank of 'a' is smaller, extent will pe padded with 1 at front.

Definition at line 176 of file odindata/data.h.

template<typename T, int N_rank>
template<class T_expr >
Data< T, N_rank >::Data ( BZ_ETPARM(_bz_ArrayExpr< T_expr >)  expr  )  [inline]

Constructor from expression template

Definition at line 182 of file odindata/data.h.

template<typename T , int N_rank>
Data< T, N_rank >::~Data (  ) 

Destructor

Definition at line 490 of file odindata/data.h.


Member Function Documentation

template<typename T , int N_rank>
int Data< T, N_rank >::autoread ( const STD_string &  filename,
const FileReadOpts opts = FileReadOpts(),
Protocol prot = 0,
ProgressMeter progmeter = 0 
)

Reads data set from file 'filename' assuming the format automatically detected by the given file extension. Extra options can be given by 'opts' and protocol settings will be stored in 'prot'. The progress meter 'progmeter' can be optionally specified to monitor the progress of the operation. Returns number of slices sucessfully read, or -1 if it fails.

Definition at line 712 of file odindata/data.h.

template<typename T , int N_rank>
int Data< T, N_rank >::autowrite ( const STD_string &  filename,
const FileWriteOpts opts = FileWriteOpts(),
const Protocol prot = 0 
) const

Writes data set to file 'filename' in the format automatically detected by the given file extension. Extra options can be given by 'opts' and protocol settings can be overwritten by 'prot'. Returns number of slices, or -1 if it fails.

Definition at line 706 of file odindata/data.h.

template<typename T , int N_rank>
T * Data< T, N_rank >::c_array (  ) 

Makes array unique and continuous and returns pointer to data

Definition at line 929 of file odindata/data.h.

template<typename T , int N_rank>
void Data< T, N_rank >::congrid ( const TinyVector< int, N_rank > &  newshape,
const TinyVector< float, N_rank > *  subpixel_shift = 0,
bool  left_to_right = false 
)

Interpolate (or extrapolate) the data in the array to the new shape. The interpolation is performed dimension-by-dimension using the GSL spline interpolation routines. Add extra shift 'subpixel_shift' in units of pixels on the destination grid if 'subpixel_shift' is non-null. if 'left_to_right' is set to true, interpolation starts at the most left dimension, i.e. at those with the highest index, down to the lowest index. If set to false, interpolation is performed vice versa.

Definition at line 841 of file odindata/data.h.

template<typename T , int N_rank>
template<typename T2 , int N_rank2>
Data< T2, N_rank2 > & Data< T, N_rank >::convert_to ( Data< T2, N_rank2 > &  dst,
bool  autoscale = true 
) const

Converts the array to type 'T2', with dimensionality 'N_rank2' and stores the result in 'dst'. 'dst' will be unique, i.e. no other references to the array exist. In addition to changing 'dst', a reference to the same array is returned for convenience. If 'autoscale' is true, use full range of integer values (if applicable).

Definition at line 738 of file odindata/data.h.

template<typename T , int N_rank>
TinyVector< int, N_rank > Data< T, N_rank >::create_index ( unsigned long  index  )  const

Creates an index vector according to a linear index for the whole array by taking the shape into account.

Definition at line 782 of file odindata/data.h.

template<typename T , int N_rank>
unsigned long Data< T, N_rank >::create_linear_index ( const TinyVector< int, N_rank > &  indexvec  )  const

Creates a linear index from an index vector

Definition at line 789 of file odindata/data.h.

template<typename T, int N_rank>
bool Data< T, N_rank >::is_filemapped (  )  const [inline]

Returns true if the array is associated with a file on disk

Definition at line 316 of file odindata/data.h.

template<typename T , int N_rank>
Data< T, N_rank >::operator tjarray< tjvector< T >, T > (  )  const

Exports this array into an equivalent tjarray (Arrays)

Definition at line 723 of file odindata/data.h.

template<typename T, int N_rank>
Data<T,N_rank>& Data< T, N_rank >::operator= ( const Array< T, N_rank > &  a  )  [inline]
template<typename T, int N_rank>
template<class T_expr >
Data<T,N_rank>& Data< T, N_rank >::operator= ( BZ_ETPARM(_bz_ArrayExpr< T_expr >)  expr  )  [inline]

Assignment operator for expression templates

Reimplemented in ComplexData< N_rank >, ComplexData< 1 >, ComplexData< 2 >, ComplexData< 3 >, ComplexData< 4 >, ComplexData< 5 >, ComplexData< 6 >, ComplexData< 7 >, and ComplexData< 8 >.

Definition at line 210 of file odindata/data.h.

template<typename T, int N_rank>
Data< T, N_rank > & Data< T, N_rank >::operator= ( const tjarray< tjvector< T >, T > &  a  ) 

Assignment from an equivalent tjarray (Arrays). If rank of 'a' is smaller, extent will pe padded with 1 at front.

Definition at line 512 of file odindata/data.h.

template<typename T, int N_rank>
Data<T,N_rank>& Data< T, N_rank >::operator= ( const T &  val  )  [inline]
template<typename T, int N_rank>
Data<T,N_rank>& Data< T, N_rank >::operator= ( const Data< T, N_rank > &  d  )  [inline]

Assignment operator

Definition at line 194 of file odindata/data.h.

template<typename T , int N_rank>
template<typename T2 >
int Data< T, N_rank >::read ( const STD_string &  filename,
LONGEST_INT  offset = 0 
)

Reads the array from a raw data file 'filename' of type 'T2'. No resizing is performed prior to reading. Skip the first 'offset' bytes.

  • Return value: 0 if succesful, otherwise -1

Definition at line 551 of file odindata/data.h.

template<typename T , int N_rank>
int Data< T, N_rank >::read ( const STD_string &  format,
const STD_string &  filename,
LONGEST_INT  offset = 0 
)

Reads the array from a raw data file 'filename' of type 'format' which can be one of 's8bit, u8bit, s16bit, u16bit, s32bit, u32bit, float or double'. No resizing is performed prior to reading. Skip the first 'offset' bytes.

  • Return value: 0 if succesful, otherwise -1

Definition at line 532 of file odindata/data.h.

template<typename T , int N_rank>
int Data< T, N_rank >::read_asc_file ( const STD_string &  filename  ) 

reads in white-space separated data from ASCII file, no resizing is performed prior to reading Return value is -1 if an error occurs.

Definition at line 682 of file odindata/data.h.

template<typename T , int N_rank>
void Data< T, N_rank >::shift ( unsigned int  shift_dim,
int  shift 
)

Shift the data by 'shift' pixels in dimension 'shift_dim'. The data is shifted cyclically, i.e. the values which are shifted out at one edge of the array will be shifted in on the other edge.

Definition at line 804 of file odindata/data.h.

template<typename T , int N_rank>
template<typename T2 >
int Data< T, N_rank >::write ( const STD_string &  filename,
bool  autoscale = true 
) const

Writes the array to a raw data file 'filename' of type 'T2'. If 'autoscale' is true, use full range of integer values (if applicable).

  • Return value: 0 if succesful, otherwise -1

Definition at line 626 of file odindata/data.h.

template<typename T , int N_rank>
int Data< T, N_rank >::write ( const STD_string &  filename,
fopenMode  mode = overwriteMode 
) const

Writes the array to a raw data file 'filename' of type the same type as the array is. The mode specifies whether an already existing file is overwritten, or the data is appended.

  • Return value: 0 if succesful, otherwise -1

Definition at line 598 of file odindata/data.h.

template<typename T , int N_rank>
int Data< T, N_rank >::write ( const STD_string &  format,
const STD_string &  filename,
bool  autoscale = true 
) const

Writes the array to a raw data file 'filename' of type 'format' which can be one of 's8bit, u8bit, s16bit, u16bit, s32bit, u32bit, float or double'. If 'autoscale' is true, use full range of integer values (if applicable).

  • Return value: 0 if succesful, otherwise -1

Definition at line 581 of file odindata/data.h.

template<typename T, int N_rank>
int Data< T, N_rank >::write_asc_file ( const STD_string &  filename,
const Array< T, N_rank > &  pre = defaultArray,
const Array< T, N_rank > &  post = defaultArray 
) const

Writes the array as a formatted ASCII file to 'filename', one value per line. If 'pre' is of the same size as this, its values are inserted before the value on each line, and the values of 'post' are inserted after the values of this array on each line. Return value is -1 if an error occurs.

Definition at line 645 of file odindata/data.h.


The documentation for this class was generated from the following file: