Zero point in the output of


I were using the FLUXMAG0 in the header of CORR-*fits to calculate the zero point (and magnitude) for the data processed with hscPipe 5. But this information is no longer in the data processed with hscPipe 7.9.1.

I wonder if anyone can give me a hint for how to calculate/obtain the apparent magnitude from the output of hscPipe 7.9.1, which has T_MAGZER =0 in the header and only has many *instFlux in the SRC-*.fits.


I believe the plan is to add this header back, but in the meantime you can get it from the photoCalib() associated with the calexp, e.g.
fluxMag0 = calexp.getPhotoCalib().getInstFluxAtZeroMagnitude()

Just write piece of code according this reference.
Is this a right way to get magnitude?

import numpy as np
import lsst.daf.persistence as dafPersist

butler = dafPersist.Butler("~/HSC/rerun/[rerun]")
dataId = {'visit':175198, 'ccd':73}
ce = butler.get('calexp', dataId)
src = butler.get('src', dataId)
tmag = -2.5*np.log10( src.columns.getPsfInstFlux() / ce.getPhotoCalib().getInstFluxAtZeroMagnitude())

I think you can just use the ce.instFluxToMagnitude method. There are a few different overloads. You can see the documentation (in c++ but it mostly carries through to the python) here

If you have an exposure and the source catalog derived from it and want to compute the fluxes and magnitudes for all of the fields in that catalog, you are best off using calexp.getPhotoCalib().calibrateCatalog().

1 Like

If you don’t need the actual calexp image, don’t bother reading the whole thing in. Instead:

photoCalib = butler.get("calexp_photoCalib", visit=175198, ccd=73)

Thanks for your replies. Paul, do you mean that to replace ce = butler.get('calexp', dataId) with following line, right?

Yes, that should be the best way to get the PhotoCalib associated with that exposure.

Note that we strongly recommend using the built-in PhotoCalib methods (e.g. instFluxToNanojansky, instFluxToMagnitude, calibrateCatalog, and calibrateImage) instead of doing your own math with an exposure-averaged flux magnitude zero point, because the calibration factor may vary across the image.

1 Like

I got an additional question: how can I get the zero point of single warp image (e.g.: warp-HSC-G-0-14,11-34490.fits) and stacked image (e.g.:calexp-HSC-G-0-14,11.fits).

I can get a value from following code, but I don’t sure what is I obtained:

dataId = {'filter': 'HSC-G', 'patch': '14,11', 'tract': 0}
exp = butler.get('deepCoadd_calexp', dataId)

or, where has a list of possible input for bulter.get? (I only found this)

The dataset name for a warp is deepCoadd_directWarp.

The code you pasted retrieves a particular coadd and determines the zero-point flux (without saving it).