From 99720d95caea3863c5edb35ff4f41e83154f652b Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Fri, 28 Aug 2020 11:06:38 +0200 Subject: [PATCH] Helper file for exoplanet data structure and replace magic numbers with constants --- include/openspace/util/distanceconstants.h | 2 + modules/exoplanets/CMakeLists.txt | 2 + modules/exoplanets/exoplanetshelper.cpp | 217 ++++++++++++++++ modules/exoplanets/exoplanetshelper.h | 83 ++++++ modules/exoplanets/exoplanetsmodule.h | 44 ---- modules/exoplanets/exoplanetsmodule_lua.inl | 243 ++---------------- .../rendering/renderableorbitdisc.cpp | 4 +- .../tasks/exoplanetscsvtobintask.cpp | 99 +------ .../exoplanets/tasks/exoplanetscsvtobintask.h | 46 ---- 9 files changed, 337 insertions(+), 403 deletions(-) create mode 100644 modules/exoplanets/exoplanetshelper.cpp create mode 100644 modules/exoplanets/exoplanetshelper.h diff --git a/include/openspace/util/distanceconstants.h b/include/openspace/util/distanceconstants.h index 8bb599cc04..e488cce1f9 100644 --- a/include/openspace/util/distanceconstants.h +++ b/include/openspace/util/distanceconstants.h @@ -27,6 +27,8 @@ namespace openspace::distanceconstants { constexpr double EarthRadius = 6371; + constexpr double JupiterRadius = 7.1492E7; + constexpr double SolarRadius = 6.95700E8; constexpr double LightYear = 9.4607304725808E15; constexpr double LightMonth = LightYear / 12; constexpr double LightDay = LightYear / 365; diff --git a/modules/exoplanets/CMakeLists.txt b/modules/exoplanets/CMakeLists.txt index 2b34dd0c4f..c69c11e49c 100644 --- a/modules/exoplanets/CMakeLists.txt +++ b/modules/exoplanets/CMakeLists.txt @@ -25,6 +25,7 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) set(HEADER_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/exoplanetshelper.h ${CMAKE_CURRENT_SOURCE_DIR}/exoplanetsmodule.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableorbitdisc.h ${CMAKE_CURRENT_SOURCE_DIR}/tasks/exoplanetscsvtobintask.h @@ -32,6 +33,7 @@ set(HEADER_FILES source_group("Header Files" FILES ${HEADER_FILES}) set(SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/exoplanetshelper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/exoplanetsmodule.cpp ${CMAKE_CURRENT_SOURCE_DIR}/exoplanetsmodule_lua.inl ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableorbitdisc.cpp diff --git a/modules/exoplanets/exoplanetshelper.cpp b/modules/exoplanets/exoplanetshelper.cpp new file mode 100644 index 0000000000..67187b76d8 --- /dev/null +++ b/modules/exoplanets/exoplanetshelper.cpp @@ -0,0 +1,217 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#include + +namespace openspace::exoplanets { + +std::string getSpeckStarname(std::string csvName) { + std::string explName = csvName; + if (csvName == "HD 1237") + explName = "GJ 3021"; + else if (csvName == "MOA-2009-BLG-387L") + explName = "MOA 2009-BLG-387L"; + else if (csvName == "HD 126614 A") + explName = "HD 126614"; + else if (csvName == "epsilon Ret") + explName = "HD 27442"; + else if (csvName == "PH-1") + explName = "PH1"; + else if (csvName == "gamma Leo A") + explName = "gam 1 Leo"; + else if (csvName == "OGLE-2007-BLG-368L") + explName = "OGLE 2007-BLG-368L"; + else if (csvName == "alpha Ari") + explName = "alf Ari"; + else if (csvName == "mu Ara") + explName = "HD 160691"; + else if (csvName == "OGLE-05-169L") + explName = "OGLE 2005-BLG-169L"; + else if (csvName == "tau Gru") + explName = "HD 216435"; + else if (csvName == "iota Hor") + explName = "HR 810"; + else if (csvName == "OGLE-05-071L") + explName = "OGLE 2005-BLG-71L"; + else if (csvName == "OGLE235-MOA53") + explName = "OGLE 2003-BLG-235L"; + else if (csvName == "MOA-2008-BLG-310L") + explName = "MOA 2008-BLG-310L"; + else if (csvName == "KIC 11442793") + explName = "KOI-351"; + else if (csvName == "OGLE-2006-BLG-109L") + explName = "OGLE 2006-BLG-109L"; + else if (csvName == "HD 137388") + explName = "HD 137388 A"; + else if (csvName == "kappa CrB") + explName = "kap CrB"; + else if (csvName == "XO-2") + explName = "XO-2 N"; + else if (csvName == "epsilon Tau") + explName = "eps Tau"; + else if (csvName == "epsilon Eri") + explName = "eps Eri"; + else if (csvName == "Kepler-448") + explName = "KOI-12"; + else if (csvName == "omega Ser") + explName = "ome Ser"; + else if (csvName == "MOA-2010-BLG-477L") + explName = "MOA 2010-BLG-477L"; + else if (csvName == "GJ 176") + explName = "HD 285968"; + else if (csvName == "HIP 2247") + explName = "BD-17 63"; + else if (csvName == "MOA-2009-BLG-266L") + explName = "MOA 2009-BLG-266L"; + else if (csvName == "Kepler-89") + explName = "KOI-94"; + else if (csvName == "iota Dra") + explName = "HIP 75458"; + else if (csvName == "MOA-2007-BLG-400L") + explName = "MOA 2007-BLG-400L"; + else if (csvName == "upsilon And") + explName = "ups And"; + else if (csvName == "OGLE-2011-BLG-0251") + explName = "OGLE 2011-BLG-251L"; + else if (csvName == "OGLE-05-390L") + explName = "OGLE 2005-BLG-390L"; + else if (csvName == "Kepler-420") + explName = "KOI-1257"; + else if (csvName == "beta Pic") + explName = "bet Pic"; + else if (csvName == "gamma Cep") + explName = "gam Cep"; + else if (csvName == "MOA-2007-BLG-192L") + explName = "MOA 2007-BLG-192L"; + else if (csvName == "MOA-2009-BLG-319L") + explName = "MOA 2009-BLG-319L"; + else if (csvName == "omicron CrB") + explName = "omi CrB"; + else if (csvName == "beta Gem") + explName = "HD 62509"; + else if (csvName == "epsilon CrB") + explName = "eps CrB"; + else if (csvName == "omicron UMa") + explName = "omi UMa"; + else if (csvName == "HD 142022") + explName = "HD 142022 A"; + + return explName; +} + +std::string getCsvStarname(std::string explName) { + std::string csvName = explName; + if (explName == "GJ 3021") + csvName = "HD 1237"; + else if (explName == "MOA 2009-BLG-387L") + csvName = "MOA-2009-BLG-387L"; + else if (explName == "HD 126614") + csvName = "HD 126614 A"; + else if (explName == "HD 27442") + csvName = "epsilon Ret"; + else if (explName == "PH1") + csvName = "PH-1"; + else if (explName == "gam 1 Leo") + csvName = "gamma Leo A"; + else if (explName == "OGLE 2007-BLG-368L") + csvName = "OGLE-2007-BLG-368L"; + else if (explName == "alf Ari") + csvName = "alpha Ari"; + else if (explName == "HD 160691") + csvName = "mu Ara"; + else if (explName == "OGLE 2005-BLG-169L") + csvName = "OGLE-05-169L"; + else if (explName == "HD 216435") + csvName = "tau Gru"; + else if (explName == "HR 810") + csvName = "iota Hor"; + else if (explName == "OGLE 2005-BLG-71L") + csvName = "OGLE-05-071L"; + else if (explName == "OGLE 2003-BLG-235L") + csvName = "OGLE235-MOA53"; + else if (explName == "MOA 2008-BLG-310L") + csvName = "MOA-2008-BLG-310L"; + else if (explName == "KOI-351") + csvName = "KIC 11442793"; + else if (explName == "OGLE 2006-BLG-109L") + csvName = "OGLE-2006-BLG-109L"; + else if (explName == "HD 137388 A") + csvName = "HD 137388"; + else if (explName == "kap CrB") + csvName = "kappa CrB"; + else if (explName == "XO-2 N") + csvName = "XO-2"; + else if (explName == "eps Tau") + csvName = "epsilon Tau"; + else if (explName == "eps Eri") + csvName = "epsilon Eri"; + else if (explName == "KOI-12") + csvName = "Kepler-448"; + else if (explName == "ome Ser") + csvName = "omega Ser"; + else if (explName == "MOA 2010-BLG-477L") + csvName = "MOA-2010-BLG-477L"; + else if (explName == "HD 285968") + csvName = "GJ 176"; + else if (explName == "BD-17 63") + csvName = "HIP 2247"; + else if (explName == "MOA 2009-BLG-266L") + csvName = "MOA-2009-BLG-266L"; + else if (explName == "KOI-94") + csvName = "Kepler-89"; + else if (explName == "HIP 75458") + csvName = "iota Dra"; + else if (explName == "MOA 2007-BLG-400L") + csvName = "MOA-2007-BLG-400L"; + else if (explName == "ups And") + csvName = "upsilon And"; + else if (explName == "OGLE 2011-BLG-251L") + csvName = "OGLE-2011-BLG-0251"; + else if (explName == "OGLE 2005-BLG-390L") + csvName = "OGLE-05-390L"; + else if (explName == "KOI-1257") + csvName = "Kepler-420"; + else if (explName == "bet Pic") + csvName = "beta Pic"; + else if (explName == "gam Cep") + csvName = "gamma Cep"; + else if (explName == "MOA 2007-BLG-192L") + csvName = "MOA-2007-BLG-192L"; + else if (explName == "MOA 2009-BLG-319L") + csvName = "MOA-2009-BLG-319L"; + else if (explName == "omi CrB") + csvName = "omicron CrB"; + else if (explName == "HD 62509") + csvName = "beta Gem"; + else if (explName == "eps CrB") + csvName = "epsilon CrB"; + else if (explName == "omi UMa") + csvName = "omicron UMa"; + else if (explName == "HD 142022 A") + csvName = "HD 142022"; + + return csvName; +} + +} // namespace openspace::exoplanets diff --git a/modules/exoplanets/exoplanetshelper.h b/modules/exoplanets/exoplanetshelper.h new file mode 100644 index 0000000000..6a8061e5e5 --- /dev/null +++ b/modules/exoplanets/exoplanetshelper.h @@ -0,0 +1,83 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_MODULE_EXOPLANETS___EXOPLANET_HELPER___H__ +#define __OPENSPACE_MODULE_EXOPLANETS___EXOPLANET_HELPER___H__ + +#include + +namespace openspace::exoplanets { + +struct Exoplanet { + float A; // Orbital semi-major axis in AU + double AUPPER; // Upper uncertainty of orbital semi-major axis + double ALOWER; // Lower uncertainty of orbital semi-major axis + double UA; // Uncertainty of orbital semi-major axis + float BIGOM; // Longitude of ascending node in degrees + float BIGOMUPPER; // Upper uncertainty of longitude of ascending node + float BIGOMLOWER; // Lower uncertainty of longitude of ascending node + float UBIGOM; // Uncertainty of longitude of ascending node + bool BINARY; // Star known to be binary? + float BMV; // B − V color + float ECC; // Orbital eccentricity + float ECCUPPER; // Upper uncertainty of orbital eccentricity + float ECCLOWER; // Lower uncertainty of orbital eccentricity + float UECC; // 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 + float UI; // Uncertainty of orbital inclination + int NCOMP; // Number of planetary companions known + float OM; // Argument of periastron in degrees + float OMUPPER; // Upper uncertainty of argument of periastron + float OMLOWER; // Lower uncertainty of argument of periastron + float UOM; // Uncertainty of argument of periastron + double PER; // Orbital period in days + float PERUPPER; // Upper uncertainty of period + float PERLOWER; // Lower uncertainty of period + float UPER; // Uncertainty of period + double R; // Radius of the planet in Jupiter radii + double RUPPER; // Upper uncertainty of radius of the planet + double RLOWER; // Lower uncertainty of radius of the planet + double UR; // Uncertainty of radius of the planet + 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 URSTAR; // Uncertainty of estimated star radius + 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 + float UTT; // Uncertainty of epoch of transit center + float POSITIONX; // Star position's X-coordinate in parsec + float POSITIONY; // Star position's Y-coordinate in parsec + float POSITIONZ; // Star position's Z-coordinate in parsec +}; + +std::string getSpeckStarname(std::string csvName); + +std::string getCsvStarname(std::string explName); + +} // namespace openspace::exoplanets + +#endif // __OPENSPACE_MODULE_EXOPLANETS___EXOPLANETSMODULE___H__ diff --git a/modules/exoplanets/exoplanetsmodule.h b/modules/exoplanets/exoplanetsmodule.h index f6b7778280..cf6d4e31ac 100644 --- a/modules/exoplanets/exoplanetsmodule.h +++ b/modules/exoplanets/exoplanetsmodule.h @@ -29,50 +29,6 @@ #include namespace openspace { - struct Exoplanet { - float A; - double AUPPER; - double ALOWER; - double UA; - float BIGOM; - float BIGOMUPPER; - float BIGOMLOWER; - float UBIGOM; - bool BINARY; - float BMV; - float ECC; - float ECCUPPER; - float ECCLOWER; - float UECC; - float I; - float IUPPER; - float ILOWER; - float UI; - int NCOMP; - float OM; - float OMUPPER; - float OMLOWER; - float UOM; - double PER; - float PERUPPER; - float PERLOWER; - float UPER; - double R; - double RUPPER; - double RLOWER; - double UR; - float RSTAR; - float RSTARUPPER; - float RSTARLOWER; - float URSTAR; - double TT; - float TTUPPER; - float TTLOWER; - float UTT; - float POSITIONX; - float POSITIONY; - float POSITIONZ; - }; class ExoplanetsModule : public OpenSpaceModule { public: diff --git a/modules/exoplanets/exoplanetsmodule_lua.inl b/modules/exoplanets/exoplanetsmodule_lua.inl index 6c88f45af2..874504b6c4 100644 --- a/modules/exoplanets/exoplanetsmodule_lua.inl +++ b/modules/exoplanets/exoplanetsmodule_lua.inl @@ -22,10 +22,13 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ +#include #include #include #include +#include #include +#include #include #include #include @@ -83,194 +86,6 @@ glm::dmat4 computeOrbitPlaneRotationMatrix(float i, float bigom, float om , glm: return orbitPlaneRotation; } -std::string getSpeckStarname(std::string csvName) { - std::string explName = csvName; - if (csvName == "HD 1237") - explName = "GJ 3021"; - else if (csvName == "MOA-2009-BLG-387L") - explName = "MOA 2009-BLG-387L"; - else if (csvName == "HD 126614 A") - explName = "HD 126614"; - else if (csvName == "epsilon Ret") - explName = "HD 27442"; - else if (csvName == "PH-1") - explName = "PH1"; - else if (csvName == "gamma Leo A") - explName = "gam 1 Leo"; - else if (csvName == "OGLE-2007-BLG-368L") - explName = "OGLE 2007-BLG-368L"; - else if (csvName == "alpha Ari") - explName = "alf Ari"; - else if (csvName == "mu Ara") - explName = "HD 160691"; - else if (csvName == "OGLE-05-169L") - explName = "OGLE 2005-BLG-169L"; - else if (csvName == "tau Gru") - explName = "HD 216435"; - else if (csvName == "iota Hor") - explName = "HR 810"; - else if (csvName == "OGLE-05-071L") - explName = "OGLE 2005-BLG-71L"; - else if (csvName == "OGLE235-MOA53") - explName = "OGLE 2003-BLG-235L"; - else if (csvName == "MOA-2008-BLG-310L") - explName = "MOA 2008-BLG-310L"; - else if (csvName == "KIC 11442793") - explName = "KOI-351"; - else if (csvName == "OGLE-2006-BLG-109L") - explName = "OGLE 2006-BLG-109L"; - else if (csvName == "HD 137388") - explName = "HD 137388 A"; - else if (csvName == "kappa CrB") - explName = "kap CrB"; - else if (csvName == "XO-2") - explName = "XO-2 N"; - else if (csvName == "epsilon Tau") - explName = "eps Tau"; - else if (csvName == "epsilon Eri") - explName = "eps Eri"; - else if (csvName == "Kepler-448") - explName = "KOI-12"; - else if (csvName == "omega Ser") - explName = "ome Ser"; - else if (csvName == "MOA-2010-BLG-477L") - explName = "MOA 2010-BLG-477L"; - else if (csvName == "GJ 176") - explName = "HD 285968"; - else if (csvName == "HIP 2247") - explName = "BD-17 63"; - else if (csvName == "MOA-2009-BLG-266L") - explName = "MOA 2009-BLG-266L"; - else if (csvName == "Kepler-89") - explName = "KOI-94"; - else if (csvName == "iota Dra") - explName = "HIP 75458"; - else if (csvName == "MOA-2007-BLG-400L") - explName = "MOA 2007-BLG-400L"; - else if (csvName == "upsilon And") - explName = "ups And"; - else if (csvName == "OGLE-2011-BLG-0251") - explName = "OGLE 2011-BLG-251L"; - else if (csvName == "OGLE-05-390L") - explName = "OGLE 2005-BLG-390L"; - else if (csvName == "Kepler-420") - explName = "KOI-1257"; - else if (csvName == "beta Pic") - explName = "bet Pic"; - else if (csvName == "gamma Cep") - explName = "gam Cep"; - else if (csvName == "MOA-2007-BLG-192L") - explName = "MOA 2007-BLG-192L"; - else if (csvName == "MOA-2009-BLG-319L") - explName = "MOA 2009-BLG-319L"; - else if (csvName == "omicron CrB") - explName = "omi CrB"; - else if (csvName == "beta Gem") - explName = "HD 62509"; - else if (csvName == "epsilon CrB") - explName = "eps CrB"; - else if (csvName == "omicron UMa") - explName = "omi UMa"; - else if (csvName == "HD 142022") - explName = "HD 142022 A"; - - return explName; -} - -std::string getCsvStarname(std::string explName) { - std::string csvName = explName; - if (explName == "GJ 3021") - csvName = "HD 1237"; - else if (explName == "MOA 2009-BLG-387L") - csvName = "MOA-2009-BLG-387L"; - else if (explName == "HD 126614") - csvName = "HD 126614 A"; - else if (explName == "HD 27442") - csvName = "epsilon Ret"; - else if (explName == "PH1") - csvName = "PH-1"; - else if (explName == "gam 1 Leo") - csvName = "gamma Leo A"; - else if (explName == "OGLE 2007-BLG-368L") - csvName = "OGLE-2007-BLG-368L"; - else if (explName == "alf Ari") - csvName = "alpha Ari"; - else if (explName == "HD 160691") - csvName = "mu Ara"; - else if (explName == "OGLE 2005-BLG-169L") - csvName = "OGLE-05-169L"; - else if (explName == "HD 216435") - csvName = "tau Gru"; - else if (explName == "HR 810") - csvName = "iota Hor"; - else if (explName == "OGLE 2005-BLG-71L") - csvName = "OGLE-05-071L"; - else if (explName == "OGLE 2003-BLG-235L") - csvName = "OGLE235-MOA53"; - else if (explName == "MOA 2008-BLG-310L") - csvName = "MOA-2008-BLG-310L"; - else if (explName == "KOI-351") - csvName = "KIC 11442793"; - else if (explName == "OGLE 2006-BLG-109L") - csvName = "OGLE-2006-BLG-109L"; - else if (explName == "HD 137388 A") - csvName = "HD 137388"; - else if (explName == "kap CrB") - csvName = "kappa CrB"; - else if (explName == "XO-2 N") - csvName = "XO-2"; - else if (explName == "eps Tau") - csvName = "epsilon Tau"; - else if (explName == "eps Eri") - csvName = "epsilon Eri"; - else if (explName == "KOI-12") - csvName = "Kepler-448"; - else if (explName == "ome Ser") - csvName = "omega Ser"; - else if (explName == "MOA 2010-BLG-477L") - csvName = "MOA-2010-BLG-477L"; - else if (explName == "HD 285968") - csvName = "GJ 176"; - else if (explName == "BD-17 63") - csvName = "HIP 2247"; - else if (explName == "MOA 2009-BLG-266L") - csvName = "MOA-2009-BLG-266L"; - else if (explName == "KOI-94") - csvName = "Kepler-89"; - else if (explName == "HIP 75458") - csvName = "iota Dra"; - else if (explName == "MOA 2007-BLG-400L") - csvName = "MOA-2007-BLG-400L"; - else if (explName == "ups And") - csvName = "upsilon And"; - else if (explName == "OGLE 2011-BLG-251L") - csvName = "OGLE-2011-BLG-0251"; - else if (explName == "OGLE 2005-BLG-390L") - csvName = "OGLE-05-390L"; - else if (explName == "KOI-1257") - csvName = "Kepler-420"; - else if (explName == "bet Pic") - csvName = "beta Pic"; - else if (explName == "gam Cep") - csvName = "gamma Cep"; - else if (explName == "MOA 2007-BLG-192L") - csvName = "MOA-2007-BLG-192L"; - else if (explName == "MOA 2009-BLG-319L") - csvName = "MOA-2009-BLG-319L"; - else if (explName == "omi CrB") - csvName = "omicron CrB"; - else if (explName == "HD 62509") - csvName = "beta Gem"; - else if (explName == "eps CrB") - csvName = "epsilon CrB"; - else if (explName == "omi UMa") - csvName = "omicron UMa"; - else if (explName == "HD 142022 A") - csvName = "HD 142022"; - - return csvName; -} - // Rotate the original coordinate system (where x is pointing to First Point of Aries) // so that x is pointing from star to the sun. // Modified from http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-17-quaternions/#how-do-i-find-the-rotation-between-2-vectors- @@ -355,7 +170,7 @@ int addExoplanetSystem(lua_State* L) { long location = std::stol(location_s.c_str()); data.seekg(location); - data.read((char*)&p, sizeof(struct Exoplanet)); + data.read((char*)&p, sizeof(Exoplanet)); planetNames.push_back(name); planetSystem.push_back(p); @@ -371,12 +186,10 @@ int addExoplanetSystem(lua_State* L) { } Time epoch; - const double parsec = 0.308567756E17; - glm::dvec3 starPosition = glm::dvec3( - p.POSITIONX * parsec, - p.POSITIONY * parsec, - p.POSITIONZ * parsec + p.POSITIONX * distanceconstants::Parsec, + p.POSITIONY * distanceconstants::Parsec, + p.POSITIONZ * distanceconstants::Parsec ); glm::dvec3 sunPosition = glm::dvec3(0.0, 0.0, 0.0); @@ -441,16 +254,16 @@ int addExoplanetSystem(lua_State* L) { Exoplanet firstPlanet = planetSystem[0]; if (isnan(firstPlanet.ECC)) { - firstPlanet.ECC = 0; + firstPlanet.ECC = 0.f; } if (isnan(firstPlanet.I)) { - firstPlanet.I = 90; + firstPlanet.I = 90.f; } if (isnan(firstPlanet.BIGOM)) { - firstPlanet.BIGOM = 180; + firstPlanet.BIGOM = 180.f; } if (isnan(firstPlanet.OM)) { - firstPlanet.OM = 90; + firstPlanet.OM = 90.f; } std::string sEpochStar; if (!isnan(firstPlanet.TT)) { @@ -465,7 +278,7 @@ int addExoplanetSystem(lua_State* L) { "Parent = '" + starNameSpeck + "'," "Renderable = {" "Type = 'RenderableGlobe'," - "Radii = " + std::to_string(starRadius) + " * 6.957E8," + "Radii = " + std::to_string(starRadius * distanceconstants::SolarRadius) + "," "SegmentsPerPatch = 64," "PerformShading = false," "Layers = {" @@ -494,13 +307,13 @@ int addExoplanetSystem(lua_State* L) { "Translation = {" "Type = 'KeplerTranslation'," "Eccentricity = " + std::to_string(firstPlanet.ECC) + "," //ECC - "SemiMajorAxis = 0," // 149 597 871km = 1 AU. A + "SemiMajorAxis = 0," "Inclination = " + std::to_string(firstPlanet.I) + "," //I "AscendingNode = " + std::to_string(firstPlanet.BIGOM) + "," //BIGOM "ArgumentOfPeriapsis = " + std::to_string(firstPlanet.OM) + "," //OM "MeanAnomaly = 180.0," "Epoch = '" + sEpochStar + "'," //TT. JD to YYYY MM DD hh:mm:ss - "Period = " + std::to_string(firstPlanet.PER) + "* 86400" //PER. 86 400sec = 1 day. + "Period = " + std::to_string(firstPlanet.PER * static_cast(SecondsPerDay)) + "," "}" "}" "}"; @@ -516,16 +329,16 @@ int addExoplanetSystem(lua_State* L) { std::string planetName = planetNames[i]; if (isnan(planet.ECC)) { - planet.ECC = 0; + planet.ECC = 0.f; } if (isnan(planet.I)) { - planet.I = 90; + planet.I = 90.f; } if (isnan(planet.BIGOM)) { - planet.BIGOM = 180; + planet.BIGOM = 180.f; } if (isnan(planet.OM)) { - planet.OM = 90; + planet.OM = 90.f; } std::string sEpoch; if (!isnan(planet.TT)) { @@ -540,15 +353,15 @@ int addExoplanetSystem(lua_State* L) { if (isnan(planet.R)) { if (isnan(planet.RSTAR)) { - planetRadius = planet.A * 149597870700.f * 0.001f; + planetRadius = planet.A * 0.001f * distanceconstants::AstronomicalUnit; } else { - planetRadius = planet.RSTAR * 6.95700E8f * 0.1f; + planetRadius = planet.RSTAR * distanceconstants::SolarRadius * 0.1f; } enabled = "false"; } else { - planetRadius = planet.R * 7.1492E7; // 1 jupiter radii = 7.1492×10e7 m + planetRadius = planet.R * distanceconstants::JupiterRadius; enabled = "true"; } @@ -580,13 +393,13 @@ int addExoplanetSystem(lua_State* L) { "Translation = {" "Type = 'KeplerTranslation'," "Eccentricity = " + std::to_string(planet.ECC) + "," //ECC - "SemiMajorAxis = " + std::to_string(planet.A) + " * 149597871," // 149 597 871km = 1 AU. A + "SemiMajorAxis = " + std::to_string(planet.A * 0.001f * distanceconstants::AstronomicalUnit) + "," // km "Inclination = " + std::to_string(planet.I) + "," //I "AscendingNode = " + std::to_string(planet.BIGOM) + "," //BIGOM "ArgumentOfPeriapsis = " + std::to_string(planet.OM) + "," //OM "MeanAnomaly = 0.0," "Epoch = '" + sEpoch + "'," //TT. JD to YYYY MM DD hh:mm:ss - "Period = " + std::to_string(planet.PER) + "* 86400" //PER. 86 400sec = 1 day. + "Period = " + std::to_string(planet.PER * static_cast(SecondsPerDay)) + "," "}," "}," "}"; @@ -607,13 +420,13 @@ int addExoplanetSystem(lua_State* L) { "Translation = {" "Type = 'KeplerTranslation'," "Eccentricity = " + std::to_string(planet.ECC) + "," //ECC - "SemiMajorAxis = " + std::to_string(planet.A) + " * 149597871," // 149 597 871km = 1 AU. A + "SemiMajorAxis = " + std::to_string(planet.A * 0.001f * distanceconstants::AstronomicalUnit) + "," // km "Inclination = " + std::to_string(planet.I) + "," //I "AscendingNode = " + std::to_string(planet.BIGOM) + "," //BIGOM "ArgumentOfPeriapsis = " + std::to_string(planet.OM) + "," //OM "MeanAnomaly = 0.0," "Epoch = '" + sEpoch + "'," //TT. JD to YYYY MM DD hh:mm:ss - "Period = " + std::to_string(planet.PER) + "* 86400" //PER. 86 400sec = 1 day. + "Period = " + std::to_string(planet.PER * static_cast(SecondsPerDay)) + "," "}," "Color = { 1, 1, 1 }" "}," @@ -639,7 +452,7 @@ int addExoplanetSystem(lua_State* L) { "Renderable = {" "Type = 'RenderableOrbitdisc'," "Texture = openspace.absPath('${MODULE_EXOPLANETS}/disc3.png')," - "Size = " + std::to_string(planet.A) + " * 149597870700," // 149 597 870 700 m = 1 AU. A + "Size = " + std::to_string(planet.A * distanceconstants::AstronomicalUnit) + "," "Eccentricity = " + std::to_string(planet.ECC) + "," "Offset = { " + std::to_string(planet.ALOWER) + ", " + std::to_string(planet.AUPPER) + " }," //min / max extend "Opacity = 0.5" @@ -673,7 +486,7 @@ int addExoplanetSystem(lua_State* L) { "Renderable = {" "Type = 'RenderableOrbitdisc'," "Texture = openspace.absPath('${MODULE_EXOPLANETS}/discL.png')," - "Size = " + std::to_string(planet.A) + " * 149597870700," // 149 597 870 700 m = 1 AU. A + "Size = " + std::to_string(planet.A * distanceconstants::AstronomicalUnit) + "," "Eccentricity = " + std::to_string(lowerEccentricity) + "," "Offset = { " + std::to_string(planet.ALOWER) + ", " + std::to_string(planet.AUPPER) + " }," //min / max extend "Opacity = 0.98," @@ -703,7 +516,7 @@ int addExoplanetSystem(lua_State* L) { "Renderable = {" "Type = 'RenderableOrbitdisc'," "Texture = openspace.absPath('${MODULE_EXOPLANETS}/discU.png')," - "Size = " + std::to_string(planet.A) + " * 149597870700," // 149 597 870 700 m = 1 AU. A + "Size = " + std::to_string(planet.A * distanceconstants::AstronomicalUnit) + "," "Eccentricity = " + std::to_string(upperEccentricity) + "," "Offset = { " + std::to_string(planet.ALOWER) + ", " + std::to_string(planet.AUPPER) + " }," //min / max extend "Opacity = 0.98," diff --git a/modules/exoplanets/rendering/renderableorbitdisc.cpp b/modules/exoplanets/rendering/renderableorbitdisc.cpp index dcc2d80692..bdd85fe8ab 100644 --- a/modules/exoplanets/rendering/renderableorbitdisc.cpp +++ b/modules/exoplanets/rendering/renderableorbitdisc.cpp @@ -30,7 +30,7 @@ #include #include #include - +#include #include #include #include @@ -135,7 +135,7 @@ RenderableOrbitdisc::RenderableOrbitdisc(const ghoul::Dictionary& dictionary) addProperty(_offset); _size = static_cast(dictionary.value(SizeInfo.identifier)); - _size = _size + (_offset.value().y * 149597870700); + _size = _size + (_offset.value().y * distanceconstants::AstronomicalUnit); setBoundingSphere(_size); _size.onChange([&]() { _planeIsDirty = true; }); addProperty(_size); diff --git a/modules/exoplanets/tasks/exoplanetscsvtobintask.cpp b/modules/exoplanets/tasks/exoplanetscsvtobintask.cpp index ab03da3d43..af8fae1c10 100644 --- a/modules/exoplanets/tasks/exoplanetscsvtobintask.cpp +++ b/modules/exoplanets/tasks/exoplanetscsvtobintask.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -62,100 +63,6 @@ std::string ExoplanetsCsvToBinTask::description() { " and write as bin to " + _outputBinPath; } -std::string ExoplanetsCsvToBinTask::getExoplanetName(std::string csvName) { - std::string name = csvName; - if (csvName == "HD 1237") - name = "GJ 3021"; - else if (csvName == "MOA-2009-BLG-387L") - name = "MOA 2009-BLG-387L"; - else if (csvName == "HD 126614 A") - name = "HD 126614"; - else if (csvName == "epsilon Ret") - name = "HD 27442"; - else if (csvName == "PH-1") - name = "PH1"; - else if (csvName == "gamma Leo A") - name = "gam 1 Leo"; - else if (csvName == "OGLE-2007-BLG-368L") - name = "OGLE 2007-BLG-368L"; - else if (csvName == "alpha Ari") - name = "alf Ari"; - else if (csvName == "mu Ara") - name = "HD 160691"; - else if (csvName == "OGLE-05-169L") - name = "OGLE 2005-BLG-169L"; - else if (csvName == "tau Gru") - name = "HD 216435"; - else if (csvName == "iota Hor") - name = "HR 810"; - else if (csvName == "OGLE-05-071L") - name = "OGLE 2005-BLG-71L"; - else if (csvName == "OGLE235-MOA53") - name = "OGLE 2003-BLG-235L"; - else if (csvName == "MOA-2008-BLG-310L") - name = "MOA 2008-BLG-310L"; - else if (csvName == "KIC 11442793") - name = "KOI-351"; - else if (csvName == "OGLE-2006-BLG-109L") - name = "OGLE 2006-BLG-109L"; - else if (csvName == "HD 137388") - name = "HD 137388 A"; - else if (csvName == "kappa CrB") - name = "kap CrB"; - else if (csvName == "XO-2") - name = "XO-2 N"; - else if (csvName == "epsilon Tau") - name = "eps Tau"; - else if (csvName == "epsilon Eri") - name = "eps Eri"; - else if (csvName == "Kepler-448") - name = "KOI-12"; - else if (csvName == "omega Ser") - name = "ome Ser"; - else if (csvName == "MOA-2010-BLG-477L") - name = "MOA 2010-BLG-477L"; - else if (csvName == "GJ 176") - name = "HD 285968"; - else if (csvName == "HIP 2247") - name = "BD-17 63"; - else if (csvName == "MOA-2009-BLG-266L") - name = "MOA 2009-BLG-266L"; - else if (csvName == "Kepler-89") - name = "KOI-94"; - else if (csvName == "iota Dra") - name = "HIP 75458"; - else if (csvName == "MOA-2007-BLG-400L") - name = "MOA 2007-BLG-400L"; - else if (csvName == "upsilon And") - name = "ups And"; - else if (csvName == "OGLE-2011-BLG-0251") - name = "OGLE 2011-BLG-251L"; - else if (csvName == "OGLE-05-390L") - name = "OGLE 2005-BLG-390L"; - else if (csvName == "Kepler-420") - name = "KOI-1257"; - else if (csvName == "beta Pic") - name = "bet Pic"; - else if (csvName == "gamma Cep") - name = "gam Cep"; - else if (csvName == "MOA-2007-BLG-192L") - name = "MOA 2007-BLG-192L"; - else if (csvName == "MOA-2009-BLG-319L") - name = "MOA 2009-BLG-319L"; - else if (csvName == "omicron CrB") - name = "omi CrB"; - else if (csvName == "beta Gem") - name = "HD 62509"; - else if (csvName == "epsilon CrB") - name = "eps CrB"; - else if (csvName == "omicron UMa") - name = "omi UMa"; - else if (csvName == "HD 142022") - name = "HD 142022 A"; - - return name; -} - glm::vec3 ExoplanetsCsvToBinTask::getStarPosition(std::string starName) { glm::vec3 position; position[0] = NAN; @@ -680,7 +587,7 @@ void ExoplanetsCsvToBinTask::perform(const Task::ProgressCallback& progressCallb getline(lineStream, data, ','); // SPECREF getline(lineStream, data, ','); // SPECURL getline(lineStream, data, ','); // STAR - std::string speckStarname = getExoplanetName(data); + std::string speckStarname = getSpeckStarname(data); glm::vec3 pos = getStarPosition(speckStarname); p.POSITIONX = pos[0]; p.POSITIONY = pos[1]; @@ -804,7 +711,7 @@ void ExoplanetsCsvToBinTask::perform(const Task::ProgressCallback& progressCallb long pos = binFile.tellp(); planetname = speckStarname + " " + component; lutFile << planetname << "," << pos << std::endl; - binFile.write((char *)&p, sizeof(struct Exoplanet)); + binFile.write((char *)&p, sizeof(Exoplanet)); } } diff --git a/modules/exoplanets/tasks/exoplanetscsvtobintask.h b/modules/exoplanets/tasks/exoplanetscsvtobintask.h index 9646f0c6d0..483e4fa045 100644 --- a/modules/exoplanets/tasks/exoplanetscsvtobintask.h +++ b/modules/exoplanets/tasks/exoplanetscsvtobintask.h @@ -44,53 +44,7 @@ private: std::string _outputBinPath; std::string _outputLutPath; - std::string getExoplanetName(std::string csvName); glm::vec3 getStarPosition(std::string starName); - - struct Exoplanet { - float A; - double AUPPER; - double ALOWER; - double UA; - float BIGOM; - float BIGOMUPPER; - float BIGOMLOWER; - float UBIGOM; - int BINARY; // **one or more stars** - float BMV; - float ECC; - float ECCUPPER; - float ECCLOWER; - float UECC; - float I; - float IUPPER; - float ILOWER; - float UI; - int NCOMP; // **number of planets** - float OM; - float OMUPPER; - float OMLOWER; - float UOM; - double PER; - float PERUPPER; - float PERLOWER; - float UPER; - double R; - double RUPPER; - double RLOWER; - double UR; - float RSTAR; - float RSTARUPPER; - float RSTARLOWER; - float URSTAR; - double TT; - float TTUPPER; - float TTLOWER; - float UTT; - float POSITIONX; - float POSITIONY; - float POSITIONZ; - }; }; } // namespace openspace::exoplanets