Esempio n. 1
0
def sed(p, nu_in, T, betain, alphain): #; m = [A, T, Beta, Alpha] - return SED (array) in Jy
#def sed(p, nu_in, ng, T, betain, alphain): #; m = [A, T, Beta, Alpha] - return SED (array) in Jy
	#P[0] = A
	#P[1] = T
	#P[2] = Beta
	#P[3] = Alpha

	v = p.valuesdict()
	A0= v['Ain']
	A=np.asarray(A0)
	#T = v['Tin']
	#betain = v['betain']
	#alphain = v['alphain']
	ng = np.size(A)

	ns = len(nu_in)
	base = 2.0 * (6.626)**(-2.0 - betain - alphain) * (1.38)**(3. + betain + alphain) / (2.99792458)**2.0
	expo = 34.0 * (2.0 + betain + alphain) - 23.0 * (3.0 + betain + alphain) - 16.0 + 26.0
	K = base * 10.0**expo
	w_num = A * K * (T * (3.0 + betain + alphain))**(3.0 + betain + alphain) 
	w_den = (np.exp(3.0 + betain + alphain) - 1.0)
	w_div = w_num/w_den 
	nu_cut = (3.0 + betain + alphain) * 0.208367e11 * T

	graybody = np.reshape(A,(ng,1)) * nu_in**np.reshape(betain,(ng,1)) * black(nu_in, T) / 1000.0 
	#powerlaw = np.reshape(w_div,(ng,1)) * nu_in**np.reshape(-1.0 * betain,(ng,1))
	# GJS: Changed "betain" to "alphain"; old script not compatible with the case betain != alphain
	powerlaw = np.reshape(w_div,(ng,1)) * nu_in**np.reshape(-1.0 * alphain,(ng,1))
	graybody[np.where(nu_in >= np.reshape(nu_cut,(ng,1)))]=powerlaw[np.where(nu_in >= np.reshape(nu_cut,(ng,1)))]

	return graybody
Esempio n. 2
0
def sedint(p, nu_in, Lir, T, betain, alphain): # m = [A, T, Beta, Alpha] - return integrated SED flux (one number) in Jy x Hz
#def sedint(p, nu_in, Lir, ng, T, betain, alphain): # m = [A, T, Beta, Alpha] - return integrated SED flux (one number) in Jy x Hz
	#P[0] = A
	#P[1] = T
	#P[2] = Beta
	#P[3] = Alpha

	v = p.valuesdict()
	A0 = v['Ain']
	A=np.asarray(A0)
	#pdb.set_trace()
	#T = v['Tin']
	#betain = v['betain']
	#alphain = v['alphain']


	#print 'A is ' + str(A)
	ns = len(nu_in)
	#pdb.set_trace()
	ng = np.size(A)
	base = 2.0 * (6.626)**(-2.0 - betain - alphain) * (1.38)**(3. + betain + alphain) / (2.99792458)**2.0
	expo = 34.0 * (2.0 + betain + alphain) - 23.0 * (3.0 + betain + alphain) - 16.0 + 26.0
	K = base * 10.0**expo
	w_num = A * K * (T * (3.0 + betain + alphain))**(3.0 + betain + alphain) 
	w_den = (np.exp(3.0 + betain + alphain) - 1.0)
	w_div = w_num/w_den 
	nu_cut = (3.0 + betain + alphain) * 0.208367e11 * T
	
	#nu_cut_ind = find_nearest_index(nu_in,nu_cut)

	graybody = np.reshape(A,(ng,1)) * nu_in**np.reshape(betain,(ng,1)) * black(nu_in, T) / 1000.0 
	#powerlaw = np.reshape(w_div,(ng,1)) * nu_in**np.reshape(-1.0 * betain,(ng,1))
	# GJS: Changed "betain" to "alphain"; old script not compatible with the case betain != alphain
	powerlaw = np.reshape(w_div,(ng,1)) * nu_in**np.reshape(-1.0 * alphain,(ng,1))
	graybody[np.where(nu_in >= np.reshape(nu_cut,(ng,1)))]=powerlaw[np.where(nu_in >= np.reshape(nu_cut,(ng,1)))]

	#pdb.set_trace()

	dnu = nu_in[1:ns] - nu_in[0:ns-1]
	dnu = np.append(dnu[0],dnu)

	return np.ravel([np.sum(graybody * dnu, axis=1) - Lir]) 
Esempio n. 3
0
def sedint2(p, nu_in, Lir, ng): # m = [A, T, Beta, Alpha] - return integrated SED flux (one number) in Jy x Hz
	#P[0] = A
	#P[1] = T
	#P[2] = Beta
	#P[3] = Alpha

	v = p.valuesdict()
	A = v['Ain']
	T = v['Tin']
	betain = v['betain']
	alphain = v['alphain']


	print 'A is ' + str(A)
	ns = len(nu_in)
	#ng = len(A)
	base = 2.0 * (6.626)**(-2.0 - betain - alphain) * (1.38)**(3. + betain + alphain) / (2.99792458)**2.0
	expo = 34.0 * (2.0 + betain + alphain) - 23.0 * (3.0 + betain + alphain) - 16.0 + 26.0
	K = base * 10.0**expo
	w_num = A * K * (T * (3.0 + betain + alphain))**(3.0 + betain + alphain) 
	w_den = (np.exp(3.0 + betain + alphain) - 1.0)
	w_div = w_num/w_den 
	nu_cut = (3.0 + betain + alphain) * 0.208367e11 * T
	
	#nu_cut_ind = find_nearest_index(nu_in,nu_cut)

	graybody = np.reshape(A,(ng,1)) * nu_in**np.reshape(betain,(ng,1)) * black(nu_in, T) / 1000.0 
	powerlaw = np.reshape(w_div,(ng,1)) * nu_in**np.reshape(-1.0 * betain,(ng,1))
	graybody[np.where(nu_in >= np.reshape(nu_cut,(ng,1)))]=powerlaw[np.where(nu_in >= np.reshape(nu_cut,(ng,1)))]

	#pdb.set_trace()

	dnu = nu_in[1:ns] - nu_in[0:ns-1]
	dnu = np.append(dnu[0],dnu)

	return np.ravel([np.sum(graybody * dnu, axis=1) - Lir]) 
nu_mod = c * 1.e6/lambda_mod # Hz
cosmo = FlatLambdaCDM(H0 = 70.5 * u.km / u.s / u.Mpc, Om0 = 0.273)
conversion = 4.0 * np.pi *(1.0E-13 * cosmo.luminosity_distance(zin) * 3.08568025E22)**2.0 / L_sun # 4 * pi * D_L^2    units are L_sun/(Jy x Hz)
int_sed = Lin / conversion # Jy x Hz


Ain = np.array([1.e-36])#,3.e-36,1.2e-36]) #good starting parameter
Tin = np.array([20.0])#,24.0,28.0])
betain = np.array([2.0])#,2.0,2.0])
alphain =np.array([2.0])#,2.0,2.0])
#Ain = np.array([1.e-36]) #good starting parameter
#Tin = np.array([23.0])
#betain = np.array([2.0])
#alphain =np.array([2.0])

test1 = black(nu_mod,Tin)

#pdb.set_trace()


#Ain = (2.e-36,3.e-36,1.2e-36)
#Ain = (2.e-3,3.e-3,1.2e-3)

ngal = len(Ain)
print ngal
fit_params = Parameters()
fit_params.add('Ain', value= Ain[0])
#pdb.set_trace()
#fit_params.add('Tin', value= Tin, vary = False)
#fit_params.add('betain', value= betain, vary = False)
#fit_params.add('alphain', value= alphain, vary = False)