spike package — spike 0.99.8-407 documentation

# spike package

## Subpackages

- spike.Algo package
  - Submodules
  - spike.Algo.BC module
  - spike.Algo.CS_transformations module
  - spike.Algo.Cadzow module
  - spike.Algo.Cadzow_mpi module
  - spike.Algo.Cadzow_mpi2 module
  - spike.Algo.Laplace module
  - spike.Algo.Linpredic module
  - spike.Algo.SL0 module
  - spike.Algo.SL0_test module
  - spike.Algo.maxent module
  - spike.Algo.rQRd module
  - spike.Algo.sane module
  - spike.Algo.sane_old module
    - sane.py
  - spike.Algo.savitzky_golay module
  - spike.Algo.urQRd module
    - urQRd.py
  - Module contents
- spike.Display package
  - Submodules
  - spike.Display.fakeplot module
  - spike.Display.testplot module
  - Module contents
- spike.File package
  - Submodules
  - spike.File.Apex module
  - spike.File.BrukerMS module
  - spike.File.BrukerNMR module
  - spike.File.BrukerSMX module
  - spike.File.GifaFile module
  - spike.File.HDF5File module
  - spike.File.Solarix module
  - spike.File.Spinit module
  - spike.File.Spinit_with2D module
  - spike.File.Thermo module
  - spike.File.csv module
  - spike.File.mzXML module
  - Module contents
- spike.Miscellaneous package
  - Submodules
  - spike.Miscellaneous.big module
  - spike.Miscellaneous.bruker_corr module
  - spike.Miscellaneous.downsample module
  - spike.Miscellaneous.downsampling module
  - spike.Miscellaneous.poulding module
  - spike.Miscellaneous.processing2 module
  - spike.Miscellaneous.stat module
  - Module contents
- spike.plugins package
  - Submodules
  - spike.plugins.Bruker_NMR_FT module
  - spike.plugins.Bucketing module
  - spike.plugins.FTMS_calib module
  - spike.plugins.Fitter module
  - spike.plugins.Linear_prediction module
  - spike.plugins.PALMA module
  - spike.plugins.Peaks module
  - spike.plugins.apmin module
  - spike.plugins.bcorr module
  - spike.plugins.bokeh_display module
  - spike.plugins.fastclean module
  - spike.plugins.gaussenh module
  - spike.plugins.pg_sane module
  - spike.plugins.rem_ridge module
  - spike.plugins.sane module
  - spike.plugins.sg module
  - spike.plugins.test module
  - spike.plugins.tisane module
  - spike.plugins.urQRd module
  - spike.plugins.wavelet module
  - spike.plugins.zoom3D module
  - Module contents
- spike.util package
  - Submodules
  - spike.util.ConfigForm module
  - spike.util.ValErr module
  - spike.util.compat module
  - spike.util.counter module
  - spike.util.debug_tools module
  - spike.util.dynsubplot module
  - spike.util.hashcheck module
  - spike.util.log_all module
  - spike.util.log_stderr module
  - spike.util.log_stdout module
  - spike.util.mail module
  - spike.util.mail_error_logger module
  - spike.util.mpiutil module
  - spike.util.near_prime module
  - spike.util.progrbarUi module
  - spike.util.progressbar module
  - spike.util.readwrite_tools module
  - spike.util.sendgmail module
  - spike.util.shift_comments module
  - spike.util.signal_tools module
  - spike.util.simple_logger module
  - spike.util.simple_logger2 module
  - spike.util.widgets module
  - Module contents
- spike.v1 package
  - Submodules
  - spike.v1.Bruker module
  - spike.v1.Generic module
  - spike.v1.GenericDosy module
  - spike.v1.GenericMaxEnt module
  - spike.v1.Kore module
  - spike.v1.Launch module
  - spike.v1.NPKv1 module
  - spike.v1.Nucleus module
  - spike.v1.Param module
  - spike.v1.Process1D module
  - spike.v1.Process2D module
  - spike.v1.Process3D module
  - spike.v1.ProcessDosy module
  - spike.v1.mflops module
  - spike.v1.test module
  - spike.v1.v1_Tests module
  - Module contents

## Submodules

## spike.FTICR module

This file implements all the tools for handling FT-ICR data-sets

It allows to work with 1D and 2D

To use it :

import FTICR d = FTICR.FTICRData(…) # There are several possible initialisation : empty, from file play with d

d will allows all NPKData methods, plus a few specific ones.

alternatively, use an importer : from File.(Importer_name) import Import_1D d = Import_1D(“filename)”)

Created by Marc-André on 2014-08 Copyright (c) 2014 IGBMC. All rights reserved.

class `spike.FTICR.` `FTICRAxis`(itype=0, currentunit='points', size=1024, specwidth=1000000.0, offsetfreq=0.0, left_point=0.0, highmass=10000.0, calibA=100000000.0, calibB=0.0, calibC=0.0, lowfreq=10000.0, highfreq=1000000.0)

  Bases: `spike.FTMS.FTMSAxis`

  hold information for one FT-ICR axis used internally

  `htomz`(value)

    return m/z (mz) from hertz value (h)

  `mztoh`(value)

    return Hz value (h) from m/z (mz)

  `report`()

    high level reporting

class `spike.FTICR.` `FTICRData`(dim=1, shape=None, mode='memory', group='resol1', buffer=None, name=None, debug=0)

  Bases: `spike.FTMS.FTMSData`

  subclass of FTMS.FTMSData, meant for handling FT-ICR data allows 1D and 2D data-sets

class `spike.FTICR.` `FTICR_Tests`(methodName='runTest')

  Bases: `unittest.case.TestCase`

  `announce`()
  `setUp`()
  `test_atob`()

    testing unit conversion functions

  `test_axis`()

    testing FTICRAxis object

  `test_saving_1D`()

    Testing how save_msh5 works on 1D spectrum

  `test_trim`()

    Test trimz

## spike.FTMS module

FTMS.py

This file defines generic classes for FT-MS Spectroscopy (FT-ICR and Orbitrap)

not meant to be used directly, but rather called from either Orbitrap.py or FTICR.py

Created by Marc-André on 2014-08 Copyright (c) 2014 IGBMC. All rights reserved.

class `spike.FTMS.` `FTMSAxis`(itype=0, currentunit='points', size=1024, specwidth=1000000.0, offsetfreq=0.0, left_point=0.0, highmass=10000.0, calibA=0.0, calibB=0.0, calibC=0.0)

  Bases: `spike.NPKData.Axis`

  hold information for one FT-MS axis used internally

  `Hz_axis`()

    return axis containing Hz values, can be used for display

  `borders`

    the (min, max) available windows, used typically for display

  `deltamz`(mz_value)

    computes the theorical maximum resolution in m/z at m/z location

  `display_icalib`(axis, xref, mzref, symbol='bo')

    generates a plot of the current calibration xref : list of point coordinates of the reference points mzref: list of reference m/z symbol: matplotlib notation for points (default is blue rounds)

  `extract`(zoom)

    redefines the axis parameters so that the new axe is extracted for the points [start:end] zoom is defined in current axis unit

  `freq_axis`()

    return axis containing Hz values, can be used for display

  `htoi`(value)

    returns point value (i) from Hz value (h)

  `htomz`(value)

    return m/z (mz) from Hz value

  `imzmeas` = array([-2.31584178e+077, -2.31584178e+077, 5.95461108e-313, 1.11258854e-306, 1.49457450e-154, -2.31584178e+077, 5.95461108e-313, 8.45599365e-307, -1.49457450e-154, 6.99670898e-309])
  `itoh`(value)

    returns Hz value (h) from point value (i)

  `itomz`(value)

    return m/z (mz) from point value (i)

  `itos`(value)

    returns time value (s) from point value - valid for transients

  `lowmass`

    highest mass of interest - defined by the Nyquist frequency limit

  `mass_axis`()

    return axis containing m/z values, can be used for display

  `mz_axis`()

    return axis containing m/z values, can be used for display

  `mzref` = array([2.52961611e-321, 6.71929278e-322, 6.93650648e-310, 3.95252517e-323, 1.97626258e-323, 2.18563451e-314, 2.18563452e-314, 2.18472190e-314, 2.18472198e-314, 6.95395099e-309])
  `mztoh`(value)

    return Hz value from m/z (mz)

  `mztoi`(value)

    return point value (i) from m/z (mz)

  `ppm`(axis, xref, mzref)

    computes the mean error in ppm from a array of positions (xref) and the theoretical m/z (mzref) uses l1 norm ! xref : array of point coordinates of the reference points mzref: array of reference m/z

  `ppm_error`(axis, xref, mzref)

    computes the error from a array of positions (xref) and the theoretical m/z (mzref) returns an array with errors in ppm xref : array of point coordinates of the reference points mzref: array of reference m/z

  `stoi`(value)

    returns point value (i) from time value (s)

