savu.data.data_structures.data_create module

class DataCreate(name='DataCreate')[source]

Class that deals with creating a data object.

create_dataset(*args, **kwargs)[source]
Set up required information when an output dataset has been

created by a plugin.

arg Data

A data object

keyword tuple shape

The shape of the dataset

keyword list axis_labels

The axis_labels associated with the datasets

keyword patterns

The patterns associated with the dataset (optional, see note below)

keyword type dtype

Type of the data (optional: Defaults to np.float32)

keyword bool remove

Remove from framework after completion (no link in .nxs file) (optional: Defaults to False.)

keyword bool raw

Keep dark and flats (ImageKey or NoImageKey)

Note

Creating a dataset

Each new dataset requires the following information:

  • shape

  • axis_labels

  • patterns

This function can be used to setup the required information in one of two ways:

1. Passing a Data object as the only argument: All required information is copied from this data object. For example,

>>> out_dataset[0].create_dataset(in_dataset[0])

2. Passing kwargs: shape and axis_labels are required (see above for other optional arguments). For example,

>>> out_dataset[0].create_dataset(axis_labels=labels, shape=new_shape)

Warning

If pattern keyword is not used, patterns must be added after create_dataset() by calling add_pattern().

Note

shape keyword argument

Options to pass are:

  1. Data object: Copy shape from the Data object.

    >>> out_dataset[0].create_dataset(axis_labels=labels, shape=in_dataset[0])
    
  2. tuple: Define shape explicity.

    >>> out_dataset[0].create_dataset(axis_labels=labels, shape=(10, 20, 30))
    

Note

axis_labels keyword argument

Options to pass are:

  1. Data object: Copy all labels from the Data object.

    >>> out_dataset[0].create_dataset(axis_labels=in_dataset[0], shape=new_shape)
    

2. {Data_obj: list}: Copy labels from the Data object and then remove or insert.

  • To remove dimensions: list_entry = ‘dim’. For example, to remove the first and last axis_labels from the copied list:

>>> out_dataset[0].create_dataset(axis_labels={in_dataset[0]: ['1', '-1']), shape=new_shape})
  • To add/replace dimensions: list_entry = ‘dim.name.unit’.

>>> out_dataset[0].create_dataset(axis_labels={in_dataset[0]: ['2.det_x.pixel', '3.det_y.pixel']}, shape=new_shape)
  • To insert dimensions: list_entry = ‘~dim.name.unit’.

>>> out_dataset[0].create_dataset(axis_labels={in_dataset[0]: ['~2.det_x.pixel', '~3.det_y.pixel']}, shape=new_shape)

(or a combination, where each successive step is applied after the previous changes have been made.)

  1. list: Where each element is of the form ‘name.unit’.

    >>> out_dataset[0].create_dataset(axis_labels=['rotation.deg', 'det_x.pixel', 'det_y.pixel'], shape=new_shape)
    

Note

patterns keyword argument

Options to pass are:

  1. Data object: Copy all patterns from the Data object.

    >>> out_dataset[0].create_dataset(axis_labels=labels, shape=new_shape, patterns=in_dataset[0])
    

2. {Data_obj: list}: Copy only the patterns given in the list from the Data object.

  • Copy the patterns: list_entry = ‘name’

>>> out_dataset[0].create_dataset(axis_labels=labels, shape=new_shape, patterns={in_dataset[0]: ['SINOGRAM', 'PROJECTION']})
  • Copy patterns but remove dimensions: list_entry = ‘name1.r1,r2…’:

>>> out_dataset[0].create_dataset(axis_labels=labels, shape=new_shape, patterns={in_dataset[0]: ['SINOGRAM.1', 'PROJECTION.1']})
  • Copy ALL patterns but remove dimensions: list_entry = ‘*.r1,r2…’:

>>> out_dataset[0].create_dataset(axis_labels=labels, shape=new_shape, patterns={in_dataset[0]: '*.0'})
get_dtype()[source]
set_dtype(dtype)[source]