Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-6124

Testing ngmix Psf plugin with CModel

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: meas_extensions_ngmix
    • Labels:
      None
    • Story Points:
      6
    • Epic Link:
    • Sprint:
      DRP X16-3
    • Team:
      Data Release Production

      Description

      Test that the ngmix PSF approx plugin works correctly in our measurement framework by testing it with CModel and comparing results with those produced with ShapeletPsfApprox.

        Attachments

          Issue Links

            Activity

            Hide
            pgee Perry Gee added a comment -

            The purpose of this issue was really to confirm that the translation of the multi-Gaussian estimation using ngmix/EM was actually producing results which could be used by our framework, so CModel was run after EmPsfApprox using the latter as its psfName.

            This test actually discovered that we were not running the EMRunner in ngmix correctly. It needs at least a "unitJacobian" to function correctly. Prior to supplying that, the algorithm seemed to fail unpredictably. This is really work which ended up on 6123, as I did these two simultaneously.

            Show
            pgee Perry Gee added a comment - The purpose of this issue was really to confirm that the translation of the multi-Gaussian estimation using ngmix/EM was actually producing results which could be used by our framework, so CModel was run after EmPsfApprox using the latter as its psfName. This test actually discovered that we were not running the EMRunner in ngmix correctly. It needs at least a "unitJacobian" to function correctly. Prior to supplying that, the algorithm seemed to fail unpredictably. This is really work which ended up on 6123, as I did these two simultaneously.
            Hide
            pgee Perry Gee added a comment -

            The code to run comparisons is actually in galaxy_shear_experiments, under tickets/DM-6124. I state the results here. The TripleGaussians are 3 component Gaussian Models defined for ShapeletPsfApprox, and are 000 and 000. They were installed just for comparison.

            The big differences actually seem to be in comparing nGauss1 vs. SingleGaussian. Please note that EMRunner does not run to as small a tolerance as PsfShapeletApprox, as I observed visually when I ran both plugins on pure Gaussians.

            CModel comparison: for nGauss2 vs DoubleGaussian:
            e1 differences: 0.00000028 + 0.00000180 for 10 sources
            e2 differences: 0.00000025 +- 0.00000091 for 10 sources
            CModel comparison: for nGauss1 vs SingleGaussian:
            e1 differences: 0.00000573 + 0.00002557 for 10 sources
            e2 differences: 0.00000453 +- 0.00000907 for 10 sources
            CModel comparison: for nGauss3 vs TripleGaussianInner:
            e1 differences: 0.00000048 +- 0.00000156 for 10 sources
            e2 differences: 0.00000008 +- 0.00000254 for 10 sources
            CModel comparison: for nGauss3 vs TripleGaussianOuter:
            e1 differences: 0.00000059 +- 0.00000250 for 10 sources
            e2 differences: 0.00000043 + 0.00000161 for 10 sources
            CModel comparison: for SingleGaussian vs DoubleGaussian:
            e1 differences: 0.00000048 +- 0.00000875 for 10 sources
            e2 differences: 0.00000427 + 0.00000606 for 10 sources

            Show
            pgee Perry Gee added a comment - The code to run comparisons is actually in galaxy_shear_experiments, under tickets/ DM-6124 . I state the results here. The TripleGaussians are 3 component Gaussian Models defined for ShapeletPsfApprox, and are 000 and 000 . They were installed just for comparison. The big differences actually seem to be in comparing nGauss1 vs. SingleGaussian. Please note that EMRunner does not run to as small a tolerance as PsfShapeletApprox, as I observed visually when I ran both plugins on pure Gaussians. CModel comparison: for nGauss2 vs DoubleGaussian: e1 differences: 0.00000028 + 0.00000180 for 10 sources e2 differences: 0.00000025 +- 0.00000091 for 10 sources CModel comparison: for nGauss1 vs SingleGaussian: e1 differences: 0.00000573 + 0.00002557 for 10 sources e2 differences: 0.00000453 +- 0.00000907 for 10 sources CModel comparison: for nGauss3 vs TripleGaussianInner: e1 differences: 0.00000048 +- 0.00000156 for 10 sources e2 differences: 0.00000008 +- 0.00000254 for 10 sources CModel comparison: for nGauss3 vs TripleGaussianOuter: e1 differences: 0.00000059 +- 0.00000250 for 10 sources e2 differences: 0.00000043 + 0.00000161 for 10 sources CModel comparison: for SingleGaussian vs DoubleGaussian: e1 differences: 0.00000048 +- 0.00000875 for 10 sources e2 differences: 0.00000427 + 0.00000606 for 10 sources
            Hide
            pgee Perry Gee added a comment -

            Differences in the pixels produced by the different plugins vs. the actual Psf given to them. These were PhoSim Psfs.

            SUMMARY using PsfApprox SingleGaussian with 10 exposures
            PsfApprox runtime: 0.0081 sec. +- 0 sec.
            CModel runtime: 0.0061 sec. +- 0 sec
            PSF avg pixel diff: -0.00015557
            PSF std pixel dff stdev: 0.00248383

            SUMMARY using PsfApprox DoubleGaussian with 10 exposures
            PsfApprox runtime: 0.0463 sec. +- 0 sec.
            CModel runtime: 0.0099 sec. +- 0 sec
            PSF avg pixel diff: -0.00014726
            PSF std pixel dff stdev: 0.00249288

            SUMMARY using PsfApprox nGauss1 with 10 exposures
            PsfApprox runtime: 0.0014 sec. +- 0 sec.
            CModel runtime: 0.0130 sec. +- 0 sec
            PSF avg pixel diff: -0.00016635
            PSF std pixel dff stdev: 0.00229705

            SUMMARY using PsfApprox nGauss2 with 10 exposures
            PsfApprox runtime: 0.0191 sec. +- 0 sec.
            CModel runtime: 0.0106 sec. +- 0 sec
            PSF avg pixel diff: -0.00016176
            PSF std pixel dff stdev: 0.00235760

            SUMMARY using PsfApprox nGauss3 with 10 exposures
            PsfApprox runtime: 0.2348 sec. +- 0 sec.
            CModel runtime: 0.0159 sec. +- 0 sec
            PSF avg pixel diff: -0.00016079
            PSF std pixel dff stdev: 0.00236489

            Show
            pgee Perry Gee added a comment - Differences in the pixels produced by the different plugins vs. the actual Psf given to them. These were PhoSim Psfs. SUMMARY using PsfApprox SingleGaussian with 10 exposures PsfApprox runtime: 0.0081 sec. +- 0 sec. CModel runtime: 0.0061 sec. +- 0 sec PSF avg pixel diff: -0.00015557 PSF std pixel dff stdev: 0.00248383 SUMMARY using PsfApprox DoubleGaussian with 10 exposures PsfApprox runtime: 0.0463 sec. +- 0 sec. CModel runtime: 0.0099 sec. +- 0 sec PSF avg pixel diff: -0.00014726 PSF std pixel dff stdev: 0.00249288 SUMMARY using PsfApprox nGauss1 with 10 exposures PsfApprox runtime: 0.0014 sec. +- 0 sec. CModel runtime: 0.0130 sec. +- 0 sec PSF avg pixel diff: -0.00016635 PSF std pixel dff stdev: 0.00229705 SUMMARY using PsfApprox nGauss2 with 10 exposures PsfApprox runtime: 0.0191 sec. +- 0 sec. CModel runtime: 0.0106 sec. +- 0 sec PSF avg pixel diff: -0.00016176 PSF std pixel dff stdev: 0.00235760 SUMMARY using PsfApprox nGauss3 with 10 exposures PsfApprox runtime: 0.2348 sec. +- 0 sec. CModel runtime: 0.0159 sec. +- 0 sec PSF avg pixel diff: -0.00016079 PSF std pixel dff stdev: 0.00236489
            Hide
            pgee Perry Gee added a comment -

            Here is runtime information which came out of these same tests:

            SUMMARY using PsfApprox nGauss3 with 10 exposures
            PsfApprox runtime: 0.2366 sec. +- 0 sec.
            CModel runtime: 0.0164 sec. +- 0 sec
            SUMMARY using PsfApprox SingleGaussian with 10 exposures
            PsfApprox runtime: 0.0081 sec. +- 0.003272 sec.
            CModel runtime: 0.0061 sec. +- 0.001346 sec
            SUMMARY using PsfApprox DoubleGaussian with 10 exposures
            PsfApprox runtime: 0.0463 sec. +- 0.005585 sec.
            CModel runtime: 0.0098 sec. +- 0.002891 sec
            SUMMARY using PsfApprox nGauss1 with 10 exposures
            PsfApprox runtime: 0.0014 sec. +- 0.000054 sec.
            CModel runtime: 0.0130 sec. +- 0.013712 sec
            SUMMARY using PsfApprox nGauss2 with 10 exposures
            PsfApprox runtime: 0.0188 sec. +- 0.000400 sec.
            CModel runtime: 0.0112 sec. +- 0.001392 sec
            SUMMARY using PsfApprox nGauss3 with 10 exposures
            PsfApprox runtime: 0.2340 sec. +- 0.009426 sec.
            CModel runtime: 0.0158 sec. +- 0.002432 sec
            SUMMARY using PsfApprox TripleGaussianOuter with 10 exposures
            PsfApprox runtime: 0.3727 sec. +- 0.233824 sec.
            CModel runtime: 0.0151 sec. +- 0.003921 sec
            SUMMARY using PsfApprox nGauss3 with 10 exposures
            PsfApprox runtime: 0.2347 sec. +- 0.009666 sec.
            CModel runtime: 0.0158 sec. +- 0.002065 sec
            SUMMARY using PsfApprox TripleGaussianInner with 10 exposures
            PsfApprox runtime: 0.3720 sec. +- 0.230313 sec.
            CModel runtime: 0.0149 sec. +- 0.003539 sec

            Show
            pgee Perry Gee added a comment - Here is runtime information which came out of these same tests: SUMMARY using PsfApprox nGauss3 with 10 exposures PsfApprox runtime: 0.2366 sec. +- 0 sec. CModel runtime: 0.0164 sec. +- 0 sec SUMMARY using PsfApprox SingleGaussian with 10 exposures PsfApprox runtime: 0.0081 sec. +- 0.003272 sec. CModel runtime: 0.0061 sec. +- 0.001346 sec SUMMARY using PsfApprox DoubleGaussian with 10 exposures PsfApprox runtime: 0.0463 sec. +- 0.005585 sec. CModel runtime: 0.0098 sec. +- 0.002891 sec SUMMARY using PsfApprox nGauss1 with 10 exposures PsfApprox runtime: 0.0014 sec. +- 0.000054 sec. CModel runtime: 0.0130 sec. +- 0.013712 sec SUMMARY using PsfApprox nGauss2 with 10 exposures PsfApprox runtime: 0.0188 sec. +- 0.000400 sec. CModel runtime: 0.0112 sec. +- 0.001392 sec SUMMARY using PsfApprox nGauss3 with 10 exposures PsfApprox runtime: 0.2340 sec. +- 0.009426 sec. CModel runtime: 0.0158 sec. +- 0.002432 sec SUMMARY using PsfApprox TripleGaussianOuter with 10 exposures PsfApprox runtime: 0.3727 sec. +- 0.233824 sec. CModel runtime: 0.0151 sec. +- 0.003921 sec SUMMARY using PsfApprox nGauss3 with 10 exposures PsfApprox runtime: 0.2347 sec. +- 0.009666 sec. CModel runtime: 0.0158 sec. +- 0.002065 sec SUMMARY using PsfApprox TripleGaussianInner with 10 exposures PsfApprox runtime: 0.3720 sec. +- 0.230313 sec. CModel runtime: 0.0149 sec. +- 0.003539 sec
            Hide
            pgee Perry Gee added a comment -

            The code which produced these results is in galaxy_shear_experiments. I am not concerned about checking this in, but if you want to see the code, it is on tickets/DM-6123

            Show
            pgee Perry Gee added a comment - The code which produced these results is in galaxy_shear_experiments. I am not concerned about checking this in, but if you want to see the code, it is on tickets/ DM-6123
            Hide
            pgee Perry Gee added a comment -

            Sorry. Actually, DM-6124

            Show
            pgee Perry Gee added a comment - Sorry. Actually, DM-6124
            Hide
            pgee Perry Gee added a comment -

            This is a comparison of the Gaussian fitters using their default settings. This was just a sanity test. But I did find the omission of the Jacobian because of strange problems with EMPsfApprox doing these simple tests.

            nGauss1: ngmix EMPsfApprox, nGauss = 1
            nGauss2: ngmix EMPsfApprox, nGauss = 2
            SingleGaussian: PsfShapeletApprox
            DoubleGaussian: PsfShapeletApprox

            Models running on a Single Gaussian:
            component 0: amp = 1.000000, sigma = 4.000000

            Using model nGauss1
            DIFFS: (-0.00015829129176376792, 0.0011888552335592665)
            PSF: (ixx=15.9990375642, iyy=15.9990375678, ixy=-1.59644452847e-08),
            (-5.7088e-13, 7.2717e-14))
            [ 0.27003514]

            Using model SingleGaussian
            DIFFS: (-0.00015541221422079763, 0.0012018456926277991)
            PSF: (ixx=15.9999987904, iyy=15.9999994105, ixy=-2.88753774136e-07),
            (7.0562e-10, 5.9369e-10))
            [ 0.28209478]

            Using model nGauss2
            DIFFS: (-0.00015828218642075919, 0.0011889808463263511)
            PSF: (ixx=15.437239682, iyy=15.4376494832, ixy=-0.000212610070082),
            (0.0019808, -0.0022363))
            [ 0.15543501]
            PSF: (ixx=16.7722790887, iyy=16.7717162863, ixy=0.000298129770636),
            (-0.0027039, 0.003053))
            [ 0.11461417]

            Using model DoubleGaussian
            DIFFS: (-0.0001554122121517216, 0.0012018456811670592)
            PSF: (ixx=15.9999999845, iyy=16.0000010528, ixy=-2.86920951877e-07),
            (1.1837e-09, 9.7758e-10))
            [ 0.28209478]
            PSF: (ixx=63.9982986901, iyy=63.9982986901, ixy=1.49369523773e-12),
            (-1.9056e-17, -2.3531e-17))
            [ 1.48330137e-08]

            -------------------------------------
            -------------------------------------
            Models running on a double gaussian
            component 0: amp = 1.000000, sigma = 4.000000
            component 1: amp = 0.500000, sigma = 8.000000

            Using model nGauss1
            DIFFS: (-0.00016236985259901842, 0.00093493041720977275)
            PSF: (ixx=26.4048038208, iyy=26.4048038208, ixy=-8.42381887074e-13),
            (-3.7257e-16, -6.1202e-19))
            [ 0.26343557]

            Using model SingleGaussian
            DIFFS: (-0.00016284465841898458, 0.00095982776760274104)
            PSF: (ixx=20.3547972164, iyy=20.2284155693, ixy=0.0631870250436),
            (-0.00017337, -9.5825e-05))
            [ 0.25573096]

            Using model nGauss2
            DIFFS: (-0.0001595243252360783, 0.00095397063580048111)
            PSF: (ixx=15.9668132914, iyy=15.9668132914, ixy=0.0),
            (3.8047e-16, -5.4508e-17))
            [ 0.18150405]
            PSF: (ixx=63.7248239325, iyy=63.7248239325, ixy=-3.79858632292e-16),
            (2.0634e-16, 2.0936e-17))
            [ 0.09142004]

            Using model DoubleGaussian
            DIFFS: (-0.0001572490117598259, 0.0009619403876283553)
            PSF: (ixx=16.169975098, iyy=16.1699215778, ixy=-1.24287220881e-05),
            (7.8807e-07, 2.8255e-06))
            [ 0.19159612]
            PSF: (ixx=67.2220132981, iyy=67.2225928636, ixy=0.000126914960634),
            (2.2892e-07, 4.0119e-07))
            [ 0.09126995]

            Show
            pgee Perry Gee added a comment - This is a comparison of the Gaussian fitters using their default settings. This was just a sanity test. But I did find the omission of the Jacobian because of strange problems with EMPsfApprox doing these simple tests. nGauss1: ngmix EMPsfApprox, nGauss = 1 nGauss2: ngmix EMPsfApprox, nGauss = 2 SingleGaussian: PsfShapeletApprox DoubleGaussian: PsfShapeletApprox Models running on a Single Gaussian: component 0: amp = 1.000000, sigma = 4.000000 Using model nGauss1 DIFFS: (-0.00015829129176376792, 0.0011888552335592665) PSF: (ixx=15.9990375642, iyy=15.9990375678, ixy=-1.59644452847e-08), (-5.7088e-13, 7.2717e-14)) [ 0.27003514] Using model SingleGaussian DIFFS: (-0.00015541221422079763, 0.0012018456926277991) PSF: (ixx=15.9999987904, iyy=15.9999994105, ixy=-2.88753774136e-07), (7.0562e-10, 5.9369e-10)) [ 0.28209478] Using model nGauss2 DIFFS: (-0.00015828218642075919, 0.0011889808463263511) PSF: (ixx=15.437239682, iyy=15.4376494832, ixy=-0.000212610070082), (0.0019808, -0.0022363)) [ 0.15543501] PSF: (ixx=16.7722790887, iyy=16.7717162863, ixy=0.000298129770636), (-0.0027039, 0.003053)) [ 0.11461417] Using model DoubleGaussian DIFFS: (-0.0001554122121517216, 0.0012018456811670592) PSF: (ixx=15.9999999845, iyy=16.0000010528, ixy=-2.86920951877e-07), (1.1837e-09, 9.7758e-10)) [ 0.28209478] PSF: (ixx=63.9982986901, iyy=63.9982986901, ixy=1.49369523773e-12), (-1.9056e-17, -2.3531e-17)) [ 1.48330137e-08] ------------------------------------- ------------------------------------- Models running on a double gaussian component 0: amp = 1.000000, sigma = 4.000000 component 1: amp = 0.500000, sigma = 8.000000 Using model nGauss1 DIFFS: (-0.00016236985259901842, 0.00093493041720977275) PSF: (ixx=26.4048038208, iyy=26.4048038208, ixy=-8.42381887074e-13), (-3.7257e-16, -6.1202e-19)) [ 0.26343557] Using model SingleGaussian DIFFS: (-0.00016284465841898458, 0.00095982776760274104) PSF: (ixx=20.3547972164, iyy=20.2284155693, ixy=0.0631870250436), (-0.00017337, -9.5825e-05)) [ 0.25573096] Using model nGauss2 DIFFS: (-0.0001595243252360783, 0.00095397063580048111) PSF: (ixx=15.9668132914, iyy=15.9668132914, ixy=0.0), (3.8047e-16, -5.4508e-17)) [ 0.18150405] PSF: (ixx=63.7248239325, iyy=63.7248239325, ixy=-3.79858632292e-16), (2.0634e-16, 2.0936e-17)) [ 0.09142004] Using model DoubleGaussian DIFFS: (-0.0001572490117598259, 0.0009619403876283553) PSF: (ixx=16.169975098, iyy=16.1699215778, ixy=-1.24287220881e-05), (7.8807e-07, 2.8255e-06)) [ 0.19159612] PSF: (ixx=67.2220132981, iyy=67.2225928636, ixy=0.000126914960634), (2.2892e-07, 4.0119e-07)) [ 0.09126995]
            Hide
            pgee Perry Gee added a comment -

            Note that nGauss2 finds a two Gaussian fit to a single gaussian which splits the flux between two gaussians of nearly equal sigma and flux.

            Show
            pgee Perry Gee added a comment - Note that nGauss2 finds a two Gaussian fit to a single gaussian which splits the flux between two gaussians of nearly equal sigma and flux.
            Hide
            jbosch Jim Bosch added a comment -

            Looks good. One question: did finding and fixing the Jacobian bug improve the speed of the algorithm at all? No need for lots of new tests; I was just curious whether the slow performance you saw before went away at all.

            Show
            jbosch Jim Bosch added a comment - Looks good. One question: did finding and fixing the Jacobian bug improve the speed of the algorithm at all? No need for lots of new tests; I was just curious whether the slow performance you saw before went away at all.
            Hide
            pgee Perry Gee added a comment -

            Yes, I was just sending you email about that. The EmPsfApprox algorithm seems fine now. Note comparison with ShapeletPsfApprox models of similar order.

            Show
            pgee Perry Gee added a comment - Yes, I was just sending you email about that. The EmPsfApprox algorithm seems fine now. Note comparison with ShapeletPsfApprox models of similar order.
            Hide
            pgee Perry Gee added a comment -

            I think that all the questions for 6124 and 6125 were answered by the timing information I sent you. Yes, I think the plugin is working well now, and is faster. It is about as good as the comparable lower order ShapeletPsfApprox models at reproducing the input Psf. And the CModel + EmPsfApprox pair seems to work comparably.

            Show
            pgee Perry Gee added a comment - I think that all the questions for 6124 and 6125 were answered by the timing information I sent you. Yes, I think the plugin is working well now, and is faster. It is about as good as the comparable lower order ShapeletPsfApprox models at reproducing the input Psf. And the CModel + EmPsfApprox pair seems to work comparably.

              People

              Assignee:
              pgee Perry Gee
              Reporter:
              pgee Perry Gee
              Reviewers:
              Jim Bosch
              Watchers:
              Jim Bosch, Perry Gee
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins

                  No builds found.