1
+ from pathlib import Path
2
+
1
3
import numpy as np
2
4
import scipy .sparse
3
- from pathlib import Path
5
+
4
6
from diffpy .utils .parsers .loaddata import loadData
5
7
6
8
@@ -10,8 +12,8 @@ def initialize_variables(data_input, number_of_components, data_type, sparsity=1
10
12
Parameters
11
13
----------
12
14
data_input: 2d array like
13
- The observed or simulated PDF or XRD data provided by the user. Has dimensions R x N where R is the signal length
14
- and N is the number of PDF/XRD signals.
15
+ The observed or simulated PDF or XRD data provided by the user. Has dimensions R x N where R is the signa
16
+ length and N is the number of PDF/XRD signals.
15
17
16
18
number_of_components: int
17
19
The number of component signals the user would like to decompose 'data_input' into.
@@ -20,23 +22,23 @@ def initialize_variables(data_input, number_of_components, data_type, sparsity=1
20
22
The type of data the user has passed into the program. Can assume the value of 'PDF' or 'XRD.'
21
23
22
24
sparsity: float, optional
23
- The regularization parameter that behaves as the coefficient of a "sparseness" regularization term that enhances
24
- the ability to decompose signals in the case of sparse data e.g. X-ray Diffraction data. A non-zero value
25
- indicates sparsity in the data; greater magnitudes indicate greater amounts of sparsity.
25
+ The regularization parameter that behaves as the coefficient of a "sparseness" regularization term that
26
+ enhances the ability to decompose signals in the case of sparse data e.g. X-ray Diffraction data.
27
+ A non-zero value indicates sparsity in the data; greater magnitudes indicate greater amounts of sparsity.
26
28
27
29
smoothness: float, optional
28
- The regularization parameter that behaves as the coefficient of a "smoothness" term that ensures that component
29
- signal weightings change smoothly with time. Assumes a default value of 1e18.
30
+ The regularization parameter that behaves as the coefficient of a "smoothness" term that ensures that
31
+ component signal weightings change smoothly with time. Assumes a default value of 1e18.
30
32
31
33
Returns
32
34
-------
33
35
dictionary
34
- The collection of the names and values of the constants used in the algorithm. Contains the number of observed PDF
35
- /XRD patterns, the length of each pattern, the type of the data, the number of components the user would like to
36
- decompose the data into, an initial guess for the component matrix, and initial guess for the weight factor matrix
37
- ,an initial guess for the stretching factor matrix, a parameter controlling smoothness of the solution , a
38
- parameter controlling sparseness of the solution, the matrix representing the smoothness term, and a matrix used
39
- to construct a hessian matrix.
36
+ The collection of the names and values of the constants used in the algorithm. Contains the number of
37
+ observed PDF /XRD patterns, the length of each pattern, the type of the data, the number of components
38
+ the user would like to decompose the data into, an initial guess for the component matrix, and initial
39
+ guess for the weight factor matrix, an initial guess for the stretching factor matrix , a parameter
40
+ controlling smoothness of the solution, a parameter controlling sparseness of the solution, the matrix
41
+ representing the smoothness term, and a matrix used to construct a hessian matrix.
40
42
41
43
"""
42
44
signal_length = data_input .shape [0 ]
@@ -74,22 +76,22 @@ def initialize_variables(data_input, number_of_components, data_type, sparsity=1
74
76
def load_input_signals (file_path = None ):
75
77
"""Processes a directory of a series of PDF/XRD patterns into a usable format.
76
78
77
- Constructs a 2d array out of a directory of PDF/XRD patterns containing each files dependent variable column in a
78
- new column. Constructs a 1d array containing the grid values.
79
+ Constructs a 2d array out of a directory of PDF/XRD patterns containing each files dependent variable
80
+ column in a new column. Constructs a 1d array containing the grid values.
79
81
80
82
Parameters
81
83
----------
82
84
file_path: str or Path object, optional
83
- The path to the directory containing the input XRD/PDF data. If no path is specified, defaults to the current
84
- working directory. Accepts a string or a pathlib.Path object. Input data not on the same grid as the first file
85
- read will be ignored.
85
+ The path to the directory containing the input XRD/PDF data. If no path is specified, defaults to the
86
+ current working directory. Accepts a string or a pathlib.Path object. Input data not on the same grid
87
+ as the first file read will be ignored.
86
88
87
89
Returns
88
90
-------
89
91
tuple
90
- The tuple whose first element is an R x M 2d array made of PDF/XRD patterns as each column; R is the length of the
91
- signal and M is the number of patterns. The tuple contains a 1d array containing the values of the grid points as
92
- its second element; Has length R.
92
+ The tuple whose first element is an R x M 2d array made of PDF/XRD patterns as each column; R is the
93
+ length of the signal and M is the number of patterns. The tuple contains a 1d array containing the values
94
+ of the grid points as its second element; Has length R.
93
95
94
96
"""
95
97
0 commit comments