Find detector (ccd) id for a given ra/dec and a given exposure id (visit)

Hi all,

I have an external catalog of sources, with position in ra and dec.
I would like to plot cutouts around these sources from calexps or image differences.
Note that I don’t have coadds for these visits (I have seen a solution on slack for that specific case)

Is there some kind of function in gen2 that can return the corresponding dataId for a a given ra, dec, MJD?
Or even simpler here, for ra/dec and a visit number?

Something like:
dataId = getdataId(ra, dec, time)
or
ccdId = getccdId(ra, dec, visitId)

I cooked up something based on the detector’s bbox, using the wcs to transfer to sky, but it assumes that my ccds are rectangles defined by (ra_min,ra_max,dec_min,dec_max), which is not the case, due to rotations and projections on the sky. It gives a ball park estimate but is really not ideal.

Thanks,

Ben

PS: also, out of curiousity, is there something coming up in gen3 to do that?

In the Gen2 middleware, there is no persistent mapping between ra,dec and visit. I believe this is one of the important shortcomings that is being addressed in Gen3.

The way to do this in the Gen2 world is to iterate over all the images’ WCSes. I would do that once and record the bounding boxes on the sky using some sphgeom objects.