diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 4c3ae91..488ce5c 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -23,10 +23,8 @@ requirements: - scipy - h5py - bokeh =2.3 - - matplotlib - numba - lmfit - - uncertainties about: diff --git a/pyzebra/xtal.py b/pyzebra/xtal.py index 38381ff..f4d1100 100644 --- a/pyzebra/xtal.py +++ b/pyzebra/xtal.py @@ -1,15 +1,5 @@ -import math - import numpy as np from numba import njit -from scipy.optimize import curve_fit - -import pyzebra - -try: - from matplotlib import pyplot as plt -except ImportError: - print("matplotlib is not available") pi_r = 180 / np.pi @@ -393,84 +383,3 @@ def gauss(x, *p): """ A, mu, sigma = p return A * np.exp(-((x - mu) ** 2) / (2.0 * sigma ** 2)) - - -def box_int(file, box): - """Calculates center of the peak in the NB-geometry angles and Intensity of the peak - - Args: - file name, box size [x0:xN, y0:yN, fr0:frN] - - Returns: - gamma, omPeak, nu polar angles, Int and data for 3 fit plots - """ - - dat = pyzebra.read_detector_data(file) - - sttC = dat["gamma"][0] - om = dat["omega"] - nuC = dat["nu"][0] - ddist = dat["ddist"] - - # defining indices - x0, xN, y0, yN, fr0, frN = box - - # omega fit - om = dat["omega"][fr0:frN] - cnts = np.sum(dat["data"][fr0:frN, y0:yN, x0:xN], axis=(1, 2)) - - p0 = [1.0, 0.0, 1.0] - coeff, var_matrix = curve_fit(gauss, range(len(cnts)), cnts, p0=p0) - - frC = fr0 + coeff[1] - omF = dat["omega"][math.floor(frC)] - omC = dat["omega"][math.ceil(frC)] - frStep = frC - math.floor(frC) - omStep = omC - omF - omP = omF + omStep * frStep - Int = coeff[1] * abs(coeff[2] * omStep) * math.sqrt(2) * math.sqrt(np.pi) - # omega plot - x_fit = np.linspace(0, len(cnts), 100) - y_fit = gauss(x_fit, *coeff) - plt.figure() - plt.subplot(131) - plt.plot(range(len(cnts)), cnts) - plt.plot(x_fit, y_fit) - plt.ylabel("Intensity in the box") - plt.xlabel("Frame N of the box") - label = "om" - # gamma fit - sliceXY = dat["data"][fr0:frN, y0:yN, x0:xN] - sliceXZ = np.sum(sliceXY, axis=1) - sliceYZ = np.sum(sliceXY, axis=2) - - projX = np.sum(sliceXZ, axis=0) - p0 = [1.0, 0.0, 1.0] - coeff, var_matrix = curve_fit(gauss, range(len(projX)), projX, p0=p0) - x = x0 + coeff[1] - # gamma plot - x_fit = np.linspace(0, len(projX), 100) - y_fit = gauss(x_fit, *coeff) - plt.subplot(132) - plt.plot(range(len(projX)), projX) - plt.plot(x_fit, y_fit) - plt.ylabel("Intensity in the box") - plt.xlabel("X-pixel of the box") - - # nu fit - projY = np.sum(sliceYZ, axis=0) - p0 = [1.0, 0.0, 1.0] - coeff, var_matrix = curve_fit(gauss, range(len(projY)), projY, p0=p0) - y = y0 + coeff[1] - # nu plot - x_fit = np.linspace(0, len(projY), 100) - y_fit = gauss(x_fit, *coeff) - plt.subplot(133) - plt.plot(range(len(projY)), projY) - plt.plot(x_fit, y_fit) - plt.ylabel("Intensity in the box") - plt.xlabel("Y-pixel of the box") - - ga, nu = pyzebra.det2pol(ddist, sttC, nuC, x, y) - - return ga[0], omP, nu[0], Int