Streaks#

class cbclib.Streaks(x0, y0, x1, y1, width, length=None, h=None, k=None, l=None, hkl_id=None)[source]#

Detector streak lines container. Provides an interface to draw a pattern for a set of lines.

Parameters
contents()#

Return a list of the attributes stored in the container that are initialised.

Return type

List[str]

Returns

List of the attributes stored in the container.

get(attr, value=None)#

Retrieve a dataset, return value if the attribute is not found.

Parameters
  • attr (str) – Data attribute.

  • value (Optional[Any]) – Data which is returned if the attribute is not found.

Return type

Any

Returns

Attribute’s data stored in the container, value if attr is not found.

items()#

Return (key, value) pairs of the datasets stored in the container.

Return type

ItemsView

Returns

(key, value) pairs of the datasets stored in the container.

keys()#

Return a list of the attributes available in the container.

Return type

List[str]

Returns

List of the attributes available in the container.

mask_streaks(idxs)[source]#

Return a new streaks container with a set of streaks discarded.

Parameters

idxs (Union[int, slice, ndarray, List[int], Tuple[int]]) – A set of indices of the streaks to discard.

Return type

Streaks

Returns

A new cbclib.Streaks container.

pattern_dataframe(shape=None, dilation=0.0, profile='tophat', reduce=True)[source]#

Draw a pattern in the pandas.DataFrame format.

Parameters
  • shape (Optional[Tuple[int, int]]) – Detector grid shape.

  • dilation (float) – Line mask dilation in pixels.

  • profile (str) –

    Line width profiles. The following keyword values are allowed:

    • tophat : Top-hat (rectangular) function profile.

    • linear : Linear (triangular) function profile.

    • quad : Quadratic (parabola) function profile.

    • gauss : Gaussian function profile.

  • reduce (bool) – Discard the pixel data with reflection profile values equal to zero.

Return type

DataFrame

Returns

A pattern in pandas.DataFrame format.

pattern_dict(shape=None, dilation=0.0, profile='tophat')[source]#

Draw a pattern in the dict format.

Parameters
  • shape (Optional[Tuple[int, int]]) – Detector grid shape.

  • dilation (float) – Line mask dilation in pixels.

  • profile (str) –

    Line width profiles. The following keyword values are allowed:

    • tophat : Top-hat (rectangular) function profile.

    • linear : Linear (triangular) function profile.

    • quad : Quadratic (parabola) function profile.

    • gauss : Gaussian function profile.

Return type

Dict[str, ndarray]

Returns

A pattern in dictionary format.

pattern_image(shape, dilation=0.0, profile='gauss')[source]#

Draw a pattern in the numpy.ndarray format.

Parameters
  • shape (Tuple[int, int]) – Detector grid shape.

  • dilation (float) – Line mask dilation in pixels.

  • profile (str) –

    Line width profiles. The following keyword values are allowed:

    • tophat : Top-hat (rectangular) function profile.

    • linear : Linear (triangular) function profile.

    • quad : Quadratic (parabola) function profile.

    • gauss : Gaussian function profile.

Return type

ndarray

Returns

A pattern in numpy.ndarray format.

pattern_mask(shape, max_val=1, dilation=0.0, profile='tophat')[source]#

Draw a pattern mask.

Parameters
  • shape (Tuple[int, int]) – Detector grid shape.

  • max_val (int) – Mask maximal value.

  • dilation (float) – Line mask dilation in pixels.

  • profile (str) –

    Line width profiles. The following keyword values are allowed:

    • tophat : Top-hat (rectangular) function profile.

    • linear : Linear (triangular) function profile.

    • quad : Quadratic (parabola) function profile.

    • gauss : Gaussian function profile.

Return type

ndarray

Returns

A pattern mask.

replace(**kwargs)#

Return a new container object with a set of attributes replaced.

Parameters

kwargs (Any) – A set of attributes and the values to to replace.

Return type

~D

Returns

A new container object with updated attributes.

to_dataframe()[source]#

Export a streaks container into pandas.DataFrame.

Return type

DataFrame

Returns

A dataframe with all the data specified in cbclib.Streaks.

to_lines()[source]#

Export a streaks container into line parameters x0, y0, x1, y1, width:

  • [x0, y0], [x1, y1] : The coordinates of the line’s ends.

  • width : Line’s width.

Return type

ndarray

Returns

An array of line parameters.

values()#

Return the attributes’ data stored in the container.

Return type

ValuesView

Returns

List of data stored in the container.