Jump to content

NLCbanner2024.jpg.2478be509670e60c2d6efd04834b8b47.jpg

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? 

Link to comment
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

Link to comment
Share on other sites

3 hours ago, dan_adi said:

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.

Link to comment
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 

  • Like 2
Link to comment
Share on other sites

1 hour ago, dan_adi said:

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 

Link to comment
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.

Link to comment
Share on other sites

7 minutes ago, dan_adi said:

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.

Link to comment
Share on other sites

16 minutes ago, vlaiv said:

What sort of intensity does this function return?

Returns this when plotted:

Screenshot2024-01-03at23_34_16.png.4be33ca90fd50008eae024f4207a230b.png

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

Link to comment
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

Screenshot2024-01-04at00_06_00.png.3572037728a242f4dff6f9d25f5132d2.png

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. 

Link to comment
Share on other sites

1 hour ago, dan_adi said:

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

41 minutes ago, dan_adi said:

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.

Link to comment
Share on other sites

23 hours ago, dan_adi said:
 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.

Link to comment
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:

Screenshot2024-06-15at17_30_12.thumb.png.7aa2d4e55012b281442b83c77393deb7.png

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.

Screenshot2024-06-15at17_36_18.thumb.png.fe23a47f8d75b104687e76124f53e518.png

 

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):

Screenshot2024-06-15at17_40_10.thumb.png.2279773a2f0774b73b1128d1a1c4f36b.png

 

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.

 

 

 

 

 

 

 

 

 

 

  • Like 1
Link to comment
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

  • Thanks 1
Link to comment
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 😉

Link to comment
Share on other sites

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

https://gea.esac.esa.int/archive/documentation/GDR2/Data_processing/chap_cu5pho/sec_cu5pho_calibr/ssec_cu5pho_PhotTransf.html

Cheers

Robin

Edited by robin_astro
Link to comment
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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.