PSFModelStep

This should be considered pre-alpha, we have not got it working well yet!

This step finds saturated sources in each individual tile and attempts to either ‘paint in’ the saturation via PSF fitting or subtracting off the PSF to remove the wings that can extend over large portions of the image. Unfortunately, the PSF models are not at the level required for good subtraction currently, and we have no way of dealing with the brighter-fatter effect, so this step produces weird looking results.

API

class pjpipe.PSFModelStep(in_dir, out_dir, step_ext, procs, method='replace', npixels=9, separation=0.1, psf_fov_pixels=511, psf_thresh=1e-05, dilate_size=7, nsigma=5, overwrite=False)[source]

Step to model the PSF in saturated sources

In the centres of galaxies, saturation and PSF wings can blow out the image in an unpleasant way. This step attempts to alleviate that by finding saturated sources and either subtracting the PSF, or painting in the saturated regions

N.B. This is still highly preliminary, and should be seen as alpha. It hasn’t been thoroughly tested across the whole sample yet, so weird errors may arise. You have been warned!

Parameters:
  • in_dir – Input directory

  • out_dir – Output directory

  • step_ext – .fits extension for the files going into the step

  • procs – Number of processes to run in parallel. Currently, does nothing

  • method – Whether to “replace” saturated cores, or “subtract” the PSF. Defaults to replace

  • npixels – Minimum number of pixels to define a saturated source. Defaults to 9

  • separation – When creating catalogues for the saturated sources, this is the minimum distance (in arcsec) to identify a distinct source. Defaults to 0.1

  • psf_fov_pixels – Size of the simulated PSF. Should be odd so it has a centre. Defaults to 511

  • psf_thresh – Minimum threshold to define where we consider the PSF to be significant (and thus used in the fit). Defaults to 1e-5, i.e. 0.001% of the PSF peak

  • dilate_size – Dilate size for creating source mask before fitting, since we don’t want to fit in very bright areas. Defaults to 7

  • nsigma – Sigma-clipping limit for creating source mask, since we don’t want to fit in very bright areas. Defaults to 5

  • overwrite – Whether to overwrite or not. Defaults to False

do_step()[source]

Run PSF modelling

get_initial_amp(data, psf, x_cen, y_cen, psf_x_cen, psf_y_cen)[source]

Get initial amplitude guess for PSF

This calculates an average ratio between the image and the PSF at the initial guess of the PSF centre. Our bounds for the amplitude are quite broad, so as long as this is order-of-magnitude right, we should be OK

Parameters:
  • data – Input data

  • psf – Input PSF

  • x_cen – Guess for x centre of saturated source

  • y_cen – Guess for y centre of saturated source

  • psf_x_cen – x centre of the PSF

  • psf_y_cen – y centre of the PSF

get_psf(file)[source]

Get PSF for given observation

Parameters:

file – Input file to get PSF for

get_sat_coords(files)[source]

Get RA/Dec for the centres of saturated sources in each image

Will look for saturated pixels in each image, and then merge these given a separation to a minimum catalogue

Parameters:

files – List of input files to loop over

make_diagnostic_plot(data, psf_model, plot_name, mask=None)[source]

Create a diagnostic plot to show the fit

If subtracting, will create data/fit PSF/subtracted data, otherwise will show data/fit PSF

Parameters:
  • data – Input data

  • psf_model – Final PSF model

  • plot_name – Name to save plot to

  • mask – If not None, will NaN out pixels. Can make the visualisation clearer. Defaults to None

run_step(files, sat_coords)[source]

Run the step, fitting PSFs to catalogue positions of saturated coordinates

Parameters:
  • files – List of files to fit PSF for

  • sat_coords – List of coordinates corresponding to saturated positions