reworking to use optimize.curve_fit