Skip to content

Commit

Permalink
Fixed bug with transit datapoints not giving a full list
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderJCS committed Oct 26, 2022
1 parent 033fce8 commit d3a5174
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions include/exoSpotter/exoSpotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ std::vector<ExoSpotter::Lightcurve> ExoSpotter::FindPlanet::splitDatapoints(Ligh
/*
Returns a vector of all detected planets in a dataset splitted, grouped.
*/
std::vector<ExoSpotter::Exoplanet> ExoSpotter::FindPlanet::planetInDataPrecise(Lightcurve data)
std::vector<ExoSpotter::Exoplanet> ExoSpotter::FindPlanet::planetsInData(Lightcurve data)
{
if (data.size() < 3) {
return {};
Expand All @@ -266,6 +266,9 @@ std::vector<ExoSpotter::Exoplanet> 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<float> foundTransitFluxes = { data.flux()[i], data.flux()[j], data.flux()[closestIndex] };
std::vector<float> foundTransitDates = { data.date()[i], data.date()[j], data.date()[closestIndex] };

for (int iter = 1; nextExpectedTransit + period < data.date()[data.size() - 1]; iter++) {
nextExpectedTransit += period;

Expand All @@ -275,13 +278,15 @@ std::vector<ExoSpotter::Exoplanet> 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
};
Expand Down Expand Up @@ -365,7 +370,7 @@ std::vector<ExoSpotter::Exoplanet> ExoSpotter::FindPlanet::findPlanets(bool verb
std::vector<Exoplanet> planets;

for (auto splitData : splitted) {
std::vector<Exoplanet> exoplanets = planetInDataPrecise(splitData);
std::vector<Exoplanet> exoplanets = planetsInData(splitData);

planets.insert(planets.end(), exoplanets.begin(), exoplanets.end());
}
Expand Down
2 changes: 1 addition & 1 deletion include/exoSpotter/exoSpotter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Exoplanet> planetInDataPrecise(Lightcurve data);
std::vector<Exoplanet> planetsInData(Lightcurve data);

void printVerbose(
Lightcurve candidates, Lightcurve grouped, std::vector<Lightcurve> splitted, std::vector<Exoplanet> planets);
Expand Down

0 comments on commit d3a5174

Please sign in to comment.