# How to get from spectra to magnitude?

## Recommended Posts

Hi,

I used the b-v colour index of Polaris to determine temperature. I fitted a back body spectrum for that temperature. All done using astropy, synphot, spextra libraries in python. Easy, but when I continue a make an observation with a V filter, I get an estimated V mag of 14.69, that is way off.

The b-v colour index is 0.6, the temperature is 5967.54 K. The flux through the simulated V filter is 4.737E-15 erg/s/cm2/AA

It think it has something to do instrumental vs calibrated mags?

So basically what is the process to get the mags from an observed spectra?

##### Share on other sites

This may help. Regards Andrew

• 1
##### Share on other sites

2 hours ago, andrew s said:

This may help. Regards Andrew

Thanks Andrew seems to be what I'm looking for, but where do I find these equations? are they specific for a given catalog?

I am referring to eq. B=B0 -13.028 - 0.01(B0 - V0) etc

##### Share on other sites

So basically what is the process to get the mags from an observed spectra?

So you have a spectrum of the star and you want to calculate magnitude in particular band?

You are probably short of a multiplicative constant. You need to calibrate your instrument to be able to get precise magnitudes - and in this case it is multiplicative calibration.

Determining V band intensity from spectrum is fairly straight forward - you take spectrum and you multiply with V filter response and you integrate the result.

V band filter response can be given in percent or rather 0-1 range - so it does not influence choice of units. Spectrum on the other hand needs to be scaled to appropriate values in units of interest and if it's not - you need to scale it, to find multiplicative constant for your system.

To do that - calibrate on a known star. Take a spectrum of star whose magnitude you know - do the same integration to find numerical constant and then apply this constant back in the case of star you are interested in.

It's really like regular photometry - you need to calibrate your instrument first.

##### Share on other sites

25 minutes ago, vlaiv said:

To do that - calibrate on a known star. Take a spectrum of star whose magnitude you know - do the same integration to find numerical constant and then apply this constant back in the case of star you are interested in.

As explained in the link this assumes you have a wide slit so that you collect equally all the wave lengths. Obviously, it depends on how accurate you want it to be. However,  there are many issues for example atmospheric effects if the known star and target star are at different altitudes.  It's certainly not as easy as differential photometry.

Regards Andrew

• 2
##### Share on other sites

Thanks Andrew seems to be what I'm looking for, but where do I find these equations? are they specific for a given catalog?

I am referring to eq. B=B0 -13.028 - 0.01(B0 - V0) etc

It's  a long time since I looked seriously at this. It's explained in part 3. For a given rig you observe standard photometric stars and then use these to calculate the linear fit constants I.e. an adaptive and multiplicative constant.

Regards Andrew

##### Share on other sites

54 minutes ago, vlaiv said:

So you have a spectrum of the star and you want to calculate magnitude in particular band?

You are probably short of a multiplicative constant. You need to calibrate your instrument to be able to get precise magnitudes - and in this case it is multiplicative calibration.

Determining V band intensity from spectrum is fairly straight forward - you take spectrum and you multiply with V filter response and you integrate the result.

V band filter response can be given in percent or rather 0-1 range - so it does not influence choice of units. Spectrum on the other hand needs to be scaled to appropriate values in units of interest and if it's not - you need to scale it, to find multiplicative constant for your system.

To do that - calibrate on a known star. Take a spectrum of star whose magnitude you know - do the same integration to find numerical constant and then apply this constant back in the case of star you are interested in.

It's really like regular photometry - you need to calibrate your instrument first.

Hello Vlaiv,

It is a theoretical exercise in synphot - python

I make a source spectrum object that takes as argument Temperature [k] like this:

`sp = SourceSpectrum(BlackBodyNorm1D, temperature=bv.bv2T(0.60))`

bv2T is a method in the bv object that returns temperature having b-v colour index as argument.

I retrieve the wavelength and spectral flux density as arrays (and make unit conversion for flux):

```wave = sp.waveset
flux = sp(wave).to(u.erg / u.s / u.angstrom/u.cm**2,equivalencies=u.spectral_density(wave))```

then I make the same spectrum but with spextra library because it is easier to work with:

`sp = Spextrum.from_arrays(waves=wave,flux=flux)`

Next I make an observation using the V filter (it convolves the spectra and filter):

```integrated_flux= sp.get_flux(filter_curve="./filters_ascii/johnson_V.dat")

# result is 4.737e-15 erg/s/cm2/A```

Also I get the magnitude easily:

```V = sp.get_magnitude(filter_curve="./filters_ascii/johnson_V.dat", system_name="Vega")

# returns 14.69
# the mag V in a Simbad search is around 2.2
```

Given the difference I assumed I am actually computing instrumental mags, and I need a zero point for conversion to calibrated mags.

##### Share on other sites

Given the difference I assumed I am actually computing instrumental mags, and I need a zero point for conversion to calibrated mags.

Ok, I get what you are doing, but here are some points to think about.

`sp = SourceSpectrum(BlackBodyNorm1D, temperature=bv.bv2T(0.60))`

