I am redesigning pipelines such that you model the source -> lens light -> lens mass. The idea is the lens light pipeline should run irrespective of how the source pipeline was setup, and the mass pipeline irrespective of the source and lens light pipelines.
For example, in the mass pipeline, if the source model used in previous pipelines has 1 EllipticalSersic, it should use this model (with priors initialized from the fit in the previous phase). If the source were 4 Sersics, it shoudl use that model. If the source model was a pixelization + regularization, it should use the inversion.
We need an elegent way to setup a source galaxy model in a mass pipeline using the result source model from a previous pipeline. You might think this would be as easy as:
source = af.last.model.galaxies.source
However, there is a snag. If the source is parametric, we want it to be fitted for in the mass pipeline (e.g. pass as a 'model') whereas if its an inversion we wanted its parameters to be fixed (e.g. pass as an 'instance').
For now, I have written a rather shoddy function to do this:
if result.model.galaxies.source.pixelization is None:
return aast.GalaxyModel(
redshift=result.instance.galaxies.source.redshift,
light=result.model.galaxies.source.light,
# hyper_galaxy=af.last.hyper_combined.instance.optional.galaxies.source.hyper_galaxy,
)
else:
return aast.GalaxyModel(
redshift=result.instance.galaxies.source.redshift,
pixelization=result.instance.galaxies.source.pixelization,
regularization=result.instance.galaxies.source.regularization,
# hyper_galaxy=af.last.hyper_combined.instance.optional.galaxies.source.hyper_galaxy,
)
The problem with the above code is the parametric source will only pass correctly if it has only one light profile, and if that light profile is indeed called 'light'. We want a function that automatially scans the properties of the result and determines the GalaxyModel whereby all light profiles are passed as models (with their original attribute name) and all pixelizations / regularizations are passed as instances.
We could even has a 'inversioin_fitted_for' bool which if True passes the pix / reg as a 'model'.
I am redesigning pipelines such that you model the source -> lens light -> lens mass. The idea is the lens light pipeline should run irrespective of how the source pipeline was setup, and the mass pipeline irrespective of the source and lens light pipelines.
For example, in the mass pipeline, if the source model used in previous pipelines has 1 EllipticalSersic, it should use this model (with priors initialized from the fit in the previous phase). If the source were 4 Sersics, it shoudl use that model. If the source model was a pixelization + regularization, it should use the inversion.
We need an elegent way to setup a source galaxy model in a mass pipeline using the result source model from a previous pipeline. You might think this would be as easy as:
source = af.last.model.galaxies.source
However, there is a snag. If the source is parametric, we want it to be fitted for in the mass pipeline (e.g. pass as a 'model') whereas if its an inversion we wanted its parameters to be fixed (e.g. pass as an 'instance').
For now, I have written a rather shoddy function to do this:
The problem with the above code is the parametric source will only pass correctly if it has only one light profile, and if that light profile is indeed called 'light'. We want a function that automatially scans the properties of the result and determines the GalaxyModel whereby all light profiles are passed as models (with their original attribute name) and all pixelizations / regularizations are passed as instances.
We could even has a 'inversioin_fitted_for' bool which if True passes the pix / reg as a 'model'.