Areas which are contaminated by ghosts are masked in the 'camera' analysis stage. This is the natural location since this is the first time that the astrometric model is measured for a given exposures. We generate a number of 'dynamic mask' elements in psastro (psastroMaskUpdates) based on the locations of bright stars. For the ghosts, we use a model for the location of ghosts based on the FPA coordinates of bright stars. The model is a bit crude: the ghosts are modeled as an annular ellipse. The model uses an Nth order polynomial to predict the positions and the inner and outer ellipse sizes and orientations. At the moment, the model uses a single cut for the instrumental magnitude: if the source star is brighter than the cut-off, the region is masked; if not, then the region is not masked. Future improvements would allow for:

* two levels of cut-off, equivalent to 'bad' vs 'poor'. For some range, the ghost mask would imply that nothing in the masked region could be trusted. For a fainter range, the mask would imply that the user should be cautious about sources in the region, but they might be acceptable. The former would be masked by pswarp, while the latter would be treated as effectively unmasked.

* limits based on the surface brightness of the ghost

* limits based on the relationship between the ghost surface brightness and the local background.

I've generated a ghost model for PS1+GPC1 for a selection of Run 2 data. At this point, it is unclear for what range of data / parameters a single model can be used. It may be that different filters require different models. It may be that the model needs to be modified on a regular basis. I am ignoring these uncertainties for the moment as I only have a limited number of ghost measurements.

The model was based on a collection of images from the series o4772g0???o. I used psastroExtract to pull out the subrasters for bright stars at the expected locations of the ghosts. For each stamp, I used a mana script to measure the center and major/minor axes of the inner and outer ellipses which define the elliptical annulus. I then fitted the measured parameters to 1D (for the shape) and 2D (for the location) polynomials as functions of the source FPA position.

I added a function to psastro load the ghost model descriptions, and to mask the pixels corresponding to ghosts for stars brighter than an instrumental magnitude limit. Below are plots of the fitted functions and an example of the mask in action. The model is not perfect yet, and certainly needs to be better measured before we begin serious operations. A 3rd order polynomial leaves a scatter in the center of the ghost of about 50 pixels (somewhat less in X compared with Y). The sizes are also not extremely well constrained.

Perhaps we can get some assistance from the science consortium to measure ghost locations and to improve the ghost model.