pysersic.priors
Attributes
Classes
Class used for priors for single source fitting in PySersic |
|
Class used for priors for multi source fitting in PySersic |
|
A Class used to estimate initial guesses for source properties. |
Functions
|
|
|
Change the suffix of a pysersic prior |
|
Estimate the sky background using the edge of the cutout |
|
Simple wrapper function to generate a prior using the built-in defaults. This can be used as a starting place but may not work for all sources |
Module Contents
- pysersic.priors.base_sky_types = ['none', 'flat', 'tilted-plane']
- pysersic.priors.base_sky_params
- pysersic.priors.render_tilted_plane_sky(X, Y, back, x_sl, y_sl)
- pysersic.priors.base_profile_types = ['sersic', 'doublesersic', 'sersic_exp', 'sersic_pointsource', 'pointsource', 'exp', 'dev', 'spergel']
- pysersic.priors.base_profile_params
- class pysersic.priors.BaseSkyPrior(sky_guess: float, sky_guess_err: float, suffix: str = '')
Bases:
equinox.Module- type: eqx.AbstractClassVar()
- repr_dict: dict
- suffix: str
- dist_dict: dict
- reparam_dict: dict
- abstract sample(X: jax.numpy.array, Y: jax.numpy.array)
- update_prior(name: str, mu: float, sigma: float)
Update prior for a given parameter, assumed to be Gaussian with mu and sigma
- Parameters:
name (str) – Name of parameter
mu (float) – Location for prior
sigma (float) – width of prior
- __repr__()
- class pysersic.priors.NoSkyPrior(sky_guess: float, sky_guess_err: float, suffix: str = '')
Bases:
BaseSkyPrior- type: str = 'None'
- sample(X, Y)
- class pysersic.priors.FlatSkyPrior(sky_guess: float, sky_guess_err: float, suffix: str = '')
Bases:
BaseSkyPrior- type: str = 'flat'
- sample(X, Y)
- class pysersic.priors.TiltedPlaneSkyPrior(sky_guess: float, sky_guess_err: float, suffix: str = '')
Bases:
BaseSkyPrior- type: str = 'TiltedPlane'
- sample(X, Y)
- class pysersic.priors.BasePrior(sky_type='none', sky_guess=None, sky_guess_err=None, suffix='')
Bases:
equinox.Module- sky_type: str
- repr_dict: dict
- suffix: str
- dist_dict: dict
- reparam_dict: dict
- sky_prior: equinox.Module
Base class for priors with sky sampling included
- property param_names
- sample_sky(X: jax.numpy.array, Y: jax.numpy.array) float
Sample sky parameters and return sky model
- Parameters:
X (jax.numpy.array) – 2D mesh grid of pixel x pixel indices
Y (jax.numpy.array) – 2D mesh grid of pixel y pixel indices
- Returns:
sampled and rendered sky model
- Return type:
float
- _set_dist(var_name: str, dist: BasePrior._set_dist.dist) None
Set prior for a given variable
- Parameters:
var_name (str) – variable name
dist (dist.Distribution) – Numpyro distribution object specifying prior
- _get_dist(var_name: str) numpyro.distributions.Distribution
Get prior for a given variable
- Parameters:
var_name (str) – variable name
- Returns:
Numpyro distribution clas describing prior
- Return type:
dist.Distribution
- set_gaussian_prior(var_name: str, loc: float, scale: float) PySersicSourcePrior
Set a Gaussian prior for a variable
- Parameters:
var_name (str) – variable name
loc (float) – mean
scale (float) – standard deviation
- Returns:
returns self to allow chaining
- Return type:
- set_uniform_prior(var_name: str, low: float, high: float) PySersicSourcePrior
Set a uniform prior for a variable
- Parameters:
var_name (str) – variable name
low (float) – lower bound
high (float) – upper bound
- Returns:
returns self to allow chaining
- Return type:
- set_truncated_gaussian_prior(var_name: str, loc: float, scale: float, low: float | None = None, high: float | None = None) PySersicSourcePrior
Set a truncated Gaussian prior for a given variable
- Parameters:
var_name (str) – variable name
loc (float) – mean
scale (float) – standard deviation
low (Optional[float], optional) – lower bound, by default None
high (Optional[float], optional) – upper bound, by default None
- Returns:
Returns self to allow chaining
- Return type:
- set_custom_prior(var_name: str, prior_dist: numpyro.distributions.Distribution, reparam: numpyro.infer.reparam.Reparam | None = None) PySersicSourcePrior
Set a custom distribution as the prior for a given variable
- Parameters:
var_name (str) – variable name
prior_dist (dist.Distribution) – Numpyro Distribution object describing prior
reparam (Optional[infer.reparam.Reparam], optional) – Optional reparamaterization to use for variable, by default None
- Returns:
Returns self to allow chaining
- Return type:
- __call__() jax.numpy.array
Sample variables from prior
- Returns:
sampled variables
- Return type:
jax.numpy.array
- class pysersic.priors.PySersicSourcePrior(profile_type: str, sky_type: str | None = 'none', sky_guess: float | None = None, sky_guess_err: float | None = None, suffix: str | None = '')
Bases:
BasePriorClass used for priors for single source fitting in PySersic
- profile_type: str
- __repr__() str
- check_vars(verbose=False) bool
Function to check if all variable for the specified profile type are set with no extras
- Parameters:
verbose (bool, optional) – Wheter to print out missing and extra variables, by default False
- Returns:
True if all variable for given type are present with no extra, False otherwise
- Return type:
bool
- class pysersic.priors.PySersicMultiPrior(catalog: pandas.DataFrame | dict | numpy.recarray, sky_type: str | None = 'none', sky_guess: float | None = None, sky_guess_err: float | None = None, suffix: str | None = '')
Bases:
BasePriorClass used for priors for multi source fitting in PySersic
- catalog: dict
- N_sources: int
- suffix = ''
- __repr__() str
- pysersic.priors.update_prior_suffix(prior: BasePrior, new_suffix: str) BasePrior
Change the suffix of a pysersic prior
- class pysersic.priors.SourceProperties(image: numpy.array | jax.numpy.array, mask: numpy.array | jax.numpy.array = None)
A Class used to estimate initial guesses for source properties. If no guesses are provided, then the class will estimate them using the photutls package and the data_properties() function.
- measure_properties(**kwargs) SourceProperties
Measure default properties of the source
- Returns:
returns self
- Return type:
- set_sky_guess(sky_guess: float | None = None, sky_guess_err: float | None = None, n_pix_sample: int = 5, **kwargs) SourceProperties
Measure or set guess for initial sky background level. If no estimate is provided, the median of the n_pix_sample number of pixels around each edge is used
- Parameters:
sky_guess (Optional[float], optional) – Initial guess for level of background, by default None
sky_guess_err (Optional[float], optional) – Uncertainity on inital guess, by default None
n_pix_sample (int, optional) – Number of pixels around each edge to use to estimate sky level if neccesary, by default 5
- Returns:
returns self
- Return type:
- set_flux_guess(flux_guess: float | None = None, flux_guess_err: float | None = None, **kwargs) SourceProperties
Measure or set guess for initial flux. If no estimate is provided, the flux of the source in estimated as the total flux within the sgmentatated region for the source
- Parameters:
flux_guess (Optional[float], optional) – Initial guess for flux, by default None
flux_guess_err (Optional[float], optional) – Uncertainty on initial guess, by default None
- Returns:
returns self
- Return type:
- set_r_eff_guess(r_eff_guess: float | None = None, r_eff_guess_err: float | None = None, **kwargs) SourceProperties
Measure or set guess for effective radius. If no estimate is provided, the r_eff of the source in estimated using photutils
- Parameters:
r_eff_guess (Optional[float], optional) – Initial guess for effective radius, by default None
r_eff_guess_err (Optional[float], optional) – Uncertainty on initial guess, by default None
- Returns:
returns self
- Return type:
- set_theta_guess(theta_guess: float | None = None, **kwargs) SourceProperties
Measure or set guess for initial position angle. If no estimate is provided, the position angle of the source in estimated using the data_properties() function from photutils
- Parameters:
theta_guess (Optional[float], optional) – Estimate of the position angle in radians, by default None
- Returns:
returns self
- Return type:
- set_position_guess(position_guess: Iterable[float, float] | None = None, **kwargs) SourceProperties
Measure or set guess for initial position. If no estimate is provided, the position of the source in estimated using the data_properties() function from photutils
- Parameters:
position_guess (Optional[Iterable[float,float]], optional) – A 2 element list, tuple or array which contain the x,y pixel values of the inital guess for the centroid, by default None
- Returns:
returns self
- Return type:
- generate_prior(profile_type: str, sky_type: str | None = 'none', suffix: str | None = '') PySersicSourcePrior
Function to generate default priors based on a given image and profile type
- Parameters:
profile_type (str) – Type of profile
sky_type (str, default 'none') – Type of sky model to use, must be one of: ‘none’, ‘flat’, ‘tilted-plane’
suffix (str, default '') – Add suffix onto all source related variables, generally only used to number sources in MultiPrior
- Returns:
Pysersic prior object to be used to initialize FitSingle
- Return type:
- visualize(figsize: Tuple[float, float] = (6.0, 6.0), cmap: str = 'gray', scale: float = 1.0) None
Display a figure summarizing the current guess for the source properties
- Parameters:
figsize (Tuple[float,float], optional) – figure, by default (6.,6.)
cmap (str, optional) – color map, by default ‘gray’
scale (float, optional) – number of +/- std’s at which to clip image, by default 1
- pysersic.priors.estimate_sky(image: numpy.array, mask: numpy.array | None = None, n_pix_sample: int = 5) Tuple[float, float, int]
Estimate the sky background using the edge of the cutout
- Parameters:
im (np.array) – image, either an array or masked array
mask (Optional[np.array], optional) – mask to apply, if im is not a masked array already, by default None
n_pix_sample (int, optional) – number of pixels around the edge to use, by default 5
- Returns:
a tuple containing the median, standard deviation and number of pixels used
- Return type:
Tuple[float,float,int]
- pysersic.priors.autoprior(image: numpy.array, profile_type: str, mask: numpy.array = None, sky_type: str = 'none') PySersicSourcePrior
Simple wrapper function to generate a prior using the built-in defaults. This can be used as a starting place but may not work for all sources
- Parameters:
image (np.array) – science image
profile_type (str) – Type of profile to be fit
mask (np.array, optional) – pixel by pixel mask, by default None
sky_type (str) – Type of sky to fit, default ‘none’
- Returns:
Prior object that can be used in initializing FitSingle
- Return type: