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

Compute PSFlux chi squared metric

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: meas_base
    • Labels:

      Description

      The DPDD requires us to compute the chi squared of a point source model fit on difference imaging residuals. Develop a chi squared fit for the PSF model that can be run on the residuals which can be added to the source catalog. This may need to be run in the C++ layer at the point where the measurement is made.

        Attachments

          Issue Links

            Activity

            No builds found.
            sullivan Ian Sullivan created issue -
            Hide
            ebellm Eric Bellm added a comment -

            I wonder if it could be computed in https://github.com/lsst/meas_base/blob/master/src/PsfFlux.cc as part of PsfFluxAlgorithm::measure.

            Show
            ebellm Eric Bellm added a comment - I wonder if it could be computed in https://github.com/lsst/meas_base/blob/master/src/PsfFlux.cc as part of PsfFluxAlgorithm::measure.
            sullivan Ian Sullivan made changes -
            Field Original Value New Value
            Sprint AP S21-5 (April) [ 1084 ]
            sullivan Ian Sullivan made changes -
            Rank Ranked higher
            sullivan Ian Sullivan made changes -
            Assignee John Parejko [ parejkoj ]
            sullivan Ian Sullivan made changes -
            Story Points 6 10
            sullivan Ian Sullivan made changes -
            Rank Ranked higher
            sullivan Ian Sullivan made changes -
            Rank Ranked higher
            sullivan Ian Sullivan made changes -
            Sprint AP S21-6 (May) [ 1088 ]
            sullivan Ian Sullivan made changes -
            Rank Ranked lower
            sullivan Ian Sullivan made changes -
            Sprint AP S21-6 (May) [ 1088 ] AP S21-7 (June) [ 1096 ]
            sullivan Ian Sullivan made changes -
            Rank Ranked lower
            sullivan Ian Sullivan made changes -
            Epic Link DM-29210 [ 459212 ] DM-30435 [ 504823 ]
            Hide
            Parejkoj John Parejko added a comment -

            Note: See discussion about this topic here: https://lsstc.slack.com/archives/C2JPMCF5X/p1624291520356400

            Show
            Parejkoj John Parejko added a comment - Note: See discussion about this topic here: https://lsstc.slack.com/archives/C2JPMCF5X/p1624291520356400
            Hide
            Parejkoj John Parejko added a comment - - edited

            I believe the relevant entries that define what we need to produce here are in the various source table definitions in the DPDD. For example:

            psLnL: Natural log likelihood of the observed data given the point source model.
            psChi2: chi2 statistic of the model fit.
            psNdata: The number of data points (pixels) used to fit the model.

            I believe that is the value discussed in the ticket description. As opposed to psFluxChi2, which is "chi2 statistic for the scatter of psFlux around psFluxMean.", is only computed for DiaObjects, and I believe already exists.

            Show
            Parejkoj John Parejko added a comment - - edited I believe the relevant entries that define what we need to produce here are in the various source table definitions in the DPDD. For example: psLnL: Natural log likelihood of the observed data given the point source model. psChi2: chi2 statistic of the model fit. psNdata: The number of data points (pixels) used to fit the model. I believe that is the value discussed in the ticket description. As opposed to psFluxChi2 , which is "chi2 statistic for the scatter of psFlux around psFluxMean.", is only computed for DiaObjects, and I believe already exists.
            Parejkoj John Parejko made changes -
            Status To Do [ 10001 ] In Progress [ 3 ]
            sullivan Ian Sullivan made changes -
            Sprint AP F21-1 (June) [ 1096 ] AP F21-2 (July) [ 1102 ]
            sullivan Ian Sullivan made changes -
            Rank Ranked higher
            Hide
            Parejkoj John Parejko added a comment -

            For this ticket, I will compute and save the chi2 and number of included pixels (this might already just be the `*_area` value). Those can be output to DPDD quantities on another ticket.

            Whether we want to compute a log-likelihood here is a good question: typically that's just a variation on the reduced chi2, so may not be very informative without incorporating more knowledge of the pixel covariances.

            Show
            Parejkoj John Parejko added a comment - For this ticket, I will compute and save the chi2 and number of included pixels (this might already just be the `*_area` value). Those can be output to DPDD quantities on another ticket. Whether we want to compute a log-likelihood here is a good question: typically that's just a variation on the reduced chi2, so may not be very informative without incorporating more knowledge of the pixel covariances.
            Parejkoj John Parejko made changes -
            Attachment rc2-psf-chi2.png [ 51088 ]
            Hide
            Parejkoj John Parejko added a comment - - edited

            I've attached a histogram of the normalized chi2s (chi2/npix, which should maybe be npix-1 but that doesn't really change the result) computed with the new code for the gen3_rc2_subset data that I ran through on my desktop. There's a definite per-filter difference, ranging from ~18 for HSC-G to ~40 with a long tail for HSC-Y. I'm not sure what to make of these results, assuming I got the math right. This will be something to think about during the review.

            Show
            Parejkoj John Parejko added a comment - - edited I've attached a histogram of the normalized chi2s (chi2/npix, which should maybe be npix-1 but that doesn't really change the result) computed with the new code for the gen3_rc2_subset data that I ran through on my desktop. There's a definite per-filter difference, ranging from ~18 for HSC-G to ~40 with a long tail for HSC-Y. I'm not sure what to make of these results, assuming I got the math right. This will be something to think about during the review.
            Hide
            Parejkoj John Parejko added a comment -

            Krzysztof Findeisen: do you mind doing this small-ish review (~50 lines) of mixed C++ and python (the test code)? I don't know if there's a more optimal way to do the C++ calculation.

            Eric Bellm: can you please ponder the plot I've uploaded and see if you agree with my math on the ticket? You can look at the calculation in the python test code if you don't want to bother with the C++.

            It looks like the new calculations here increase the PsfFluxAlgorithm runtime by about 10% (roughly 52ms->58ms to run on 10k PSFs on my desktop), which is probably irrelevant in the grand scheme of things.

            Show
            Parejkoj John Parejko added a comment - Krzysztof Findeisen : do you mind doing this small-ish review (~50 lines) of mixed C++ and python (the test code)? I don't know if there's a more optimal way to do the C++ calculation. Eric Bellm : can you please ponder the plot I've uploaded and see if you agree with my math on the ticket? You can look at the calculation in the python test code if you don't want to bother with the C++. It looks like the new calculations here increase the PsfFluxAlgorithm runtime by about 10% (roughly 52ms->58ms to run on 10k PSFs on my desktop), which is probably irrelevant in the grand scheme of things.
            Parejkoj John Parejko made changes -
            Reviewers Eric Bellm, Krzysztof Findeisen [ ebellm, krzys ]
            Status In Progress [ 3 ] In Review [ 10004 ]
            Show
            Parejkoj John Parejko added a comment - Jenkins run with ci_hsc: https://ci.lsst.codes/blue/organizations/jenkins/stack-os-matrix/detail/stack-os-matrix/34628/pipeline
            krzys Krzysztof Findeisen made changes -
            Status In Review [ 10004 ] Reviewed [ 10101 ]
            Parejkoj John Parejko made changes -
            Link This issue blocks DM-31193 [ DM-31193 ]
            Hide
            Parejkoj John Parejko added a comment - - edited
            Show
            Parejkoj John Parejko added a comment - - edited Post-rebase and ap_association fix Jenkins: https://ci.lsst.codes/blue/organizations/jenkins/stack-os-matrix/detail/stack-os-matrix/34664/pipeline
            Hide
            ebellm Eric Bellm added a comment -

            Hi John Parejko, indeed there is a math error: for chi-squared we want sum( ((yi-fi)/sigma_i)**2.). The current code has sum( ((yi-fi)/sigma_i)) since you have taken the square root of the variance plane.

            Show
            ebellm Eric Bellm added a comment - Hi John Parejko , indeed there is a math error: for chi-squared we want sum( ((yi-fi)/sigma_i)**2.). The current code has sum( ((yi-fi)/sigma_i)) since you have taken the square root of the variance plane.
            Parejkoj John Parejko made changes -
            Attachment rc2-psf-chi2-1.png [ 51259 ]
            Hide
            Parejkoj John Parejko added a comment -

            Attached an updated plot, after fixing the sqrt bug that Eric reported. That looks much more like what I'd expect. Note that these plots are just for DRP output, not diffims.

            Show
            Parejkoj John Parejko added a comment - Attached an updated plot, after fixing the sqrt bug that Eric reported. That looks much more like what I'd expect. Note that these plots are just for DRP output, not diffims.
            Parejkoj John Parejko made changes -
            Resolution Done [ 10000 ]
            Status Reviewed [ 10101 ] Done [ 10002 ]
            Parejkoj John Parejko made changes -
            Link This issue relates to DM-37911 [ DM-37911 ]

              People

              Assignee:
              Parejkoj John Parejko
              Reporter:
              sullivan Ian Sullivan
              Reviewers:
              Eric Bellm, Krzysztof Findeisen
              Watchers:
              Eric Bellm, Ian Sullivan, John Parejko, Krzysztof Findeisen
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins

                  No builds found.