Creating coadd with calexps with injected sources (fakes_calexp dataset)

Hello, I’m trying to make a coadd using calexp images with injected sources (following Inject Synthetic Sources — LSST Science Pipelines). The new images are now in the butler as a dataset called fakes_calexp. For the coaddition I’m following the tutorial 9a giving the right address for new butler, the visits id with the injected source and adding these two lines:

assembleCoaddPipeline.addConfigOverride('makeWarp', 'hasFakes', True)
assembleCoaddPipeline.addConfigOverride('assembleCoadd', 'hasFakes', True)

But it seems that it isn’t reading the fakes_calexp but the calexp dataset. After runing
quanta = spe.run()

I get lines like:

lsst.makeWarp.select INFO: Selecting calexp {instrument: 'LSSTCam-imSim', detector: 4, visit: 896749, ...}
...
...

I got no erros but a new coadd without the injected source. Do you know what I’m missing?

You need to set the calExpList input of the makeWarp task to fakes_calexp.

I’m not sure what that looks like in Python, perhaps this:

assembleCoaddPipeline.addConfigOverride(‘makeWarp’, ‘connections.calExpList’, ‘fakes_calexp’)

The input dataset name should be templated using calexpType, and supposedly this is intended to be set automatically if hasFakes is set to true. But note that calexpType is set to fakes_calexp which would produce a dataset name of fakes_calexpcalexp if that line did anything. So maybe this doesn’t work as intended anyway.

I’ve been setting the dataset name of the input manually.

You’re mixing two different frameworks for source injection which may cause you problems further down the line. Anything referencing ‘fakes’ is the older-style framework (soon to be phased out). The newer source_injection repository is what we’ll be supporting longer-term.

It looks like you’re using the newer SI framework for your synthetic source injection, but using the older hasFakes methodology for everything that comes after.

I think a safer approach would be to use all of the tooling in the source_injection package wherever possible. For your purposes, this would involve generating your own injection pipeline (see documentation here). Then, in your tutorial notebook, you would replace my_uri from Pipeline.from_uri(my_uri) with the path to your own constructed pipeline YAML. If you prefer, you can keep everything within Python, without having to resort to writing a YAML pipeline definition file at all.

If you need more advice beyond the documentation above, please do get back to us.

1 Like

Hi Karla – As detailed in the README for tutorials 09a and 09b, some intermediate data products have changed since the DP0.2 data were processed, and thus the tutorials’ methods to create custom coadds will only work with an old version of the pipelines. (As Lee pointed out, your workflow is mixing old and current tasks.)

Unfortunately in this case, I think the options to accomplish your goals with the current “recommended” weekly pipelines version are either (1) inject sources directly into the coadds (not sure if that works for your science case), or (2) run processing end-to-end, starting from raw images (and including source injection).

Please reach out if you need further help figuring out how to proceed!

One further note – I am working on a tutorial notebook for source_injection that may be available soon (though of course it seems like you’ve already gotten started following lsst.source.injection — LSST Science Pipelines). If you wanted to try processing data starting from raw images, you could start with the “Getting Started” guide at The LSST Science Pipelines — LSST Science Pipelines.

1 Like

Thank you all for your answers, and guidence. The coaddition worked with @stevenstetzler suggestion, just changing inputs with connections, as:

assembleCoaddPipeline.addConfigOverride(‘makeWarp’, ‘connections.calExpList’, ‘fakes_calexp’)

and actually it doesn’t need these two lines:

assembleCoaddPipeline.addConfigOverride(‘makeWarp’, ‘hasFakes’, True)
assembleCoaddPipeline.addConfigOverride(‘assembleCoadd’, ‘hasFakes’, True)

We have also check that it works with the original name of the injected collection from “Inject Synthetic Sources — LSST Science Pipelines ” , i.e. injected_calexp (Note that before we forced the name of the collection to be fakes_calexp because we thougt it was needed).

We are aware that we are mixing old and new methods, but for the tests we want to do it seems to be ok for the short term. We will try, however, to adapt to the processing suggested by @jeffcarlin.

Thanks,
Karla

2 Likes

HI all, adding on Karla’s response (we are working together on this).
@jeffcarlin your tutorial will be very helpful :smiley:
We did a combination of using a notebook and command line to make the injection, so it will be nice to learn how to do it all from the notebook, and for several visits. Also, in case you make the example injecting a postage stamp, it would be very useful to include how to make the injection of the same image considers a specific alignment for the different visits. From what I read I kind of understood it can be done if the file with the postage stamp have a header with the WCS, but I haven’t had the time to figure it out how to actually implement it.

Finally, just for context, we are injecting Strong Lensing images and one of our goals is to see the difference between injecting at the coadd level Vs injecting at single visit and then make the coadd, we also wanted to have the flexibility to select the visits that enters into the coadd to assess the impact of the image quality.

Thanks again

Glad to hear that you got it to work, Karla! I marked @stevenstetzler’s response as the “solution.” Please reach out if you encounter further issues!

I’ve edited my original response with Karla’s fix so the marked “solution” reflects what worked.

2 Likes