Removing Outliers

Piff can remove stars that it deems to be outliers from the set of stars used to build the PSF model. This option is specified via an outliers section of the psf field in the configuration file.

class piff.Outliers[source]

The base class for handling outliers.

This is essentially an abstract base class intended to define the methods that should be implemented by any derived class.

classmethod parseKwargs(config_outliers, logger=None)[source]

Parse the outliers field of a configuration dict and return the kwargs to use for initializing an instance of the class.

The base class implementation just returns the kwargs as they are, but derived classes might want to override this if they need to do something more sophisticated with them.

Parameters
  • config_outliers – The outliers field of the configuration dict, config[‘outliers’]

  • logger – A logger object for logging debug info. [default: None]

Returns

a kwargs dict to pass to the initializer

classmethod process(config_outliers, logger=None)[source]

Parse the outliers field of the config dict.

Parameters
  • config_outliers – The configuration dict for the outliers field.

  • logger – A logger object for logging debug info. [default: None]

Returns

an Outliers instance

classmethod read(fits, extname)[source]

Read a Outliers from a FITS file.

Parameters
  • fits – An open fitsio.FITS object

  • extname – The name of the extension with the outliers information.

Returns

an Outliers handler

write(fits, extname)[source]

Write an Outliers to a FITS file.

Parameters
  • fits – An open fitsio.FITS object

  • extname – The name of the extension to write the outliers information.

class piff.ChisqOutliers(thresh=None, ndof=None, prob=None, nsigma=None, max_remove=None, include_reserve=False)[source]

An Outliers handler using the chisq of the residual of the interpolated star with the original.

The user can specify the threshold in one of four ways:

  1. The user can specify thresh directly.

  2. The user can specify ndof to give a multiple of the number of degrees of freedom of the model, thresh = ndof * dof.

  3. The user can specify prob to reject according to the probability that the chisq distribution for the model’s number of degrees of freedom would exceed chisq.

  4. The user can specify nsigma, in which case thresh is calculated according to the chisq distribution to give the equivalent rejection probability that corresponds to that many sigma.

Exactly one of thresh, ndof, nsigma, prob must be provided.

There is an option to include reserve stars in the outlier rejection, which is enabled by setting include_reserve=True. This is probably not a good idea normally. Reserve stars are often preferentially targeted by the outlier removal, which somewhat lessens their case as fair test points for diagnostics. However, it is still an option in case you want to use it.

Parameters
  • thresh – The threshold in chisq above which an object is declared an outlier.

  • ndof – The threshold as a multiple of the model’s dof.

  • prob – The probability limit that a chisq distribution with the model’s dof would exceed the given value.

  • nsigma – The number of sigma equivalent for the probability that a chisq distribution would exceed the given value.

  • max_remove – The maximum number of outliers to remove on each iteration. If this is a float < 1.0, then this is interpreted as a maximum fraction of stars to remove. e.g. 0.01 will remove at most 1% of the stars. [default: None]

  • include_reserve – Whether to include reserve stars as potential stars to be removed as outliers. [default: False]

removeOutliers(stars, logger=None)[source]

Remove outliers from a list of stars based on their chisq values.

Parameters
  • stars – A list of Star instances

  • logger – A logger object for logging debug info. [default: None]

Returns

stars, nremoved A new list of stars without outliers, and how many outliers were removed.