class `spike.FTMS.` `FTMSData`(dim=1, shape=None, mode='memory', buffer=None, name=None, debug=0)

  Bases: `spike.NPKData.NPKData`

  subclass of NPKData, meant for handling FT-MS data allows 1D and 2D data-sets

  `highmass`

    copy highmass to all the axes

  `ref_freq`

    copy ref_freq to all the axes

  `ref_mass`

    copy ref_mass to all the axes

  `save_msh5`(name, compressed=False)

    save data to a HDF5 file

    if compressed is True, file is internally compressed using HDF5 compressors (currently zlib) not final version !!

  `specwidth`

    copy specwidth to all the axes

  `trimz`(axis=0)

    extract the data so as to keep only lowmass-highmass range axis determines which axis to trim, axis=0 (default) indicates all axes

## spike.NPKConfigParser module

A utility that wraps ConfigParser for NPK

Typical use is :

cp = NPKConfigParser() cp.readfp(open(configfilename)) # where configfilename is the name of the config file var1 = cp.get( section, varname1) var2 = cp.get( section, varname2, default_value) … you can use get() getint() getfloat() getboolean() see details in methods.

Created by Marc-André on 2011-10-14. Copyright (c) 2011 IGBMC. All rights reserved.

MAD modif on 21 - may 2012 - added getword and removing trailing comments MAD, in April 2017 : adapted (painfully) to python3

class `spike.NPKConfigParser.` `NPKConfigParser`(defaults=None, dict_type=<class 'collections.OrderedDict'>, allow_no_value=False, *, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section='DEFAULT', interpolation=<object object>, converters=<object object>)

  Bases: `configparser.ConfigParser`

  this is a subclass of ConfigParser.ConfigParser, providing default value for values will never raise an error on missing values

  `get`(section, option, default=None, raw=0, verbose=False, fallback=<object object>)

    read a value from the configuration, with a default value

  `getboolean`(section, option, default='OFF', raw=0, verbose=False)

    read a boolean value from the configuration, with a default value

  `getfloat`(section, option, default=0.0, raw=0, verbose=False)

    read a float value from the configuration, with a default value

  `getint`(section, option, default=0, raw=0, verbose=False)

    read a int value from the configuration, with a default value understands 123 16k 32M 4G 2T … (units in power of 2, not power of 10 !!)

  `getword`(section, option, default=None, raw=0, verbose=False)

    read a value from the configuration, with a default value - takes the first word of the string

class `spike.NPKConfigParser.` `Tests`(methodName='runTest')

  Bases: `unittest.case.TestCase`

  `announce`()
  `setUp`()
  `test_def`()

    testing configparser default values

  `test_read`()

    testing configparser - getting values from file

## spike.NPKData module

NPKData.py

Implement the basic mechanisms for spectral data-sets

First version created by Marc-André and Marie-Aude on 2010-03-17.

class `spike.NPKData.` `Axis`(size=64, itype=0, currentunit='points')

  Bases: `object`

  hold information for one spectral axis used internally

  `borders`

    the (min, max) available windows, used typically for display

  `check_zoom`(zoom)

    check whether a zoom window (or any slice), given as (low,high) is valid - check low<high and within axis size - check that it starts on a real index if itype is complex return a boolean

  `copy`()
  `cpxsize`

    returns size of complex entries this is different from size, size == cpxsize if axis is real size == 2*cpxsize if axis is complex

  `ctoi`(val)

    converts into point value (i) from currentunit (c)

  `currentunit`

    get the current unit for this axis, to be chosen in axis.units.keys()

  `extract`(zoom)

    redefines the axis parameters so that the new axis is extracted for the points [start:end]

    zoom is given in current unit - does not modify the Data, only the axis definition

    This definition should be overloaded for each new axis, as the calibration system, associated to unit should be updated.

  `get_sampling`()

    returns the sampling scheme contained in current axis

  `getslice`(zoom)

    given a zoom window (or any slice), given as (low,high) in CURRENT UNIT,

    returns the value pair in index, as (star,end) which insures that - low<high and within axis size - that it starts on a real index if itype is complex raise error if not possible

  `itoc`(val)

    converts point value (i) to currentunit (c)

  `load_sampling`(filename)

    loads the sampling scheme contained in an external file file should contain index values, one per line, comment lines start with a # complex axes should be sampled by complex pairs, and indices go up to self.size1/2

    sampling is loaded into self.sampling and self.sampling_info is a dictionnary with information

  `points_axis`()

    return axis in points currentunit, actually 0..size-1

  `report`()
  `sampled`

    true is sampled axis

  `set_sampling`(sampling)

    sets the sampling scheme contained in current axis

  `typestr`()

    returns its type (real or complex) as a string

  `unit_axis`()

    returns an axis in the unit defined in self.currentunit

class `spike.NPKData.` `LaplaceAxis`(size=64, dmin=1.0, dmax=10.0, dfactor=1.0, currentunit='damping')

  Bases: `spike.NPKData.Axis`

  hold information for one Laplace axis (DOSY) used internally

  `D_axis`()

    return axis containing Diffusion values, can be used for display

  `dtoi`(value)

    returns point value (i) from damping value (d)

  `itod`(value)

    returns damping value (d) from point value (i)

  `load_qvalues`(fname)

    doc

  `report`()

    hight level report

class `spike.NPKData.` `NMRAxis`(size=64, specwidth=6283.185307179586, offset=0.0, frequency=400.0, itype=0, currentunit='points')

  Bases: `spike.NPKData.Axis`

  hold information for one NMR axis used internally

  `Hz_axis`()

    return axis containing Hz values, can be used for display

  `extract`(zoom)

    redefines the axis parameters so that the new axis is extracted for the points [start:end]

    zoom is given in current unit - does not modify the Data, only the axis definition

  `freq_axis`()

    return axis containing Hz values, can be used for display

  `htoi`(value)

    returns point value (i) from Hz value (h)

  `htop`(value)

    returns ppm value (p) from Hz value (h)

  `itoh`(value)

    returns Hz value (h) from point value (i)

  `itop`(value)

    returns ppm value (p) from point value (i)

  `itos`(value)

    returns time value (s) from point value

  `ppm_axis`()

    return axis containing ppm values, can be used for display

  `ptoh`(value)

    returns Hz value (h) from ppm value (p)

  `ptoi`(value)

    returns point value (i) from ppm value (p)

  `report`()

    high level reporting

  `stoi`(value)

    returns point value (i) from time value (s)

