예제 #1
0
def calc(gen: Union[PDFGenerator, DebyePDFGenerator], data_file: str,
         rlim: Tuple[float, float]) -> None:
    """
    Calculate the value of generator and compare it with the data in the file.

    Parameters
    ----------
    gen
        The PDFGenerator or DebyePDFGenerator.
    data_file
        The path to the data file.
    rlim
        The limit of calculation range.

    Returns
    -------
    None

    """
    r, g_data = loadData(data_file).T
    msk = np.logical_and(r >= rlim[0], r <= rlim[1])
    r, g_data = r[msk], g_data[msk]

    g_calc = gen(r)

    plt.figure()
    plt.plot(r, g_data, label="data")
    plt.plot(r, g_calc, label="calculation")
    plt.xlabel(r"r ($\AA$)")
    plt.ylabel(r"G ($\AA^{-2}$)")
    plt.legend()
    plt.show()
    return
예제 #2
0
def calc(gen: Union[PDFGenerator, DebyePDFGenerator], data_file: str,
         rlim: Tuple[float, float]) -> None:
    """
    calculate PDF according to generator in recipe and compare with the data.
    :param gen: generator used to calculate PDF.
    :param data_file: path to the data file.
    :param rlim: limit of r-range.
    :return: None.
    """
    r, g_data = loadData(data_file).T
    msk = np.logical_and(r >= rlim[0], r <= rlim[1])
    r, g_data = r[msk], g_data[msk]

    g_calc = gen(r)

    plt.plot(r, g_data, label="data")
    plt.plot(r, g_calc, label="calculation")

    plt.xlabel(r"r ($\AA$)")
    plt.ylabel(r"G ($\AA^{-2}$)")

    plt.legend()

    return
예제 #3
0
import matplotlib.pyplot as plt
from diffpy.utils.parsers.loaddata import loadData
#if use stylesheet remotely
path = 'https://raw.githubusercontent.com/Billingegroup/mpl-stylesheets/master/bg_style'
#if use stylesheet locally
# path = '../bg_style'
plt.style.use(path)

#load PDF data
r, gcalc, dr, dg, gdiff = loadData('./CdSe.fgr').T

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
offset = -0.5  # the offset to plot difference curve

ax.plot(r, gcalc + gdiff)  # Experimental
ax.plot(r, gcalc)  # Calculated
ax.plot(r, gdiff + offset)  # Difference
ax.axhline(y=offset, color='k', linestyle='--')

ax.set_xlim(2.0, 20.0)  # set x-axis lower and upper limits
ax.set_xlabel('r ($\mathrm{\AA}$)')
ax.set_ylabel('G ($\mathrm{\AA}$$^{-2}$)')

plt.show()
# fig.savefig('plot.png')
예제 #4
0
파일: io.py 프로젝트: st3107/pdffitx
def load_array(data_file: str, minrows=10, **kwargs) -> np.ndarray:
    """Load data columns from the .txt file and turn columns to rows and return the numpy array."""
    return loadData(data_file, minrows=minrows, **kwargs).T