# Zero point in the output of singleFrameDriver.py

**URL:** <https://www.rubin.community/t/zero-point-in-the-output-of-singleframedriver-py/3876>\
**Category:** Support\
**Created:** [October 9, 2019, 6:47am UTC](https://www.rubin.community/t/zero-point-in-the-output-of-singleframedriver-py/3876 "2019-10-09T06:47:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charles](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@Charles](https://www.rubin.community/u/Charles)\
**Post date:** [October 9, 2019, 6:47am UTC](https://www.rubin.community/t/zero-point-in-the-output-of-singleframedriver-py/3876/1 "2019-10-09T06:47:45Z")

</div>

Hi,

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.

Charles

---

<div class="post-metadata">

**Author:** ![laurenam](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/laurenam/32/128_2.png) [@laurenam](https://www.rubin.community/u/laurenam)\
**Post date:** [October 9, 2019, 8:39am UTC](https://www.rubin.community/t/zero-point-in-the-output-of-singleframedriver-py/3876/2 "2019-10-09T08:39:39Z")

</div>

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()`

---

<div class="post-metadata">

**Author:** ![Charles](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@Charles](https://www.rubin.community/u/Charles)\
**Post date:** [October 9, 2019, 12:54pm UTC](https://www.rubin.community/t/zero-point-in-the-output-of-singleframedriver-py/3876/3 "2019-10-09T12:54:50Z")

</div>

Just write piece of code according [this reference](https://hsc.mtk.nao.ac.jp/pipedoc_5_e/tools_e/index.html).  
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())
```

---

<div class="post-metadata">

**Author:** ![natelust](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/natelust/32/358_2.png) [@natelust](https://www.rubin.community/u/natelust)\
**Post date:** [October 9, 2019, 2:41pm UTC](https://www.rubin.community/t/zero-point-in-the-output-of-singleframedriver-py/3876/4 "2019-10-09T14:41:20Z")

</div>

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](https://github.com/lsst/afw/blob/27f8efa26c4fb1d9cfc4164397f63de746d3efb2/include/lsst/afw/image/PhotoCalib.h#L270)

---

<div class="post-metadata">

**Author:** ![parejkoj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/parejkoj/32/138_2.png) [@parejkoj](https://www.rubin.community/u/parejkoj)\
**Post date:** [October 9, 2019, 5:20pm UTC](https://www.rubin.community/t/zero-point-in-the-output-of-singleframedriver-py/3876/5 "2019-10-09T17:20:19Z")

</div>

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()`](http://doxygen.lsst.codes/stack/doxygen/x_masterDoxyDoc/classlsst_1_1afw_1_1image_1_1_photo_calib.html#a1ce8d76e109775c6e8bab26ea5849224).

---

<div class="post-metadata">

**Author:** ![price](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/price/32/488_2.png) [@price](https://www.rubin.community/u/price)\
**Post date:** [October 9, 2019, 7:50pm UTC](https://www.rubin.community/t/zero-point-in-the-output-of-singleframedriver-py/3876/6 "2019-10-09T19:50:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Charles](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@Charles](https://www.rubin.community/u/Charles)\
**Post date:** [October 9, 2019, 11:20pm UTC](https://www.rubin.community/t/zero-point-in-the-output-of-singleframedriver-py/3876/7 "2019-10-09T23:20:57Z")

</div>

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

> [@price](#):
>
> photoCalib = butler.get(“calexp\_photoCalib”, visit=175198, ccd=73)

---

<div class="post-metadata">

**Author:** ![parejkoj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/parejkoj/32/138_2.png) [@parejkoj](https://www.rubin.community/u/parejkoj)\
**Post date:** [October 9, 2019, 11:35pm UTC](https://www.rubin.community/t/zero-point-in-the-output-of-singleframedriver-py/3876/8 "2019-10-09T23:35:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Charles](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@Charles](https://www.rubin.community/u/Charles)\
**Post date:** [November 20, 2019, 10:29am UTC](https://www.rubin.community/t/zero-point-in-the-output-of-singleframedriver-py/3876/9 "2019-11-20T10:29:01Z")

</div>

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)
> exp.getPhotoCalib().getInstFluxAtZeroMagnitude()
> 
> ```

or, where has a list of possible input for bulter.get? (I only found [this](https://hsc.mtk.nao.ac.jp/pipedoc_e/e_tool/index.html))

---

<div class="post-metadata">

**Author:** ![price](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/price/32/488_2.png) [@price](https://www.rubin.community/u/price)\
**Post date:** [November 21, 2019, 12:00am UTC](https://www.rubin.community/t/zero-point-in-the-output-of-singleframedriver-py/3876/10 "2019-11-21T00:00:31Z")

</div>

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