class `spike.NPKData.` `NPKData`(dim=1, shape=None, buffer=None, name=None, debug=0)

  Bases: `object`

  a working data used by the NPK package

  The data is a numpy array, found in self.buffer can also be accessed directly d[i], d[i,j], …

  1D 2D and 3D are handled, 3 axes are defined : axis1 axis2 axis3 axes are defined as in NMR in 1D, every is in axis1 in 2D, the fastest varying dimension is in axis2, the slowest in axis1 in 3D, the fastest varying dimension is in axis3, the slowest in axis1 see axis_index typical properties and methods are : utilities:

  > .display() .check()

  properties
    .itype .dim .size1, .size2, .size3 …
  moving data :
    .row(i) .col(i) .set_row(i) .set_col(i) .copy() .load() .save()
  processing :
    .fft() .rfft() .modulus() .apod_xxx() sg() transpose() …
  arithmetics :
    .fill() .mult .add() also direct arithmetics : f = 2*d+e

  all methods return self, so computation can be piped etc…

  `abs`()

    This command takes the absolute value of the current the data set

  `absmax`
  `adapt_size`()

    adapt the sizes held in the axis objects to the size of the buffer TO BE CALLED each time the buffer size is modified otherwise strange things will happen

  `add`(otherdata)

    add the provided data : otherdata to the current one eg : data.add(otherdata) add content of otherdata to data buffer

    can add NPKData and numbers

  `addbase`(constant)

    add a constant to the data

  `addfreq`(freq, amp=1.0)

    add to the current data-set (1D) a single frequency sinusoid characterized by its frequency (from axis.specwidth) and amplitude

  `addnoise`(noise, seed=None)

    add to the current data-set (1D, 2D, 3D) a white-gaussian, characterized by its level noise, and the random generator seed.

  `apmin`(d, first_order=True, inwater=False, baselinecorr=True, apt=False, debug=False)

    automatic 1D phase correction phase by minimizing the negative wing of the 1D spectrum

    first_order = False inhibit optimizing 1st order phase inwater = True does not look to the central zone of the spectrum baselinecorr = True, an advanced baseline correction is applied on the final steps apt = True (Attached proton test) performs the phasing on up-down spectra, such as APT / DEPT 13C spectra.

    performs a grid/simplex search on P0 first then on (P0 P1) the dataset is returned phased and the values are stored in d.axis1.P0 and d.axis1.P1

    P1 is kept to 0 if first_order=False

    note that if baselinecorr is True
      - the algo becomes quite slow !
      - a simple linear baseline correction is always applied anyway anyhow

    adapted from NPK v1 MAD, may 2016

  `apod_apply`(axis, apod_buf)

    apply an apodisation, held into the buffer apod_buf

  `apod_em`(lb, axis=0)

    apply an exponential apodisation, lb is in Hz WARNING : different from common definition of apodisation

  `apod_gm`(gb, axis=0)

    apply an gaussian apodisation, gb is in Hz WARNING : different from common definition of apodisation

  `apod_sin`(maxi=0.0, axis=0)

    apply a sinebell apodisation maxi ranges from 0 to 0.5

  `apod_sq_sin`(maxi=0.0, axis=0)

    apply a squared sinebell apodisation maxi ranges from 0 to 0.5

  `apod_tm`(tm1, tm2, axis=0)

    apply a trapezoide apodisation, lb is in Hz WARNING : different from common definition of apodisation This commands applies a trapezoid filter function to the data- set. The function raises from 0.0 to 1.0 from the first point to point n1. The function then stays to 1.0 until point n2, from which it goes down to 0.0 at the last point. If in 2D or 3D then Fx tells on which axis to apply the filter.

  `apply_process`(axis_it, process, axis=0, mp=True, N_proc=None)

    scans through given data, using axis_it which is an iterator, applying process method (by its name) store results into self, along to axis if axis_it iterates over self, then processing is in-place

    > however it can iterate over an other data-set, thus importing the data

    if self.dim is equal to axis_it().dim, then data are

    if mp, does it in a multiprocessing fashion using multiprocessing.Pool() if N_proc is None, finds the optimum number itself.

  `axes`(axis)

    returns the required axis : 1, 2 or 3

  `bcorr`(npkd, method='spline', xpoints=None)

    recapitulate all baseline correction methods, only 1D so far

    method is either
      auto:
        use bcorr_auto, uses an automatic determination of the baseline does not work with negative peaks.
      linear:
        simple 1D correction
      spline:
        a cubic spline correction

    both linear and spline use an additional list of pivot points ‘xpoints’ used to calculate the baseline if xpoints absent, pivots are estimated automaticaly if xpoints is integer, it determines the number of computed pivots (defaut is 8 if xpoints is None)

    default is spline with automatic detection of 8 baseline points

  `bcorr_auto`(npkd, iterations=10, nbchunks=40, degree=1, nbcores=2, smooth=True)

    applies an automatic baseline correction

    Find baseline by using low norm value and then high norm value to attract the baseline on the small values. Parameters : iterations : number of iterations for convergence toward the small values. nbchunks : number of chunks on which is done the minimization. Typically, each chunk must be larger than the peaks. degree : degree of the polynome used for approaching each signal chunk. nbcores : number of cores used for minimizing in parallel on many chunks (if not None)

    smooth i True, applies a final Savitsky-Golay smoothing

  `bcorr_lin`(npkd, xpoints, axis='F2')

    ” compute and applies a linear function as a baseline correction xpoints are the location of pivot points

  `bcorr_spline`(npkd, xpoints, axis='F2')

    ” compute and applies a spline function as a baseline correction xpoints are the location of pivot points

  `bk_corr`()

    applies a correction on the spectrum for the time offset in the FID. time offset is stored in the axis property zerotime

  `bk_ftF1`(data)

    emulates Bruker ft of a 2D in F1 depending on FnMode

    None 0 QF 1 QSEQ 2 TPPI 3 States 4 States-TPPI 5 Echo-AntiEcho 6

  `bk_ftF2`(data)

    emulates Bruker ft of a 2D in F1 depending on FnMode

  `bk_pk`()

    applies a correction on the spectrum for the time offset in the FID and from proc file parameters.

  `bk_wdw`(data, axis=1)

    emulates Bruker window function

  `bk_xf1`(data)

    emulates xf1 command from topspin

  `bk_xf2`(data)

    emulates xf2 command from topspin

  `bk_xf2p`()

    applies a correction on the spectrum for the time offset in the FID and from proc file parameters.

  `bk_xfb`(data)

    emulates xfb command from topspin

  `bokeh`(npkd, scale=1.0, autoscalethresh=3.0, absmax=None, show=False, title=None, label=None, xlabel='_def_', ylabel='_def_', axis=None, image=False, mode3D=False, zoom=None, mpldic={}, dbkdic={}, dfigdic={}, linewidth=1, color=None, plot_width=600, plot_height=400, sizing_mode=None, redraw=False, tools='pan, box_zoom, box_select, reset, save')

    Display using bokeh instead of matplotlib

    scale allows to increase the vertical scale of display absmax overwrite the value for the largest point, which will not be computed

    > display is scaled so that the largest point is first computed (and stored in absmax), and then the value at absmax/scale is set full screen

    show will call bk.show() at the end, allowing every declared display to be shown on-screen
      useless in ipython/jupyter notebook

    title add a title to the bokeh plot label add a label text to plot xlabel, ylabel axes label (default is self.currentunit - use None to remove) axis used as axis if present, axis length should match experiment length

    > in 2D, should be a pair (xaxis,yaxis)

    image if True, the function will generate the 2D NMR FID of data,
      if False (Default), the function present contour plots.

    mode3D not implemented zoom is a tuple defining the zoom window (left,right) or ((F1_limits),(F2_limits))

    > defined in the current axis unit (points, ppm, m/z etc ….)

    mpldic a dictionnary passed as is to the matplotlib plot command dbkdic a dictionnary passed as is to populated the parameters of the bokeh graph dfigdic a dictionnary passed as is to populated the content of the bokeh figure linewidth linewidth for the plots (useful for example when using seaborn) color if 1D is the color of the curve,

    > if 2D FID is the palette name to be used, if 2D contour is the color set to be used by matplotlib.

    plot_width, plot_height width and height of the plot sizing_mode if provided, resize plot according to the window chosen sizes.

    > e.g. “scale_width”, “scale_height”, “scale_both”

    tools a string containing the tools to be available for bokeh interactivity.
      e.g. “pan, box_zoom, box_select, reset, save” (see bokeh doc for more info)
  `bruker_corr`()

    applies a correction on the spectrum for the time offset in the FID. time offset is stored in the axis property zerotime

  `bruker_proc_phase`()

    applies a correction on the spectrum for the time offset in the FID and from proc file parameters.

  `bucket1d`(data, zoom=(0.5, 9.5), bsize=0.04, pp=False, thresh=10, file=None)

    This tool permits to realize a bucket integration from the current 1D data-set. You will have to give (all spectral values are in ppm)

    > - zoom (low,high), : the starting and ending ppm of the integration zone in the spectrum
    > - bsize: the size of the bucket
    > - pp: if True, the number of peaks in the bucket is also added
    >     - peaks are detected if intensity is larger that thresh*noise
    > - file: the filename to which the result is written

    For a better bucket integration, you should be careful that :
      - the bucket size is not too small, size is better than number !
      - the baseline correction has been carefully done
      - the spectral window is correctly determined to encompass the meaningfull spectral zone.
  `bucket2d`(data, zoom=((0.5, 9.5), (0.5, 9.5)), bsize=(0.1, 0.1), pp=False, thresh=10, file=None)

    This tool permits to realize a bucket integration from the current 2D data-set. You will have to give the following values: (all spectral values are in ppm)

    > - zoom (F1limits, F2limits), : the starting and ending ppm of the integration zone in the spectrum
    > - bsize (F1,F2): the sizes of the bucket
    > - pp: if True, the number of peaks in the bucket is also added
    >     - peaks are detected if intensity is larger that thresh*noise
    > - file: the filename to which the result is written

    For a better bucket integration, you should be careful that :
      - the bucket size is not too small, size is better than number !
      - the baseline correction has been carefully done
      - the spectral window is correctly determined to encompass the meaningfull spectral zone.
  `calib`(npk, axis=1, method='l1', verbose=False)

    the current FTMS experiment is recalibrated optimatly along its axis ‘axis’ (usefull only in 2D) using parameters provided with set_calib() uses the current (2 or 3 parameters) calibration

    method is either ‘l1’ (robust) or ‘l2’ (classic)

    The current calibration is copied to a new unused axis called RefAxis

  `calibdosy`(npk, nucleus='1H')

    use stored parameters to determine correct DOSY calbiration

  `center`(zone=None)

    center the data, so that the sum of points is zero (usefull for FIDs)

  `centroid`(npkd, *arg, **kwarg)
  `check`(warn=False)

    check basic internal validity raises exceptions unless warn is set to True - in which case, only warnings are issued can be used in pipes as it returns self if everything is ok

  `check1D`()

    true for a 1D

  `check2D`()

    true for a 2D

  `check3D`()

    true for a 3D

  `check_zoom`(zoom)

    check whether a zoom window, given as (low,high) or ((low1,high1),(low2,high2)) is valid - check low<high and within axis size - check that it starts on a real index in itype is complex return a boolean

  `checknD`(n)
  `chsize`(sz1=-1, sz2=-1, sz3=-1)

    Change size of data, zero-fill or truncate. DO NOT change the value of OFFSET and SPECW, so EXTRACT should always be preferred on spectra (unless you know exactly what your are doing).

  `col`(i)

    returns a 1D extracted from the current 2D at position 0<=i<=size2-1

  `conjg`(axis=0)

    take the inverse conjugate of the buffer

  `conv_n_p`()

    realises the n+p to SH conversion

  `copy`()

    return a copy of itself

  `cpxsize1`

    returns the size of the F1 spectral axis in 1D 2D and 3D (number of entries, real or complex) i.e. the unique axis in 1D, the slowest axis in 2D and 3D

  `cpxsize2`

    returns the size of the F2 spectral axis in 2D and 3D (number of entries, real or complex) i.e. the slowest axis in 2D and the intermediate in 3D

  `cpxsize3`

    returns the size of the F3 spectral axis in 3D (number of entries, real or complex) i.e. the slowest axis in 3D

  `diag`(direc='F12')

    In 2D, extracts the diagonal of the 2D and put into the 1D buffer.

    In 3D, extracts one diagonal plane of the 3D cube, chosen with the direc parameter and put it into the 2D buffer direct values are :

    “F12” is the F1=F2 diagonal “F23” is the F2=F3 diagonal “F13” is the F1=F3 diagonal

  `diag2D`()
  `diag3D`(direc)
  `dim`

    returns the dimension of data : 1 2 or 3 (for 1D 2D or 3D)

  `display`(scale=1.0, autoscalethresh=3.0, absmax=None, show=False, label=None, new_fig=True, axis=None, zoom=None, xlabel='_def_', ylabel='_def_', title=None, figure=None, linewidth=1, color=None, mpldic={}, mode3D=False)

    not so quick and dirty display using matplotlib or mlab - still a first try

    scale allows to increase the vertical scale of display,
      in 2D if “auto” will compute a scale so the first level is located at at autoscalethresh sigma

    autoscalethresh used for scale=”auto” absmax overwrite the value for the largest point, which will not be computed

    > display is scaled so that the largest point is first computed (and stored in _absmax), and then the value at _bsmax/scale is set full screen

    show will call plot.show() at the end, allowing every declared display to be shown on-screen
      useless in ipython

    label add a label text to plot xlabel, ylabel : axes label (default is self.currentunit - use None to remove) axis used as axis if present, axis length should match experiment length

    > in 2D, should be a pair (xaxis,yaxis)

    new_fig will create a new window if set to True (default) (active only is figure==None)
      if new_fig is a dict, it will be passed as is to plt.figure()

    mode3D obsolete zoom is a tuple defining the zoom window (left,right) or ((F1_limits),(F2_limits))

    > defined in the current axis unit (points, ppm, m/z etc ….)

    figure if not None, will be used directly to display instead of using its own linewidth: linewidth for the plots (useful for example when using seaborn) mpldic: a dictionnary passed as is to the plot command

    can actually be called without harm, even if no graphic is available, it will just do nothing.

  `display_calib`(npkd, axis=1, compare=False)

    generates a plot of the current calibration if compare is True, will try to draw the previous calibration curve along with the current one

  `display_fit`(npkd, **kw)

    displays the result of the fit accept the same arguments than display()

  `display_peaks`(npkd, peak_label=False, peak_mode='marker', zoom=None, show=False, color=None, markersize=6, figure=None)

    display the content of the peak list, peak_mode is either “marker” (default) or “bar” (1D only) zoom is in current unit.

  `do_palma`(npkd, miniSNR=32, mppool=None, nbiter=1000, lamda=0.1, uncertainty=1.2, precision=1e-08)

    realize PALMA computation on each column of the 2D datasets dataset should have been prepared with prepare_palma()

    the noise in the initial spectrum is analysed on the first DOSY increment then each column is processed with palma() if its intensity is sufficient

    miniSNR: determines the minimum Signal to Noise Ratio of the signal for allowing the processing mppool: if passed as a multiprocessing.Pool, it will be used for parallel processing

    the other parameters are transparently passed to palma()

  `extract`([[x1, y1]])

    extract([x1, y1], [x2, y2]) or extract([x1, y1, x2, y2]) etc…

    Permits to extract a portion of the data. Data can then be processed as a regular data-set. EXTRACT changes the value of OFFSET and SPECW accordingly.

    > - extract(x1,y1) for 1D datasets.
    > - extract(x1, y1, x2, y2) for 2D datasets.

    coordinates are given in axis current unit

    see also : chsize

  `f`(x, y)

    used by 3D display

  `f1demodu`(shift, axis=1)

    ‘demodulate’ a given 2D with FID along F1 by multiplying it with the complex serie exp(j 2 pi shift) this has the effect of shifting the frequency by ‘shift’ expressed in Hz

    Only for 2D. it is assumed to have complex pairs in even and odd columns faked by calling flipphase()

  `fake`(dd, title)

    fake method

  `fastclean`(npkd, nsigma=2.0, nbseg=20, axis=0)

    set to zeros all points below nsigma times the noise level This allows the corresponding data-set, once stored to file, to be considerably more compressive.

    nsigma: float
      the ratio used, typically 1.0 to 3.0 (higher compression)
    nbseg: int
      the number of segments used for noise evaluation, see util.signal_tools.findnoiselevel
    axis: int
      the axis on which the noise is evaluated, default is fastest varying dimension
  `fft`(axis=0)

    computes the complex Fourier transform,

    takes complex time domain data and returns complex frequency domain data

    see test_axis for information on axis

  `fftr`(axis=0)

    computes the alternate Fourier transform,

    takes complex time domain data and returns real frequency domain data

    see test_axis for information on axis

  `fill`(value)

    fills the dataset with a single numerical value

  `fit`(npkd, zoom=None)

    fit the 1D npkd data-set for Lorentzian line-shape current peak list is used as an initial values for fitting Only peaks within the zoom windows are fitted

    fitting is contraint from the initial values
      - intensity will not allowed to change by more than x0.5 to x2
      - positions by more than 5 points
      - width by more than x5

      (constraints work only for scipy version >= 0.17 )

    It may help to use centroid() to pre-optimize the peak list before calling fit(), or calling fit() twice (slower)

  `flip`()

    on a 2D with axis2.itype==1 and axis1.itype==0 copies the imaginary from on axis to the other after this, we have

    > axis2.itype==0 and axis1.itype==1 size1 is doubled size2 is halved

    Useful for complex FT this is the opposite of flop()

    >>>bb=NPKData(buffer=array([[ 0., 1., 2., 3.],[ 4., 5., 6., 7.],[ 8., 9., 10., 11.],[ 12., 13., 14., 15.]])) >>>print bb.buffer array([[ 0., 1., 2., 3.],

    > [ 4., 5., 6., 7.], [ 8., 9., 10., 11.], [ 12., 13., 14., 15.]])

    >>>bb.axis2.itype=1 >>>print bb.typestr() data-set is complex in F2 >>>bb.flip() >>>print bb.typestr() data-set is complex in F1 >>>print bb.buffer array([[ 0., 2.],

    > [ 1., 3.], [ 4., 6.], [ 5., 7.], [ 8., 10.], [ 9., 11.], [ 12., 14.], [ 13., 15.]])

  `flipphase`(ph0, ph1, axis=1)

    equivalent to flip(); phase();flop() but much faster apply a phase correction along F1 axis of a 2D. on 2D where axis1.itype = 0 and axis2.itype = 1 using pairs of columns as real and imaginary pair phase corrections are in degree

  `flop`()

    on a 2D with axis2.itype==0 and axis1.itype==1 copies the imaginary from on axis to the other after this, we have

    > axis2.itype==1 and axis1.itype==0 size1 is halved size2 is doubled

    Useful for complex FT this is the opposite of flip()

  `ft_n_p`(data, axis='F1')

    F1-Fourier transform for N+P (echo/antiecho) 2D

  `ft_phase_modu`(data, axis='F1')

    F1-Fourier transform for phase-modulated 2D

  `ft_seq`(data)

    performs the fourier transform of a data-set acquired on a Bruker in simultaneous mode Processing is performed only along the F2 (F3) axis if in 2D (3D)

    (Bruker QSIM mode)

  `ft_sh`(data, axis='F1')

    States-Haberkorn F1 Fourier transform

  `ft_sh_tppi`(data, axis='F1')

    States-Haberkorn / TPPI F1 Fourier Transform

  `ft_sim`(data)

    performs the fourier transform of a data-set acquired on a Bruker in simultaneous mode Processing is performed only along the F2 (F3) axis if in 2D (3D)

    (Bruker QSIM mode)

  `ft_tppi`(data, axis='F1')

    TPPI F1 Fourier transform

  `gaussenh`(npkd, width, enhancement=2.0, axis=0)

    apply an gaussian enhancement, width is in Hz enhancement is the strength of the effect multiplies by gauss(width) * exp(-enhancement*width)

  `get_buffer`(copy=False)

    returns a view or a copy of the numpy buffer containing the NPKData values dtype is either real or complex if axis is complex. remarks :

    > - default is a view, if you want a copy, simply do d.get_buffer(copy=True)
    > - if you use a view, do not modify the size, nor the dtype
    > - see set_buffer()

    WARNING - In nD with n>1 and if NPKData is hypercomplex, only the fastest (n) axis is considered, all other imaginary parts are left as real.

  `hamming`(axis=0)

    apply a Hamming apodisation

  `hanning`(axis=0)

    apply a Hanning apodisation

  `htoi`(axis, value)
  `htop`(axis, value)
  `ifft`(axis=0)

    computes the inverse of fft(), takes complex frequency domain data and returns complex time domain data

    see test_axis for information on axis

  `ifftr`(axis=0)

    computes the inverse of fftr, takes real frequency domain data and returns complex time domain data

    see test_axis for information on axis

  `irfft`(axis=0)

    computes the inverse of rfft(), takes complex frequency domain data and returns real time domain data

    see test_axis for information on axis

  `itoh`(axis, value)
  `itop`(axis, value)
  `itype`

    returns complex type of each axes coded as single number, using NPKv1 code

  `kaiser`(beta, axis=0)

    apply a Kaiser apodisation beta is a positive number

    > beta Window shape —- ———— 0 Rectangular 5 Similar to a Hamming 6 Similar to a Hanning 8.6 Similar to a Blackman

  `load`(name)

    load data from a file

  `load_sampling`(filename, axis=1)

    equivalent to the axis.load_sampling() method - can be pipelined

  `load_txt`(name)

    load 1D data in texte, single column, no unit - with attributes as pseudo comments

  `lpext`(npkd, final_size, lprank=10, algotype='burg')

    extends a 1D FID or 2D FID in F1 up to final_size, using lprank coefficients, and algotype mode

  `mean`(zone=None)

    computes mean value in the designed spectral zone (NEW!) returns a complex if data is complex along fastest axis

  `median`()

    Executes a median filter on the data-set (1D or 2D).a window of x points (or y by x in 2D) is moved along the data set, the point are ordered, and the indexth point is taken as the new point for the data set.

  `minus`()

    Sets to zero the positive part of the data set see also : minus, zeroing

  `modulus`()

    takes the modulus of the dataset depends on the value f axis(i).itype

  `mult`(multiplier)

    Multiply data-set by a scalar eg : d.mult(alpha) multiplies d buffer by alpha

  `mult_by_vector`(axis, vector, mode='real')

    multiply the data-set by a vector, along a given axis if mode == “real”, does it point by point regardles of itype if mode == “complex” uses axis.itype to determine how handle complex values

    > in all cases vector can be real or complex

  `palma`(npkd, N, nbiter=1000, uncertainty=1.0, lamda=0.1, precision=1e-08, full_output=False)

    realize PALMA computation on a 1D dataset containing a decay dataset should have been prepared with prepare_palma on each column, the noise is estimated, then PPXA+ algorithm is applied nbiter: maximum iteration number of the PALMA algo

    uncertainty: noise is estimated on the dataset, and then multiplied by this value
      so uncertainty=1 is full confidence in the noise evaluation algo uncertainty>1 allows more room for algo when data quality is poor
    lamda is the balance between entropy and L1
      lamda = 0 is full L1 lamda = 1 is full Ent

    precision: is the required precision for the convergence full_output is used for debugging purposes, do not use in production

    > check PPXAplus() doc for details

  `peakpick`(npkd, threshold=None, zoom=None, autothresh=3.0, verbose=True)

    performs a peak picking of the current experiment threshold is the level above which peaks are picked

    > None (default) means that autothresh*(noise level of dataset) will be used - using d.std() as proxy for noise-level

    zoom defines the region on which detection is made
      zoom is in currentunit (same syntax as in display) None means the whole data
  `peaks2d`(npkd, threshold, zoom)

    math code for NPKData 2D peak picker

  `pg_sane`(npkd, HTmode='projection', axis=1, iterations=10, HTratio=None, rank=20, Lthresh=2.0, sampling=None, size=None, final='SANE')

    Papoulis Gershberg algorithm - stabilized with SANE

    This function takes FID with a partial sampling, and fills the holes with estimated values. The FID can then be processed normally, as it was completely acquired.

    mode (threshold or projection) determine PG algorithm iterations : the number of iterations used for the program

    > pg_sane converges quite rapidely, and usually 5 to 20 iterations are suffisant. when the SNR is high, or for large data-sets (>8k) more iterations might be needed

    HTratio: number of lines left by HT/projection - usually a few % of the whole spectrum
      default is 0.01 ( 1% )
    rank : a rough estimate of the number of lines present in the FT spectrum of the FID - not stringent -
      if in doubt, use a slightly larger value.
    Lthresh : the multiplier for HT/threshold, usually 2.0
      lower recovers more weak signals but requires more iterations higher requires less iteration but look only to larger peaks.
    sampling : if provided, the sampling index list and npkd is supposed to be zerofilled (missing values set to zero)
      if None, npkd.axis1.sampled should be True, and sampling it will be fetched via npkd.axis1.get_sampling()
    final: the final step after iterations,
      default is ‘SANE’: better (noise-less) data-sets, the best reconstruction quality in simulations ‘PG’ to reapply PG step - produces the cleanest/more compressible data-sets ‘Reinject’: the closest to acquired data - to use if there is very little noise.

    size: if different from None, pg_sane will also extrapolate to size

  `phase`(ph0, ph1, axis=0)

    apply a phase correction along given axis phase corrections are in degree for a N complex spectrum, correction on ith point is

    > ph = ph0 +ph1*(i/N - 0.5) so central point is unchanged

  `plane`(axis, i)

    returns a 2D extracted from the current 3D at position 0<=i<=size1-1

  `plus`()

    Sets to zero the negative part of the data set see also : minus, zeroing

  `pp`(npkd, threshold=None, zoom=None, autothresh=3.0, verbose=True)

    performs a peak picking of the current experiment threshold is the level above which peaks are picked

    > None (default) means that autothresh*(noise level of dataset) will be used - using d.std() as proxy for noise-level

    zoom defines the region on which detection is made
      zoom is in currentunit (same syntax as in display) None means the whole data
  `prepare_palma`(npkd, finalsize, Dmin, Dmax)

    this method prepares a DOSY dataset for processing - computes experimental values from imported parameter file - prepare DOSY transformation matrix

  `proj`(axis=0, projtype='s')

    returns a projection of the dataset on the given axis projtype determines the algorithm :

    > “s” is for skyline projection (the highest point is retained) “m” is for mean,

  `ptoh`(axis, value)
  `ptoi`(axis, value)
  `real`(axis=0)

    This command extract the real part of the current the data set considered as complex. <ul> <li>axis is not needed in 1D, <li>can be F1, F2 or F12 in 2D, <li>and can be F1, F2, F3, F12, F13, F23, or F123 in 3D. </ul>

  `rem_ridge`(data)

    This function removes a F1 ridge by evaluating a mean avalue over the last 10% data of each column of a 2D

  `report`()

    reports itself

  `report_peaks`(npkd, file=None, format=None)

    print the content of the peak list, using the current unit

    if file should be an already opened writable file stream. if None, output will go to stdout

    for documentation, check Peak1D.report() and Peak2D.report()

  `reverse`(axis=0)

    reverse the order of the current data-set (i.e. first points are last, last points are first). If dataset is complex, REVERSE will reverse the complex vector (2 by 2).

  `revf`(axis=0)

    Processes FID data-sets by multiplying by -1 2 points out of 4. Permits to preprocess Bruker FIDs in Dim 2 (Bruker trick) before RFT, or permits to bring back zero frequency in the center for some other data formats

  `rfft`(axis=0)

    computes the real Fourier transform, takes real time domain data and returns complex frequency domain data

    see test_axis for information on axis

  `row`(i)

    returns a 1D extracted from the current 2D at position 0<=i<=size1-1

  `sane`(npkd, rank, orda=None, iterations=1, axis=0, trick=True, optk=False, ktrick=False)

    Apply “sane” denoising to data rank is about 2 x number_of_expected_lines Manages real and complex cases. Handles the case of hypercomplex for denoising of 2D FTICR for example.

    sane algorithm. Name stands for Support Selection for Noise Elimination. From a data series return a denoised series denoised data : the series to be denoised - a (normally complex) numpy buffer rank : the rank of the analysis orda : is the order of the analysis

    > internally, a Hankel matrix (M,N) is constructed, with M = orda and N = len(data)-orda+1 if None (default) orda = (len(data)+1)/2

    iterations : the number of time the operation should be repeated optk : if set to True will calculate the rank giving the best recovery for an automatic estimated noise level. trick : permits to enhanced the denoising by using a cleaned signal as the projective space. “Support Selection” ktrick : if a value is given, it permits to change the rank on the second pass.

    > The idea is that for the first pass a rank large enough as to be used to compensate for the noise while for the second pass a lower rank can be used.

  `save`(name)

    save data to a file

  `save_csv`(name, fmt='%.9g')

    save 1D data in csv, in 2 columns : x, y x values are conditions by the .currentunit attribute data attributes are stored as pseudo comments

    data can be read back with File.csv.Import_1D()

  `save_txt`(name)

    save 1D data in texte, single column, no unit - with attributes as pseudo comments

  `set_buffer`(buff)

    modify the internal buffer of the NPKData. allows real or complex arrays to be used remarks

    > - see get_buffer()

  `set_calib`(npkd, mzmeas, mzref, axis=1)

    preset parameters for mass calibration mzref : list of reference m/z of calibrants mzmeas : list of measured m/z of calibrants

    axis is the axis to be calibrated, defaut is 1

  `set_col`(i, d1D)

    set into the current 2D the given 1D, as the column at position 0<=i<=size2-1

  `set_plane`(axis, i, d2D)

    set into the current 3D the given 2D, as a plane at position i

  `set_row`(i, d1D)

    set into the current 2D the given 1D, as the row at position 0<=i<=size1-1

  `set_unit`(currentunit)

    a method equivalent to the unit property can be used in processing pipelines if currentunit is a list/tuple, each entries are applied to the different axes

  `sg`(npkd, window_size, order, deriv=0, axis=0)

    applies Savitzky-Golay of order filter to data window_size : int

    > the length of the window. Must be an odd integer number.

    order : int
      the order of the polynomial used in the filtering. Must be less than window_size - 1.
    deriv: int
      the order of the derivative to compute (default = 0 means only smoothing)
    axis: int
      the axis on which the filter is to be applied, default is fastest varying dimension
  `sg2D`(npkd, window_size, order, deriv=None)

    applies a 2D Savitzky-Golay of order filter to data window_size : int

    > the length of the square window. Must be an odd integer number.

    order : int
      the order of the polynomial used in the filtering. Must be less than window_size - 1.
    deriv: None, ‘col’, or ‘row’. ‘both’ mode does not work.
      the direction of the derivative to compute (default = None means only smoothing)

    can be applied to a 2D only.

  `simulate`(npkd, zoom=None)

    Simulate the 1D npkd data-set using the content of the Peak List replace the current data-set

  `size1`

    returns the size of the F1 spectral axis in 1D 2D and 3D i.e. the unique axis in 1D, the slowest axis in 2D and 3D warning, if data along axis is complex, the size is twice the number of complex pairs

    > i.e. this is the size of the underlying array

  `size2`

    returns the size of the F2 spectral axis in 2D and 3D i.e. the slowest axis in 2D and the intermediate in 3D warning, if data along axis is complex, the size is twice the number of complex pairs

    > i.e. this is the size of the underlying array

  `size3`

    returns the size of the F3 spectral axis in 3D i.e. the slowest axis in 3D warning, if data along axis is complex, the size is twice the number of complex pairs

    > i.e. this is the size of the underlying array

  `std`(zone=None)

    computes standard deviation in the designed spectral zone Computes value on the real part only

  `swap`(axis=0)

    swap both parth to complex this is the opposite of swa() >>>aa=NPKData(buffer=arange(8.)) >>>aa.axis1.itype=1 >>>print aa.buffer array([ 0., 1., 2., 3., 4., 5., 6., 7.]) >>>print aa.swa().buffer array([ 0., 4., 1., 5., 2., 6., 3., 7.])

  `test_axis`(axis=0)

    tests on axis

    > in 1D, axis is not used
    >   axis has to be 1 or “F1”
    > in 2D, axis is either 2 for horizontal / faster incremented dimension == “F2”
    >   or 1 for the other dimension == “F1” defaut is 2
    > in 3D, axis is 3, 2 or 1 with 3 the faster incremented and 1 the slower == F3 F2 F1
    >   defaut is 3

    > alternativaly, you may use the strings “F1”, “F2” or “F3” BUT not F12 F23 as 0 is set to default

  `tisane`(npkd, rank=None, nbinterv=400, above_noise=3, threshold=False, slice_bounds=None, nbcores=1, mixing=False, iterations=1, debug=1)

    Algorithm for an application of Sane by parts. tisane stands for Tilded Integration for Sane Ti-Sane denoises the spectrum on tilded truncks.. half of each denoised interval is superposed on left and right on neighbours intervals. The algorithm uses Multiprocessing. It works on complex spectrum. ### npkd : NPKData object rank : rank for Sane, if no rank is given, it uses OPTK nbinterv : number of intervals above_noise : number of time the threshold is above the noise level. threshold : if True, calculate a threshold applied to the whole dataset when processed with Sane. slice_bounds : interval used. nbcores : number of cores used for parallelization mixing : used for giving a correct weight to each denoised interval iterations = nb of times that sane is repeated inside tisane

  `transpose`(axis=0)

    Transposes the 2D matrix or planes of the 3D cube. The sizes of the matrix must be a power of two for this command to be used. After transposition, the two dimensions are completely permuted

    axis is used in 3D to tell which submatrices should be transposed

    see also : sym chsize modifysize

  `typestr`()

    returns its type (real, complex or hypercomplex) as a string

  `unit`

    copy currentunit to all the axes

  `unswap`(axis=0)

    this is the opposite of swap() >>>aa=NPKData(buffer=arange(8.)) >>>aa.axis1.itype=1 >>>print aa.buffer array([ 0., 1., 2., 3., 4., 5., 6., 7.]) >>>print aa.unswa().buffer array([ 0., 2., 4., 6., 1., 3., 5., 7.])

  `urqrd`(npkd, k, orda=None, iterations=1, axis=0)

    Apply urQRd denoising to data k is about 2 x number_of_expected_lines Manages real and complex cases. Handles the case of hypercomplex for denoising of 2D FTICR for example.

  `wavelet`(npkd, nsigma=1.0, wavelet='db3')

    Performs the wavelet denoising of a 1D or 2D spectrum.

    nsigma the threshold is nsigma times the estimate noise level,
      default 1.0 - corresponds to a relatively strong denoising
    wavelet the wavelet basis used, default ‘db3’ (Daubechies 3)
      check pywt.wavelist() for the list of possible wavelet

    eg: d.wavelet(nsigma=0.5) # d is cleaned after execution

    ref: Donoho DL (1995) De-noising by soft-thresholding. IEEE Trans Inf Theory 41:613–621.

    Based on the PyWavelet library

  `xcol`(start=0, stop=None, step=1)

    an iterator over columns of a 2D so for c in matrix.xcol():

    > do something with c…

    is equivalent to for i in range(matrix.size2): # i.e. all cols

    > c = matrix.col(i) do something with c…

    you can limit the range by giving start, stop and step arguments - using the same syntax as xrange()

    on hypercomplex data matrix.xcol( step=matrix.axis2.itype+1 ) will step only on cols associated to the real point

  `xplane`(axis, start=0, stop=None, step=1)

    an iterator over planes of a 3D along axis (1, 2 or 3) (see test_axis() for documentation on axis selection)

    so for p in matrix.xplane(“F1”):

    > do something with p…

    will scan through all F1 planes

    you can limit the range by giving start, stop and step arguments - using the same syntax as xrange()

    on hypercomplex axis matrix.xplane(“F2, step=matrix.axis2.itype+1 ) will step only on planes associated to the real point

  `xrow`(start=0, stop=None, step=1)

    an iterator over rows of a 2D so for r in matrix.xrow():

    > do something with r…

    is equivalent to for i in range(matrix.size1): # i.e. all rows

    > r = matrix.row(i) do something with r…

    you can limit the range by giving start, stop and step arguments - using the same syntax as xrange()

    on hypercomplex data matrix.xrow( step=matrix.axis1.itype+1 ) will step only on rows associated to the real point

  `zeroing`(threshold)

    Sets to zero points below threshold (in absolute value) see also : plus, minus

  `zf`(zf1=None, zf2=None, zf3=None)

    Zerofill data by adding zeros. for a dataset of length size, will add zeros up to zf*size

    do nothing by default unless axis is sampled, in which case, missing unsampled points are replaced by 0.0

