Skip to content
Merged
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
14 changes: 11 additions & 3 deletions hexrd/powder/wppf/WPPF.py
Original file line number Diff line number Diff line change
Expand Up @@ -2023,7 +2023,7 @@ def computespectrum_2D(self):
simulated_2d = np.empty([nspec, x.shape[0]])
azimuth_texture_factor = {}
for iph, p in enumerate(self.phases):
if p in self.texture_model:
if self.texture_model.get(p) is not None:
self.texture_model[p].calc_pf_rings(
self.params,
eta_min=self.eta_min,
Expand Down Expand Up @@ -2112,15 +2112,20 @@ def Refine(self):
print("Nothing to refine...")

def RefineTexture(self):
final_result = None
for name, model in self.texture_model.items():
if model is None:
continue

print(f'Refining texture parameters for "{name}"')
results = model.calculate_harmonic_coefficients(self.params)
if results is None:
print(f'No "{name}" parameters marked as "vary". Skipping...')

final_result = results if results is not None else final_result

# Set the results to the final one
self.res = results
self.res = final_result

self.computespectrum()
self.niter += 1
Expand Down Expand Up @@ -2156,7 +2161,7 @@ def any_texture_params_varied(self):
@property
def texture_models_have_pfdata(self):
for model in self.texture_model.values():
if not model.pfdata:
if model is not None and not model.pfdata:
return False

return True
Expand Down Expand Up @@ -2419,6 +2424,9 @@ def compute_texture_data(
if model is None:
continue

# Sanitize the name
mat_key = mat_key.replace('-', '_')

pfdata = {}
for ii, nnz in enumerate(results[3]):
eta = self.eta_min + (nnz + 1) * np.radians(azimuthal_interval)
Expand Down
4 changes: 4 additions & 0 deletions hexrd/powder/wppf/texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,10 @@ def calculate_harmonic_coefficients(self, params, hkls=None):
for name in self.parameter_names:
harmonic_params[name] = copy.deepcopy(params[name])

if not any(param.vary for param in harmonic_params.values()):
# No parameters are marked as vary. Return early.
return None

self.sph_c = {}
self.sph_s = {}

Expand Down
Loading