Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Contributors
------------

For a list of contributors, visit
https://github.com/diffpy/diffpy.snmf/graphs/contributors
https://github.com/diffpy/diffpy.stretched-nmf/graphs/contributors
39 changes: 39 additions & 0 deletions docs/examples/XRD_MgMnO_YCl_real.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from pathlib import Path

import numpy as np

from diffpy.stretched_nmf.snmf_class import SNMFOptimizer

# Input data
DATA_DIR = Path(__file__).resolve().parent / "data/XRD_MgMnO_YCl_real"
source_matrix_file = np.loadtxt(
DATA_DIR / "source_matrix.txt", dtype=float, skiprows=4
)

# Optional starting initialization
# Without it, would need to provide n_components = 2 to get these results
init_components_file = np.loadtxt(
DATA_DIR / "init_components.txt", dtype=float
)
init_stretch_file = np.loadtxt(DATA_DIR / "init_stretch.txt", dtype=float)
init_weights_file = np.loadtxt(DATA_DIR / "init_weights.txt", dtype=float)

my_model = SNMFOptimizer(
show_plots=True,
rho=1e12,
eta=610,
)
# Experimentally found best fit parameters for this data
my_model.fit(
source_matrix=source_matrix_file,
init_weights=init_weights_file,
init_components=init_components_file,
init_stretch=init_stretch_file,
)

print("Done")
np.savetxt(
"my_norm_components.txt", my_model.components_, fmt="%.6g", delimiter=" "
)
np.savetxt("my_norm_weights.txt", my_model.weights_, fmt="%.6g", delimiter=" ")
np.savetxt("my_norm_stretch.txt", my_model.stretch_, fmt="%.6g", delimiter=" ")
Loading
Loading