# How do I make a patchRef?

**URL:** <https://www.rubin.community/t/how-do-i-make-a-patchref/7003>\
**Category:** Support\
**Tags:** butler, dp0\
**Created:** [August 18, 2022, 1:25am UTC](https://www.rubin.community/t/how-do-i-make-a-patchref/7003 "2022-08-18T01:25:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwv](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mwv](https://www.rubin.community/u/mwv)\
**Post date:** [August 18, 2022, 1:25am UTC](https://www.rubin.community/t/how-do-i-make-a-patchref/7003/1 "2022-08-18T01:25:09Z")

</div>

makeWarpTask.runDataRef wants a patchRef. I have the tract, patch, band information. But how do I make the required `patchRef` object?

```auto
dataId = {'tract': 4431, 'patch': 17, 'band': 'i'}

```

I’m running under `w_2022_32` using the DP0.2 dataset on the RSP.

---

<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:** [August 18, 2022, 5:39pm UTC](https://www.rubin.community/t/how-do-i-make-a-patchref/7003/2 "2022-08-18T17:39:01Z")

</div>

Hi @mwv, could I see more the executable statement you used, and the error message? In running a pipeline task my first thought is perhaps the skymap wasn’t passed along with tract, patch, and band.

---

<div class="post-metadata">

**Author:** ![timj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/timj/32/10_2.png) [@timj](https://www.rubin.community/u/timj)\
**Post date:** [August 18, 2022, 6:31pm UTC](https://www.rubin.community/t/how-do-i-make-a-patchref/7003/3 "2022-08-18T18:31:47Z")

</div>

> [@mwv](#):
>
> makeWarpTask.runDataRef wants a patchRef.

Gen2 support was completely removed in w.2022.31 so your code will not run at all in weekly 32…

---

<div class="post-metadata">

**Author:** ![timj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/timj/32/10_2.png) [@timj](https://www.rubin.community/u/timj)\
**Post date:** [August 18, 2022, 7:23pm UTC](https://www.rubin.community/t/how-do-i-make-a-patchref/7003/4 "2022-08-18T19:23:39Z")

</div>

> [@mwv](#):
>
> DP0.2 dataset on the RSP.

Just noticed this part of your message. `runDataRef` is a Gen2 API, hence my comment above, but of course if you are using DP0.2 on RSP that is a Gen3 butler. The gen3 equivalent of `runDataRef` is `runQuantum` but setting up the parameters to call `runQuantum` is non-trivial (you need to populate a dict with all the `DatasetRef` information). You can therefore either get the datasets you want separately from butler and call `.run()`or else go a bit higher level and call `lsst.ctrl.mpexec.SimplePipelineExecutor`, which is a simple frontend to `pipetask` command line.

---

<div class="post-metadata">

**Author:** ![mwv](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mwv](https://www.rubin.community/u/mwv)\
**Post date:** [August 18, 2022, 11:19pm UTC](https://www.rubin.community/t/how-do-i-make-a-patchref/7003/5 "2022-08-18T23:19:50Z")

</div>

Thanks, both.

Yeah, I was really struggling to figure out how to structure the call to `runQuantum`.

---

<div class="post-metadata">

**Author:** ![mwv](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mwv](https://www.rubin.community/u/mwv)\
**Post date:** [August 18, 2022, 11:21pm UTC](https://www.rubin.community/t/how-do-i-make-a-patchref/7003/6 "2022-08-18T23:21:21Z")

</div>

I’ve posted a Notebook example in [How do I coadd specifically selected calexps in a Jupyter notebook](http://www.rubin.community/t/how-do-i-coadd-specifically-selected-calexps-in-a-jupyter-notebook/7015)

along with the larger thing I’m trying to do: make coadds for templates.

---

<div class="post-metadata">

**Author:** ![mwv](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mwv](https://www.rubin.community/u/mwv)\
**Post date:** [August 18, 2022, 11:35pm UTC](https://www.rubin.community/t/how-do-i-make-a-patchref/7003/7 "2022-08-18T23:35:52Z")

</div>

FWIW, I think

```auto
patch_ref = butler.registry.findDataset(datasetType="skyMap", dataId=dataId)

```

is one incorrect answer to my question. It generates a datasetRef to the patch.

But as @timj points out, that doesn’t generate the actual `patchRef` object that the Gen2 `runDataRef` call was expecting.

---

<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:** [August 19, 2022, 12:13am UTC](https://www.rubin.community/t/how-do-i-make-a-patchref/7003/8 "2022-08-19T00:13:02Z")

</div>

I responded in the new thread you started, and I think the draft notebook I sent you via direct message, which demos use of the SimplePipelineExecutor but is not yet ready as a production-level tutorial, will be what you need here.

So I’ll mark this topic as resolved, and we’ll continue in the new thread.

---

<div class="post-metadata">

**Author:** ![timj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/timj/32/10_2.png) [@timj](https://www.rubin.community/u/timj)\
**Post date:** [August 20, 2022, 9:38pm UTC](https://www.rubin.community/t/how-do-i-make-a-patchref/7003/9 "2022-08-20T21:38:42Z")

</div>

> [@mwv](#):
>
> `patchRef` object that the Gen2 `runDataRef` call

Yes. `patchRef` is a gen2 butler reference to a dataset, equivalent, but not the same as, a gen3 `DeferredDatasetHandle`.