What sort of intensity does this function return?

Imagine you have two stars - both have the same temperature and ideal black body spectrum. Both are exactly the same - but one of them is at half the distance of the other with respect to us.

You record those two spectra - and they will have exact same shape - except one of them will be x4 "stronger" than the other - simply because star is closer to us and consequently appears brighter.

You don't have means to specify "brightness" of the spectrum in this method.

Similarly:

```wave = sp.waveset
flux = sp(wave).to(u.erg / u.s / u.angstrom/u.cm**2,equivalencies=u.spectral_density(wave))```

I don't see how you tell the function how to calculate physical flux - is it "stronger" or "weaker" of two spectra? Flux should be x4 as high numerically for same values between the two - but if we don't have that information in SP and you did not use any parameter to explain how to convert to flux - flux simply does not contain "true" values here.

In the end - integrated flux will be some number that will correspond to some magnitude - but that is simply because numerical values for flux are some arbitrary numbers and not true numbers for true star with some defined brightness.

It does not need to be a real star - but it has to have defined brightness and I don't see how that is defined.

##### Share on other sites

16 minutes ago, vlaiv said:

What sort of intensity does this function return?

Returns this when plotted:

But I do understand what you're saying. The b-v colour index I got from Simbad, I thought it encodes the intensity as well.

Hmm, seems harder than I thought.

I'm thinking of trying the other way around for fun, simulate the spectrum, then search the V band mag in Simbad, then scale the spectrum to that magnitude, then make a synthetic observation with the V filter and see if I get the same magnitude as Simbad. Scaling to the magnitude would basically underline your idea about brightness

##### Share on other sites

46 minutes ago, vlaiv said:

n the end - integrated flux will be some number that will correspond to some magnitude - but that is simply because numerical values for flux are some arbitrary numbers and not true numbers for true star with some defined brightness.

Quite wright,

If I take the V band mag from Simbad v = 2.02 and scale the spectra at that amplitude, and then convolve the synthetic filter with the scaled spectra, I get the same mag as the input.

```sp2 = Spextrum.from_arrays(waves=wave,flux=flux, flux_unit='FLAM').scale_to_magnitude(amplitude=2.02 * u.mag,filter_curve="./filters_ascii/johnson_V.dat")
sp2.plot(flux_unit='FLAM')```

Plot

Returned magnitude with V filter observation:

```v2= sp2.get_magnitude(filter_curve="./filters_ascii/johnson_V.dat", system_name="Vega")

#output 2.02 mag```

So that means the color index only provides information about temperature, but not brightness. Makes sense distance is a factor in brightness, besides temperature.

##### Share on other sites

I'm thinking of trying the other way around for fun, simulate the spectrum, then search the V band mag in Simbad, then scale the spectrum to that magnitude, then make a synthetic observation with the V filter and see if I get the same magnitude as Simbad. Scaling to the magnitude would basically underline your idea about brightness

If you scale against V and measure V - you will get the same value.

Here is what you can do as an exercise:

- find a star in catalog with known V and B magnitude, then use Gaia dataset to find effective temperature of that star - not one from color index.

- generate spectrum according to that temperature

- scale spectrum based on V mangnitude

- measure B magnitude and compare to catalog value of B and compare your B-V index to Gaia effective temperature

So that means the color index only provides information about temperature, but not brightness. Makes sense distance is a factor in brightness, besides temperature.

Well, if you think about what color index actually represents - you will have a better understanding of why it only corresponds to temperature.

Color index is difference of two magnitudes. Magnitudes are log based, and we know that if we have ratio of two quantities - corresponding thing in "log space" is difference. ( * and / turn to + and - in log).

What this really means it that color index is ratio of two intensities - intensity in V band and intensity in B band - turned into magnitude / log system.

If we have certain star and we increase it's apparent brightness by say making it closer - its intensity will change - maybe it will double - but that means that both V band intensity will double and B band intensity will double. However - ratio of these two values won't change as 2*V/2*B = V/B. Color index of a star does not change with its apparent brightness. It only contains ratio of different band intensities.

Since this ratio varies with temperature as black body curve is different - color index represents temperature of the star in a nutshell.

##### Share on other sites

The problem is stars are not black bodies,  the effective temperature Teff is not the temperature of the star and the relationship between B-V and Teff is an empirical not theoretical one

Robin

• 1
##### Share on other sites

You are also mixing up absolute and apparent magnitude and if you are trying to relate absolute magnitude to the flux of a black body you have to consider the radius (surface area) of the star

• 1

Cheers

Robin

##### Share on other sites

` result is 4.737e-15 erg/s/cm2/A`

This is the flux per unit area surface A of the (theoretical black body) star.  When we measure the flux on earth, the units might look the same,  erg/s/cm2/A but on earth we measure the flux per unit collecting area of the collecting instrument.  The two measurements are not directly related.

##### Share on other sites

• 5 months later...
On 04/01/2024 at 01:00, vlaiv said:

If you scale against V and measure V - you will get the same value.

