# conversion from magnitude to flux

I am using GalSim for creating mock galaxies in a magnitude range of 28-29. GalSim requires the input flux in units of photons/cm^2/s . I have used the halflight radii as per the value for this redshift range .Coming to the magnitude part, My science images are in units of MJy/sr having pixelscale of 0.03" and zeropoint of 28.08 AB mags. So I can convert the mag into flux in MJy/sr as ,

flux [MJy/sr]=10^((ZPAB−magAB)/2.5.


also I have , PHOTMJSR= 0.4047000110149384 / Flux density (MJy/steradian) producing 1 cps.From this I can extract the flux in counts/s by flux_mjy_sr / photmjsr. I have to convert now it into flux in counts/s/cm^2 . How can I do this ? ( I also have my nominal pixel area in arcsecond^2 as 0.0009)

• If you create mock data, you can obviously also create the mock spectral data. Actually you may even want to do that the right way around: create mock galaxies with their mock spectra and distances, and derive the apparent magnitudes and other derived fluxes and photon counts from that Commented Sep 3 at 12:05
• @planetmaker I actually want to insert mock galaxies with different magnitudes into an existing image and then retrieve it. So I have to use the flux/magnitude as an input
– Alan
Commented Sep 3 at 12:48
• yep. And you can retrieve those inputs rather easily from an assumed spectrum (Maybe just a planck curve with some appropriate redshift applied might suffice?), luminosity and distance or redshift. And with that you can also derive the photon count. Commented Sep 3 at 13:52
• Of course you can walk the way backward: assume a flux and magnitude, then use that to calculate a synthetic spectrum which is fitted to your flux data by deconvoling it with the optical filters and derive the flux from that. Thus to me it seems easier to assume the original properties and calculate derivatives from that - especially as it gives you greater flexibility to adjust your test data to a wider ranger of real sources as you only have to apply the filters as they are applied by real instruments, too, instead of backward-engineering it. Commented Sep 3 at 13:59
• Thanks. I'll try this way
– Alan
Commented Sep 4 at 9:48