Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug with scales after 'fitsignal' #53

Closed
ritsch-i opened this issue Oct 29, 2020 · 1 comment
Closed

bug with scales after 'fitsignal' #53

ritsch-i opened this issue Oct 29, 2020 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@ritsch-i
Copy link

ritsch-i commented Oct 29, 2020

Hi, I upgraded to DeerLab 0.12.0, and (as it mentions in the release notes) there are changes in how the fit output is now saved in terms of model scaling. However, the release mode don't say, how the final output is now scaled exactly (would be nice, because I had to adjust all my plot files accordingly...). And I think there is also a bug, because the scaling is differnet, when I used `fitsignal' with free distribtution or with model fit
In oder to get all lines on top of each other I need to scale differnt outputs differently, e.g.:

plt.plot(t,V/deerfit[i].scale,'.b')#/deerfit[i].scale
plt.plot(t,deerfit[i].V,color='r') # free distribution
plt.plot(t,deerfit_gauss[i].V/deerfit[i].scale,color='k')# gauss model
@luisfabib luisfabib added the bug Something isn't working label Nov 3, 2020
@luisfabib luisfabib added this to the 0.13.0 milestone Nov 3, 2020
@luisfabib
Copy link
Collaborator

luisfabib commented Nov 3, 2020

There is indeed a discrepancy in how the signal scales are reported after fitsignal. The fully parametric mode returns fit.V with the scale of the experimental data, while the non-parametric modes return fit.V scaled down by fit.scale.

Here is a MWE displaying this:

import numpy as np 
import deerlab as dl
import matplotlib.pyplot as plt

t = np.linspace(-0.3,5,200)
r = np.linspace(1,5,200)
P = dl.dd_gauss(r,[3.5,0.3])
K = dl.dipolarkernel(t,r,0.3,dl.bg_hom3d(t,50,0.3))
V = K@P + dl.whitegaussnoise(t,0.01,seed=1)
V = V*1.4e6

deerfit = dl.fitsignal(V,t,r)
deerfit_gauss = dl.fitsignal(V,t,r,dl.dd_gauss)

plt.figure()
plt.plot(t,V,'.b')
plt.plot(t,deerfit.V,color='r') # snlls - mode
plt.plot(t,deerfit_gauss.V,color='k')  # fitparamodel - mode
plt.show()

t = np.linspace(-0.3,5,200)
r = np.linspace(1,5,200)
P = dl.dd_gauss(r,[3.5,0.3])
K = dl.dipolarkernel(t,r)
V = K@P + dl.whitegaussnoise(t,0.01,seed=1)
V = V*1.4e6

deerfit = dl.fitsignal(V,t,r,'P',None,None)
deerfit_gauss = dl.fitsignal(V,t,r,dl.dd_gauss,None,None)

plt.figure()
plt.plot(t,V,'.b')
plt.plot(t,deerfit.V,color='r') # fitregmodel - mode
plt.plot(t,deerfit_gauss.V,color='k') # fitparamodel - mode
plt.show()

The test suite has not been covering this, but rather the correct values of the scaling. Therefore it has gone unnoticed. This must be fixed as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants