discSpec.py
def FineTuneSolution(tau, t, Gexp, isPlateau, estimateError=False):
	"""Given a spacing of modes tau, tries to do NLLS to fine tune it further
	   If it fails, then it returns the old tau back
	   
	   Uses helper function: res_tG which computes residuals
	   """
	success = False
		   
	try:
		res  = least_squares(res_tG, tau, bounds=(0., np.inf),	args=(t, Gexp, isPlateau))
		tau  = res.x
		tau0 = tau.copy()

		# Error Estimate	
		if estimateError:
			J = res.jac
			cov = np.linalg.pinv(J.T.dot(J)) * (res.fun**2).mean()
			dtau = np.sqrt(np.diag(cov))

		success = True			
	except:	
		pass

	
	g, tau, _, _ = MaxwellModes(np.log(tau), t, Gexp, isPlateau)   # Get g_i, taui

	#
	# if mode has dropped out, then need to delete corresponding dtau mode
	#
	if estimateError and success:
		if len(tau) < len(tau0):		
			nkill = 0
			for i in range(len(tau0)):
				if np.min(np.abs(tau0[i] - tau)) > 1e-12 * tau0[i]:
					dtau = np.delete(dtau, i-nkill)
					nkill += 1
		return g, tau, dtau
	elif estimateError:
		return g, tau, -1*np.ones(len(tau))
	else:
		return g, tau
Given a spacing of modes tau, tries to do NLLS to fine tune it further
	   If it fails, then it returns the old tau back
	   
	   Uses helper function: res_tG which computes residuals
	   
Given a spacing of modes tau, tries to do NLLS to fine tune it further
If it fails, then it returns the old tau back

Uses helper function: res_tG which computes residuals
Given a spacing of modes tau tries to do NLLS to fine tune it further If it fails then it returns the old tau back Uses helper function : res_tG which computes residuals
def FineTuneSolution(tau, t, Gexp, isPlateau, estimateError=False):
	success = False
	try:
		res  = least_squares(res_tG, tau, bounds=(0., np.inf),	args=(t, Gexp, isPlateau))
		tau  = res.x
		tau0 = tau.copy()
		if estimateError:
			J = res.jac
			cov = np.linalg.pinv(J.T.dot(J)) * (res.fun**2).mean()
			dtau = np.sqrt(np.diag(cov))
		success = True			
	except:	
		pass
	g, tau, _, _ = MaxwellModes(np.log(tau), t, Gexp, isPlateau)   
	 if mode has dropped out, then need to delete corresponding dtau mode
	if estimateError and success:
		if len(tau) < len(tau0):		
			nkill = 0
			for i in range(len(tau0)):
				if np.min(np.abs(tau0[i] - tau)) > 1e-12 * tau0[i]:
					dtau = np.delete(dtau, i-nkill)
					nkill += 1
		return g, tau, dtau
	elif estimateError:
		return g, tau, -1*np.ones(len(tau))
	else:
		return g, tau
def FineTuneSolution ( tau , t , Gexp , isPlateau , estimateError = False ) : success = False try : res = least_squares ( res_tG , tau , bounds = ( 0. , np . inf ) , args = ( t , Gexp , isPlateau ) ) tau = res . x tau0 = tau . copy ( ) if estimateError : J = res . jac cov = np . linalg . pinv ( J . T . dot ( J ) ) * ( res . fun ** 2 ) . mean ( ) dtau = np . sqrt ( np . diag ( cov ) ) success = True except : pass g , tau , _ , _ = MaxwellModes ( np . log ( tau ) , t , Gexp , isPlateau ) if estimateError and success : if len ( tau ) < len ( tau0 ) : nkill = 0 for i in range ( len ( tau0 ) ) : if np . min ( np . abs ( tau0 [ i ] - tau ) ) > 1e-12 * tau0 [ i ] : dtau = np . delete ( dtau , i - nkill ) nkill += 1 return g , tau , dtau elif estimateError : return g , tau , - 1 * np . ones ( len ( tau ) ) else : return g , tau
Given a spacing of modes tau, tries to do NLLS to fine tune it further
If it fails, then it returns the old tau back
Given a spacing of modes tau tries to do NLLS to fine tune it further If it fails then it returns the old tau back
"""Given a spacing of modes tau, tries to do NLLS to fine tune it further
	   If it fails, then it returns the old tau back
	   
	   Uses helper function: res_tG which computes residuals
	   """ # Error Estimate	 # Get g_i, taui # # if mode has dropped out, then need to delete corresponding dtau mode #
tau
t
Gexp
isPlateau
estimateError