nmrsim icon indicating copy to clipboard operation
nmrsim copied to clipboard

Introduction of matplotlib-independent simulating, peak-wise width values and optional region of interest (ROI) based line calculation for significant speed increase.

Open mwhayward opened this issue 9 months ago • 0 comments

General: Moved peak width at half height values into the peaklist variables to allow for peak-wise (and therein multiplet-wise) width control. Peaklist handling methods and functions have been adapted to handle the new values. Width default values have been consistently set to 0.5Hz throughout the package.

plt.py: Divided mplplot into two functions (mplplot in plt.py and create_lineshape in math.py) to separate the matplotlib object creation from the NMR line. This allows users to skip matplotlib if they want to use the line for other uses. Fixed a bug in mplplot_stick which uses the outdated use_line_collection argument in ax.stem.

qm.py: Removed the print lines in qm.hamiltonian_sparse. Added width arguments to _compile_peaklist permit the new peaklist structure.

math.py: Added the new create_lineshape function that is taken from plt.mplplot so it can be called independently. Added width arguments to many of the functions. Added gaussian functions to complement lorentz functions. Converted add_lorentzians to add_lorentzians_limitable which includes a new and optional parameter: cutoff. This argument allows the restriction of lorentzian curve calculation to only above the given intensity cutoff. Uses the (also new) inverse_lorentz and get_index_of_nearest functions to quickly calculate the restriction zones without any element-wise calculation by numpy. This permits much faster simulation speeds if speed is more valuable than 100% accuracy. Default is None so tutorial/older examples behave the same.

Other files: Added support for the new width parameter. Refactoring for add_lorentzians_limitable function.

Tests: All executed successfully after modifying expected values to accommodate the above changes.

mwhayward avatar May 14 '25 22:05 mwhayward