Selecting Good PSF Stars¶
It is not uncommon to want to select only a subset of the objects in an input catalog to use for PSF estimation.
Even if your input catalog is nominally all real stars, you may want to exclude stars that have nearby neighbors or are too fain.
More realistically, some of the input “stars” may not in fact be stars. There may be a few quasars or AGN, which are not precisely point-like, in the catalog.
And finally, you may only have an input catalog of all detections, including both stars and extended objects, and you want Piff to pick out the stars for you.
All of these types of selection can be effected by the select
field in the config file.
The class used for selection is specified by a type
item as usual. Options currently
include:
“Flag” selects stars according some kind of flags column in the input catalog. See
FlagSelect
.“Properties” selects stars according to any columns that are identified as “properties” to read in for each obect. See
PropertiesSelect
.“SizeMag” selects stars by looking for a stellar locus in a size-magnitude diagram. See
SizeMagSelect
.“SmallBright” selects stars that are small and bright. This isn’t typically very good on its own, but it can be a decent seed selection for the “SizeMag” selection. See
SmallBrightSelect
.
Finally, all of the selection types allow additional rejection steps after the initial selection.
These are described in Select
.
-
class
piff.
Select
(config, logger=None)[source]¶ The base class for selecting which stars to use for characterizing the PSF.
This is essentially an abstract base class intended to define the methods that should be implemented by any derived class.
-
classmethod
process
(config_select, objects, logger=None, select_only=False)[source]¶ Parse the select field of the config dict.
This stage handles three somewhat separate actions:
Select which objects in the input catalog are likely to be stars.
Reject stars according to a number of possible criteria.
Reserve some fraction of the remaining stars to not use for PSF fitting.
The first step is handled by the derived classes. There are a number of possible algorithms for doing that. The default select type (Flag) selects objects that are not flagged, or if no flag property is specified, then uses all input objects.
The second and third steps are common to all types and are handled by the base class.
The following parameters are relevant to steps 2 and 3 and are allowed for all select types:
- min_snr
The minimum S/N ratio to use. If an input star is too faint, it is removed from the input list of PSF stars.
- max_snr
The maximum S/N ratio to allow for any given star. If an input star is too bright, it can have too large an influence on the interpolation, so this parameter limits the effective S/N of any single star. Basically, it adds noise to bright stars to lower their S/N down to this value. [default: 100]
- max_edge_frac
Cutoff on the fraction of the flux comming from pixels on the edges of the postage stamp. [default: None]
- stamp_center_size
Distance from center of postage stamp (in pixels) to consider as defining the edge of the stamp for the purpose of the max_edge_fact cut. The default value of 13 is most of the radius of a 32x32 stamp size. If you change stamp_size, you should consider what makes sense here. [default 13].
- max_mask_pixels
If given, reject stars with more than this many masked pixels (i.e. those with w=0). [default: None]
- hsm_size_reject
Whether to reject stars with a very different hsm-measured size than the other stars in the input catalog. (Used to reject objects with neighbors or other junk in the postage stamp.) [default: False] If this is a float value, it gives the number of inter-quartile-ranges to use for rejection relative to the median. hsm_size_reject=True is equivalent to hsm_size_reject=10.
- max_pixel_cut
Reject stars with a maximum pixel value greater than this value. Note: this cut is actually made using a flux cut such that the average star with the threshold flux would have this peak pixel value. This is in order to avoid a selection bias where smaller stars get preferentially excluded, since smaller stars, at a given flux, have a higher maximum pixel value. [default: None]
- reject_where
Reject stars based on an arbitrary eval string using variables that are properties of each star (usually input using property_cols). It should evaluate to a bool for a single star or an array of bool if the variables are arrays of property values for all the stars. [default: None]
- reserve_frac
Reserve a fraction of the stars from the PSF calculations, so they can serve as fair points for diagnostic testing. These stars will not be used to constrain the PSF model, but the output files will contain the reserve stars, flagged as such. Generally 0.2 is a good choice if you are going to use this. [default: 0.]
- seed
A seed to use for numpy.random.default_rng, if desired. [default: None]
Note
The max_snr parameter is not actually a “selection” parameter. It doesn’t change what stars are used. Rather, it adjusts the relative weight that is given to the brightest stars (so that they don’t dominate the fit).
- Parameters
config_select – The configuration dict.
objects – A list of Star instances, which are at this point all potential objects to consider as possible stars.
logger – A logger object for logging debug info. [default: None]
select_only – Whether to stop after the primary selection step. [default: False]
- Returns
stars, the subset of objects which are to be considered stars
-
rejectStars
(stars, logger=None)[source]¶ Reject some nominal stars that may not be good exemplars of the PSF.
- Parameters
stars – A list of Star instances.
logger – A logger object for logging debug info. [default: None]
- Returns
The subset of the input list that passed the rejection cuts.
-
reserveStars
(stars, logger=None)[source]¶ Mark some of the stars as reserve stars.
This operates on the star list in place, adding the property
is_reserve
to each star (only if some stars are being reserved).- Parameters
stars – A list of Star instances.
logger – A logger object for logging debug info. [default: None]
-
classmethod
-
class
piff.
FlagSelect
(config, logger=None)[source]¶ An Select handler that picks stars according to a flag column in the input catalog.
The Flag type uses the following parameters, all optional.
- flag_name
The name of the flag property (typically the column name in the input file) to use for selecting stars. [default: None]
- use_flag
The flag indicating which items to use. [default: None] Items with flag & use_flag != 0 will be used.
- skip_flag
The flag indicating which items not to use. [default: -1] Items with flag & skip_flag != 0 will be skipped.
The default behavior if flag_name is not given is to consier all input objects as stars. If flag_name is given, but the others are not, then it selects all objects with flag=0. Otherwise, it will select according to the prescriptions given above.
- Parameters
config – The configuration dict used to define the above parameters. (Normally the ‘select’ field in the overall configuration dict).
logger – A logger object for logging debug info. [default: None]
-
class
piff.
PropertiesSelect
(config, logger=None)[source]¶ A Select handler that picks stars according to any property or combination of properties in the input catalog.
Parse the config dict (Normally the ‘where’ field in the overall configuration dict).
The Properties type uses the following parameter, which is required.
- where
A string to be evaluated, which is allowed to use any properties of the stars as variables. It should evaluate to a bool for a single object or an array of bool if the variables are arrays of property values for all the objects.
- Parameters
config – The configuration dict used to define the above parameters.
logger – A logger object for logging debug info. [default: None]
-
class
piff.
SizeMagSelect
(config, logger=None)[source]¶ A Select handler that picks stars by finding where the stellar locus in the size-magnitude diagram starts to blend into the galaxy locus.
By default, the initial selection uses the SmallBright selector, but you can provide any other selection algorithm for the initial stars.
The following parameters are tunable in the config field, but they all have reasonable default values:
- fit_order
The order of the polynomial fit of log(size) vs (u,v) across the field of view. This is used to subtract off the gross size variation across the focal plane, which tends to tighten up the stellar locus. [default: 2]
- impurity
The maximum ratio of objects at the minimum between the stellar locus and the galaxy locus to the number of stars found. This shouldn’t be taken to be a quantitative estimate of the actual impurity in the sample, but larger values of impurity will correspond to larger samples with more impurities. Smaller impurity will likely result in a purer selection of stars, but also one with fewer total stars. [default: 0.01]
- num_iter
How many iterations to repeat the processing of building a histogram looking for when it merges with the galaxy locus. [default: 3]
In addition to these, you may specify the algorithm for making the initial selection in an
inital_select
dict, which should specify the selection algorithm to use. The default is to use the SmallBright selection algorithm with default parameters. But you could specify non-default parameters for that as follows (e.g.):select: type: SizeMag initial_select: type: SmallBright bright_fraction: 0.3 small_fraction: 0.4 locus_fraction: 0.3 fit_order: 3
Or, you may want to start with stars according to some other selection algorith. E.g. to use some column(s) from the input catalog:
select: type: SizeMag initial_select: type: Properties where: (CLASS_STAR > 0.9) & (MAX_AUTO < 16)
- Parameters
config – The configuration dict used to define the above parameters. (Normally the ‘select’ field in the overall configuration dict)
logger – A logger object for logging debug info. [default: None]
-
class
piff.
SmallBrightSelect
(config, logger=None)[source]¶ A Select handler that picks stars by looking for a locus of small, bright objects that are all about the same size.
This is a very crude selection. It is typically used to provide an initial selection to the SizeMag selector.
The following parameters are tunable in the config field, but they all have reasonable default values:
- bright_fraction
The fraction of the detected objects to consider “bright” and thus available for consideration for star selection. [default: 0.2]
- small_fraction
The fraction of the bright objects to consider “small”. [default: 0.2]
- locus_fraction
The fraction of the initial small, bright objects to look for having all nearly the same size. These constitude the first extremely crude selection of high-confidence stars. [default: 0.5]
- max_spread
The maximum spread in log(T) to allow for the final set of stars. From the initial high-confidence stars, we expand the range in size to try to capture the full stellar locus based on the inter-quartile range of the candidate stars. This parameter sets a maximum range to allow for this locus to make sure it doesn’t erroneously expand to include everything. [default: 0.1]
- Parameters
config – The configuration dict used to define the above parameters. (Normally the ‘select’ field in the overall configuration dict).
logger – A logger object for logging debug info. [default: None]