def f_integral_surfaceroche_v2(theta,omega,psi,x): """ Returns the integral of x over the equipotential surface. I = \int_S x(\theta) \mathrm{d}S """ if len(theta) < 2 or len(x) < 2 or len(theta) != len(x): func_name = sys._getframe().f_code.co_name print '<<',func_name,'>>' print 'There is something wrong with the integration!' print '' return np.nan for i in xrange(0,len(theta)): if not (theta[i] >= 0.0*np.pi and theta[i] <= 0.5*np.pi): func_name = sys._getframe().f_code.co_name print '<<',func_name,'>>' print 'The thetas you gave me are out of the desired range!' print '' return np.nan if i > 0 and theta[i] <= theta[i-1]: func_name = sys._getframe().f_code.co_name print '<<',func_name,'>>' print 'The thetas you gave me are not in ascending order!' print '' return np.nan npts=len(theta) dtheta=np.array([theta[i+1]-theta[i] for i in xrange(0,len(theta)-1)]) rocheradius=np.array([f_rocheradius(theta[i],omega,psi) for i in xrange(0,len(dtheta))]) ds=np.array([f_dalinha(theta[i],omega,psi,dtheta[i]) for i in xrange(0,len(dtheta))]) integral_roche=2.*lrr.integrate_trapezia(x,ds) return integral_roche
def f_vw(omega,psi,npts): """Returns the volume inside the equipotential surface.""" thetamin=0.0; thetamax=0.5*np.pi theta=np.array([thetamin+(thetamax-thetamin)*float(i)/float(npts-1) for i in xrange(0,npts)]) rocheradius=np.array([f_rocheradius(theta[i],omega,psi) for i in xrange(0,len(theta))]) integ=np.array([0.5*np.sin(theta[i])*rocheradius[i]**3. for i in xrange(0,len(theta))]) dtheta=np.array([theta[i+1]-theta[i] for i in xrange(0,len(theta)-1)]) vw=2.*lrr.integrate_trapezia(integ,dtheta) return vw
def f_M_disk(outputs_list_element): M_disk=[] Req2=(outputs_list_element[1][6]*phc.Rsun.cgs)**2. ln_relR=outputs_list_element[4] d_ln_relR=np.array([outputs_list_element[4][j+1]-outputs_list_element[4][j] for j in xrange(0,len(outputs_list_element[4])-1)]) relR=outputs_list_element[5] # over iterations... for i in xrange(0,len(outputs_list_element[8])): Sigmas=np.array([elem for elem in outputs_list_element[12][:,i]]) M_disk.append(2.*np.pi*Req2*lrr.integrate_trapezia(relR**2.*Sigmas,d_ln_relR)) return np.array([elem for elem in M_disk])
def f_M_disk(outputs_list_element): M_disk = [] Req2 = (outputs_list_element[1][6] * phc.Rsun.cgs)**2. ln_relR = outputs_list_element[4] d_ln_relR=np.array([outputs_list_element[4][j+1]-outputs_list_element[4][j] \ for j in xrange(0,len(outputs_list_element[4])-1)]) relR = outputs_list_element[5] # over iterations... for i in xrange(0, len(outputs_list_element[8])): Sigmas = np.array([elem for elem in outputs_list_element[12][:, i]]) M_disk.append(2. * np.pi * Req2 * lrr.integrate_trapezia(relR**2. * Sigmas, d_ln_relR)) return np.array([elem for elem in M_disk])
def f_vw(omega,psi,npts): """Returns the volume inside the equipotential surface.""" thetamin=0.0; thetamax=0.5*np.pi theta=np.array([thetamin+(thetamax-thetamin)*\ float(i)/float(npts-1) for i in xrange(0,npts)]) rocheradius=np.array([f_rocheradius(theta[i],omega,psi) \ for i in xrange(0,len(theta))]) integ=np.array([0.5*np.sin(theta[i])*rocheradius[i]**3. \ for i in xrange(0,len(theta))]) dtheta=np.array([theta[i+1]-theta[i] \ for i in xrange(0,len(theta)-1)]) vw=2.*lrr.integrate_trapezia(integ,dtheta) return vw
def f_J_disk(outputs_list_element): J_disk=[] Req=outputs_list_element[1][6]*phc.Rsun.cgs Req2=(outputs_list_element[1][6]*phc.Rsun.cgs)**2. massa=outputs_list_element[1][5] leq=(phc.G.cgs*massa*phc.Msun.cgs*Req)**0.5 ln_relR=outputs_list_element[4] d_ln_relR=np.array([outputs_list_element[4][j+1]-outputs_list_element[4][j] for j in xrange(0,len(outputs_list_element[4])-1)]) relR=outputs_list_element[5] # over iterations... for i in xrange(0,len(outputs_list_element[8])): Sigmas=np.array([elem for elem in outputs_list_element[12][:,i]]) J_disk.append(2.*np.pi*Req2*leq*lrr.integrate_trapezia(relR**2.5*Sigmas,d_ln_relR)) return np.array([elem for elem in J_disk])
def f_J_disk(outputs_list_element): J_disk = [] Req = outputs_list_element[1][6] * phc.Rsun.cgs Req2 = (outputs_list_element[1][6] * phc.Rsun.cgs)**2. massa = outputs_list_element[1][5] leq = (phc.G.cgs * massa * phc.Msun.cgs * Req)**0.5 ln_relR = outputs_list_element[4] d_ln_relR=np.array([outputs_list_element[4][j+1]-outputs_list_element[4][j] \ for j in xrange(0,len(outputs_list_element[4])-1)]) relR = outputs_list_element[5] # over iterations... for i in xrange(0, len(outputs_list_element[8])): Sigmas = np.array([elem for elem in outputs_list_element[12][:, i]]) J_disk.append(2. * np.pi * Req2 * leq * lrr.integrate_trapezia(relR**2.5 * Sigmas, d_ln_relR)) return np.array([elem for elem in J_disk])
def f_integral_surfaceroche(theta, omega, psi, x): """ Returns the integral of x over the equipotential surface. $I = \int_S x(\theta) \mathrm{d}S$ """ if len(theta) < 2 or len(x) < 2 or len(theta) != len(x): func_name = sys._getframe().f_code.co_name print('<<', func_name, '>>') print('There is something wrong with the integration!') print('') return np.nan for i in xrange(0, len(theta)): if not (theta[i] >= 0.0 * np.pi and theta[i] <= 0.5 * np.pi): func_name = sys._getframe().f_code.co_name print('<<', func_name, '>>') print('The thetas you gave me are out of the desired range!') print('') return np.nan if i > 0 and theta[i] <= theta[i - 1]: func_name = sys._getframe().f_code.co_name print('<<', func_name, '>>') print('The thetas you gave me are not in ascending order!') print('') return np.nan npts = len(theta) dtheta=np.array([theta[i+1]-theta[i] \ for i in xrange(0,len(theta)-1)]) rocheradius=np.array([f_rocheradius(theta[i],omega,psi) \ for i in xrange(0,len(dtheta))]) drochedtheta=np.array([f_drochedtheta(theta[i],omega,psi) \ for i in xrange(0,len(dtheta))]) roche_dafac=np.array([f_roche_dafac(rocheradius[i],\ drochedtheta[i]) for i in xrange(0,len(dtheta))]) ds=np.array([f_ds(theta[i],dtheta[i],2.*np.pi,roche_dafac[i]) \ for i in xrange(0,len(dtheta))]) integral_roche = 2. * lrr.integrate_trapezia(x, ds) return integral_roche
def line_observables(Bralpha,Pfgamma,Brgamma,Humphreys,Brackets,BL,RL,\ files_fullsed_new, fullsed_contents): """ In this procedure, the interesting line observables are calculated for each of the desired lines. """ for ifile in xrange(0, len(files_fullsed_new)): print("Obtaining line observables for file") print(files_fullsed_new[ifile][0]) ### First, the line observables of the desired lines are calculated ### Line observables for the Br alpha hwidth = lbc_Bralpha[1] lbc = lbc_Bralpha[0] contents = fullsed_contents[ifile][1] auxilinflux,auxiew,auxiPS,auxiFWHM = \ obtaining_flux_ew_PS(contents,lbc,hwidth) Bralpha.append([auxilinflux, auxiew, auxiPS, auxiFWHM]) ### Line observables for the Br gamma hwidth = lbc_Brgamma[1] lbc = lbc_Brgamma[0] contents = fullsed_contents[ifile][1] auxilinflux,auxiew,auxiPS,auxiFWHM = \ obtaining_flux_ew_PS(contents,lbc,hwidth) Brgamma.append([auxilinflux, auxiew, auxiPS, auxiFWHM]) ### Line observables for the Pf gamma hwidth = lbc_Pfgamma[1] lbc = lbc_Pfgamma[0] contents = fullsed_contents[ifile][1] auxilinflux,auxiew,auxiPS,auxiFWHM = \ obtaining_flux_ew_PS(contents,lbc,hwidth) Pfgamma.append([auxilinflux, auxiew, auxiPS, auxiFWHM]) ### Line observables for the Bracket's Bracketsauxi = [] for iHump in range(0, len(lbc_Bracketoth)): hwidth = lbc_Bracketoth[iHump][1] lbc = lbc_Bracketoth[iHump][0] contents = fullsed_contents[ifile][1] auxilinflux,auxiew,auxiPS,auxiFWHM = \ obtaining_flux_ew_PS(contents,lbc,hwidth) Bracketsauxi.append([auxilinflux, auxiew, auxiPS, auxiFWHM]) Brackets.append(Bracketsauxi) ### Line observables for the Humphrey's Humphreysauxi = [] for iHump in range(0, len(lbc_Humphreyoth)): hwidth = lbc_Humphreyoth[iHump][1] lbc = lbc_Humphreyoth[iHump][0] contents = fullsed_contents[ifile][1] auxilinflux,auxiew,auxiPS,auxiFWHM = \ obtaining_flux_ew_PS(contents,lbc,hwidth) Humphreysauxi.append([auxilinflux, auxiew, auxiPS, auxiFWHM]) Humphreys.append(Humphreysauxi) ### Now, obtaining the B and R fluxes defined by ### Mennickent et al. 2009PASP..121..125M print("Obtaining the B and R fluxes defined by Mennickentet al. 2009.") contents = fullsed_contents[ifile][1] BLfluxauxi = [] RLfluxauxi = [] ### Loop over inclinations for incs in range(0, len(contents[1])): xlp = contents[2][incs, :, 0] ### lambda [microns] ylp = contents[2][incs, :, 1] ### HDUST's flux [microns^-1] Nnpts = 50 ### this number must be >= 3. A good choice is 50. ### Obtaining F(BL) [erg/s cm^2] llamb = np.array([lamb1_BL+(lamb2_BL-lamb1_BL)/\ float(Nnpts-1)*float(i) for i in range(0,Nnpts)]) dllamb = np.array( [llamb[i + 1] - llamb[i] for i in range(0, Nnpts - 1)]) ylpf = np.array([lrr.interpLinND([llamb[i]],[xlp],ylp) \ for i in range(0,Nnpts)]) BLflux = lrr.integrate_trapezia(ylpf, dllamb) BLflux = BLflux * contents[4][3]*phc.Lsun.cgs/4./np.pi/\ (dist_std*phc.pc.cgs)**2. BLfluxauxi.append(BLflux) ### Obtaining F(RL) [erg/s cm^2] llamb = np.array([lamb1_RL+(lamb2_RL-lamb1_RL)/\ float(Nnpts-1)*float(i) for i in range(0,Nnpts)]) dllamb = np.array( [llamb[i + 1] - llamb[i] for i in range(0, Nnpts - 1)]) ylpf = np.array([lrr.interpLinND([llamb[i]],[xlp],ylp) \ for i in range(0,Nnpts)]) RLflux = lrr.integrate_trapezia(ylpf, dllamb) RLflux = RLflux * contents[4][3]*phc.Lsun.cgs/4./np.pi/\ (dist_std*phc.pc.cgs)**2. RLfluxauxi.append(RLflux) BLfluxauxi = np.array(BLfluxauxi) BL.append(BLfluxauxi) RLfluxauxi = np.array(RLfluxauxi) RL.append(RLfluxauxi) return Bralpha, Pfgamma, Brgamma, Humphreys, Brackets, BL, RL
linflux = spt.absLineCalc(xplot, ylp[idx], vw=hwidth) linflux=linflux * contents[4][3]*phc.Lsun.cgs/4./np.pi/\ (dist_std*phc.pc.cgs)**2.*1e5*lbc/phc.c.cgs linfluxes.append(linflux / linflux19) plt.plot(wvlengths, linfluxes, color=colorvec[ii]) #plt.subplot(212) Nnpts = 50 llamb=np.array([lamb1_BL+(lamb2_BL-lamb1_BL)/\ float(Nnpts-1)*float(i) for i in range(0,Nnpts)]) dllamb = np.array( [llamb[i + 1] - llamb[i] for i in range(0, Nnpts - 1)]) ylpf=np.array([lrr.interpLinND([llamb[i]],[xlp],ylp) \ for i in range(0,Nnpts)]) BLflux = lrr.integrate_trapezia(ylpf, dllamb) BLflux=BLflux * contents[4][3]*phc.Lsun.cgs/4./np.pi/\ (dist_std*phc.pc.cgs)**2. print(BLflux) llamb=np.array([lamb1_RL+(lamb2_RL-lamb1_RL)/\ float(Nnpts-1)*float(i) for i in range(0,Nnpts)]) dllamb = np.array( [llamb[i + 1] - llamb[i] for i in range(0, Nnpts - 1)]) ylpf=np.array([lrr.interpLinND([llamb[i]],[xlp],ylp) \ for i in range(0,Nnpts)]) RLflux = lrr.integrate_trapezia(ylpf, dllamb) RLflux=RLflux * contents[4][3]*phc.Lsun.cgs/4./np.pi/\ (dist_std*phc.pc.cgs)**2. print(RLflux) lbc = lbc_Humphrey14