From d3a5174cbbaf94af9affbde0ae243dc2ed9d982a Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 26 Oct 2022 17:15:25 -0400 Subject: [PATCH] Fixed bug with transit datapoints not giving a full list --- include/exoSpotter/exoSpotter.cpp | 17 +++++++++++------ include/exoSpotter/exoSpotter.h | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/exoSpotter/exoSpotter.cpp b/include/exoSpotter/exoSpotter.cpp index a35093d..599f89b 100644 --- a/include/exoSpotter/exoSpotter.cpp +++ b/include/exoSpotter/exoSpotter.cpp @@ -241,7 +241,7 @@ std::vector ExoSpotter::FindPlanet::splitDatapoints(Ligh /* Returns a vector of all detected planets in a dataset splitted, grouped. */ -std::vector ExoSpotter::FindPlanet::planetInDataPrecise(Lightcurve data) +std::vector ExoSpotter::FindPlanet::planetsInData(Lightcurve data) { if (data.size() < 3) { return {}; @@ -266,6 +266,9 @@ std::vector ExoSpotter::FindPlanet::planetInDataPrecise(L int expectedTransits = (data.date()[data.size() - 1] - data.date()[0]) / period; int missedTransits = (data.date()[i] - rawData.date()[0]) / period; + std::vector foundTransitFluxes = { data.flux()[i], data.flux()[j], data.flux()[closestIndex] }; + std::vector foundTransitDates = { data.date()[i], data.date()[j], data.date()[closestIndex] }; + for (int iter = 1; nextExpectedTransit + period < data.date()[data.size() - 1]; iter++) { nextExpectedTransit += period; @@ -275,13 +278,15 @@ std::vector ExoSpotter::FindPlanet::planetInDataPrecise(L if (fabs(closest - nextExpectedTransit) > TTVRange * iter * 0.75) { missedTransits++; } + + else { + foundTransitFluxes.push_back(data.flux()[closestIndex]); + foundTransitDates.push_back(closest); + } } Exoplanet candidate = Exoplanet{ - Lightcurve{ - {data.flux()[i], data.flux()[j], data.flux()[closestIndex]}, - {data.date()[i], data.date()[j], data.date()[closestIndex]} - }, + Lightcurve{ foundTransitFluxes, foundTransitDates }, 1 - (float)missedTransits / (float)expectedTransits }; @@ -365,7 +370,7 @@ std::vector ExoSpotter::FindPlanet::findPlanets(bool verb std::vector planets; for (auto splitData : splitted) { - std::vector exoplanets = planetInDataPrecise(splitData); + std::vector exoplanets = planetsInData(splitData); planets.insert(planets.end(), exoplanets.begin(), exoplanets.end()); } diff --git a/include/exoSpotter/exoSpotter.h b/include/exoSpotter/exoSpotter.h index 931d254..a379552 100644 --- a/include/exoSpotter/exoSpotter.h +++ b/include/exoSpotter/exoSpotter.h @@ -88,7 +88,7 @@ namespace ExoSpotter This method is to provide a more sophisticated algorithm which counteracts the warning in the planetInData method, at the cost of time. */ - std::vector planetInDataPrecise(Lightcurve data); + std::vector planetsInData(Lightcurve data); void printVerbose( Lightcurve candidates, Lightcurve grouped, std::vector splitted, std::vector planets);