Skip to content

Commit

Permalink
import nmf_mapping_code as nmf
Browse files Browse the repository at this point in the history
  • Loading branch information
bobleesj committed Nov 1, 2024
1 parent 257824a commit 150a416
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 67 deletions.
64 changes: 0 additions & 64 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://diffpy.github.io/diffpy.nmf_mapping>`_ for tutorials and API references.

Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/nmf_mapping/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/nmf_mapping/nmf_mapping_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_load_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 150a416

Please sign in to comment.