class `spike.NPKData.` `NPKDataTests`(methodName='runTest')

  Bases: `unittest.case.TestCase`

  - Testing NPKData basic behaviour -
  `test_dampingunit`()

    test itod and dtoi

  `test_fft`()
    - Testing FFT methods -
  `test_flatten`()

    test the flatten utility

  `test_hypercomplex_modulus`()

    Test of hypercomplex modulus

  `test_load`()
    - Testing load methods
  `test_math`()
    - Testing dataset arithmetics -
  `test_plugin`()

    Test of plugin mechanism

  `test_unitval`()

    testing unit conversion functions

  `test_zf`()

`spike.NPKData.` `NPKData_plugin`(name, method, verbose=False)

  This function allows to register a new method inside the NPKData class.

  for instance - define myfunc() anywhere in your code :

  def myfunc(npkdata, args):
    “myfunc doc” …do whatever, assuming npkdata is a NPKData return npkdata # THIS is important, that is the standard NPKData mechanism

  then elsewhere do : NPKData_plugin(“mymeth”, myfunc)

  then all NPKData created will have the method .mymeth()

  look at ..plugins for details

class `spike.NPKData.` `Unit`(name='points', converter=<function ident>, bconverter=<function ident>, reverse=False, scale='linear')

  Bases: `object`

  a small class to hold parameters for units name: the name of the “unit” converter: a function converting from points to “unit” bconverter: a function converting from “unit” to points reverse: direction in which axis are displayed (True means right to left) scale: scale along this axis, possible values are ‘linear’ or ‘log’

