SourceXtractorPlusPlus  0.16
Please provide a description of the project.
Classes | Functions | Variables
sourcextractor.config.model_fitting Namespace Reference

Classes

class  RangeType
 
class  Range
 
class  Unbounded
 
class  ParameterBase
 
class  ConstantParameter
 
class  FreeParameter
 
class  DependentParameter
 
class  FluxParameterType
 
class  Prior
 
class  ModelBase
 
class  CoordinateModelBase
 
class  PointSourceModel
 
class  ConstantModel
 
class  SersicModelBase
 
class  SersicModel
 
class  ExponentialModel
 
class  DeVaucouleursModel
 
class  ComputeGraphModel
 
class  WorldCoordinate
 

Functions

def print_parameters (file=sys.stderr)
 
def get_pos_parameters ()
 
def get_flux_parameter (type=FluxParameterType.ISO, scale=1)
 
def add_prior (param, value, sigma)
 
def _set_model_to_frames (group, model)
 
def add_model (group, model)
 
def print_model_fitting_info (group, show_params=False, prefix='', file=sys.stderr)
 
def set_max_iterations (iterations)
 
def set_modified_chi_squared_scale (scale)
 
def set_engine (engine)
 
def use_iterative_fitting (use_iterative_fitting)
 
def set_meta_iterations (meta_iterations)
 
def set_deblend_factor (deblend_factor)
 
def set_meta_iteration_stop (meta_iteration_stop)
 
def pixel_to_world_coordinate (x, y)
 
def get_sky_coord (x, y)
 
def radius_to_wc_angle (x, y, rad)
 
def get_separation_angle (x1, y1, x2, y2)
 
def get_position_angle (x1, y1, x2, y2)
 
def get_world_position_parameters (x, y)
 
def get_world_parameters (x, y, radius, angle, ratio)
 

Variables

dictionary constant_parameter_dict = {}
 
dictionary free_parameter_dict = {}
 
dictionary dependent_parameter_dict = {}
 
dictionary prior_dict = {}
 
dictionary frame_models_dict = {}
 
dictionary constant_model_dict = {}
 
dictionary point_source_model_dict = {}
 
dictionary sersic_model_dict = {}
 
dictionary exponential_model_dict = {}
 
dictionary de_vaucouleurs_model_dict = {}
 
dictionary onnx_model_dict = {}
 
dictionary params_dict
 

Function Documentation

◆ _set_model_to_frames()

def sourcextractor.config.model_fitting._set_model_to_frames (   group,
  model 
)
private

Definition at line 472 of file model_fitting.py.

Referenced by sourcextractor.config.model_fitting.add_model().

◆ add_model()

def sourcextractor.config.model_fitting.add_model (   group,
  model 
)
Add a model to be fitted to the given group.

Parameters
----------
group : MeasurementGroup
model : ModelBase

Definition at line 482 of file model_fitting.py.

References sourcextractor.config.model_fitting._set_model_to_frames().

Here is the call graph for this function:

◆ add_prior()

def sourcextractor.config.model_fitting.add_prior (   param,
  value,
  sigma 
)
Add a prior to the given parameter.

Parameters
----------
param : ParameterBase
value : float or callable that receives a source and returns a float
    Mean of the Gaussian
sigma : float or callable that receives a source and returns a float
    Standard deviation of the Gaussian

Definition at line 453 of file model_fitting.py.

◆ get_flux_parameter()

def sourcextractor.config.model_fitting.get_flux_parameter (   type = FluxParameterType.ISO,
  scale = 1 
)
Convenience function for the flux parameter.

Parameters
----------
type : int
    One of the values defined in FluxParameterType
scale : float
    Scaling of the initial flux. Defaults to 1.

Returns
-------
flux : FreeParameter
    Flux parameter, starting at the flux defined by `type`, and limited to +/- 1e3 times the initial value.

Definition at line 404 of file model_fitting.py.

◆ get_pos_parameters()

def sourcextractor.config.model_fitting.get_pos_parameters ( )
Convenience function for the position parameter X and Y.

Returns
-------
x : FreeParameter
    X coordinate, starting at the X coordinate of the centroid and linearly limited to X +/- the object radius.
y : FreeParameter
    Y coordinate, starting at the Y coordinate of the centroid and linearly limited to Y +/- the object radius.
Notes
-----
X and Y are fitted on the detection image X and Y coordinates. Internally, these are translated to measurement
images using the WCS headers.

Definition at line 374 of file model_fitting.py.

◆ get_position_angle()

def sourcextractor.config.model_fitting.get_position_angle (   x1,
  y1,
  x2,
  y2 
)
Get the position angle in sky coordinates for two points defined in pixels on the detection image.

Parameters
----------
x1
y1
x2
y2

Returns
-------
Position angle in degrees, normalized to -/+ 90

Definition at line 1058 of file model_fitting.py.

