def associate_hyper_images(self, instance: af.ModelInstance) -> af.ModelInstance: """ Takes images from the last result, if there is one, and associates them with galaxies in this phase where full-path galaxy names match. If the galaxy collection has a different name then an association is not made. e.g. galaxies.lens will match with: galaxies.lens but not with: galaxies.lens galaxies.source Parameters ---------- instance A model instance with 0 or more galaxies in its tree Returns ------- instance The input instance with images associated with galaxies where possible. """ if self.hyper_galaxy_image_path_dict is not None: for galaxy_path, galaxy in instance.path_instance_tuples_for_class( g.Galaxy): if galaxy_path in self.hyper_galaxy_image_path_dict: galaxy.hyper_model_image = self.hyper_model_image galaxy.hyper_galaxy_image = self.hyper_galaxy_image_path_dict[ galaxy_path] return instance
def associate_hyper_images(self, instance: af.ModelInstance) -> af.ModelInstance: """ Using the model image and galaxy images that were set up as the hyper dataset, associate the galaxy images of that result with the galaxies in this model fit. Association is performed based on galaxy names, whereby if the name of a galaxy in this search matches the full-path name of galaxies in the hyper dataset the galaxy image is passed. If the galaxy collection has a different name then an association is not made. For example, `galaxies.lens` will match with: `galaxies.lens` but not with: `galaxies.source` Parameters ---------- instance An instance of the model that is being fitted to the data by this analysis (whose parameters have been set via a non-linear search), which has 0 or more galaxies in its tree. Returns ------- instance The input instance with images associated with galaxies where possible. """ if self.hyper_galaxy_image_path_dict is not None: for galaxy_path, galaxy in instance.path_instance_tuples_for_class(Galaxy): if galaxy_path in self.hyper_galaxy_image_path_dict: galaxy.hyper_model_image = self.hyper_model_image galaxy.hyper_galaxy_image = self.hyper_galaxy_image_path_dict[ galaxy_path ] return instance
def image_function(instance: af.ModelInstance): image = instance.gaussian(x) if hasattr(instance, "perturbation"): image += instance.perturbation(x) return image