`spike.NPKData.` `as_cpx`(arr)

  interpret arr as a complex array useful to move between complex and real arrays (see as_float)

      >>> print as_cpx(np.arange(4.0))
      [ 0.+1.j  2.+3.j]

`spike.NPKData.` `as_float`(arr)

  interpret arr as a float array useful to move between complex and real arrays (see as_float)

      >>> print as_float(np.arange(4)*(1+1j))
      [ 0.  0.  1.  1.  2.  2.  3.  3.]

`spike.NPKData.` `conj_ip`(a)

  computes conjugate() in-place

      >>> conj_ip(np.arange(4)*(1+1j))
      [ 0.-0.j  1.-1.j  2.-2.j  3.-3.j]

`spike.NPKData.` `copyaxes`(inp, out)

  copy axes values from NPKDAta in to out.

  internal use

`spike.NPKData.` `flatten`(*arg)

  flatten recursively a list of lists

  >>>print flatten( ( (1,2), 3, (4, (5,), (6,7) ) ) ) [1, 2, 3, 4, 5, 6, 7]

`spike.NPKData.` `hypercomplex_modulus`(arr, size1, size2)

  Calculates the modulus of an array of hypercomplex numbers. input:

  > arr : hypercomplex array size1 : size counting horizontally each half quadrant. size2 : siez counting vertically each half quadrant.

  eg:
    arr = np.array([[1, 4],[3, 7],[1, 9],[5, 7]]) is an hypercomplex with size1 = 2 and size2 = 2

