Skip to content

Commit

Permalink
Prevent potential failures. Clarify notebook plot label.
Browse files Browse the repository at this point in the history
  • Loading branch information
czwa committed Dec 3, 2021
1 parent d355719 commit 29891e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/cpVerifyBfk.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@
" pf = np.polyfit(np.array(M)[mask], np.array(D)[mask], 2)\n",
" \n",
" plt.scatter(detStats['CATALOG']['MAGNITUDES'], detStats['CATALOG']['SIZE_DIFF'])\n",
" plt.plot(XX, np.polyval(pf, XX), label=f\"numpy simple {pf}\")\n",
" plt.plot(XX, np.polyval(pf, XX), label=f\"polynomial (N=2) {pf}\")\n",
" # plt.plot(XX, np.polyval(ZZ.x, XX), label=\"robust\")\n",
" plt.plot(XX, f(XX, *ZZ.x), label=f\"exponential {ZZ.x}\")\n",
" plt.ylim(-1, 5)\n",
Expand Down
8 changes: 6 additions & 2 deletions python/lsst/cp/verify/verifyBfk.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ def catalogStatistics(self, exposure, catalog, uncorrectedCatalog, statControl):

magnitude = []
sizeDiff = []
if not matches:
outputStatistics['MAGNITUDES'] = magnitude
outputStatistics['SIZE_DIFF'] = sizeDiff
return outputStatistics

for source, uncorrectedSource, d in matches:
# This uses the simple difference in source moments.
sourceMagnitude = -2.5 * np.log10(source.getPsfInstFlux())
Expand All @@ -143,7 +148,7 @@ def catalogStatistics(self, exposure, catalog, uncorrectedCatalog, statControl):

mask = np.isfinite(magnitude) * np.isfinite(sizeDiff)
if 'BRIGHT_SLOPE' in self.config.catalogStatKeywords:
exponentialFit = least_squares(modelResidual, [0.0, 0.0, 0.0],
exponentialFit = least_squares(modelResidual, [0.0, -0.01, 0.0],
args=(np.array(magnitude)[mask], np.array(sizeDiff)[mask]),
loss='cauchy')

Expand All @@ -154,7 +159,6 @@ def catalogStatistics(self, exposure, catalog, uncorrectedCatalog, statControl):
outputStatistics['MAGNITUDES'] = magnitude
outputStatistics['SIZE_DIFF'] = sizeDiff

# This should have a debug view
return outputStatistics

def debugFit(self, stepname, xVector, yVector, yModel):
Expand Down

0 comments on commit 29891e2

Please sign in to comment.