jjhelmus / nmrglue

A module for working with NMR data in Python
BSD 3-Clause "New" or "Revised" License
209 stars 86 forks source link

Problem with proc_autophase.autops(data, "acme") #102

Closed jakobjakobson13 closed 5 years ago

jakobjakobson13 commented 5 years ago

Dear Jonathan,

i tried your example for the automatic phase correction algorithms. However the automatic phasing with the acme function

#! /usr/bin/env python

import nmrglue as ng
import matplotlib.pyplot as plt

# read in the bruker formatted data
dic, data = ng.bruker.read('expnmr_00001_1')

# remove the digital filter
data = ng.bruker.remove_digital_filter(dic, data)

# process the spectrum
data = ng.proc_base.zf_size(data, 32768)    # zero fill to 32768 points
data = ng.proc_base.fft(data)               # Fourier transform
data = ng.proc_autophase.autops(data, "acme")      # phase correction

does not work due to the following error message: Warning: Maximum number of function evaluations has been exceeded.

The peak_minima does work fine. So, regardless of this bug in the acme function: Thanks a lot for this package.

Regards

Jakob

jjhelmus commented 5 years ago

The warning indicates that the autophase algorithm is not converging in a reasonable amount of time. I do not know enough about the routine to debug this.

jakobjakobson13 commented 5 years ago

Okay, no problem. Should I close the bug report then?

kaustubhmote commented 5 years ago

This seems like an edge case. The current autops function does not give user acess to maxiter and maxfev args for the scipy.optimize.fmin function, and so by default, these are set to 2*200. Currently acme seems to converge in about 350 function evaluations on my computer on this dataset, and thats significantly short of the maximum, but its possible that a different version of scipy/numpy/python will push this over to 400 at which point it will fail. I did manage to make it fail once, but can't seem to repeat that. Changing the start value of p0 helps, and so does the post_proc=True method for digital filter removal (#24, #67) to start with a flat basline. This maybe a good time to revisit #48 and make many of these options available.