def fit_line(X, y): """ ================ INPUT: array of X data (temperature), array of Y data (heat flow) OUTPUT: array of X data (temperature), array of Y data (best-fit-line heat flow) ================ Returns two arrays, of the x's and y's of the best-fit-line. """ peak_X, peak_y = pdetect.get_peak_X_y(X, y) onset_point, end_point = pdetect.get_points(X, y) (x_0, y_0), (x_1, y_1) = pdetect.get_points_coordinates(X, y) line_X, line_y = construct_line(x_0, y_0, x_1, y_1, peak_X ) return line_X, line_y
def get_enthalpy(X, y): """ ================ INPUT: array of X data (temperature), array of Y data (heat flow) OUTPUT: float ================ Returns the enthalpy of the reaction. In order, this function: 1. Gets the interval of the peak 2. Fits a line between its end points 3. Takes the difference between the line and the peak 4. Finds the integral of the difference """ peak_X, peak_y = pdetect.get_peak_X_y(X, y) onset_point, end_point = pdetect.get_points(X, y) line_X, line_y = fit_line(X, y) differences = line_y - peak_y return simps(differences, x = peak_X)