diff --git a/hexrd/powder/wppf/WPPF.py b/hexrd/powder/wppf/WPPF.py index a468f307..8f6ed33e 100644 --- a/hexrd/powder/wppf/WPPF.py +++ b/hexrd/powder/wppf/WPPF.py @@ -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, @@ -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 @@ -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 @@ -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) diff --git a/hexrd/powder/wppf/texture.py b/hexrd/powder/wppf/texture.py index 3cd9112c..af3f7c26 100644 --- a/hexrd/powder/wppf/texture.py +++ b/hexrd/powder/wppf/texture.py @@ -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 = {}