`spike.NPKData.` `ident`(v)

  a identity function used by default converter

`spike.NPKData.` `parsezoom`(npkd, zoom)

  takes zoom (in currentunit) for NPKData npkd, and return either in 1D : zlo, zup in 2D : z1lo, z1up, z2lo, z2up if zoom is None, it returns the full zone

`spike.NPKData.` `warning`(msg)

  issue a warning message to the user

## spike.NPKError module

untitled.py

Created by Marc-André on 2010-07-20. Copyright (c) 2010 IGBMC. All rights reserved.

exception `spike.NPKError.` `NPKError`(msg='', data=None)

  Bases: `Exception`

  implements NPK generic exception adds the named argument data, which can be used to describe the NPKData involved

## spike.Orbitrap module

This file implements all the tools for handling Orbitrap data-sets

To use it :

import Orbitrap d = Orbitrap.OrbiData(…) # There are several possible initialisation : empty, from file play with d

d will allows all NPKData methods, plus a few specific ones.

alternatively, use an importer : from File.(Importer_name) import Import_1D d = Import_1D(“filename)”)

Created by Marc-Andre’ on 2014-09 Copyright (c) 2014 IGBMC. All rights reserved.

class `spike.Orbitrap.` `OrbiAxis`(itype=0, currentunit='points', size=1024, specwidth=1000000.0, offsetfreq=0.0, left_point=0.0, highmass=10000.0, calibA=0.0, calibB=100000000000000.0, calibC=0.0)

  Bases: `spike.FTMS.FTMSAxis`

  hold information for one Orbitrap axis used internally

  `htomz`(value)

    return m/z (mz) from Hertz value (h)

  `mztoh`(value)

    return Hz value (h) from m/z (mz)

  `report`()

    high level reporting