Here is what you can do as an exercise:

- find a star in catalog with known V and B magnitude, then use Gaia dataset to find effective temperature of that star - not one from color index.

- generate spectrum according to that temperature

- scale spectrum based on V mangnitude

- measure B magnitude and compare to catalog value of B and compare your B-V index to Gaia effective temperature

Well, if you think about what color index actually represents - you will have a better understanding of why it only corresponds to temperature.

Color index is difference of two magnitudes. Magnitudes are log based, and we know that if we have ratio of two quantities - corresponding thing in "log space" is difference. ( * and / turn to + and - in log).

What this really means it that color index is ratio of two intensities - intensity in V band and intensity in B band - turned into magnitude / log system.

If we have certain star and we increase it's apparent brightness by say making it closer - its intensity will change - maybe it will double - but that means that both V band intensity will double and B band intensity will double. However - ratio of these two values won't change as 2*V/2*B = V/B. Color index of a star does not change with its apparent brightness. It only contains ratio of different band intensities.

Since this ratio varies with temperature as black body curve is different - color index represents temperature of the star in a nutshell.

Hi Vlaiv,

So after some time of researching mostly through the synphot, astropy python libraries, I managed to crack the problem.

So here it goes:

1. Search GAIA database for a desired star
2. Retrieve star radius, star temperature, star distance, star logg (surface gravity)
3. Use these parameters to construct a star spectrum using the Phoenix spectra library
4. Scale the spectrum to the value we expect above earth taking into account star distance and radius
```scale_factor = float(self.star_radius * u.R_sun / self.star_distance) ** 2
star_spectrum_scaled = star_spectrum * scale_factor```

5. Correct the spectrum for airmass extinction

```def objectSpectra_below_atmosphere(self):
extinction_factor = np.exp(-self.extinction * self.airmass)
self.objectFluxBA = self.objectFlux * extinction_factor

return Spextrum.from_arrays(waves = self.objectWave, flux = self.objectFluxBA)```

6. Make an observation using the built in Observation class from synphot

```def _get_object_counts(self):

throughput = self.myFilter_transmission() * self.mySky_transmission() * self.mySensor_QE_transmission()
myObject_Observation = Observation(self.objectSpectra_below_atmosphere(), throughput,force='extrap')

objectCounts = myObject_Observation.countrate(area=self.area)

return objectCounts # e-/s```

7. Retrieve the magnitude (to be checked with actual data from Simbad)  of the star using whatever filters we want

```def _get_VEGAmag(self):
return self.objectSpectra().get_magnitude(filter_curve=self.filter_curve, system_name="VEGA")

def _get_ABmag(self):
return self.objectSpectra().get_magnitude(filter_curve=self.filter_curve, system_name="AB")
```

In the end I make a table like this for the star BD+32 2547 Simbad link:

The flux density and magnitude are above the atmosphere, and the counts are below the atmosphere (corrected for airmass, filter extinction). Of course I had to determine the extinction coefficients for my Sloan filters ..

The beauty of working with the spectrum is that you can model the expected magnitude in different filters even if the mags are not available for every filter you want.

Further, we can test the accuracy of the prediction model.

I took a 30 second exposure using the Sloan r' filter, and measured the peak counts in APT and compared the result with the prediction.

The experimental peak value is 39534 ADUs.

Now we use the theoretical computed counts to compute the peak ADUs (I computed the peak of a gaussian star model), for a range of exposure time intervals (the plot button on the right of the table):

And the result is quite accurate, 40032 ADUs vs the experimental value of 39534.

This makes the computation valuable if you want to know how much to expose in order to avoid star saturation.

• 1
##### Share on other sites

On 03/01/2024 at 22:30, andrew s said:

It's  a long time since I looked seriously at this. It's explained in part 3. For a given rig you observe standard photometric stars and then use these to calculate the linear fit constants I.e. an adaptive and multiplicative constant.

Regards Andrew

Hi Andrew,

In the end I solved the issue, although it took some time, and learning. See my post above

• 1
##### Share on other sites

How do you allow for Interstellar extinction ? (I find the Teff in Gaia can sometimes be unreliable, probably because it confuses IS extinction with Teff so perhaps two wrongs make a right for your application 😉

##### Share on other sites

Posted (edited)

Going via a synthetic spectrum based on the Gaia calculated physical parameters and then converting from absolute to apparent magnitude sounds overly complicated to me. The Gaia physical parameters are just estimates based on the Gaia photometry. They are useful as statistical samples but can at times be way off. Why not just use the Gaia photometry as your basis and transform to Johnson or whatever filter passband you are using using the colour indices.  eg

Cheers

Robin

Edited by robin_astro
##### Share on other sites

A much simpler method to estimate the exposure needed would be to measure a star with known apparent magnitudes at two different air masses in your chosen filter system. You then just scale the result according to the brightness of the star you want to observe, correcting for the  air mass  and the effect of seeing (which will affect the star image FWHM and therefore the peak pixel ADU)

Cheers

Robin

## Create an account

Register a new account