# Background subtracted from co-adds

**URL:** <https://www.rubin.community/t/background-subtracted-from-co-adds/6330>\
**Category:** Support\
**Tags:** dp0\
**Created:** [February 16, 2022, 4:01pm UTC](https://www.rubin.community/t/background-subtracted-from-co-adds/6330 "2022-02-16T16:01:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![nandinihazra](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/nandinihazra/32/1875_2.png) [@nandinihazra](https://www.rubin.community/u/nandinihazra)\
**Post date:** [February 16, 2022, 4:01pm UTC](https://www.rubin.community/t/background-subtracted-from-co-adds/6330/1 "2022-02-16T16:01:19Z")

</div>

Dear all,  
There is a problem I have been running into with the background estimation for co-added images. It is quite simple to find out the subtracted background for calexp images, but I am not able to do the same for the co-added ones.  
If anyone has any pointers on how to do it I’ll be really grateful.

Thank you for your time  
Nandini

---

<div class="post-metadata">

**Author:** ![MelissaGraham](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/melissagraham/32/2549_2.png) [@MelissaGraham](https://www.rubin.community/u/MelissaGraham)\
**Post date:** [February 16, 2022, 5:00pm UTC](https://www.rubin.community/t/background-subtracted-from-co-adds/6330/2 "2022-02-16T17:00:57Z")

</div>

Hi Nandini, thanks for posting this question. Could you share an example of the code you tried and the error message that was returned when it failed?

---

<div class="post-metadata">

**Author:** ![nandinihazra](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/nandinihazra/32/1875_2.png) [@nandinihazra](https://www.rubin.community/u/nandinihazra)\
**Post date:** [February 16, 2022, 8:07pm UTC](https://www.rubin.community/t/background-subtracted-from-co-adds/6330/3 "2022-02-16T20:07:31Z")

</div>

Hello Melissa, thank you for your response. I am looking for some sort of documentation of the co-add images to retrieve the background estimation. So there is a tutorial for how to obtain the background for a calexp frame, as given in Notebook 5 on the RSP:  
bkgd = butler.get(‘calexpBackground’, \*\*dataId) [for example]  
I am not sure what is the analogous command to get the background subtracted for the co-added images  
(My apologies if I am doing something silly)

---

<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:** [February 16, 2022, 11:02pm UTC](https://www.rubin.community/t/background-subtracted-from-co-adds/6330/4 "2022-02-16T23:02:20Z")

</div>

Try the `deepCoadd_calexp_background` dataset type.

---

<div class="post-metadata">

**Author:** ![MelissaGraham](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/melissagraham/32/2549_2.png) [@MelissaGraham](https://www.rubin.community/u/MelissaGraham)\
**Post date:** [February 22, 2022, 2:36am UTC](https://www.rubin.community/t/background-subtracted-from-co-adds/6330/5 "2022-02-22T02:36:09Z")

</div>

Thanks @price .

Since I didn’t know much about working with the subtracted backgrounds, I’ve drafted a notebook to explore them. It’s here in my branch of the `delegate-contributions-dp01` repo: [https://github.com/rubin-dp0/delegate-contributions-dp01/tree/u/melissagraham/backgrounds](https://github.com/rubin-dp0/delegate-contributions-dp01/tree/u/melissagraham/backgrounds)

I have a couple of questions about the `deepCoadd_calexp_background` – is there a place in the LSST Science Pipelines where I can learn more about it? I searched [pipelines.lsst.io](http://pipelines.lsst.io), but could not find descriptions.

In the notebook, I retrieve the background for a random `coadd` – it is uniform and very small values. Maybe this makes sense, since the backgrounds would be subtracted before coaddition, but then… was this tiny amount subtracted off the `coadd` after it was created? Is there something better to use that represents the backgrounds of the individual images, or should the user obtain the backgrounds for the individual `calexps` that went into the `coadd`? Suggestions of what else to include for users in this draft notebook would be very welcome.

---

<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:** [February 22, 2022, 4:20pm UTC](https://www.rubin.community/t/background-subtracted-from-co-adds/6330/6 "2022-02-22T16:20:49Z")

</div>

Backgrounds are subtracted off the individual images before coaddition, so there isn’t much background to subtract from the coadd.

---

<div class="post-metadata">

**Author:** ![nandinihazra](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/nandinihazra/32/1875_2.png) [@nandinihazra](https://www.rubin.community/u/nandinihazra)\
**Post date:** [February 22, 2022, 4:51pm UTC](https://www.rubin.community/t/background-subtracted-from-co-adds/6330/7 "2022-02-22T16:51:45Z")

</div>

Thank you for your reply @price  
Are the values in the deepCoadd\_calexp\_background images weighted for the individual calexp images that have been stacked to create the Coadd frames?  
And is there a place where it is possible to read more about the background dataset for such kind of information in general?

---

<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:** [February 22, 2022, 5:08pm UTC](https://www.rubin.community/t/background-subtracted-from-co-adds/6330/8 "2022-02-22T17:08:01Z")

</div>

The coadd background is just measured from the coadd. There’s no direct weighting; maybe the variance plane is used, I don’t remember.

I don’t think there’s much LSST documentation on background estimation. I know there are Community posts about sky frames. There should be some information in the HSC SSP release and pipeline papers.

---

<div class="post-metadata">

**Author:** ![MelissaGraham](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/melissagraham/32/2549_2.png) [@MelissaGraham](https://www.rubin.community/u/MelissaGraham)\
**Post date:** [February 22, 2022, 7:08pm UTC](https://www.rubin.community/t/background-subtracted-from-co-adds/6330/9 "2022-02-22T19:08:20Z")

</div>

Thanks @price and @nandinihazra.

To the intro-to-backgrounds draft notebook I added links to [Bosch et al. (2019)](https://ui.adsabs.harvard.edu/abs/2019ASPC..523..521B/abstract) and to the [Data Management Science Pipelines Design document](https://docushare.lsst.org/docushare/dsweb/Get/LDM-151) which I think are currently the best two places to read more about background subtraction. @nandinihazra I think you might find answers to your questions in the latter.

I also added a bit more introductory information about the process, based on some of the comments above. We’ll get my branch of the delegate-contributions-dp01 repo merged to main soon.

---

<div class="post-metadata">

**Author:** ![MelissaGraham](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/melissagraham/32/2549_2.png) [@MelissaGraham](https://www.rubin.community/u/MelissaGraham)\
**Post date:** [February 24, 2022, 6:32pm UTC](https://www.rubin.community/t/background-subtracted-from-co-adds/6330/10 "2022-02-24T18:32:40Z")

</div>

Thanks again @nandinihazra for bringing this up, and for reviewing the notebook for me.

Any readers who are looking for this notebook, see:

> [@New contributed notebook on subtracted backgrounds](http://www.rubin.community/t/new-contributed-notebook-on-subtracted-backgrounds/6346):
>
> In the shared delegate-contributions-dp01 repository there is a new directory, backgrounds/, with a new notebook that explains the basics of how to retrieve and display the backgrounds which were subtracted from calexps and deepCoadds. [View the notebook intro-to-backgrounds.ipynb](https://github.com/rubin-dp0/delegate-contributions-dp01/blob/main/backgrounds/intro-to-backgrounds.ipynb). The notebook also contains a few links to more information about background estimation and subtraction in the LSST Science Pipelines. It is a fairly basic demonstration, and DP0 Delegates might be interested to devel…
