From 51869784fdef607a24df04dc5df23cdac8102f0c Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Wed, 9 Dec 2020 13:41:03 +0100 Subject: [PATCH] Add some additional data about the star --- modules/exoplanets/exoplanetshelper.h | 19 +++++-- modules/exoplanets/exoplanetsmodule_lua.inl | 14 +++-- .../tasks/exoplanetsdatapreparationtask.cpp | 54 +++++++++++++++---- 3 files changed, 67 insertions(+), 20 deletions(-) diff --git a/modules/exoplanets/exoplanetshelper.h b/modules/exoplanets/exoplanetshelper.h index 97001e9ff1..58e6a2adbc 100644 --- a/modules/exoplanets/exoplanetshelper.h +++ b/modules/exoplanets/exoplanetshelper.h @@ -39,14 +39,15 @@ struct ExoplanetDataEntry { float bigOmegaUpper; // Upper uncertainty of longitude of ascending node float bigOmegaLower; // Lower uncertainty of longitude of ascending node bool binary; // Star known to be binary? - float bmv; // B − V color + float bmv; // Star B − V color float ecc; // Orbital eccentricity float eccUpper; // Upper uncertainty of orbital eccentricity float eccLower; // Lower uncertainty of orbital eccentricity float i; // Orbital inclination in degrees (for transiting systems only) float iUpper; // Upper uncertainty of orbital inclination float iLower; // Lower uncertainty of orbital inclination - int nComp; // Number of planetary companions known + int nPlanets; // Number of known planets in the planetary system + int nStars; // Number of stars in the planetary system float omega; // Argument of periastron in degrees float omegaUpper; // Upper uncertainty of argument of periastron float omegaLower; // Lower uncertainty of argument of periastron @@ -59,6 +60,12 @@ struct ExoplanetDataEntry { float rStar; // Estimated radius of the star in solar radii float rStarUpper; // Upper uncertainty of estimated star radius float rStarLower; // Lower uncertainty of estimated star radius + float luminosity; // Star luminosity, in units of solar luminosities [log(Solar)] + float luminosityUpper; // Upper uncertainty of star luminosity [log(Solar)] + float luminosityLower; // Lower uncertainty of star luminosity [log(Solar)] + float teff; // Star's effective temperature in Kelvin + float teffUpper; // Upper uncertainty of effective temperature + float teffLower; // Lower uncertainty of effective temperature double tt; // Epoch of transit center in HJD-2440000 float ttUpper; // Upper uncertainty of epoch of transit center float ttLower; // Lower uncertainty of epoch of transit center @@ -71,9 +78,11 @@ struct ExoplanetDataEntry { }; struct StarData { - glm::vec3 position = glm::vec3(std::numeric_limits::quiet_NaN()); // In parsec - float radius = std::numeric_limits::quiet_NaN(); // In solar radii - float bvColorIndex = std::numeric_limits::quiet_NaN(); + glm::vec3 position = glm::vec3(std::numeric_limits::quiet_NaN()); // In parsec + float radius = std::numeric_limits::quiet_NaN(); // In solar radii + float bv = std::numeric_limits::quiet_NaN(); + float teff = std::numeric_limits::quiet_NaN(); // In Kelvin + float luminosity = std::numeric_limits::quiet_NaN(); // In log(Solar) }; struct ExoplanetSystem { diff --git a/modules/exoplanets/exoplanetsmodule_lua.inl b/modules/exoplanets/exoplanetsmodule_lua.inl index 8456c34c36..a6072dd936 100644 --- a/modules/exoplanets/exoplanetsmodule_lua.inl +++ b/modules/exoplanets/exoplanetsmodule_lua.inl @@ -110,12 +110,18 @@ ExoplanetSystem findExoplanetSystemInData(std::string_view starName) { if (system.starData.position != pos && isValidPosition(pos)) { system.starData.position = pos; } - if (system.starData.bvColorIndex != p.bmv && !std::isnan(p.bmv)) { - system.starData.bvColorIndex = p.bmv; - } if (system.starData.radius != p.rStar && !std::isnan(p.rStar)) { system.starData.radius = p.rStar; } + if (system.starData.bv != p.bmv && !std::isnan(p.bmv)) { + system.starData.bv = p.bmv; + } + if (system.starData.teff != p.teff && !std::isnan(p.teff)) { + system.starData.teff = p.teff; + } + if (system.starData.luminosity != p.luminosity && !std::isnan(p.luminosity)) { + system.starData.luminosity = p.luminosity; + } } } @@ -167,7 +173,7 @@ void createExoplanetSystem(const std::string& starName) { } std::string colorLayers; - const float bv = system.starData.bvColorIndex; + const float bv = system.starData.bv; if (!std::isnan(bv)) { const glm::vec3 color = starColor(bv); diff --git a/modules/exoplanets/tasks/exoplanetsdatapreparationtask.cpp b/modules/exoplanets/tasks/exoplanetsdatapreparationtask.cpp index 90918c46a1..190b31baab 100644 --- a/modules/exoplanets/tasks/exoplanetsdatapreparationtask.cpp +++ b/modules/exoplanets/tasks/exoplanetsdatapreparationtask.cpp @@ -88,12 +88,20 @@ void ExoplanetsDataPreparationTask::perform( int version = 1; binFile.write(reinterpret_cast(&version), sizeof(int)); - std::string planetRow; - getline(inputDataFile, planetRow); // The first line, containing the data names + auto readFirstDataRow = [](std::ifstream& file, std::string& line) -> void { + while (getline(file, line)) { + bool shouldSkip = line[0] == '#' || line.empty(); + if (!shouldSkip) break; + } + }; + + // Find the line containing the data names + std::string columnNamesRow; + readFirstDataRow(inputDataFile, columnNamesRow); // Read column names into a vector, for later access std::vector columnNames; - std::stringstream sStream(planetRow); + std::stringstream sStream(columnNamesRow); std::string colName; while (getline(sStream, colName, ',')) { columnNames.push_back(colName); @@ -101,12 +109,15 @@ void ExoplanetsDataPreparationTask::perform( // Read total number of items int total = 0; - while (getline(inputDataFile, planetRow)) { + std::string row; + while (getline(inputDataFile, row)) { ++total; } inputDataFile.clear(); inputDataFile.seekg(0); - getline(inputDataFile, planetRow); // The first line, containing the data names + + // Read past the first line, containing the data names + readFirstDataRow(inputDataFile, row); LINFO(fmt::format("Loading {} exoplanets", total)); @@ -156,7 +167,7 @@ void ExoplanetsDataPreparationTask::perform( ExoplanetDataEntry p; std::string data; int exoplanetCount = 0; - while (getline(inputDataFile, planetRow)) { + while (getline(inputDataFile, row)) { ++exoplanetCount; progressCallback(static_cast(exoplanetCount) / static_cast(total)); @@ -167,7 +178,7 @@ void ExoplanetsDataPreparationTask::perform( float dec = std::numeric_limits::quiet_NaN(); // decimal degrees float distanceInParsec = std::numeric_limits::quiet_NaN(); - std::istringstream lineStream(planetRow); + std::istringstream lineStream(row); int columnIndex = 0; while (getline(lineStream, data, ',')) { const std::string& column = columnNames[columnIndex]; @@ -273,18 +284,39 @@ void ExoplanetsDataPreparationTask::perform( else if (column == "st_raderr2") { p.rStarLower = -readFloatData(data); } - // Color of star (B-V color index computed from star's effective temperature) + // Effective temperature and color of star + // (B-V color index computed from star's effective temperature) else if (column == "st_teff") { - float teff = readFloatData(data); - p.bmv = bvFromTeff(teff); + p.teff = readFloatData(data); + p.bmv = bvFromTeff(p.teff); + } + else if (column == "st_tefferr1") { + p.teffUpper = readFloatData(data); + } + else if (column == "st_tefferr2") { + p.teffLower = -readFloatData(data); + } + // Star luminosity + else if (column == "st_lum") { + p.luminosity = readFloatData(data); + } + else if (column == "st_lumerr1") { + p.luminosityUpper = readFloatData(data); + } + else if (column == "st_lumerr2") { + p.luminosityLower = -readFloatData(data); } // Is the planet orbiting a binary system? else if (column == "cb_flag") { p.binary = static_cast(readIntegerData(data)); } + // Number of stars in the system + else if (column == "sy_snum") { + p.nStars = readIntegerData(data); + } // Number of planets in the system else if (column == "sy_pnum") { - p.nComp = readIntegerData(data); + p.nPlanets = readIntegerData(data); } }