Skip to content

Commit a23dbdd

Browse files
committed
Fixed BEST_FROM_SIM=1 giving infinite chi2 and issues with best SEDs
1 parent 41e7ce9 commit a23dbdd

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/fast++-fitter.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,14 +528,16 @@ void fitter_t::fit_galaxies(const model_t& model, uint_t i0, uint_t i1) {
528528
}
529529
}
530530

531-
if (!opts.best_from_sim && opts.parallel == parallel_choice::none) {
531+
if (opts.parallel == parallel_choice::none) {
532532
// Compare to best
533533
// WARNING: read/modify shared resource
534534
if (output.best_chi2.safe[is] > wsp.chi2.safe[i]) {
535535
output.best_chi2.safe[is] = wsp.chi2.safe[i];
536536
output.best_model.safe[is] = model.igrid;
537-
for (uint_t ip : range(model.props)) {
538-
output.best_params.safe(is,gridder.nparam+ip,0) = wsp.props.safe(i,ip);
537+
if (!opts.best_from_sim) {
538+
for (uint_t ip : range(model.props)) {
539+
output.best_params.safe(is,gridder.nparam+ip,0) = wsp.props.safe(i,ip);
540+
}
539541
}
540542
}
541543
}
@@ -630,7 +632,7 @@ void fitter_t::fit_galaxies(const model_t& model, uint_t i0, uint_t i1) {
630632
}
631633
}
632634

633-
if (!opts.best_from_sim && opts.parallel != parallel_choice::none) {
635+
if (opts.parallel != parallel_choice::none) {
634636
// Compare to best
635637
// WARNING: read/modify shared resource
636638
std::lock_guard<std::mutex> lock(output.fit_result_mutex);
@@ -640,8 +642,10 @@ void fitter_t::fit_galaxies(const model_t& model, uint_t i0, uint_t i1) {
640642
if (output.best_chi2.safe[is] > wsp.chi2[i]) {
641643
output.best_chi2.safe[is] = wsp.chi2[i];
642644
output.best_model.safe[is] = model.igrid;
643-
for (uint_t ip : range(model.props)) {
644-
output.best_params.safe(is,gridder.nparam+ip,0) = wsp.props.safe(i,ip);
645+
if (!opts.best_from_sim) {
646+
for (uint_t ip : range(model.props)) {
647+
output.best_params.safe(is,gridder.nparam+ip,0) = wsp.props.safe(i,ip);
648+
}
645649
}
646650
}
647651
}

0 commit comments

Comments
 (0)