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.
- _finish_write(writer)[source]
Finish the writing process with any class-specific steps.
The base class implementation doesn’t do anything, which is often appropriate, but this hook exists in case any Outliers classes need to write extra information to the fits file.
- Parameters:
writer – A writer object that encapsulates the serialization format.
name – A name to associate with the outliers in the serialized output.
- _finish_read(reader)[source]
Finish the reading process with any class-specific steps.
The base class implementation doesn’t do anything, which is often appropriate, but this hook exists in case any Outliers classes need to read extra information from the fits file.
- Parameters:
reader – A reader object that encapsulates the serialization format.
- 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
- class piff.ChisqOutliers(thresh=None, ndof=None, prob=None, nsigma=None, max_remove=None, include_reserve=None, logger=None)[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:
The user can specify thresh directly.
The user can specify ndof to give a multiple of the number of degrees of freedom of the model, thresh = ndof * dof.
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.
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.
Note
Reserve stars do not count toward max_remove when flagging outliers. Any reserve star that is flagged as an outlier still shows up in the output file, but has flag_psf=1. You can decide whether or not you want to include it in any diagnostic tests you perform using the reserve stars.
- 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]
logger – A logger object for logging debug info. [default: None]
- 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 with outliers flagged, and how many outliers were flagged.