rhayes777 / PyAutoFit

PyAutoFit: Classy Probabilistic Programming
https://pyautofit.readthedocs.io/
MIT License
60 stars 11 forks source link

More info in model.info and model.result files #268

Closed Jammy2211 closed 3 years ago

Jammy2211 commented 3 years ago

A model.info file currently appears as follows:

Total Free Parameters = 12 

galaxies
    lens
        redshift                                                                          0.169
        bulge
            centre
                centre_0                                                                  GaussianPrior, mean = 0.0, sigma = 0.1001
                centre_1                                                                  GaussianPrior, mean = 0.0, sigma = 0.1001
            elliptical_comps
                elliptical_comps_0                                                        GaussianPrior, mean = 0.0, sigma = 0.5
                elliptical_comps_1                                                        GaussianPrior, mean = 0.0, sigma = 0.5
            intensity                                                                     LogUniformPrior, lower_limit = 1e-06, upper_limit = 1000000.0
            effective_radius                                                              UniformPrior, lower_limit = 0.0, upper_limit = 30.0
            sersic_index                                                                  UniformPrior, lower_limit = 0.5, upper_limit = 5.0
        disk
            centre
                centre_0                                                                  GaussianPrior, mean = 0.0, sigma = 0.1001
                centre_1                                                                  GaussianPrior, mean = 0.0, sigma = 0.1001
            elliptical_comps
                elliptical_comps_0                                                        GaussianPrior, mean = 0.0, sigma = 0.5
                elliptical_comps_1                                                        GaussianPrior, mean = 0.0, sigma = 0.5
            intensity                                                                     LogUniformPrior, lower_limit = 1e-06, upper_limit = 1000000.0
            effective_radius                                                              UniformPrior, lower_limit = 0.0, upper_limit = 30.0
            sersic_index                                                                  UniformPrior, lower_limit = 0.5, upper_limit = 5.0
        mass
            centre                                                                        (-0.00615916909625434, 0.0006271389611037185)
            elliptical_comps                                                              (0.12239920963551537, -0.092993694036409)
            axis_ratio                                                                    0.7335250388054474
            angle                                                                         63.613009396134146
            einstein_radius                                                               1.927023192602814
            slope                                                                         2.0
            core_radius                                                                   0.0
        shear
            centre                                                                        (0.0, 0.0)
            elliptical_comps                                                              (-0.16064318233604757, 0.20601700615747018)
            axis_ratio                                                                    0.5857340353445692
            angle                                                                         161.02721500628257
            magnitude                                                                     0.2612455527987792
    source
        redshift                                                                          0.451
        pixelization
            weight_floor                                                                  0.7042409761058225
            weight_power                                                                  11.145179705714781
        regularization
            inner_coefficient                                                             0.8761915011579707
            outer_coefficient                                                             27.464742031426074
            signal_scale                                                                  0.11478913855248421

It would be good if we could add a summary of the model parameterization at the top:

Total Free Parameters = 12 

galaxies->lens->bulge:                                                                    EllSersic (N=7)
galaxies->lens->disk:                                                                     EllSersic (N=5)
galaxies->lens->mass:                                                                     EllIsothermal (N=5)
galaxies->lens->shear:                                                                    ExternalShear (N=2)
galaxies->lens->redshift:                                                                 Redshift (N=0)
galaxies->source->pixelization:                                                           VoronoiBrightness (N=0)
galaxies->source->regularization:                                                         Constant (N=0)

galaxies
    lens
        redshift                                                                          0.169
        bulge
            centre
                centre_0                                                                  GaussianPrior, mean = 0.0, sigma = 0.1001
                centre_1                                                                  GaussianPrior, mean = 0.0, sigma = 0.1001
            elliptical_comps
                elliptical_comps_0                                                        GaussianPrior, mean = 0.0, sigma = 0.5
                elliptical_comps_1                                                        GaussianPrior, mean = 0.0, sigma = 0.5
            intensity                                                                     LogUniformPrior, lower_limit = 1e-06, upper_limit = 1000000.0
            effective_radius                                                              UniformPrior, lower_limit = 0.0, upper_limit = 30.0
            sersic_index                                                                  UniformPrior, lower_limit = 0.5, upper_limit = 5.0
        disk
            centre
                centre_0                                                                  GaussianPrior, mean = 0.0, sigma = 0.1001
                centre_1                                                                  GaussianPrior, mean = 0.0, sigma = 0.1001
            elliptical_comps
                elliptical_comps_0                                                        GaussianPrior, mean = 0.0, sigma = 0.5
                elliptical_comps_1                                                        GaussianPrior, mean = 0.0, sigma = 0.5
            intensity                                                                     LogUniformPrior, lower_limit = 1e-06, upper_limit = 1000000.0
            effective_radius                                                              UniformPrior, lower_limit = 0.0, upper_limit = 30.0
            sersic_index                                                                  UniformPrior, lower_limit = 0.5, upper_limit = 5.0
        mass
            centre                                                                        (-0.00615916909625434, 0.0006271389611037185)
            elliptical_comps                                                              (0.12239920963551537, -0.092993694036409)
            axis_ratio                                                                    0.7335250388054474
            angle                                                                         63.613009396134146
            einstein_radius                                                               1.927023192602814
            slope                                                                         2.0
            core_radius                                                                   0.0
        shear
            centre                                                                        (0.0, 0.0)
            elliptical_comps                                                              (-0.16064318233604757, 0.20601700615747018)
            axis_ratio                                                                    0.5857340353445692
            angle                                                                         161.02721500628257
            magnitude                                                                     0.2612455527987792
    source
        redshift                                                                          0.451
        pixelization
            weight_floor                                                                  0.7042409761058225
            weight_power                                                                  11.145179705714781
        regularization
            inner_coefficient                                                             0.8761915011579707
            outer_coefficient                                                             27.464742031426074
            signal_scale                                                                  0.11478913855248421

