Skip to content

Commit d3a5174

Browse files
committed
Fixed bug with transit datapoints not giving a full list
1 parent 033fce8 commit d3a5174

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

include/exoSpotter/exoSpotter.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ std::vector<ExoSpotter::Lightcurve> ExoSpotter::FindPlanet::splitDatapoints(Ligh
241241
/*
242242
Returns a vector of all detected planets in a dataset splitted, grouped.
243243
*/
244-
std::vector<ExoSpotter::Exoplanet> ExoSpotter::FindPlanet::planetInDataPrecise(Lightcurve data)
244+
std::vector<ExoSpotter::Exoplanet> ExoSpotter::FindPlanet::planetsInData(Lightcurve data)
245245
{
246246
if (data.size() < 3) {
247247
return {};
@@ -266,6 +266,9 @@ std::vector<ExoSpotter::Exoplanet> ExoSpotter::FindPlanet::planetInDataPrecise(L
266266
int expectedTransits = (data.date()[data.size() - 1] - data.date()[0]) / period;
267267
int missedTransits = (data.date()[i] - rawData.date()[0]) / period;
268268

269+
std::vector<float> foundTransitFluxes = { data.flux()[i], data.flux()[j], data.flux()[closestIndex] };
270+
std::vector<float> foundTransitDates = { data.date()[i], data.date()[j], data.date()[closestIndex] };
271+
269272
for (int iter = 1; nextExpectedTransit + period < data.date()[data.size() - 1]; iter++) {
270273
nextExpectedTransit += period;
271274

@@ -275,13 +278,15 @@ std::vector<ExoSpotter::Exoplanet> ExoSpotter::FindPlanet::planetInDataPrecise(L
275278
if (fabs(closest - nextExpectedTransit) > TTVRange * iter * 0.75) {
276279
missedTransits++;
277280
}
281+
282+
else {
283+
foundTransitFluxes.push_back(data.flux()[closestIndex]);
284+
foundTransitDates.push_back(closest);
285+
}
278286
}
279287

280288
Exoplanet candidate = Exoplanet{
281-
Lightcurve{
282-
{data.flux()[i], data.flux()[j], data.flux()[closestIndex]},
283-
{data.date()[i], data.date()[j], data.date()[closestIndex]}
284-
},
289+
Lightcurve{ foundTransitFluxes, foundTransitDates },
285290

286291
1 - (float)missedTransits / (float)expectedTransits
287292
};
@@ -365,7 +370,7 @@ std::vector<ExoSpotter::Exoplanet> ExoSpotter::FindPlanet::findPlanets(bool verb
365370
std::vector<Exoplanet> planets;
366371

367372
for (auto splitData : splitted) {
368-
std::vector<Exoplanet> exoplanets = planetInDataPrecise(splitData);
373+
std::vector<Exoplanet> exoplanets = planetsInData(splitData);
369374

370375
planets.insert(planets.end(), exoplanets.begin(), exoplanets.end());
371376
}

include/exoSpotter/exoSpotter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ namespace ExoSpotter
8888
This method is to provide a more sophisticated algorithm which counteracts the
8989
warning in the planetInData method, at the cost of time.
9090
*/
91-
std::vector<Exoplanet> planetInDataPrecise(Lightcurve data);
91+
std::vector<Exoplanet> planetsInData(Lightcurve data);
9292

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

0 commit comments

Comments
 (0)