mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-22 19:29:04 -05:00
Some more cleanup
This commit is contained in:
@@ -26,189 +26,189 @@
|
||||
|
||||
namespace openspace::exoplanets {
|
||||
|
||||
std::string getSpeckStarname(std::string csvName) {
|
||||
std::string explName = csvName;
|
||||
std::string getSpeckStarName(std::string csvName) {
|
||||
std::string name = csvName;
|
||||
if (csvName == "HD 1237")
|
||||
explName = "GJ 3021";
|
||||
name = "GJ 3021";
|
||||
else if (csvName == "MOA-2009-BLG-387L")
|
||||
explName = "MOA 2009-BLG-387L";
|
||||
name = "MOA 2009-BLG-387L";
|
||||
else if (csvName == "HD 126614 A")
|
||||
explName = "HD 126614";
|
||||
name = "HD 126614";
|
||||
else if (csvName == "epsilon Ret")
|
||||
explName = "HD 27442";
|
||||
name = "HD 27442";
|
||||
else if (csvName == "PH-1")
|
||||
explName = "PH1";
|
||||
name = "PH1";
|
||||
else if (csvName == "gamma Leo A")
|
||||
explName = "gam 1 Leo";
|
||||
name = "gam 1 Leo";
|
||||
else if (csvName == "OGLE-2007-BLG-368L")
|
||||
explName = "OGLE 2007-BLG-368L";
|
||||
name = "OGLE 2007-BLG-368L";
|
||||
else if (csvName == "alpha Ari")
|
||||
explName = "alf Ari";
|
||||
name = "alf Ari";
|
||||
else if (csvName == "mu Ara")
|
||||
explName = "HD 160691";
|
||||
name = "HD 160691";
|
||||
else if (csvName == "OGLE-05-169L")
|
||||
explName = "OGLE 2005-BLG-169L";
|
||||
name = "OGLE 2005-BLG-169L";
|
||||
else if (csvName == "tau Gru")
|
||||
explName = "HD 216435";
|
||||
name = "HD 216435";
|
||||
else if (csvName == "iota Hor")
|
||||
explName = "HR 810";
|
||||
name = "HR 810";
|
||||
else if (csvName == "OGLE-05-071L")
|
||||
explName = "OGLE 2005-BLG-71L";
|
||||
name = "OGLE 2005-BLG-71L";
|
||||
else if (csvName == "OGLE235-MOA53")
|
||||
explName = "OGLE 2003-BLG-235L";
|
||||
name = "OGLE 2003-BLG-235L";
|
||||
else if (csvName == "MOA-2008-BLG-310L")
|
||||
explName = "MOA 2008-BLG-310L";
|
||||
name = "MOA 2008-BLG-310L";
|
||||
else if (csvName == "KIC 11442793")
|
||||
explName = "KOI-351";
|
||||
name = "KOI-351";
|
||||
else if (csvName == "OGLE-2006-BLG-109L")
|
||||
explName = "OGLE 2006-BLG-109L";
|
||||
name = "OGLE 2006-BLG-109L";
|
||||
else if (csvName == "HD 137388")
|
||||
explName = "HD 137388 A";
|
||||
name = "HD 137388 A";
|
||||
else if (csvName == "kappa CrB")
|
||||
explName = "kap CrB";
|
||||
name = "kap CrB";
|
||||
else if (csvName == "XO-2")
|
||||
explName = "XO-2 N";
|
||||
name = "XO-2 N";
|
||||
else if (csvName == "epsilon Tau")
|
||||
explName = "eps Tau";
|
||||
name = "eps Tau";
|
||||
else if (csvName == "epsilon Eri")
|
||||
explName = "eps Eri";
|
||||
name = "eps Eri";
|
||||
else if (csvName == "Kepler-448")
|
||||
explName = "KOI-12";
|
||||
name = "KOI-12";
|
||||
else if (csvName == "omega Ser")
|
||||
explName = "ome Ser";
|
||||
name = "ome Ser";
|
||||
else if (csvName == "MOA-2010-BLG-477L")
|
||||
explName = "MOA 2010-BLG-477L";
|
||||
name = "MOA 2010-BLG-477L";
|
||||
else if (csvName == "GJ 176")
|
||||
explName = "HD 285968";
|
||||
name = "HD 285968";
|
||||
else if (csvName == "HIP 2247")
|
||||
explName = "BD-17 63";
|
||||
name = "BD-17 63";
|
||||
else if (csvName == "MOA-2009-BLG-266L")
|
||||
explName = "MOA 2009-BLG-266L";
|
||||
name = "MOA 2009-BLG-266L";
|
||||
else if (csvName == "Kepler-89")
|
||||
explName = "KOI-94";
|
||||
name = "KOI-94";
|
||||
else if (csvName == "iota Dra")
|
||||
explName = "HIP 75458";
|
||||
name = "HIP 75458";
|
||||
else if (csvName == "MOA-2007-BLG-400L")
|
||||
explName = "MOA 2007-BLG-400L";
|
||||
name = "MOA 2007-BLG-400L";
|
||||
else if (csvName == "upsilon And")
|
||||
explName = "ups And";
|
||||
name = "ups And";
|
||||
else if (csvName == "OGLE-2011-BLG-0251")
|
||||
explName = "OGLE 2011-BLG-251L";
|
||||
name = "OGLE 2011-BLG-251L";
|
||||
else if (csvName == "OGLE-05-390L")
|
||||
explName = "OGLE 2005-BLG-390L";
|
||||
name = "OGLE 2005-BLG-390L";
|
||||
else if (csvName == "Kepler-420")
|
||||
explName = "KOI-1257";
|
||||
name = "KOI-1257";
|
||||
else if (csvName == "beta Pic")
|
||||
explName = "bet Pic";
|
||||
name = "bet Pic";
|
||||
else if (csvName == "gamma Cep")
|
||||
explName = "gam Cep";
|
||||
name = "gam Cep";
|
||||
else if (csvName == "MOA-2007-BLG-192L")
|
||||
explName = "MOA 2007-BLG-192L";
|
||||
name = "MOA 2007-BLG-192L";
|
||||
else if (csvName == "MOA-2009-BLG-319L")
|
||||
explName = "MOA 2009-BLG-319L";
|
||||
name = "MOA 2009-BLG-319L";
|
||||
else if (csvName == "omicron CrB")
|
||||
explName = "omi CrB";
|
||||
name = "omi CrB";
|
||||
else if (csvName == "beta Gem")
|
||||
explName = "HD 62509";
|
||||
name = "HD 62509";
|
||||
else if (csvName == "epsilon CrB")
|
||||
explName = "eps CrB";
|
||||
name = "eps CrB";
|
||||
else if (csvName == "omicron UMa")
|
||||
explName = "omi UMa";
|
||||
name = "omi UMa";
|
||||
else if (csvName == "HD 142022")
|
||||
explName = "HD 142022 A";
|
||||
name = "HD 142022 A";
|
||||
|
||||
return explName;
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string getCsvStarname(std::string explName) {
|
||||
std::string csvName = explName;
|
||||
if (explName == "GJ 3021")
|
||||
std::string getCsvStarName(std::string name) {
|
||||
std::string csvName = name;
|
||||
if (name == "GJ 3021")
|
||||
csvName = "HD 1237";
|
||||
else if (explName == "MOA 2009-BLG-387L")
|
||||
else if (name == "MOA 2009-BLG-387L")
|
||||
csvName = "MOA-2009-BLG-387L";
|
||||
else if (explName == "HD 126614")
|
||||
else if (name == "HD 126614")
|
||||
csvName = "HD 126614 A";
|
||||
else if (explName == "HD 27442")
|
||||
else if (name == "HD 27442")
|
||||
csvName = "epsilon Ret";
|
||||
else if (explName == "PH1")
|
||||
else if (name == "PH1")
|
||||
csvName = "PH-1";
|
||||
else if (explName == "gam 1 Leo")
|
||||
else if (name == "gam 1 Leo")
|
||||
csvName = "gamma Leo A";
|
||||
else if (explName == "OGLE 2007-BLG-368L")
|
||||
else if (name == "OGLE 2007-BLG-368L")
|
||||
csvName = "OGLE-2007-BLG-368L";
|
||||
else if (explName == "alf Ari")
|
||||
else if (name == "alf Ari")
|
||||
csvName = "alpha Ari";
|
||||
else if (explName == "HD 160691")
|
||||
else if (name == "HD 160691")
|
||||
csvName = "mu Ara";
|
||||
else if (explName == "OGLE 2005-BLG-169L")
|
||||
else if (name == "OGLE 2005-BLG-169L")
|
||||
csvName = "OGLE-05-169L";
|
||||
else if (explName == "HD 216435")
|
||||
else if (name == "HD 216435")
|
||||
csvName = "tau Gru";
|
||||
else if (explName == "HR 810")
|
||||
else if (name == "HR 810")
|
||||
csvName = "iota Hor";
|
||||
else if (explName == "OGLE 2005-BLG-71L")
|
||||
else if (name == "OGLE 2005-BLG-71L")
|
||||
csvName = "OGLE-05-071L";
|
||||
else if (explName == "OGLE 2003-BLG-235L")
|
||||
else if (name == "OGLE 2003-BLG-235L")
|
||||
csvName = "OGLE235-MOA53";
|
||||
else if (explName == "MOA 2008-BLG-310L")
|
||||
else if (name == "MOA 2008-BLG-310L")
|
||||
csvName = "MOA-2008-BLG-310L";
|
||||
else if (explName == "KOI-351")
|
||||
else if (name == "KOI-351")
|
||||
csvName = "KIC 11442793";
|
||||
else if (explName == "OGLE 2006-BLG-109L")
|
||||
else if (name == "OGLE 2006-BLG-109L")
|
||||
csvName = "OGLE-2006-BLG-109L";
|
||||
else if (explName == "HD 137388 A")
|
||||
else if (name == "HD 137388 A")
|
||||
csvName = "HD 137388";
|
||||
else if (explName == "kap CrB")
|
||||
else if (name == "kap CrB")
|
||||
csvName = "kappa CrB";
|
||||
else if (explName == "XO-2 N")
|
||||
else if (name == "XO-2 N")
|
||||
csvName = "XO-2";
|
||||
else if (explName == "eps Tau")
|
||||
else if (name == "eps Tau")
|
||||
csvName = "epsilon Tau";
|
||||
else if (explName == "eps Eri")
|
||||
else if (name == "eps Eri")
|
||||
csvName = "epsilon Eri";
|
||||
else if (explName == "KOI-12")
|
||||
else if (name == "KOI-12")
|
||||
csvName = "Kepler-448";
|
||||
else if (explName == "ome Ser")
|
||||
else if (name == "ome Ser")
|
||||
csvName = "omega Ser";
|
||||
else if (explName == "MOA 2010-BLG-477L")
|
||||
else if (name == "MOA 2010-BLG-477L")
|
||||
csvName = "MOA-2010-BLG-477L";
|
||||
else if (explName == "HD 285968")
|
||||
else if (name == "HD 285968")
|
||||
csvName = "GJ 176";
|
||||
else if (explName == "BD-17 63")
|
||||
else if (name == "BD-17 63")
|
||||
csvName = "HIP 2247";
|
||||
else if (explName == "MOA 2009-BLG-266L")
|
||||
else if (name == "MOA 2009-BLG-266L")
|
||||
csvName = "MOA-2009-BLG-266L";
|
||||
else if (explName == "KOI-94")
|
||||
else if (name == "KOI-94")
|
||||
csvName = "Kepler-89";
|
||||
else if (explName == "HIP 75458")
|
||||
else if (name == "HIP 75458")
|
||||
csvName = "iota Dra";
|
||||
else if (explName == "MOA 2007-BLG-400L")
|
||||
else if (name == "MOA 2007-BLG-400L")
|
||||
csvName = "MOA-2007-BLG-400L";
|
||||
else if (explName == "ups And")
|
||||
else if (name == "ups And")
|
||||
csvName = "upsilon And";
|
||||
else if (explName == "OGLE 2011-BLG-251L")
|
||||
else if (name == "OGLE 2011-BLG-251L")
|
||||
csvName = "OGLE-2011-BLG-0251";
|
||||
else if (explName == "OGLE 2005-BLG-390L")
|
||||
else if (name == "OGLE 2005-BLG-390L")
|
||||
csvName = "OGLE-05-390L";
|
||||
else if (explName == "KOI-1257")
|
||||
else if (name == "KOI-1257")
|
||||
csvName = "Kepler-420";
|
||||
else if (explName == "bet Pic")
|
||||
else if (name == "bet Pic")
|
||||
csvName = "beta Pic";
|
||||
else if (explName == "gam Cep")
|
||||
else if (name == "gam Cep")
|
||||
csvName = "gamma Cep";
|
||||
else if (explName == "MOA 2007-BLG-192L")
|
||||
else if (name == "MOA 2007-BLG-192L")
|
||||
csvName = "MOA-2007-BLG-192L";
|
||||
else if (explName == "MOA 2009-BLG-319L")
|
||||
else if (name == "MOA 2009-BLG-319L")
|
||||
csvName = "MOA-2009-BLG-319L";
|
||||
else if (explName == "omi CrB")
|
||||
else if (name == "omi CrB")
|
||||
csvName = "omicron CrB";
|
||||
else if (explName == "HD 62509")
|
||||
else if (name == "HD 62509")
|
||||
csvName = "beta Gem";
|
||||
else if (explName == "eps CrB")
|
||||
else if (name == "eps CrB")
|
||||
csvName = "epsilon CrB";
|
||||
else if (explName == "omi UMa")
|
||||
else if (name == "omi UMa")
|
||||
csvName = "omicron UMa";
|
||||
else if (explName == "HD 142022 A")
|
||||
else if (name == "HD 142022 A")
|
||||
csvName = "HD 142022";
|
||||
|
||||
return csvName;
|
||||
|
||||
@@ -74,9 +74,11 @@ struct Exoplanet {
|
||||
float POSITIONZ; // Star position's Z-coordinate in parsec
|
||||
};
|
||||
|
||||
std::string getSpeckStarname(std::string csvName);
|
||||
// Convert csv-file specific names to the corresponding name in the speck data file
|
||||
std::string getSpeckStarName(std::string name);
|
||||
|
||||
std::string getCsvStarname(std::string explName);
|
||||
// Convert speck-file specific names to the corresponding name in the csv data file
|
||||
std::string getCsvStarName(std::string name);
|
||||
|
||||
} // namespace openspace::exoplanets
|
||||
|
||||
|
||||
@@ -42,38 +42,30 @@
|
||||
namespace openspace::exoplanets::luascriptfunctions {
|
||||
|
||||
std::string getStarColor(float bv, std::ifstream& colormap) {
|
||||
std::string colorString;
|
||||
|
||||
int t = round(((bv + 0.4) / (2.0 + 0.4)) * 255);
|
||||
|
||||
const int t = round(((bv + 0.4) / (2.0 + 0.4)) * 255);
|
||||
std::string color;
|
||||
for (size_t i = 0; i < t + 12; i++) {
|
||||
getline(colormap, color);
|
||||
}
|
||||
|
||||
std::istringstream colorstream(color);
|
||||
std::string r, g, b;
|
||||
getline(colorstream, r, ' ');
|
||||
getline(colorstream, g, ' ');
|
||||
getline(colorstream, b, ' ');
|
||||
colorString = "{" + r + ", " + g + ", " + b + "}";
|
||||
|
||||
colormap.close();
|
||||
|
||||
return colorString;
|
||||
std::istringstream colorStream(color);
|
||||
std::string r, g, b;
|
||||
getline(colorStream, r, ' ');
|
||||
getline(colorStream, g, ' ');
|
||||
getline(colorStream, b, ' ');
|
||||
|
||||
return "{" + r + ", " + g + ", " + b + "}";
|
||||
}
|
||||
|
||||
glm::dmat4 computeOrbitPlaneRotationMatrix(float i, float bigom, float om , glm::dmat3 rot) {
|
||||
glm::dmat4 computeOrbitPlaneRotationMatrix(float i, float bigom,
|
||||
float om, glm::dmat3 rot)
|
||||
{
|
||||
// Exoplanet defined inclination changed to be used as Kepler defined inclination
|
||||
|
||||
const glm::dvec3 ascendingNodeAxisRot = rot * glm::dvec3(0.f, 0.f, 1.f);
|
||||
const glm::dvec3 inclinationAxisRot = rot * glm::dvec3(1.f, 0.f, 0.f );
|
||||
const glm::vec3 argPeriapsisAxisRot = rot * glm::dvec3( 0.f, 0.f, 1.f );
|
||||
|
||||
/*const glm::vec3 ascendingNodeAxisRot = { 0.f, 0.f, 1.f };
|
||||
const glm::vec3 inclinationAxisRot = { 1.f, 0.f, 0.f };
|
||||
const glm::vec3 argPeriapsisAxisRot = { 0.f, 0.f, 1.f };*/
|
||||
|
||||
const double asc = glm::radians(bigom);
|
||||
const double inc = glm::radians(i);
|
||||
const double per = glm::radians(om);
|
||||
@@ -91,18 +83,16 @@ glm::dmat4 computeOrbitPlaneRotationMatrix(float i, float bigom, float om , glm:
|
||||
// Modified from http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-17-quaternions/#how-do-i-find-the-rotation-between-2-vectors-
|
||||
glm::dmat3 getExoplanetSystemRotation(glm::dvec3 start, glm::dvec3 end) {
|
||||
glm::quat rotationQuat;
|
||||
//glm::dvec3 oldXVec = glm::dvec3(1.0, 0.0, 0.0); //parent nod x-vec
|
||||
//glm::dvec3 starToSunVec = normalize(glm::dvec3(0.0, 0.0, 0.0) - end);
|
||||
|
||||
float cosTheta = dot(start, end);
|
||||
glm::dvec3 rotationAxis;
|
||||
const float cosTheta = dot(start, end);
|
||||
constexpr float Epsilon = 1E-3f;
|
||||
|
||||
if (cosTheta < -1 + 0.001f) {
|
||||
if (cosTheta < -1.f + Epsilon) {
|
||||
// special case when vectors in opposite directions:
|
||||
// there is no "ideal" rotation axis
|
||||
// So guess one; any will do as long as it's perpendicular to startvector(oldXVec)
|
||||
// So guess one; any will do as long as it's perpendicular to start vector
|
||||
rotationAxis = cross(glm::dvec3(0.0, 0.0, 1.0), start);
|
||||
if (length2(rotationAxis) < 0.01) // bad luck, they were parallel, try again!
|
||||
if (length2(rotationAxis) < 0.01f) // bad luck, they were parallel, try again!
|
||||
rotationAxis = cross(glm::dvec3(1.0, 0.0, 0.0), start);
|
||||
|
||||
rotationAxis = normalize(rotationAxis);
|
||||
@@ -112,8 +102,8 @@ glm::dmat3 getExoplanetSystemRotation(glm::dvec3 start, glm::dvec3 end) {
|
||||
|
||||
rotationAxis = cross(start, end);
|
||||
|
||||
float s = sqrt((1 + cosTheta) * 2);
|
||||
float invs = 1 / s;
|
||||
const float s = sqrt((1.f + cosTheta) * 2.f);
|
||||
const float invs = 1.f / s;
|
||||
|
||||
rotationQuat = glm::quat(
|
||||
s * 0.5f,
|
||||
@@ -129,10 +119,8 @@ int addExoplanetSystem(lua_State* L) {
|
||||
const int StringLocation = -1;
|
||||
const std::string starName = luaL_checkstring(L, StringLocation);
|
||||
|
||||
//change expl-starname to exoplanet.csv-starname
|
||||
std::string starnameCsv = getCsvStarname(starName);
|
||||
// If user have given name as in EOD, change it to speck-name
|
||||
std::string starNameSpeck = getSpeckStarname(starName);
|
||||
std::string starNameSpeck = getSpeckStarName(starName);
|
||||
std::replace(starNameSpeck.begin(), starNameSpeck.end(), ' ', '_');
|
||||
|
||||
std::ifstream data(
|
||||
@@ -182,7 +170,10 @@ int addExoplanetSystem(lua_State* L) {
|
||||
lut.close();
|
||||
|
||||
if (!found || isnan(p.POSITIONX) || isnan(p.A) || isnan(p.PER)) { // || p.BINARY
|
||||
return ghoul::lua::luaError(L, "No star with that name or not enough data about it.");
|
||||
return ghoul::lua::luaError(
|
||||
L,
|
||||
"No star with that name or not enough data about it."
|
||||
);
|
||||
}
|
||||
|
||||
Time epoch;
|
||||
@@ -203,10 +194,13 @@ int addExoplanetSystem(lua_State* L) {
|
||||
);
|
||||
glm::dvec3 celestialNorth = normalize(galaxticToCelectialMatrix * galacticNorth);
|
||||
|
||||
// Earths north vector projected onto the skyplane, the plane perpendicular to the viewing vector (starTosunVec)
|
||||
glm::dvec3 northProjected = normalize(celestialNorth - (((dot(celestialNorth, starToSunVec)) / (glm::length(starToSunVec))) * starToSunVec));
|
||||
// Earth's north vector projected onto the skyplane, the plane perpendicular to the viewing vector (starToSunVec)
|
||||
const float celestialAngle = dot(celestialNorth, starToSunVec);
|
||||
glm::dvec3 northProjected = glm::normalize(
|
||||
celestialNorth - (celestialAngle / glm::length(starToSunVec)) * starToSunVec
|
||||
);
|
||||
|
||||
glm::dvec3 beta = normalize(cross(starToSunVec, northProjected));
|
||||
glm::dvec3 beta = glm::normalize(glm::cross(starToSunVec, northProjected));
|
||||
|
||||
const glm::dmat3 exoplanetSystemRotation = glm::dmat3(
|
||||
northProjected.x,
|
||||
@@ -243,9 +237,12 @@ int addExoplanetSystem(lua_State* L) {
|
||||
);
|
||||
|
||||
float starRadius = p.RSTAR;
|
||||
|
||||
if (!isnan(starRadius)) {
|
||||
std::ifstream colorMap(absPath("${SYNC}/http/stars_colormap/2/colorbv.cmap"), std::ios::in);
|
||||
std::ifstream colorMap(
|
||||
absPath("${SYNC}/http/stars_colormap/2/colorbv.cmap"),
|
||||
std::ios::in
|
||||
);
|
||||
|
||||
if (!colorMap.good()) {
|
||||
ghoul::lua::luaError(L, "Failed to open colormap data file");
|
||||
}
|
||||
@@ -270,15 +267,19 @@ int addExoplanetSystem(lua_State* L) {
|
||||
epoch.setTime("JD " + std::to_string(firstPlanet.TT));
|
||||
sEpochStar = epoch.ISO8601();
|
||||
}
|
||||
else
|
||||
else {
|
||||
sEpochStar = "2009-05-19T07:11:34.080";
|
||||
}
|
||||
|
||||
const float period = firstPlanet.PER * static_cast<float>(SecondsPerDay);
|
||||
const float radiusInMeter = starRadius * distanceconstants::SolarRadius;
|
||||
|
||||
const std::string starGlobeNode = "{"
|
||||
"Identifier = '" + starNameSpeck + "Globe',"
|
||||
"Parent = '" + starNameSpeck + "',"
|
||||
"Renderable = {"
|
||||
"Type = 'RenderableGlobe',"
|
||||
"Radii = " + std::to_string(starRadius * distanceconstants::SolarRadius) + ","
|
||||
"Radii = " + std::to_string(radiusInMeter) + ","
|
||||
"SegmentsPerPatch = 64,"
|
||||
"PerformShading = false,"
|
||||
"Layers = {"
|
||||
@@ -313,7 +314,7 @@ int addExoplanetSystem(lua_State* L) {
|
||||
"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 * static_cast<float>(SecondsPerDay)) + ","
|
||||
"Period = " + std::to_string(period) + ","
|
||||
"}"
|
||||
"}"
|
||||
"}";
|
||||
@@ -345,8 +346,9 @@ int addExoplanetSystem(lua_State* L) {
|
||||
epoch.setTime("JD " + std::to_string(planet.TT));
|
||||
sEpoch = epoch.ISO8601();
|
||||
}
|
||||
else
|
||||
else {
|
||||
sEpoch = "2009-05-19T07:11:34.080";
|
||||
}
|
||||
|
||||
float planetRadius;
|
||||
std::string enabled = "";
|
||||
@@ -356,7 +358,7 @@ int addExoplanetSystem(lua_State* L) {
|
||||
planetRadius = planet.A * 0.001f * distanceconstants::AstronomicalUnit;
|
||||
}
|
||||
else {
|
||||
planetRadius = planet.RSTAR * distanceconstants::SolarRadius * 0.1f;
|
||||
planetRadius = planet.RSTAR * 0.1f * distanceconstants::SolarRadius;
|
||||
}
|
||||
enabled = "false";
|
||||
}
|
||||
@@ -365,6 +367,10 @@ int addExoplanetSystem(lua_State* L) {
|
||||
enabled = "true";
|
||||
}
|
||||
|
||||
const float period = planet.PER * static_cast<float>(SecondsPerDay);
|
||||
const float semiMajorAxisInMeter = planet.A * distanceconstants::AstronomicalUnit;
|
||||
const float semiMajorAxisInKm = semiMajorAxisInMeter * 0.001f;
|
||||
|
||||
const std::string planetNode = "{"
|
||||
"Identifier = '" + planetName + "',"
|
||||
"Parent = '" + starNameSpeck + "',"
|
||||
@@ -393,13 +399,13 @@ int addExoplanetSystem(lua_State* L) {
|
||||
"Translation = {"
|
||||
"Type = 'KeplerTranslation',"
|
||||
"Eccentricity = " + std::to_string(planet.ECC) + "," //ECC
|
||||
"SemiMajorAxis = " + std::to_string(planet.A * 0.001f * distanceconstants::AstronomicalUnit) + "," // km
|
||||
"SemiMajorAxis = " + std::to_string(semiMajorAxisInKm) + ","
|
||||
"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 * static_cast<float>(SecondsPerDay)) + ","
|
||||
"Period = " + std::to_string(period) + ","
|
||||
"},"
|
||||
"},"
|
||||
"}";
|
||||
@@ -420,13 +426,13 @@ int addExoplanetSystem(lua_State* L) {
|
||||
"Translation = {"
|
||||
"Type = 'KeplerTranslation',"
|
||||
"Eccentricity = " + std::to_string(planet.ECC) + "," //ECC
|
||||
"SemiMajorAxis = " + std::to_string(planet.A * 0.001f * distanceconstants::AstronomicalUnit) + "," // km
|
||||
"SemiMajorAxis = " + std::to_string(semiMajorAxisInKm) + ","
|
||||
"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 * static_cast<float>(SecondsPerDay)) + ","
|
||||
"Period = " + std::to_string(period) + ","
|
||||
"},"
|
||||
"Color = { 1, 1, 1 }"
|
||||
"},"
|
||||
@@ -437,13 +443,18 @@ int addExoplanetSystem(lua_State* L) {
|
||||
openspace::scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
|
||||
bool hasUpperSemiMajor = !isnan(planet.AUPPER);
|
||||
bool hasLowerSemiMajor = !isnan(planet.ALOWER);
|
||||
bool hasUpperAUncertainty = !isnan(planet.AUPPER);
|
||||
bool hasLowerAUncertainty = !isnan(planet.ALOWER);
|
||||
|
||||
if (hasUpperSemiMajor && hasLowerSemiMajor)
|
||||
if (hasUpperAUncertainty && hasLowerAUncertainty)
|
||||
{
|
||||
// Get the orbit plane that the trail orbit and planet have from the KeplerTranslation
|
||||
glm::dmat4 orbitPlaneRotationMatrix = computeOrbitPlaneRotationMatrix(planet.I, planet.BIGOM, planet.OM, exoplanetSystemRotation);
|
||||
glm::dmat4 orbitPlaneRotationMatrix = computeOrbitPlaneRotationMatrix(
|
||||
planet.I,
|
||||
planet.BIGOM,
|
||||
planet.OM,
|
||||
exoplanetSystemRotation
|
||||
);
|
||||
glm::dmat3 rotation = orbitPlaneRotationMatrix;
|
||||
const std::string discNode = "{"
|
||||
"Identifier = '" + planetName + "Disc',"
|
||||
@@ -452,9 +463,12 @@ int addExoplanetSystem(lua_State* L) {
|
||||
"Renderable = {"
|
||||
"Type = 'RenderableOrbitdisc',"
|
||||
"Texture = openspace.absPath('${MODULE_EXOPLANETS}/disc3.png'),"
|
||||
"Size = " + std::to_string(planet.A * distanceconstants::AstronomicalUnit) + ","
|
||||
"Size = " + std::to_string(semiMajorAxisInMeter) + ","
|
||||
"Eccentricity = " + std::to_string(planet.ECC) + ","
|
||||
"Offset = { " + std::to_string(planet.ALOWER) + ", " + std::to_string(planet.AUPPER) + " }," //min / max extend
|
||||
"Offset = { " +
|
||||
std::to_string(planet.ALOWER) + ", " +
|
||||
std::to_string(planet.AUPPER) +
|
||||
" }," //min / max extend
|
||||
"Opacity = 0.5"
|
||||
"},"
|
||||
"Transform = {"
|
||||
@@ -470,10 +484,11 @@ int addExoplanetSystem(lua_State* L) {
|
||||
openspace::scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
|
||||
bool hasLowerUncertainty = !isnan(planet.ECCLOWER) && planet.ECCLOWER > 0.0;
|
||||
bool hasUpperUncertainty = !isnan(planet.ECCUPPER) && (planet.ECCUPPER > 0.0);
|
||||
// Eccentricity uncertainty
|
||||
bool hasLowerEccUncertainty = !isnan(planet.ECCLOWER) && planet.ECCLOWER > 0.0;
|
||||
bool hasUpperEccUncertainty = !isnan(planet.ECCUPPER) && planet.ECCUPPER > 0.0;
|
||||
|
||||
if (hasLowerUncertainty && hasUpperUncertainty)
|
||||
if (hasLowerEccUncertainty && hasUpperEccUncertainty)
|
||||
{
|
||||
double lowerEccentricity = planet.ECC - planet.ECCLOWER;
|
||||
if (lowerEccentricity < 0.0) {
|
||||
@@ -486,9 +501,12 @@ int addExoplanetSystem(lua_State* L) {
|
||||
"Renderable = {"
|
||||
"Type = 'RenderableOrbitdisc',"
|
||||
"Texture = openspace.absPath('${MODULE_EXOPLANETS}/discL.png'),"
|
||||
"Size = " + std::to_string(planet.A * distanceconstants::AstronomicalUnit) + ","
|
||||
"Size = " + std::to_string(semiMajorAxisInMeter) + ","
|
||||
"Eccentricity = " + std::to_string(lowerEccentricity) + ","
|
||||
"Offset = { " + std::to_string(planet.ALOWER) + ", " + std::to_string(planet.AUPPER) + " }," //min / max extend
|
||||
"Offset = { " +
|
||||
std::to_string(planet.ALOWER) + ", " +
|
||||
std::to_string(planet.AUPPER) +
|
||||
" }," //min / max extend
|
||||
"Opacity = 0.98,"
|
||||
"Enabled = false"
|
||||
"},"
|
||||
@@ -516,9 +534,12 @@ int addExoplanetSystem(lua_State* L) {
|
||||
"Renderable = {"
|
||||
"Type = 'RenderableOrbitdisc',"
|
||||
"Texture = openspace.absPath('${MODULE_EXOPLANETS}/discU.png'),"
|
||||
"Size = " + std::to_string(planet.A * distanceconstants::AstronomicalUnit) + ","
|
||||
"Size = " + std::to_string(semiMajorAxisInMeter) + ","
|
||||
"Eccentricity = " + std::to_string(upperEccentricity) + ","
|
||||
"Offset = { " + std::to_string(planet.ALOWER) + ", " + std::to_string(planet.AUPPER) + " }," //min / max extend
|
||||
"Offset = { " +
|
||||
std::to_string(planet.ALOWER) + ", " +
|
||||
std::to_string(planet.AUPPER) +
|
||||
" }," //min / max extend
|
||||
"Opacity = 0.98,"
|
||||
"Enabled = false"
|
||||
"},"
|
||||
@@ -544,7 +565,7 @@ int addExoplanetSystem(lua_State* L) {
|
||||
int removeExoplanetSystem(lua_State* L) {
|
||||
const int StringLocation = -1;
|
||||
const std::string starName = luaL_checkstring(L, StringLocation);
|
||||
std::string starNameSpeck = getSpeckStarname(starName);
|
||||
std::string starNameSpeck = getSpeckStarName(starName);
|
||||
std::replace(starNameSpeck.begin(), starNameSpeck.end(), ' ', '_');
|
||||
|
||||
openspace::global::scriptEngine.queueScript(
|
||||
|
||||
@@ -126,12 +126,12 @@ void ExoplanetsCsvToBinTask::perform(const Task::ProgressCallback& progressCallb
|
||||
|
||||
Exoplanet p;
|
||||
|
||||
std::string planetname;
|
||||
std::string planetName;
|
||||
std::string component;
|
||||
std::string planetRow;
|
||||
getline(csvFile, planetRow); // The first line, containing the data names
|
||||
|
||||
bool iskeplerobject = false;
|
||||
bool isKeplerObject = false;
|
||||
int total = 0;
|
||||
while (getline(csvFile, planetRow)) {
|
||||
++total;
|
||||
@@ -587,11 +587,11 @@ void ExoplanetsCsvToBinTask::perform(const Task::ProgressCallback& progressCallb
|
||||
getline(lineStream, data, ','); // SPECREF
|
||||
getline(lineStream, data, ','); // SPECURL
|
||||
getline(lineStream, data, ','); // STAR
|
||||
std::string speckStarname = getSpeckStarname(data);
|
||||
glm::vec3 pos = getStarPosition(speckStarname);
|
||||
p.POSITIONX = pos[0];
|
||||
p.POSITIONY = pos[1];
|
||||
p.POSITIONZ = pos[2];
|
||||
std::string speckStarname = getSpeckStarName(data);
|
||||
glm::vec3 position = getStarPosition(speckStarname);
|
||||
p.POSITIONX = position[0];
|
||||
p.POSITIONY = position[1];
|
||||
p.POSITIONZ = position[2];
|
||||
|
||||
getline(lineStream, data, ','); // STARDISCMETH
|
||||
getline(lineStream, data, ','); // T0
|
||||
@@ -660,46 +660,54 @@ void ExoplanetsCsvToBinTask::perform(const Task::ProgressCallback& progressCallb
|
||||
getline(lineStream, data, ','); // VSINIURL
|
||||
getline(lineStream, data, ','); // KEPID
|
||||
if (!data.empty())
|
||||
iskeplerobject = true;
|
||||
isKeplerObject = true;
|
||||
getline(lineStream, data); // KDE
|
||||
|
||||
if (!iskeplerobject) {
|
||||
if (!isKeplerObject) {
|
||||
// calculate B-V from Teff if not exsisting
|
||||
if (std::isnan(p.BMV)) {
|
||||
if (!std::isnan(teff)) {
|
||||
float teff_current, teff_upper, teff_lower, BV, bv_upper, bv_lower = 0;
|
||||
std::ifstream teffToBvFile(
|
||||
absPath("${BASE}/modules/exoplanets/teff_bv.txt")
|
||||
);
|
||||
|
||||
std::ifstream teff_bv(absPath("${BASE}/modules/exoplanets/teff_bv.txt"));
|
||||
if (!teff_bv.good()) {
|
||||
if (!teffToBvFile.good()) {
|
||||
LERROR(fmt::format("Failed to open teff_bv.txt file"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string row, teff_string, bv_string;
|
||||
while (getline(teff_bv, row)) {
|
||||
float BV = 0.f;
|
||||
float bvUpper = 0.f;
|
||||
float bvLower = 0.f;
|
||||
float teffLower, teffUpper;
|
||||
std::string row, teffString, bvString;
|
||||
while (getline(teffToBvFile, row)) {
|
||||
std::istringstream lineStream(row);
|
||||
getline(lineStream, teff_string, ',');
|
||||
getline(lineStream, bv_string);
|
||||
getline(lineStream, teffString, ',');
|
||||
getline(lineStream, bvString);
|
||||
|
||||
teff_current= std::stof(teff_string.c_str(), nullptr);
|
||||
|
||||
if (teff > teff_current) {
|
||||
teff_lower = teff_current;
|
||||
bv_lower = std::stof(bv_string.c_str(), nullptr);
|
||||
float teffCurrent = std::stof(teffString.c_str(), nullptr);
|
||||
float bvCurrent = std::stof(bvString.c_str(), nullptr);
|
||||
|
||||
if (teff > teffCurrent) {
|
||||
teffLower = teffCurrent;
|
||||
bvLower = bvCurrent;
|
||||
}
|
||||
else {
|
||||
teff_upper = teff_current;
|
||||
bv_upper = std::stof(bv_string.c_str(), nullptr);
|
||||
if (bv_lower == 0) {
|
||||
BV = 2.00;
|
||||
teffUpper = teffCurrent;
|
||||
bvUpper = bvCurrent;
|
||||
if (bvLower == 0.f) {
|
||||
BV = 2.f;
|
||||
}
|
||||
else {
|
||||
BV = (((bv_upper - bv_lower) * (teff - teff_lower)) / (teff_upper - teff_lower)) + bv_lower;
|
||||
float bvDiff = (bvUpper - bvLower);
|
||||
float teffDiff = (teffUpper - teffLower);
|
||||
BV = ((bvDiff * (teff - teffLower)) / teffDiff) + bvLower;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
teff_bv.close();
|
||||
teffToBvFile.close();
|
||||
p.BMV = BV;
|
||||
}
|
||||
else {
|
||||
@@ -709,8 +717,8 @@ void ExoplanetsCsvToBinTask::perform(const Task::ProgressCallback& progressCallb
|
||||
|
||||
// crate look-up table
|
||||
long pos = binFile.tellp();
|
||||
planetname = speckStarname + " " + component;
|
||||
lutFile << planetname << "," << pos << std::endl;
|
||||
planetName = speckStarname + " " + component;
|
||||
lutFile << planetName << "," << pos << std::endl;
|
||||
binFile.write((char *)&p, sizeof(Exoplanet));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user