def getGalaxyModel(params): """Return the image of a single galaxy optionally drawn with a psf. Look at :mod:`analysis.models` to figure out which galaxy models and psf models are supported as well as their corresponding implemented parameters. You can even add your own galaxies if desired. Args: params(dict): Dictionary containing the information of a single galaxy where the keys is the name(str) of the parameter and the values are the values of the parametes. Returns: A :class:`galsim.GSObject` """ galaxy_model = params['galaxy_model'] gal_cls = models.getModelCls(galaxy_model) gal_model = gal_cls(params) final = gal_model.gal if params.get('psf_flux', 0) != 0: if params.get('psf_flux', 1) != 1: raise ValueError('I do not think you want a psf of flux not 1') psf_cls = models.getPsfModelCls(params['psf_model']) psf_model = psf_cls(params) final = galsim.Convolve([final, psf_model.psf]) return final
def getOmitFit(id_params, omit): omit_fit = {} for gal_id in id_params: params_omit = omit.get(gal_id,[]) params = id_params[gal_id] galaxy_model = params['galaxy_model'] cls = models.getModelCls(galaxy_model) obj = cls(params_omit=params_omit) omit_fit[gal_id] = obj.omit_fit return omit_fit
def sortModelParamsNames(self): """Return the keys of :attr:`params` in an ordered specified by the class parameters. And when having more than one galaxy, all the parameters from one of the galaxies are ordered together. """ param_names = [] for gal_id in self.id_params: galaxy_model = self.id_params[gal_id]['galaxy_model'] cls = models.getModelCls(galaxy_model) for name in cls.parameters: for param in self.id_params[gal_id]: if param not in self.omit_fit.get(gal_id, []): if param == name: param_names.append(param + '_' + str(gal_id)) return param_names