References sourcextractor.config.model_fitting.get_sky_coord().

Referenced by sourcextractor.config.model_fitting.get_world_parameters().

Here is the call graph for this function:

◆ get_separation_angle()

def sourcextractor.config.model_fitting.get_separation_angle (   x1,
  y1,
  x2,
  y2 
)
Get the separation angle in sky coordinates for two points defined in pixels on the detection image.

Parameters
----------
x1 : float
y1 : float
x2 : float
y2 : float

Returns
-------
Separation in degrees

Definition at line 1038 of file model_fitting.py.

References sourcextractor.config.model_fitting.get_sky_coord().

Referenced by sourcextractor.config.model_fitting.get_world_parameters(), and sourcextractor.config.model_fitting.radius_to_wc_angle().

Here is the call graph for this function:

◆ get_sky_coord()

def sourcextractor.config.model_fitting.get_sky_coord (   x,
  y 
)
Transform an (X, Y) in pixel coordinates on the detection image to astropy SkyCoord.

Parameters
----------
x : float
y : float

Returns
-------
SkyCoord

Definition at line 1003 of file model_fitting.py.

References sourcextractor.config.model_fitting.pixel_to_world_coordinate().

Referenced by sourcextractor.config.model_fitting.get_position_angle(), and sourcextractor.config.model_fitting.get_separation_angle().

Here is the call graph for this function:

◆ get_world_parameters()

def sourcextractor.config.model_fitting.get_world_parameters (   x,
  y,
  radius,
  angle,
  ratio 
)
Convenience function for generating five dependent parameters, in world coordinates, for the position
and shape of a model.

Parameters
----------
x : ParameterBase
y : ParameterBase
radius : ParameterBase
angle : ParameterBase
ratio : ParameterBase

Returns
-------
ra : DependentParameter
    Right ascension
dec : DependentParameter
    Declination
rad : DependentParameter
    Radius as degrees
angle : DependentParameter
    Angle in degrees
ratio : DependentParameter
    Aspect ratio. It has to be recomputed as the axis of the ellipse may have different ratios
    in image coordinates than in world coordinates

Examples
--------
>>> flux = get_flux_parameter()
>>> x, y = get_pos_parameters()
>>> radius = FreeParameter(lambda o: o.radius, Range(lambda v, o: (.01 * v, 100 * v), RangeType.EXPONENTIAL))
>>> angle = FreeParameter(lambda o: o.angle, Range((-np.pi, np.pi), RangeType.LINEAR))
>>> ratio = FreeParameter(1, Range((0, 10), RangeType.LINEAR))
>>> add_model(group, ExponentialModel(x, y, flux, radius, ratio, angle))
>>> ra, dec, wc_rad, wc_angle, wc_ratio = get_world_parameters(x, y, radius, angle, ratio)
>>> add_output_column('mf_world_angle', wc_angle)

Definition at line 1112 of file model_fitting.py.

References sourcextractor.config.model_fitting.get_position_angle(), sourcextractor.config.model_fitting.get_separation_angle(), and sourcextractor.config.model_fitting.pixel_to_world_coordinate().

Here is the call graph for this function:

◆ get_world_position_parameters()

def sourcextractor.config.model_fitting.get_world_position_parameters (   x,
  y 
)
Convenience function for generating two dependent parameter with world (alpha, delta) coordinates
from image (X, Y) coordinates.

Parameters
----------
x : ParameterBase
y : ParameterBase

Returns
-------
ra : DependentParameter
dec : DependentParameter

See Also
--------
get_pos_parameters

Examples
--------
>>> x, y = get_pos_parameters()
>>> ra, dec = get_world_position_parameters(x, y)
>>> add_output_column('mf_ra', ra)
>>> add_output_column('mf_dec', dec)

Definition at line 1081 of file model_fitting.py.

References sourcextractor.config.model_fitting.pixel_to_world_coordinate().

Here is the call graph for this function:

◆ pixel_to_world_coordinate()

def sourcextractor.config.model_fitting.pixel_to_world_coordinate (   x,
  y 
)
Transform an (X, Y) in pixel coordinates on the detection image to (RA, DEC) in world coordinates.
Parameters
----------
x : float
y : float

Returns
-------
WorldCoordinate

Definition at line 985 of file model_fitting.py.

Referenced by sourcextractor.config.model_fitting.get_sky_coord(), sourcextractor.config.model_fitting.get_world_parameters(), and sourcextractor.config.model_fitting.get_world_position_parameters().

◆ print_model_fitting_info()

def sourcextractor.config.model_fitting.print_model_fitting_info (   group,
  show_params = False,
  prefix = '',
  file = sys.stderr 
)
Print a human-readable representation of the configured models.

Parameters
----------
group : MeasurementGroup
    Print the models for this group.
show_params : bool
    If True, print also the parameters that belong to the model
