Skip to content

Commit

Permalink
Add method to count fitted->refStar associations
Browse files Browse the repository at this point in the history
Update metric numbers to the new, correct, values.
  • Loading branch information
parejkoj committed Jan 9, 2018
1 parent bdafc55 commit 2651e55
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 36 deletions.
11 changes: 6 additions & 5 deletions include/lsst/jointcal/Associations.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,12 @@ class Associations {
/**
* @brief return the number of CcdImages with non-empty catalogs to-be-fit.
*/
int nCcdImagesValidForFit() const {
return std::count_if(
ccdImageList.begin(), ccdImageList.end(),
[](std::shared_ptr<CcdImage> const &item) { return item->getCatalogForFit().size() > 0; });
}
int nCcdImagesValidForFit() const;

/**
* @brief Return the number of fittedStars that have an associated refStar.
*/
size_t nFittedStarsWithAssociatedRefStar() const;

private:
void associateRefStars(double matchCutInArcsec, const Gtransfo *gtransfo);
Expand Down
1 change: 1 addition & 0 deletions python/lsst/jointcal/associations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void declareAssociations(py::module &mod) {
cls.def("collectRefStars", &Associations::collectRefStars);
cls.def("deprojectFittedStars", &Associations::deprojectFittedStars);
cls.def("nCcdImagesValidForFit", &Associations::nCcdImagesValidForFit);
cls.def("nFittedStarsWithAssociatedRefStar", &Associations::nFittedStarsWithAssociatedRefStar);

cls.def("addImage", &Associations::addImage);
cls.def("selectFittedStars", &Associations::selectFittedStars);
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/jointcal/jointcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def _do_load_refcat_and_fit(self, associations, defaultFilter, center, radius,
associations.selectFittedStars(self.config.minMeasurements)
self._check_star_lists(associations, name)
add_measurement(self.job, 'jointcal.selected_%s_refStars' % name,
associations.refStarListSize())
associations.nFittedStarsWithAssociatedRefStar())
add_measurement(self.job, 'jointcal.selected_%s_fittedStars' % name,
associations.fittedStarListSize())
add_measurement(self.job, 'jointcal.selected_%s_ccdImages' % name,
Expand Down
16 changes: 15 additions & 1 deletion src/Associations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,20 @@ void Associations::deprojectFittedStars() {
fittedStarList.inTangentPlaneCoordinates = false;
}

int Associations::nCcdImagesValidForFit() const {
return std::count_if(ccdImageList.begin(), ccdImageList.end(), [](std::shared_ptr<CcdImage> const &item) {
return item->getCatalogForFit().size() > 0;
});
}

size_t Associations::nFittedStarsWithAssociatedRefStar() const {
size_t count = 0;
for (auto const &fittedStar : fittedStarList) {
if ((fittedStar != nullptr) & (fittedStar->getRefStar() != nullptr)) count++;
}
return count;
}

#ifdef TODO
void Associations::collectMCStars(int realization) {
CcdImageIterator I;
Expand Down Expand Up @@ -417,6 +431,6 @@ void Associations::setFittedStarColors(std::string dicStarListName, std::string
}
}

#endif /* STORAGE */
#endif /* TODO */
} // namespace jointcal
} // namespace lsst
8 changes: 4 additions & 4 deletions tests/test_jointcal_cfht.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def test_jointcalTask_2_visits(self):
pa1 = 0.014
metrics = {'collected_astrometry_refStars': 825,
'collected_photometry_refStars': 825,
'selected_astrometry_refStars': 825,
'selected_photometry_refStars': 825,
'selected_astrometry_refStars': 350,
'selected_photometry_refStars': 350,
'associated_astrometry_fittedStars': 2269,
'associated_photometry_fittedStars': 2269,
'selected_astrometry_fittedStars': 1239,
Expand Down Expand Up @@ -109,7 +109,7 @@ def test_jointcalTask_2_visits_constrainedPoly(self):
dist_rms_absolute = 54e-3*u.arcsecond
pa1 = None
metrics = {'collected_astrometry_refStars': 825,
'selected_astrometry_refStars': 825,
'selected_astrometry_refStars': 350,
'associated_astrometry_fittedStars': 2269,
'selected_astrometry_fittedStars': 1239,
'selected_astrometry_ccdImages': 12,
Expand All @@ -128,7 +128,7 @@ def test_jointcalTask_2_visits_constrainedPhotometry_no_astrometry(self):

pa1 = 0.017
metrics = {'collected_photometry_refStars': 825,
'selected_photometry_refStars': 825,
'selected_photometry_refStars': 350,
'associated_photometry_fittedStars': 2269,
'selected_photometry_fittedStars': 1239,
'selected_photometry_ccdImages': 12,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_jointcal_cfht_minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_jointcalTask_2_visits_photometry(self):
# NOTE: ndof==1 from 4 fit parameters (2 model, 2 fittedStar), and
# 5 degrees-of-freedom (3 star measurements, with 2 reference stars).
metrics = {'collected_photometry_refStars': 183,
'selected_photometry_refStars': 183,
'selected_photometry_refStars': 2,
'associated_photometry_fittedStars': 2,
'selected_photometry_fittedStars': 2,
'selected_photometry_ccdImages': 2,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_jointcal_decam.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def test_jointcalTask_2_visits(self):
# NOTE: decam fits are currently not converging; the chi2 jumps around, so skip that Metric.
metrics = {'collected_astrometry_refStars': 8194,
'collected_photometry_refStars': 8190,
'selected_astrometry_refStars': 8194,
'selected_photometry_refStars': 8190,
'selected_astrometry_refStars': 773,
'selected_photometry_refStars': 773,
'associated_astrometry_fittedStars': 8241,
'associated_photometry_fittedStars': 8241,
'selected_astrometry_fittedStars': 2261,
Expand Down Expand Up @@ -98,7 +98,7 @@ def test_jointcalTask_2_visits_constrainedPoly(self):
relative_error = 20e-3*u.arcsecond
pa1 = None
metrics = {'collected_astrometry_refStars': 8194,
'selected_astrometry_refStars': 8194,
'selected_astrometry_refStars': 773,
'associated_astrometry_fittedStars': 8241,
'selected_astrometry_fittedStars': 2261,
'selected_astrometry_ccdImages': 17,
Expand Down
27 changes: 10 additions & 17 deletions tests/test_jointcal_hsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def test_jointcalTask_2_visits(self):
pa1 = 0.024
metrics = {'collected_astrometry_refStars': 2187,
'collected_photometry_refStars': 2187,
'selected_astrometry_refStars': 2187,
'selected_photometry_refStars': 2187,
'selected_astrometry_refStars': 515,
'selected_photometry_refStars': 515,
'associated_astrometry_fittedStars': 1151,
'associated_photometry_fittedStars': 1151,
'selected_astrometry_fittedStars': 770,
Expand Down Expand Up @@ -95,27 +95,20 @@ def test_jointcalTask_11_visits_no_photometry(self):
dist_rms_relative = 17e-3*u.arcsecond
pa1 = None # pa1 = 0.134
metrics = {'collected_astrometry_refStars': 3649,
'collected_photometry_refStars': 3649,
'selected_astrometry_refStars': 3649,
'selected_photometry_refStars': 3649,
'selected_astrometry_refStars': 1038,
'associated_astrometry_fittedStars': 2908,
'associated_photometry_fittedStars': 2908,
'selected_astrometry_fittedStars': 2203,
'selected_photometry_fittedStars': 2203,
'selected_astrometry_ccdImages': 33,
'selected_photometry_ccdImages': 33,
'astrometry_final_chi2': 7929.656,
'astrometry_final_ndof': 14262,
'photometry_final_chi2': None,
'photometry_final_ndof': None
}
self._testJointcalTask(11, dist_rms_relative, self.dist_rms_absolute, pa1, metrics=metrics)

def testJointcalTask_2_visits_no_astrometry(self):
"""Test turning off fitting astrometry."""
pa1 = 0.024
metrics = {'collected_photometry_refStars': 2187,
'selected_photometry_refStars': 2187,
'selected_photometry_refStars': 515,
'associated_photometry_fittedStars': 1151,
'selected_photometry_fittedStars': 770,
'selected_photometry_ccdImages': 6,
Expand Down Expand Up @@ -149,7 +142,7 @@ def testJointcalTask_2_visits_no_photometry(self):
"""Test turning off fitting photometry."""
dist_rms_relative = 17e-3*u.arcsecond
metrics = {'collected_astrometry_refStars': 2187,
'selected_astrometry_refStars': 2187,
'selected_astrometry_refStars': 515,
'associated_astrometry_fittedStars': 1151,
'selected_astrometry_fittedStars': 770,
'selected_astrometry_ccdImages': 6,
Expand Down Expand Up @@ -194,8 +187,8 @@ def test_jointcalTask_2_visits_gaia_refcat(self):
pa1 = 0.02405
metrics = {'collected_astrometry_refStars': 1425,
'collected_photometry_refStars': 2187,
'selected_astrometry_refStars': 1425,
'selected_photometry_refStars': 2187,
'selected_astrometry_refStars': 271,
'selected_photometry_refStars': 515,
'associated_astrometry_fittedStars': 1151,
'associated_photometry_fittedStars': 1151,
'selected_astrometry_fittedStars': 645,
Expand All @@ -222,7 +215,7 @@ def test_jointcalTask_2_visits_no_photometry_match_cut_10(self):

dist_rms_relative = 17e-3*u.arcsecond
metrics = {'collected_astrometry_refStars': 2187,
'selected_astrometry_refStars': 2187,
'selected_astrometry_refStars': 546,
'associated_astrometry_fittedStars': 1151,
'selected_astrometry_fittedStars': 790,
'selected_astrometry_ccdImages': 6,
Expand All @@ -242,7 +235,7 @@ def test_jointcalTask_3_visits_no_photometry(self):

dist_rms_relative = 17e-3*u.arcsecond
metrics = {'collected_astrometry_refStars': 2187,
'selected_astrometry_refStars': 2187,
'selected_astrometry_refStars': 541,
'associated_astrometry_fittedStars': 1270,
'selected_astrometry_fittedStars': 946,
'selected_astrometry_ccdImages': 8,
Expand All @@ -264,7 +257,7 @@ def test_jointcalTask_3_visits_no_photometry_min_measurements_3(self):

dist_rms_relative = 17e-3*u.arcsecond
metrics = {'collected_astrometry_refStars': 2187,
'selected_astrometry_refStars': 2187,
'selected_astrometry_refStars': 541,
'associated_astrometry_fittedStars': 1270,
'selected_astrometry_fittedStars': 696,
'selected_astrometry_ccdImages': 8,
Expand Down
8 changes: 4 additions & 4 deletions tests/test_jointcal_lsstSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def testJointcalTask_2_visits(self):
# 'photometry_final_chi2': 2310.628,
# 'photometry_final_ndof': 727
metrics = {'collected_astrometry_refStars': 1686,
'selected_astrometry_refStars': 1686,
'selected_astrometry_refStars': 176,
'associated_astrometry_fittedStars': 1365,
'selected_astrometry_fittedStars': 789,
'selected_astrometry_ccdImages': 2,
Expand Down Expand Up @@ -118,7 +118,7 @@ def testJointcalTask_10_visits(self):
# 'photometry_final_chi2': 35321.947,
# 'photometry_final_ndof': 9140
metrics = {'collected_astrometry_refStars': 1686,
'selected_astrometry_refStars': 1686,
'selected_astrometry_refStars': 203,
'associated_astrometry_fittedStars': 1823,
'selected_astrometry_fittedStars': 1506,
'selected_astrometry_ccdImages': 10,
Expand All @@ -132,7 +132,7 @@ def testJointcalTask_2_visits_no_astrometry(self):
"""Test turning off fitting astrometry."""
pa1 = 2.64e-3
metrics = {'collected_photometry_refStars': 1686,
'selected_photometry_refStars': 1686,
'selected_photometry_refStars': 176,
'associated_photometry_fittedStars': 1365,
'selected_photometry_fittedStars': 789,
'selected_photometry_ccdImages': 2,
Expand Down Expand Up @@ -166,7 +166,7 @@ def testJointcalTask_2_visits_no_photometry(self):
"""Test turning off fitting photometry."""
dist_rms_relative = 9.7e-3*u.arcsecond
metrics = {'collected_astrometry_refStars': 1686,
'selected_astrometry_refStars': 1686,
'selected_astrometry_refStars': 176,
'associated_astrometry_fittedStars': 1365,
'selected_astrometry_fittedStars': 789,
'selected_astrometry_ccdImages': 2,
Expand Down

0 comments on commit 2651e55

Please sign in to comment.