From 150a41664e34e51a1dc5446dd9153307f8d51f38 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Fri, 1 Nov 2024 00:23:02 -0400 Subject: [PATCH] import nmf_mapping_code as nmf --- README.rst | 64 ---------------------- src/diffpy/nmf_mapping/main.py | 2 +- src/diffpy/nmf_mapping/nmf_mapping_code.py | 2 +- tests/test_load_data.py | 2 +- 4 files changed, 3 insertions(+), 67 deletions(-) diff --git a/README.rst b/README.rst index bd51e03..2233def 100644 --- a/README.rst +++ b/README.rst @@ -105,70 +105,6 @@ and run the following :: Getting Started --------------- -Input: -- directory: path to the directory containing the diffraction files that are to be analyzed - - format: string (filepath) - - eg: '/Users/zthatcher/Desktop/Data/nmf_mapping/time_data/' or . for cwd - -- save-files (optional): boolean as to whether or not you would like to save the dataframes, plots, and -components (note: pdf data saves as .cgr and xrd data saves as .xy) - - format: boolean - - eg: --save-files False - - default: True - -- threshold (optional and mut-exc to other thresholds): a threshold for the number of structural phases graphed (NMF components returned) - - format as: integer - - eg: --threshold 2 - - default: 10 - -- improve-thresh (optional and mut-exc to other thresholds): a threshold (between 0 and 1) for the relative improvement ratio necessary to - add an additional component. Default is 0.001. 0.1 Recommended for real data. - - format: float - - eg: --improve-thresh 0.1 - - default = 0.001 - -- pca-thresh (optional and mut-exc to other thresholds): explained variance threshold for PCA component counting cutoff - - format: float - - eg: --pca-thresh 0.95 - - default = None - -- n-iter (optional): total number of iterations to run NMF algo. Defaults to 1000. 10000 typical to publish. - - format: int - - eg: --n-iter 10000 - - default: 1000 - -- x-range (optional): the active x-range over which to run the NMF analysis (must be between shortest and -longest range in the set of files) - - format: pair of integers representing the lower r bound and the upper r bound with a comma between - the lower and upper bound - - eg: --xrange 5,10 12,15 - - default: entire range - -- xrd (optional): set this option if the directory contains xy or xye files rather than gr. - - format: boolean - - eg: --xrd True - - default: False - -- x_units (required if xrd): set this as either twotheta or q if working with xrd data. - - format: enum[str] - - eg: --x_units twotheta - - default: None (since --xrd defaults to False) - -- show graphs (optional): whether you or not you would like display the images - - format: boolean - - eg: --show False - - default: True - -Returns: -- Figure One: PDF or XRD pattern of structural phase components contributing to the NMF reconstruction -- Figure Two: Weights of the phase components plotted in Figure One -- Figure Three: Reconstruction error as a function of components -- (Optional) Figure Four: Explained Variance plot as a function of components for PCA thresholding - -Example: - -nmf_mapping . --threshold 3 --xrange 5,10 --show True - You may consult our `online documentation `_ for tutorials and API references. diff --git a/src/diffpy/nmf_mapping/main.py b/src/diffpy/nmf_mapping/main.py index f833902..06daff0 100644 --- a/src/diffpy/nmf_mapping/main.py +++ b/src/diffpy/nmf_mapping/main.py @@ -6,7 +6,7 @@ import numpy as np -from diffpy.nmf_mapping import nmf +import diffpy.nmf_mapping.nmf_mapping_code as nmf def boolean_string(s): diff --git a/src/diffpy/nmf_mapping/nmf_mapping_code.py b/src/diffpy/nmf_mapping/nmf_mapping_code.py index 4ad293a..58827f5 100644 --- a/src/diffpy/nmf_mapping/nmf_mapping_code.py +++ b/src/diffpy/nmf_mapping/nmf_mapping_code.py @@ -16,7 +16,7 @@ from sklearn.decomposition import NMF, PCA from sklearn.exceptions import ConvergenceWarning -plt.style.use(all_styles["bg_style"]) +plt.style.use(all_styles["bg-style"]) warnings.filterwarnings("ignore", category=FutureWarning) warnings.filterwarnings("ignore", category=ConvergenceWarning) diff --git a/tests/test_load_data.py b/tests/test_load_data.py index be03c35..8c2f6a3 100644 --- a/tests/test_load_data.py +++ b/tests/test_load_data.py @@ -3,7 +3,7 @@ import numpy as np -from diffpy.nmf_mapping import nmf +import diffpy.nmf_mapping.nmf_mapping_code as nmf dir = pathlib.Path(__file__).parent.resolve()