<p>I have an SED with wavelength in microns, and fluxes in mJy. I try the following code but my derived luminosity is a factor of 2 less (I should get 2.5e-3 L_sun). I think I am converting the fluxes incorrect but I can't figure out how else to convert them.</p>
<pre><code>wavl = stellar_wavl*1e-6 # convert to m
freq = (3e8)/wavl

d = 29.43*3.086e16  # distance to star
r = 0.01 * Rsun
WD_int = stellar_flux / (np.pi *  (0.01*r/d)**2 * 1e26 * 1000) # convert mJy to W/m2/Hz

# define function to integrate
flux_interp = interp1d(freq, WD_int, kind='linear')

mu_min = min(freq)
mu_max = max(freq)

integrand = lambda mu: flux_interp(mu)

# Perform the integration
I, _ = quad(integrand, mu_min, mu_max)
Lbol = I * (4*np.pi*(Rsun*0.01)**2.) 
Lbol/(3.846e26)

= 0.001245
</code></pre>
<p>Any help is appreciated!</p>

CC BY-SA 4.0
2024-04-20T01:54:17.370Z
Can you mention what a SED is? Also, could you write the actual equation your using in mathematical notation in addition to your code? Use [MathJax](https://math.meta.stackexchange.com/q/5020/284619). Thanks! and *Welcome to Stack Exchange!*
uhoh
CC BY-SA 4.0
2024-04-20T05:42:55.980Z
What is stellar_wav1 used for? Where is stellar_,flux defined? Why does your conversion of flux units involve the radius and distance of the star? A mJy is just $10^{-29}$ W/m$^2$/Hz.
ProfRob
<units><black-body>
Calculating luminosity from SED
hnn
# Calculating luminosity from SED

(Asked by: username_0 on 2024-04-19)

I have an SED with wavelength in microns, and fluxes in mJy. I try the following code but my derived luminosity is a factor of 2 less (I should get 2.5e-3 L_sun). I think I am converting the fluxes incorrect but I can't figure out how else to convert them.
wavl = stellar_wavl*1e-6 # convert to m
freq = (3e8)/wavl

d = 29.43*3.086e16  # distance to star
r = 0.01 * Rsun
WD_int = stellar_flux / (np.pi *  (0.01*r/d)**2 * 1e26 * 1000) # convert mJy to W/m2/Hz

# define function to integrate
flux_interp = interp1d(freq, WD_int, kind='linear')

mu_min = min(freq)
mu_max = max(freq)

integrand = lambda mu: flux_interp(mu)

# Perform the integration
I, _ = quad(integrand, mu_min, mu_max)
Lbol = I * (4*np.pi*(Rsun*0.01)**2.) 
Lbol/(3.846e26)

= 0.001245

Any help is appreciated!

**Tags:** units, black-body

> **Comments:**
> **username_1**: Can you mention what a SED is? Also, could you write the actual equation your using in mathematical notation in addition to your code? Use [MathJax](https://math.meta.stackexchange.com/q/5020/284619). Thanks! and *Welcome to Stack Exchange!*  
> **username_2**: What is stellar_wav1 used for? Where is stellar_,flux defined? Why does your conversion of flux units involve the radius and distance of the star? A mJy is just $10^{-29}$ W/m$^2$/Hz.  

---

## 0 answers

