ncempy.eval package

Submodules

ncempy.eval.line_profile module

ncempy.eval.line_profile.line_profile(im0, p0, p1, num_points, width=0, step=0.5)[source]

Use interpolation to measure a line scan across a 2D image. map_coordinates uses a different convention from numpy indexing. So the x and y positions need to be flipped.

Parameters:
  • im0 (ndarray) – The 2D array of the image
  • p0 (tuple) – The start of the line scan (x0,y0) and (row,col)
  • p1 (tuple) – The end of the line scan (x1,y1)
  • num_points (int) – The number of points in the line scan
  • width (int) – The width of the line scan to average over. Must be an integer.
  • step (float) – The step size laterally for the interpolation. Must be < 1
Returns:

A tuple containing the line profile and the positions where the interpolation was performed

Return type:

tuple

Note

As an example: if width = 1 and step = 0.5 then there will be 3 line scans averaged.

Example

>> line, (xx, yy) = line_profile(image,(0,100),(175,100),50,step=0.5,width=5) >> fg, ax = plt.subplots(1,2) >> ax[0].plot(line,’*-‘) >> ax[1].imshow(image) >> ax[1].scatter(xx, yy)

ncempy.eval.ring_diff module

Module to process ring diffraction patterns.

ncempy.eval.ring_diff.cur_eva_vers = 'ring_diffraction_evaluation_vers0.1'

Used to identify evaluation hdf5 groups.

Type:str
ncempy.eval.ring_diff.cur_set_vers = 'ring_diffraction_setting_vers0.1'

Used to identify settings hdf5 groups.

Type:str
ncempy.eval.ring_diff.dummy_settings = {'back_init': (1.0, 1.0, 1.0), 'back_xs': (1.0, 2.0, 3.0), 'back_xswidth': 0.1, 'fit_funcs': ('voigt',), 'fit_init': (1.0, 1.0, 1.0, 1.0), 'fit_maxfev': 10, 'fit_rrange': (1.0, 2.0), 'lmax_cinit': (1, 1), 'lmax_r': 1, 'lmax_range': (1.0, 2.0), 'lmax_thresh': 1, 'mask': array([[1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.]]), 'ns': (1,), 'plt_imgminmax': (0.0, 1.0), 'rad_dr': 0.1, 'rad_rmax': 1, 'rad_sigma': 0.1}

Dummy settings with all parameters set.

Type:dict
ncempy.eval.ring_diff.get_settings(parent)[source]

Get settings for radial profile evaluation.

Parameters:parent (h5py.Group) – Input group.
Returns:Settings read from parent.
Return type:dict
ncempy.eval.ring_diff.min_dummy_settings = {'back_init': (1.0, 1.0, 1.0), 'back_xs': (1.0, 2.0, 3.0), 'back_xswidth': 0.1, 'fit_funcs': ('voigt',), 'fit_init': (1.0, 1.0, 1.0, 1.0), 'fit_maxfev': None, 'fit_rrange': (1.0, 2.0), 'lmax_cinit': (1, 1), 'lmax_r': 1, 'lmax_range': (1.0, 2.0), 'lmax_thresh': 1, 'mask': None, 'ns': (1,), 'plt_imgminmax': None, 'rad_dr': None, 'rad_rmax': None, 'rad_sigma': None}

Dummy settings with all parameters set but all optional ones as Nones.

Type:dict
ncempy.eval.ring_diff.put_settings(parent, settings)[source]

Put settings for radial profile evaluation.

Creates a subgroup in parent holding the settings as attributes.

Parameters:
  • parent (h5py.Group) – Group to hold settings subgroup.
  • setting (dict) – Settings to write.
Returns:

Handle to settings group.

Return type:

h5py.Group

ncempy.eval.ring_diff.put_sglgroup(parent, label, data_grp)[source]

Adds the evaluation into parent.

Remember that the resource of the external link must not be already opened elsewhere to access data.

Parameters:
  • parent (h5py.Group) – Hdf5 group to add this evaluation group to.
  • label (str) – Label for the evaluation group.
  • data_grp (h5py.Group) – Emdtype group where to find the data.
Returns:

Handle to group.

Return type:

h5py.Group

ncempy.eval.ring_diff.run_all(parent, outfile, overwrite=False, verbose=False, showplots=False)[source]

Run on a set-up emd file to do evaluations and save results.

All evaluations within parent are run.

Parameters:
  • parent (h5py.Group) – Handle to parent.
  • outfile (ncempy.io.emd.fileEMD) – Emdfile for output.
  • overwrite (bool) – Set to overwrite existing results in outfile.
  • verbose (bool) – Set to get verbose output during run.
  • showplots (bool) – Set to directly show plots interactively.
ncempy.eval.ring_diff.run_sglgroup(group, outfile, overwrite=False, verbose=False, showplots=False)[source]

Run evaluation on a single group.

Parameters:
  • group (h5py.Group) – Handle to evaluation group to execute.
  • outfile (ncempy.io.emd.fileEMD) – Emdfile for output.
  • overwrite (bool) – Set to overwrite existing results in outfile.
  • verbose (bool) – Set to get verbose output during run.
  • showplots (bool) – Set to directly show plots interactively.

ncempy.eval.stack_align module

ncempy.eval.stack_align.stack_align(stack, align_type='static', **kwargs)[source]

Align a series of images by correlation using multicorr. All images are aligned to the start image or as dynamically starting with the start image and then each successive image. keyword arguments are passed to multicorr. Shifting is done in Fourier space which is very accurate, but wraps edges.

Parameters:
  • stack (ndarray, 3D,) – Stack of images to align. Shape [num, Y, X]
  • align_type (str) – static or dynamic alignment. Static aligns all images to the first image. Dynamic aligns each image to the previous image starting with the first image
Returns:

A tuple containing the aligned images as a 3D ndarray of shape [num, Y, X] and shifts as a 2D ndarray of shape [num, 2]

Return type:

tuple, aligned stack, shifts