{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-beam/scikit-beam/issues/381","labels_url":"https://api.github.com/repos/scikit-beam/scikit-beam/issues/381/labels{/name}","comments_url":"https://api.github.com/repos/scikit-beam/scikit-beam/issues/381/comments","events_url":"https://api.github.com/repos/scikit-beam/scikit-beam/issues/381/events","html_url":"https://github.com/scikit-beam/scikit-beam/issues/381","id":121809619,"number":381,"title":"lineshapes question","user":{"login":"ordirules","id":705366,"avatar_url":"https://avatars.githubusercontent.com/u/705366?v=3","gravatar_id":"","url":"https://api.github.com/users/ordirules","html_url":"https://github.com/ordirules","followers_url":"https://api.github.com/users/ordirules/followers","following_url":"https://api.github.com/users/ordirules/following{/other_user}","gists_url":"https://api.github.com/users/ordirules/gists{/gist_id}","starred_url":"https://api.github.com/users/ordirules/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ordirules/subscriptions","organizations_url":"https://api.github.com/users/ordirules/orgs","repos_url":"https://api.github.com/users/ordirules/repos","events_url":"https://api.github.com/users/ordirules/events{/privacy}","received_events_url":"https://api.github.com/users/ordirules/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-12-11T23:07:41Z","updated_at":"2015-12-13T03:29:17Z","closed_at":null,"body":"The lineshapes (core/fitting/lineshapes.py) seem like they could be very useful for multiple libraries in here in the long run. I would like to see that they are made as easy to use as possible.\r\n\r\nI have a suggestion for perhaps standardizing future additions of lineshapes:\r\n- convert all 1d functions to the format (x,pars) where pars is a dictionary object (see function below for example). This would allow fitting routines to easily use these functions without having to write their own wrapper functions.\r\n- add a test to see if it's a Parameters object used by lmfit. It's a very useful library that allows bounding parameters during fitting and tweaking whether or not to fit them.\r\n\r\nI've included an example below. Any suggestions about this or do you know of any nice python trickery to make this even neater? Anyway, I thought I'd give feedback. This might not be a good idea but I would like to hear others opinions.\r\n\r\n```python \r\ndef polyfitfunc(x,pars):\r\n    ''' poly fit y = (sum_i) a_i*(x**b_i)\r\n        (negative powers permitted, which is not longer polynomial)\r\n        values should be named as follows:\r\n            a0, ..., an\r\n            b0, ..., bn\r\n    '''\r\n\r\n    # check if it's a Parameters object and grad the dictionary entries\r\n    if(hasattr(pars['a0'],\"value\")):\r\n        pars = pars.valuesdict()\r\n\r\n    # check how many parameters there are\r\n    cnt = 0\r\n    while('a{}'.format(cnt) in pars):\r\n        cnt += 1\r\n\r\n    res = x*0\r\n\r\n    # if none just return zeros\r\n    if(cnt == -1):\r\n        return res\r\n\r\n    # now sum pars\r\n    for i in range(cnt):\r\n        res += pars['a{}'.format(i)]*x**(pars['b{}'.format(i)])\r\n\r\n    return res\r\n```"},"comment":{"url":"https://api.github.com/repos/scikit-beam/scikit-beam/issues/comments/164215235","html_url":"https://github.com/scikit-beam/scikit-beam/issues/381#issuecomment-164215235","issue_url":"https://api.github.com/repos/scikit-beam/scikit-beam/issues/381","id":164215235,"user":{"login":"ericdill","id":6223243,"avatar_url":"https://avatars.githubusercontent.com/u/6223243?v=3","gravatar_id":"","url":"https://api.github.com/users/ericdill","html_url":"https://github.com/ericdill","followers_url":"https://api.github.com/users/ericdill/followers","following_url":"https://api.github.com/users/ericdill/following{/other_user}","gists_url":"https://api.github.com/users/ericdill/gists{/gist_id}","starred_url":"https://api.github.com/users/ericdill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericdill/subscriptions","organizations_url":"https://api.github.com/users/ericdill/orgs","repos_url":"https://api.github.com/users/ericdill/repos","events_url":"https://api.github.com/users/ericdill/events{/privacy}","received_events_url":"https://api.github.com/users/ericdill/received_events","type":"User","site_admin":false},"created_at":"2015-12-13T03:29:17Z","updated_at":"2015-12-13T03:29:17Z","body":"Glad I could help. @danielballan is definitely the local expert in lmfit. I will let you close this issue if you feel that it is resolved"}}