class `spike.Orbitrap.` `OrbiData`(dim=1, shape=None, mode='memory', buffer=None, name=None, debug=0)

  Bases: `spike.FTMS.FTMSData`

  subclass of FTMS.FTMSData, meant for handling Orbitrap data doc to be written …

class `spike.Orbitrap.` `Orbi_Tests`(methodName='runTest')

  Bases: `unittest.case.TestCase`

  `announce`()
  `setUp`()
  `test_atob`()

    testing unit conversion functions

  `test_trim`()

    Test trimz

## spike.Tests module

Tests.py

Created by Marc-André on 2010-07-20.

Runs tests on selected modules using the integrated unittests in the different SPIKE modules.

most default values can be overloaded with run time arguments

Example on a module :
  python -m spike.Tests -D DATA_test -t File.Apex

class `spike.Tests.` `NPKTest`(methodName='runTest')

  Bases: `unittest.case.TestCase`

  overload unittest.TestCase for default verbosity - Not Used -

  `announce`()
  `setUp`()

`spike.Tests.` `cleandir`(verbose=True)

  checking files in DATA_dir directory and removes files created by previous tests

`spike.Tests.` `cleanspike`()

  Removes the .pyc in spike

`spike.Tests.` `directory`()

  returns the location of the directory containing dataset for tests

