Model class¶
-
class
Model
¶ The overall model to be created
The model includes the width and height of the image to produce, as well as the resolution to use when performing calculations. Having resolution allows us to specify pixel position with decimal places; e.g., the center point for a given profile.
Public Functions
-
Model
(unsigned int width = 0, unsigned int height = 0)¶ Constructor
It creates a new model to which profiles can be added, and that can be used to calculate an image.
-
Model
(Dimensions dimensions)¶ Like Model(unsigned int, unsigned int), but accepting a Dimensions object.
-
ProfilePtr
add_profile
(const std::string &profile_name)¶ Creates a new profile for the given name and adds it to the given model. On success, the new profile is created, added to the model, and its reference is returned for further customization. If a profile with the given name is not supported an invalid_parameter exception is thrown.
- Return
- A pointer to the new profile that corresponds to the given name
- Parameters
profile_name
: The name of the profile that should be created
-
bool
has_profiles
() const¶ Whether this model contains any profiles or not.
- Return
true
if this module contains at least one profile,false
otherwise
-
Image
evaluate
(Point &offset_out = NO_OFFSET)¶ Calculates an image using the information contained in the model. The result of the computation is returned as an Image, which may be of a different size from the one originally requested if the user set this model’s
crop
property tofalse
(via set_crop). If users want to know the offset at which the image resulting of evaluating this Model with its configured parameters is with respect to the Image value returned by this method, hen they must provide a Point inoffset_out
, which will contain the information after the method returns.In other words, the Image returned by this method can be bigger than the Model’s dimensions if the user requested this Model to return a non-cropped Image.
- Return
- The image created by libprofit.
- Parameters
offset_out
: The potential offset with respect to the image returned by this method at which the image of this Model’s dimensions can be found.
-
std::map<std::string, std::shared_ptr<ProfileStats>>
get_stats
() const¶ Return a map of all profile statistics.
- Return
- A map indexed by profile name with runtime statistics
-
void
set_dimensions
(const Dimensions &dimensions)¶ Sets the dimensions of the model image to generate
- Parameters
dimensions
: The dimensions of the model image to generate
-
void
set_psf
(const Image &psf)¶ Sets the PSF image that this Model should use
- Parameters
psf
: The PSF image that this Model should use
-
void
set_image_pixel_scale
(const PixelScale &scale)¶ Sets the pixel scale of the generated model image.
The image scale is the width (and height) of a single pixel in image coordinates.
- Parameters
scale
: The pixel scale of the model image
-
PixelScale
get_image_pixel_scale
() const¶ Returns the pixel scale of the generated model image.
- Return
- the image scale of the generated model image
- See
- set_image_pixel_scale(double, double)
-
void
set_psf_pixel_scale
(const PixelScale &scale)¶ Sets the PSF’s pixel scale.
- See
- set_image_pixel_scale(double, double)
- Parameters
scale
: The pixel scale of the PSF
-
PixelScale
get_psf_pixel_scale
() const¶ Returns the pixel scale of the PSF.
- Return
- the image scale of the generated model image
- See
- set_psf_pixel_scale(double, double)
-
void
set_magzero
(double magzero)¶ Sets the base magnitude to be applied to all profiles.
- Parameters
magzero
: The base magnitude to be applied to all profiles.
-
void
set_mask
(const Mask &mask)¶ Set the calculation mask. If given it must be the same size of the expected output image, and its values are used to limit the profile calculation only to a given area (i.e., those cells where the value is
true
).- Parameters
mask
: The mask to use to limit profile calculations
-
void
set_adjust_mask
(bool adjust_mask)¶ Sets whether the mask given by the user should be automatically adjusted in order to preserve flux during convolution or not. By default masks are adjusted as necessary, but if users have a pre-adjusted Mask (obtained via adjust(Mask &, const Dimensions &, const Image &, unsigned int)) and pass that to the Model, then they need to indicate that no further adjustment in necessary
- See
- adjust(Mask &, const Dimensions &, const Image &, unsigned int)
- Parameters
adjust_mask
: Whether this model should internally adjust the mask given by the user or not.
-
void
set_convolver
(ConvolverPtr convolver)¶ Set a convolver for this Model. A convolver is an object used to carry out the convolution, if necessary. If a convolver is present before calling
evaluate
then it is used. If missing and one is required, a new one is created internally.
-
void
set_crop
(bool crop)¶ Set the cropping flag.
Due to their internal workings, some convolvers produce actually bigger which are (by default) cropped to the size of the original images created by the profiles. If this option is set to true, then the result of the convolution will not be cropped, meaning that the result of the model evaluation will be bigger than what was originally requested.
- Parameters
crop
: Whether this model returns a cropped image (default) or not to the user.
-
void
set_dry_run
(bool dry_run)¶ Sets the dry run flag. The dry run flag determines whether the actual evaluation of profiles should be skipped or not; if skipped profile validation still takes place.
- Parameters
dry_run
: Whether evaluation of profiles should take place (default) or not
-
void
set_return_finesampled
(bool return_finesampled)¶ Set the return finesampled flag.
When users set a finesampling factor on the model (via set_finesampling()) the image calculated by this model will have bigger dimensions than those originally set in the Model. This flag controls whether this bigger image should be returned (default behavior), or whether a smaller version of the image with dimensions equals to the ones requested (plus any padding introduced by convolution) should be returned. If a smaller image is returned, the total flux of the image is still preserved.
- Parameters
return_finesampled
: Whether this model should return finesampled images as-is (true
) or if they should be downsampled to match the original model dimensions.
-
void
set_omp_threads
(unsigned int omp_threads)¶ Sets the maximum number of OpenMP threads to use to evaluate the profiles contained in this model. 0 threads means that no OpenMP support has been requested.
- Parameters
omp_threads
: the number of OpenMP threads to use for profile evaluation
Public Static Functions
-
void
adjust
(Mask &mask, const Dimensions &dims, const Image &psf, unsigned int finesampling = 1)¶ Modifies
mask
in the same way that it would be modified internally by a Model object in order to preserve flux during the convolution step of the Model evaluation.- See
- set_adjust_mask(bool)
- Parameters
Public Static Attributes
-
Point
NO_OFFSET
¶ The Point object that indicates that users don’t want to retrieve back the potential image offset when calling evaluate(Point &)
-