The N=? are the number of free parameters, so when they are zero is means all parameters associated with that prior are fixed values of an isntance.

We should add the same summary info to the model.result file, this can be a literal repeat of the stuff above, its just conveninent having everything in one place.

Jammy2211 commented 3 years ago

The implemented solution gives the following:

galaxies->lens:                                                               Galaxy (N=5)
galaxies->source:                                                             Galaxy (N=0) 

Can we make it so it goes all the way down the Collection? e.g.:

galaxies->lens:                                                               Galaxy (N=5)
galaxies->lens->bulge:                                                                    EllSersic (N=7)
galaxies->lens->disk:                                                                     EllSersic (N=5)
galaxies->lens->mass:                                                                     EllIsothermal (N=5)
galaxies->lens->shear:                                                                    ExternalShear (N=2)
galaxies->lens->redshift:                                                                 Redshift (N=0)
galaxies->source:                                                             Galaxy (N=0) 
galaxies->source->pixelization:                                                           VoronoiBrightness (N=0)
galaxies->source->regularization: 

If its not hard to format it may be worth mimicking the indentation of the model.info / model.results:

galaxies                                                                        Collection(N=17)
    lens                                                                        Galaxy (N=5)
        bulge                                                                    EllSersic (N=7)
        disk                                                                      EllSersic (N=5)
        mass                                                                     EllIsothermal (N=5)
        shear                                                                     ExternalShear (N=2)
        redshift                                                                  Redshift (N=0)
    source                                                                       Galaxy (N=0) 
        pixelization                                                             VoronoiBrightness (N=0)
        regularization                                                          Constant (N=0)
Jammy2211 commented 3 years ago

Could you also put the same text in the model.result file

Jammy2211 commented 3 years ago

Now looks like this:

(root)                                                                                    CollectionPriorModel (N=20)
    galaxies                                                                              CollectionPriorModel (N=20)
        lens                                                                              Galaxy (N=14)
            bulge                                                                         EllSersic (N=7)
                centre                                                                    TuplePrior (N=0)
                elliptical_comps                                                          TuplePrior (N=0)
            mass                                                                          EllIsothermal (N=5)
                centre                                                                    TuplePrior (N=0)
                elliptical_comps                                                          TuplePrior (N=0)
            shear                                                                         ExternalShear (N=2)
                elliptical_comps                                                          TuplePrior (N=0)
        source                                                                            Galaxy (N=6)
            bulge                                                                         EllExponential (N=6)
                centre                                                                    TuplePrior (N=0)
                elliptical_comps                                                          TuplePrior (N=0) 

Can we remove the TuplePrior entries altogether?

rhayes777 commented 3 years ago

How would you want it to look?

Jammy2211 commented 3 years ago

Replace (root) with model if it is (root) just cause it looks a bit weird and remove tuples.

Also, the Galaxy objects should have a Redshift, which seems to have gone missing? This is a fixed float in this example, but can obviously be a prior in certain circumstances.

model                                                                                    CollectionPriorModel (N=20)
    galaxies                                                                              CollectionPriorModel (N=20)
        lens                                                                              Galaxy (N=14)
            redshift                                                                       Redshift (N=0)
            bulge                                                                         EllSersic (N=7)
            mass                                                                          EllIsothermal (N=5)
            shear                                                                         ExternalShear (N=2)
        source                                                                            Galaxy (N=6)
            bulge                                                                         EllExponential (N=6)
rhayes777 commented 3 years ago

If the redshift is just a float then it won't have a parameterization. These entries are effectively one level up from the model.info entries which are any float or prior