def check_scatter_consistancy(value): atoms, exp = value[0:2] proc, alg = value[-1] scat = ElasticScatter(exp_dict=exp, verbose=True) scat.set_processor(proc, alg) ans = scat.get_pdf(atoms) ans1 = scat.get_fq(atoms) print(len(ans1)) print(scat.get_scatter_vector().shape) ans2 = scat.get_sq(atoms) print(len(ans2)) ans3 = scat.get_iq(atoms)
def test_consistency2(): outs = [[] for i in range(len(test_atoms))] s = ElasticScatter(verbose=True) for i, atoms in enumerate(test_data): stru = convert_atoms_to_stru(atoms) srfit_calc = DebyePDFCalculator() srfit_calc.qmin = s.exp['qmin'] srfit_calc.qmax = s.exp['qmax'] srfit_calc.qstep = s.exp['qbin'] srfit_calc(stru) stats_check(s.get_scatter_vector(), srfit_calc.qgrid) fq = srfit_calc.fq outs[i % len(test_atoms)].append(fq) for j in range(len(test_atoms)): for a, b in permutations(outs[j], 2): stats_check(a, b)
def test_fq_against_srfit(): # unpack the atoms and experiment atoms = local_test_atoms exp = None # get the pyIID F(Q) s = ElasticScatter(exp) # s.set_processor('CPU', 'nxn') # get the SrFit F(Q) stru = convert_atoms_to_stru(atoms) srfit_calc = DebyePDFCalculator() srfit_calc.qmin = s.exp['qmin'] srfit_calc.qmax = s.exp['qmax'] srfit_calc.qstep = s.exp['qbin'] srfit_calc(stru) stats_check(s.get_scatter_vector(), srfit_calc.qgrid) ans1 = s.get_fq(atoms) ans2 = srfit_calc.fq stats_check(ans1, ans2, rtol=1e-4, atol=5e-6) del srfit_calc stats_check(ans1, ans2, rtol=1e-4, atol=5e-6)
import numpy as np from ase.atoms import Atoms from pyiid.experiments.elasticscatter import ElasticScatter import matplotlib.pyplot as plt from matplotlib.colors import LogNorm import ase.io __author__ = 'christopher' # atoms = Atoms('Au4', [[0, 0, 0], [3, 0, 0], [0, 3, 0], [3, 3, 0]]) atoms = ase.io.read('/mnt/work-data/dev/IID_data/db_test/PDF_LAMMPS_587.traj') scat = ElasticScatter() scat.update_experiment({'qmax': 8, 'qmin': .5}) s = scat.get_scatter_vector() k = 100 i_max, j_max = k, k pixel_array = np.zeros((i_max, j_max)) for i in range(i_max): for j in range(j_max): pixel_array[i, j] = np.sqrt(i**2 + j**2) pixel_array /= np.max(pixel_array) pixel_array *= np.max(s) img = scat.get_2d_scatter(atoms, pixel_array) print img.shape # plt.imshow(pixel_array) print np.max(img), np.min(img) plt.imshow(img, aspect='auto')
import numpy as np from ase.atoms import Atoms from pyiid.experiments.elasticscatter import ElasticScatter import matplotlib.pyplot as plt from matplotlib.colors import LogNorm import ase.io __author__ = 'christopher' # atoms = Atoms('Au4', [[0, 0, 0], [3, 0, 0], [0, 3, 0], [3, 3, 0]]) atoms = ase.io.read('/mnt/work-data/dev/IID_data/db_test/PDF_LAMMPS_587.traj') scat = ElasticScatter() scat.update_experiment({'qmax': 8, 'qmin': .5}) s = scat.get_scatter_vector() k = 100 i_max, j_max = k, k pixel_array = np.zeros((i_max, j_max)) for i in range(i_max): for j in range(j_max): pixel_array[i, j] = np.sqrt(i ** 2 + j ** 2) pixel_array /= np.max(pixel_array) pixel_array *= np.max(s) img = scat.get_2d_scatter(atoms, pixel_array) print img.shape # plt.imshow(pixel_array) print np.max(img), np.min(img)