Data Function

class nmrPype.fn.function.DataFunction(params: dict = {})

Data Function is a template class for all types of functions to run on the NMR data. New user functions should copy format laid out by this class.

Parameters:

params (dict) – Dictionary of parameters associated with the designated function

static clArgs(subparser, parent_parser)

Command-line arguments template

clArgs adds function parser to the subparser, with its corresponding default args called by nmrPype.parse.parser(). The Destinations are formatted typically by {function}_{argument}, e.g. the zf_pad destination stores the pad argument for the zf function.

Parameters:

subparser (_SubParsersAction[ArgumentParser]) – Subparser object that will receive function and its arguments

initialize(data: DataFrame)
Initialization follows the following steps:
  • Handle function specific arguments

  • Update any header values before any calculations occur that are independent of the data, such as flags and parameter storage

Parameters:

data (DataFrame) – Target data to manipulate

static mpPrint(func_name: str, chunk_num: int, chunk_sizes: tuple[int, int], type: str = 'start')

Print out multiprocess information for verbose print

Parameters:
  • func_name (str) – Name of function to display on verbose print

  • chunk_num (int) – Number of chunks being processed

  • chunk_sizes (tuple[int,int]) – Size of majority chunk [0] and outlier chunk [1]

  • type (str, optional) – Start print or end print type, by default ‘start’

static nullDeclare(subparser, parent_parser)

Null Function declaration

Parameters:

subparser (_SubParsersAction[ArgumentParser]) – Subparser object that will receive null function

parallelize(array: ndarray, verb: tuple[int, int, str] = (0, 16, 'H')) ndarray

The General Multiprocessing implementation for function, utilizing cores and threads. Parallelize should be overloaded if array_shape changes in processing or process requires more args.

Parameters:
  • array (ndarray) – Target data array to process with function

  • verb (tuple[int,int,str], optional)

  • print (Tuple containing elements for verbose) –

    • Verbosity level

    • Verbosity Increment

    • Direct Dimension Label

  • (0 (by default) –

    • Verbosity level

    • Verbosity Increment

    • Direct Dimension Label

  • 16

    • Verbosity level

    • Verbosity Increment

    • Direct Dimension Label

  • 'H')

    • Verbosity level

    • Verbosity Increment

    • Direct Dimension Label

Returns:

new_array – Updated array after function operation

Return type:

ndarray

process(array: ndarray, verb: tuple[int, int, str] = (0, 16, 'H')) ndarray

Process is called by function’s run, returns modified array when completed. Likely attached to multiprocessing for speed

Parameters:
  • array (ndarray) – Target data array to process with function

  • verb (tuple[int,int,str], optional)

  • print (Tuple containing elements for verbose) –

    • Verbosity level

    • Verbosity Increment

    • Direct Dimension Label

  • (0 (by default) –

    • Verbosity level

    • Verbosity Increment

    • Direct Dimension Label

  • 16

    • Verbosity level

    • Verbosity Increment

    • Direct Dimension Label

  • 'H')

    • Verbosity level

    • Verbosity Increment

    • Direct Dimension Label

Returns:

Updated array after function operation

Return type:

ndarray

run(data: DataFrame) int
Main body of function code.
  • Initializes Header

  • Start Process (process data vector by vector in multiprocess)

  • Update Header

  • Return information if necessary

Overload run for function specific operations

Parameters:

data (DataFrame) – Target data to to run function on

Returns:

Integer exit code (e.g. 0 success 1 fail)

Return type:

int

updateHeader(data: DataFrame)

Update the header following the main function’s calculations. Typically this includes header fields that relate to data size.

Parameters:

data (DataFrame) – Target data frame containing header to update

static verbPrint(func_name: str, index, size, step, verb: tuple[int, str] = (16, 'H'), keepIndex: bool = False)

Print out progress through each array using verbosity

Parameters:
  • func_name (str) – Name of function to display on verbose print

  • index (_type_) – Current array out of total arrays to print

  • size (_type_) – Total array count to print

  • step (_type_) – How many elements are in each array

  • verb (tuple[int,int,str], optional) –

    Tuple containing elements for verbose print, by default (16,’H’)
    • Verbosity Increment

    • Direct Dimension Label

  • keepIndex (bool, optional) – Whether or not to divide index by step size, by default False

Transpose Template

class nmrPype.fn.TP.Transpose(tp_noord: bool = False, tp_exch: bool = False, tp_minMax: bool = True, tp_axis: int = 0, params: dict = {})

Template Data Function object for transposition operations

Parameters:
  • tp_noord (bool) – Do not change header FDORDER1 and 2.

  • tp_exch (bool) – Exchange header parameters for the two dimensions.

  • tp_minMax (bool) – Update FDMIN and FDMAX.

  • tp_axis (int) – Indirect dimension axis to be swapped with direct dimension

static clArgs(subparser, parent_parser)

Transpose command-line arguments

Adds Transpose parser to the subparser, with its corresponding default args. Called by nmrPype.parse.parser()

Note

Command-line arguments function is only called once for all transpose types

Parameters:

subparser (_SubParsersAction[ArgumentParser]) – Subparser object that will receive function and its arguments

static headerArgsTP(parser)

Helper function to parse commands related to header adjustment.

initialize(data: DataFrame)
Initialization follows the following steps:
  • Handle function specific arguments

  • Update any header values before any calculations occur that are independent of the data, such as flags and parameter storage

Parameters:

data (DataFrame) – Target data frame to initialize

matrixTP(array, dim1, dim2)
parallelize(array: ndarray) ndarray

Blanket transpose parralelize implementation for function, utilizing cores and threads. Function Should be overloaded if array_shape changes in processing or process requires more args.

Note

Multiprocessing and mulithreading transpose is likely slower due to stitching.

Parameters:

array (ndarray) – Target data array to process with function

Returns:

new_array – Updated array after function operation

Return type:

ndarray

process(array: ndarray) ndarray

Process is called by function’s run, returns modified array when completed. Likely attached to multiprocessing for speed

Parameters:

array (ndarray) – array to process

Returns:

modified array post-process

Return type:

ndarray

updateHeader(data: DataFrame)

Update the header following the main function’s calculations. Typically this includes header fields that relate to data size.

Parameters:

data (DataFrame) – Data frame containing header that will be updated