LSSTDESC / WeakLensingDeblending

Weak lensing fast simulations and analysis of blended objects.
http://weaklensingdeblending.readthedocs.io/en/latest/index.html
Other
14 stars 13 forks source link

How to rescale an image to a zero point #47

Closed esheldon closed 4 years ago

esheldon commented 4 years ago

I'm generating images with this package, and I'd like to rescale them to a common zero point, say 30.0. This is important so that they can all be on the same footing to, e.g. be coadded (for example coadding r+i+z) and so it is easy to compute magnitudes downstream (all bands on the same zero point) etc.

What formula should I apply to do this conversion?

fjaviersanchez commented 4 years ago

We computed the zeropoints as follows (see #19) (note that you will need speclite that is pip-installable).

from speclite.filters import load_filter, ab_reference_flux
import astropy.units as u
def calculate_zero_point(band_name, B0=24):
    filt = load_filter(band_name)
    return (filt.convolve_with_function(ab_reference_flux) *
            10 ** (-0.4 * B0)).to(1 / (u.s * u.m**2))

So for example, to compute the LSST-r band zeropoint you would do calculate_zero_point('lsst2016-r'). The lsst2016 filter throughputs assume airmass=1.2. After this you have to multiply times the effective area of the telescope (for LSST it is 32.4 m^2)

fjaviersanchez commented 4 years ago

I forgot to say that the fluxes are then computed as: exposure_time*zero_point*10**(-0.4*(ab_magnitude-24))

esheldon commented 4 years ago

I'm talking about the magnitude zero point which is a different thing that you have there

fjaviersanchez commented 4 years ago

That would be 2.5*log10(zero_point)+24 where zero_point is calculated as mentioned above and can be found in descwl/survey.py for each one of the surveys/filters combinations.

fjaviersanchez commented 4 years ago

So I guess that the answer to your question about how to get an image with magnitude zeropoint of 30 would be setting the option --zero-point 251.1886

esheldon commented 4 years ago

I don't use the command line interface, I use the library.

Something that doesn't look right is that your flux definition has exposure time in it. Mags are not defined that way with respect to the zero point.

A mag is defined as mag = ZEROPOINT - 2.5*log10(flux). It looks like you instead use flux*time

fjaviersanchez commented 4 years ago

Yes, our definition of zeropoint is not the usual of magnitude to get a flux of 1 e-/second but e-/s at 24th magnitude. See more here: https://github.com/LSSTDESC/WeakLensingDeblending/issues/1#issuecomment-156719248

Yes, sorry, what I wrote above was the rendered number of counts of source for a given exposure time instead of the flux itself which is (given our convention) zero_point*10**(-0.4*(ab_magnitude-24)). If you are using the library, and want a magnitude zeropoint of 30, then you would have to change the value of the zero_point of your Survey object to 251.1886. I agree that maybe it's a good idea to migrate to the normal definition of zeropoint.

esheldon commented 4 years ago

The images need the exposure time taken out. Here is the formula to get a desired zero point (in this case 30)

zp = 30.0
filter = 'r'
pars = descwl.survey.Survey.get_defaults(
    survey_name='LSST',
    filter=filter,
)
pars['zero_point'] = 10.0**(0.4*(zp - 24.0))/pars['exposure_time']

FYI @beckermr

esheldon commented 4 years ago

but note that then the noise is not correct, so I think I'll end up doing this after generating the image

esheldon commented 4 years ago

For posterity:

    s_zp = survey.zero_point
    s_et = survey.exposure_time
    fac = 10.0**(0.4*(ZERO_POINT - 24.0))/s_zp/s_et
    image *= fac                                                                                                                                                                     
esheldon commented 4 years ago

Thanks, I'll close this issue