legacysurvey / legacypipe

Image reduction pipeline for the DESI Legacy Imaging Surveys, using the Tractor framework
BSD 3-Clause "New" or "Revised" License
37 stars 22 forks source link

Enforce continuity of skies across amplifier boundaries #571

Open djschlegel opened 4 years ago

djschlegel commented 4 years ago

For the CP-processed mosaic z-band images, Rongpu's construction of nightly template skies pick up very little un-subtracted structure in the sky other than amp-to-amp corrections. We could consider explicitly fitting for the sky jumps across these boundaries, perhaps as the ratio of the median of pixels on either side of each boundary. For a 4-amp CCD, the problem is over-constrained because there are really only 3 values to solve for (ie, all the differences relative to one fiducial amplifier), but 4 measurements (the amp jump across 4 boundaries).

dstndstn commented 4 years ago

Could you elaborate on the strategy you're proposing here? How does this relate to Eddie's (multiplicative) amp corrections, which are applied after sky subtraction? Are you saying we should find additive offsets to each amp to minimize their differences, and average to zero? This would be a data-model change to the splinesky models?

djschlegel commented 4 years ago

Dustin- It would probably be best achieved as a data model change to the splinesky models, allowing an independent piston value for each of the amplifiers. But it's possible this could make the sky modeling worse, so we can't blindly make a change like this and assume it's an improvement. For example, the 90prime amplifiers have a significant CTE which will is different for each amplifier, which rolls off the charge after the last physical pixel in the serial register into the overscan region.

schlafly commented 4 years ago

My proposal would have been to measure the differences across the 4 amps, using just the single row/column of pixels right on the edge of each amp. Then solve for the offsets to apply to each amp.

Implementation would either be on the fly at image read-in time or via a mechanism like that used for the DECam residual sky templates, where you'd look up the values for the amps from a table.

We'd want to apply the sky correction before the gain correction. I might look at this now to see if it would actually work.

schlafly commented 4 years ago

Trying this... I don't think it works terribly well. I think it probably works fine in the perpendicular-to-readout direction but the parallel-to-readout direction has correlated features frequently enough that you don't want to just do a median along the amp in that direction. If I do the 20 columns on each side of the amp things look like they behave pretty well, but I'm sure there's a narrow spiral galaxy right on one side of an amp boundary somewhere that will mess that up.

So then one is left with approaches like Rongpu's, masking sources and median filtering over a night. We could certainly tweak the template creation algorithm there to just median over each amp and write out nightly templates as before. I don't have a sense for where these features are coming from or if we would expect them to scale with sky.