prefix : str
    Prefix each line with this string. Used internally for indentation.
file : file object
    Where to print the representation. Defaults to sys.stderr

Definition at line 499 of file model_fitting.py.

◆ print_parameters()

def sourcextractor.config.model_fitting.print_parameters (   file = sys.stderr)
Print a human-readable representation of the configured model fitting parameters.

Parameters
----------
file : file object
    Where to print the representation. Defaults to sys.stderr

Definition at line 189 of file model_fitting.py.

◆ radius_to_wc_angle()

def sourcextractor.config.model_fitting.radius_to_wc_angle (   x,
  y,
  rad 
)
Transform a radius in pixels on the detection image to a radius in sky coordinates.

Parameters
----------
x : float
y : float
rad : float

Returns
-------
Radius in degrees

Definition at line 1021 of file model_fitting.py.

References sourcextractor.config.model_fitting.get_separation_angle().

Here is the call graph for this function:

◆ set_deblend_factor()

def sourcextractor.config.model_fitting.set_deblend_factor (   deblend_factor)
Parameters
----------

Definition at line 584 of file model_fitting.py.

◆ set_engine()

def sourcextractor.config.model_fitting.set_engine (   engine)
Parameters
----------
engine : str
    Minimization engine for the model fitting : levmar or gsl

Definition at line 557 of file model_fitting.py.

◆ set_max_iterations()

def sourcextractor.config.model_fitting.set_max_iterations (   iterations)
Parameters
----------
iterations : int
    Max number of iterations for the model fitting.

Definition at line 534 of file model_fitting.py.

◆ set_meta_iteration_stop()

def sourcextractor.config.model_fitting.set_meta_iteration_stop (   meta_iteration_stop)
Parameters
----------

Definition at line 592 of file model_fitting.py.

◆ set_meta_iterations()

def sourcextractor.config.model_fitting.set_meta_iterations (   meta_iterations)
Parameters
----------
meta_iterations : int
    number of meta iterations on the whole group (when using iterative model fitting) 

Definition at line 575 of file model_fitting.py.

◆ set_modified_chi_squared_scale()

def sourcextractor.config.model_fitting.set_modified_chi_squared_scale (   scale)
Parameters
----------
scale : float
    Sets u0, as used by the modified chi squared residual comparator, a function that reduces the effect of large
    deviations.
    Refer to the SourceXtractor++ documentation for a better explanation of how residuals are computed and how
    this value affects the model fitting.

Definition at line 544 of file model_fitting.py.

◆ use_iterative_fitting()

def sourcextractor.config.model_fitting.use_iterative_fitting (   use_iterative_fitting)
Parameters
----------
use_iterative_fitting : boolean
    use iterative model fitting or legacy 

Definition at line 566 of file model_fitting.py.

Variable Documentation

◆ constant_model_dict

dictionary sourcextractor.config.model_fitting.constant_model_dict = {}

Definition at line 524 of file model_fitting.py.

◆ constant_parameter_dict

dictionary sourcextractor.config.model_fitting.constant_parameter_dict = {}

Definition at line 184 of file model_fitting.py.

◆ de_vaucouleurs_model_dict

dictionary sourcextractor.config.model_fitting.de_vaucouleurs_model_dict = {}

Definition at line 528 of file model_fitting.py.

◆ dependent_parameter_dict

dictionary sourcextractor.config.model_fitting.dependent_parameter_dict = {}

Definition at line 186 of file model_fitting.py.

◆ exponential_model_dict

dictionary sourcextractor.config.model_fitting.exponential_model_dict = {}

Definition at line 527 of file model_fitting.py.

◆ frame_models_dict

dictionary sourcextractor.config.model_fitting.frame_models_dict = {}

Definition at line 469 of file model_fitting.py.

◆ free_parameter_dict

dictionary sourcextractor.config.model_fitting.free_parameter_dict = {}

Definition at line 185 of file model_fitting.py.

◆ onnx_model_dict

dictionary sourcextractor.config.model_fitting.onnx_model_dict = {}

Definition at line 529 of file model_fitting.py.

◆ params_dict

dictionary sourcextractor.config.model_fitting.params_dict
Initial value:
1 = {"max_iterations": 200, "modified_chi_squared_scale": 10, "engine": "", "use_iterative_fitting": True, "meta_iterations": 5,
2  "deblend_factor": 0.95, "meta_iteration_stop": 0.0001}

Definition at line 530 of file model_fitting.py.

◆ point_source_model_dict

dictionary sourcextractor.config.model_fitting.point_source_model_dict = {}

Definition at line 525 of file model_fitting.py.

◆ prior_dict

dictionary sourcextractor.config.model_fitting.prior_dict = {}

Definition at line 426 of file model_fitting.py.

◆ sersic_model_dict

dictionary sourcextractor.config.model_fitting.sersic_model_dict = {}

Definition at line 526 of file model_fitting.py.