Accessing individual PDFs after two phase fit

66 views
Skip to first unread message

Nathan Nakamura

unread,
Dec 10, 2019, 11:51:45 PM12/10/19
to diffpy-users
Hi everyone,

I've been performing two phase fits in Diffpy-CMI following the general guidelines in the Ni and Si fitting example at https://github.com/diffpy/diffpy.srfit/blob/4edfa967679ac13ad69e6558eac1bb4b96c07926/doc/examples/crystalpdftwophase.py.

Is there a way to access each individual PDF calculated by the separate phases in addition to the total calculated PDF? For example, the line 'recipe.nisi.profile.ycalc' gives the calculated PDF for the total fit to Ni and Si, but is there a similar command that can access the calculated PDF from just the Ni or just the Si phase?

I believe this could also be done by fitting each individual phase separately under its own profile, but I was wondering if the single phase PDFs can be obtained within the framework of the two phase fit.


Best,
Nathan

Andy Anker

unread,
Dec 19, 2019, 5:13:37 AM12/19/19
to diffpy-users
Hi Nathan,

I think what you are looking for, is the following 2 lines of code, which give you the PDFs for the 2 phases separately.
    g_ni = recipe.nisi.evaluateEquation("scale * (G_ni)")
    g_si = recipe.nisi.evaluateEquation("scale * (G_si)")
I have modified the equation, that you set in the script (line 88) to only include one of the phases at the time.

For example this code shows the plot of the Ni phase:
    r = recipe.nisi.profile.x
    g = recipe.nisi.profile.y
    gcalc = recipe.nisi.evaluate()
    g_ni = recipe.nisi.evaluateEquation("scale * (G_ni)")
    g_si = recipe.nisi.evaluateEquation("scale * (G_si)")
    
    diffzero = -0.8 * max(g) * numpy.ones_like(g)
    diff = g - gcalc + diffzero

    import pylab
    pylab.plot(r, g,'bo',label="G(r) Data")
#    pylab.plot(r, gcalc,'r-',label="G(r) Fit")
    pylab.plot(r, g_ni,'r-',label="G(r) Fit - Ni")
#    pylab.plot(r, g_si,'g-',label="G(r) Fit - Si")
    pylab.plot(r,diff,'g-',label="G(r) diff")
    pylab.plot(r,diffzero,'k-')
    pylab.xlabel(r"$r (\AA)$")
    pylab.ylabel(r"$G (\AA^{-2})$")
    pylab.legend(loc=1)

    pylab.show()
   
I hope this answers your question
Andy

Nathan Nakamura

unread,
Dec 19, 2019, 2:29:18 PM12/19/19
to diffpy-users
Hi Andy,

Yes, that worked great and was exactly what I needed. Thank you!

Best,
Nathan
Reply all
Reply to author
Forward
0 new messages