`spike.Tests.` `do_Test`()

  Performs all tests then indicates if successfull. Gives total time elapsed.

`spike.Tests.` `filename`(name)

  returns the full name of a test dataset located in the test directory

`spike.Tests.` `main`()

`spike.Tests.` `msg`(st, sep='=')

  Message in Tests.py

## spike.dev_setup module

dev_setup.py

To be called any time a new version is rolled out !

Created by Marc-Andre’ on 2010-07-20.

`spike.dev_setup.` `do`(arg)

  print and execute

`spike.dev_setup.` `generate_file`(fname)

  write version to the file “name”, usually “version.py”, used later on then version.py is imported at SPIKE initialization. No revision version is included

`spike.dev_setup.` `generate_file_rev`(fname)

  write version to the file “name”, usually “version.py”, used later on then version.py is imported at SPIKE initialization.

  > it assumes hg is used on client side ! - no svn version.

`spike.dev_setup.` `generate_notes`(fname)

  write the release notes file

`spike.dev_setup.` `generate_version`()

  generates version string, revision id and data

`spike.dev_setup.` `plier`()

  fabrique le zip

## spike.processing module

Processing.py

This program makes the processing of a 2D-FTICR dataset

First version by Marc-Andre on 2011-09-23.

class `spike.processing.` `Proc_Parameters`(configfile=None)

  Bases: `object`

  this class is a container for processing parameters

  `from_json`(jsontxt)

    updates attributes from json text input

  `load`(cp)

    load from cp config file - should have been opened with ConfigParser() first

  `report`()

    print a formatted report

  `to_json`()

    creates a json output of self

  `verify`()

    performs internal coherence of parameters

`spike.processing.` `Report_Table_Param`()

`spike.processing.` `Set_Table_Param`()

class `spike.processing.` `Test`(methodName='runTest')

  Bases: `unittest.case.TestCase`

  tests

  `test_intelli`()

    testing ‘intelligent’ rounding

  `test_proc`()

    apply a complete processing test

  `test_zf`()

    testing zerofilling computation

`spike.processing.` `apod`(d, size, axis=0)

  apply apodisation and change size 4 cases

  > - 2D F1 or F2
  > - 1D coming from F1 or F2

  1D or 2D in F2 are default - apodisation in apod_sin(0.5) in 2D F1 (axis=1) - apodisation is kaiser(5)

  3 situations
    size after > size before size after < size before size after == size before

`spike.processing.` `comp_sizes`(d0, zflist=None, szmlist=None, largest=8589934592, sizemin=1024, vignette=True)
  return a list with data-sizes, computed either
    zflist : from zerofilling index eg : (1,0,-1) szmlist : from multiplicant pairs eg : (2,2)

  largest determines the largest dataset allowed sizemini determines the minimum size when downzerofilling when vignette == True (default) a minimum size data (defined by sizemini) is appended to the list

`spike.processing.` `do_proc_F1`(dinp, doutp, parameter)

  scan all cols of dinp, apply proc() and store into doutp

`spike.processing.` `do_proc_F1_demodu_modu`(dinp, doutp, parameter)

  as do_proc_F1, but applies demodu and then complex modulus() at the end

`spike.processing.` `do_proc_F1_modu`(dinp, doutp, parameter)

  as do_proc_F1, but applies hypercomplex modulus() at the end

`spike.processing.` `do_proc_F2`(dinp, doutp, parameter)

  do the F2 processing - serial code

`spike.processing.` `do_proc_F2mp`(dinp, doutp, parameter)

  do the F2 processing in MP

`spike.processing.` `do_process2D`(dinp, datatemp, doutp, parameter)

  apply the processing to an input 2D data set : dinp result is found in an output file : doutp

  dinp and doutp should have been created before, size of doutp will determine the processing will use a temporay file if needed

`spike.processing.` `downsample2D`(data, outp, n1, n2, compress=False, compress_level=3.0)

  takes data (a 2D) and generate a smaller dataset downsampled by factor (n1,n2) on each axis then returned data-set is n1*n2 times smaller - do a filtered decimation along n2 - simply takes the mean along n1 - set to zero all entries below 3*sigma if compress is True ** Not fully tested on non powers of 2 **

`spike.processing.` `hmclear`(d)

  given a 1D spectrum d, set to zeros all points betwen freq 0 and highmass helps compression

`spike.processing.` `intelliround`(x)

  returns a number rounded to the nearest ‘round’ (easy to FT) integer

`spike.processing.` `iterarg`(dinp, rot, size, parameter)

  an iterator used by the processing to allow multiprocessing or MPI set-up

`spike.processing.` `iterargF2`(dinp, size, scan)

  an iterator used by the F2 processing to allow multiprocessing or MPI set-up

`spike.processing.` `load_input`(name)

  load input file and returns it, in read-only mode

`spike.processing.` `main`(argv=None)

  Does the whole on-file processing, syntax is processing.py [ configuration_file.mscf ] if no argument is given, the standard file : process.mscf is used.

`spike.processing.` `pred_sizes`(d0, szmult=(1, 1), sizemin=1024)
  given an input data set, determines the optimum size s1,s2 to process it
    with a size multiplicant of szmult

  szmult (szm1, szm2) where szm1 is multiplicant for s1 and szm2 for s2 szmx = 1 : no change / 2 : size doubling / 0.5 : size halving any strictly positive value is possible, 0.2 0.33 1.1 2 2.2 5 etc…

  however, axes can never get smaller than sizemin returns (si1, si2, …) as the dataset dimension

`spike.processing.` `pred_sizes_zf`(d0, zf=0, sizemin=1024)

  given an input data set, determines the optimum size s1,s2 to process it with a zerofilling of zf zf = +n is doubling n times along each axis zf = -n is halving n times along each axis zf = 0 is no zerofiling however, axes can never get smaller than sizemin returns (si1, si2, …) as the dataset dimension

`spike.processing.` `print_time`(t, st='Processing time')

  prints processing time, t is in seconds

## spike.version module

`spike.version.` `report`()

  prints version name when SPIKE starts

## spike.version_rev module

`spike.version_rev.` `report`()

  prints version name when SPIKE starts

## Module contents

The Spike Package