@@ -94,14 +94,14 @@ def make_kernel(cq_range, eta_range, method, isotope):
94
94
95
95
spin_systems = [
96
96
SpinSystem (sites = [Site (isotope = isotope , quadrupolar = dict (Cq = cq * 1e6 , eta = e ))])
97
- for cq , e in zip (Cq .flatten (), eta .flatten ())
97
+ for cq , e in zip (Cq .ravel (), eta .ravel ())
98
98
]
99
99
sim = Simulator (spin_systems = spin_systems , methods = [method ])
100
100
sim .config .decompose_spectrum = "spin_system"
101
- sim .run (pack_as_csdm = False )
101
+ sim .run (pack_as_csdm = False ) # Will return spectrum as numpy array, not CSDM object
102
102
103
103
amp = sim .methods [0 ].simulation .real
104
- return np . swapaxes ( amp , 0 , 1 )
104
+ return amp . T
105
105
106
106
107
107
# Create ranges to construct cq and eta grid points
@@ -127,7 +127,7 @@ def make_kernel(cq_range, eta_range, method, isotope):
127
127
# {\bf s} = {\bf K \cdot f},
128
128
#
129
129
# A constant isotropic chemical shift, whose value is also in the Parameters object,
130
- # is applied to :math:`{\bf s}` using the `Fouier shift relation
130
+ # is applied to :math:`{\bf s}` using the `Fourier shift relation
131
131
# <https://en.wikipedia.org/wiki/Fourier_transform#Translation_/_time_shifting>`__.
132
132
# Finally, the spectrum is scaled and returned.
133
133
def make_spectrum_from_parameters (
@@ -156,7 +156,7 @@ def make_spectrum_from_parameters(
156
156
_ , _ , amp = model_quad .pdf (pos = [cq_range , eta_range ])
157
157
158
158
# Create spectra by dotting the amplitude distribution with the kernel
159
- dist = kernel .dot (amp .flatten ())
159
+ dist = kernel .dot (amp .ravel ())
160
160
161
161
# Pack numpy array as csdm object and apply signal processing
162
162
guess_dataset = cp .CSDM (
@@ -165,8 +165,8 @@ def make_spectrum_from_parameters(
165
165
)
166
166
167
167
# Calculate isotropic shift in Hz
168
- ppm_to_hz_factor = Isotope (symbol = "139La" ).gyromagnetic_ratio * 17.6
169
- iso_shift_in_hz = ppm_to_hz_factor * iso_shift
168
+ larmor_freq = Isotope (symbol = "139La" ).gyromagnetic_ratio * 17.6
169
+ iso_shift_in_hz = larmor_freq * iso_shift
170
170
171
171
# Apply isotropic shift using FFT shift theorem
172
172
guess_dataset = guess_dataset .fft ()
@@ -235,9 +235,7 @@ def minimization_function(params, experiment, processor, kernel, sigma=sigma):
235
235
236
236
# %%
237
237
# Create the Minimization object with all the functions and variables previously
238
- # created. Here the ``powell`` method is used for minimization since the
239
- # ``least_squares`` method will not optimize values due to no interpolation scheme
240
- # being used when creating the spectrum from the kernel and pdf.
238
+ # created.
241
239
minner = Minimizer (
242
240
minimization_function , params , fcn_args = (experiment , processor , kernel )
243
241
)
@@ -253,7 +251,6 @@ def minimization_function(params, experiment, processor, kernel, sigma=sigma):
253
251
final_fit = make_spectrum_from_parameters (best_fit_params , kernel , processor )
254
252
residual_spectrum = residuals (experiment , final_fit )
255
253
256
- # plt.rcParams['figure.facecolor'] = 'white'
257
254
plt .figure (figsize = (6 , 4 ))
258
255
ax = plt .subplot (projection = "csdm" )
259
256
ax .plot (experiment , "k" , alpha = 0.5 )
0 commit comments