Merge lp:~alexwolf/stellarium/apparent-magnitude-algorithm into lp:stellarium
- apparent-magnitude-algorithm
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 7113 |
Proposed branch: | lp:~alexwolf/stellarium/apparent-magnitude-algorithm |
Merge into: | lp:stellarium |
Diff against target: |
411 lines (+196/-104) 4 files modified
src/core/modules/Planet.cpp (+144/-100) src/core/modules/Planet.hpp (+19/-4) src/core/modules/SolarSystem.cpp (+15/-0) src/core/modules/SolarSystem.hpp (+18/-0) |
To merge this branch: | bzr merge lp:~alexwolf/stellarium/apparent-magnitude-algorithm |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
gzotti | Approve | ||
Fabien Chéreau | Pending | ||
Stellarium | Pending | ||
Review via email: mp+240359@code.launchpad.net |
Commit message
Description of the change
This branch extends customization for computation of apparent magnitudes.
I introduced the new option in config.ini "astro/
Possible values for it:
* Planesas (algorithm provided by Pere Planesas (Observatorio Astronomico Nacional))
* Mueller (G. Mueller, based on visual observations 1877-91. [Expl.Suppl.1961])
* Harris (Astronomical Almanac 1984 and later. These give V (instrumental) magnitudes)
I activated Harris's algorithm by default because users asks about "wrong magnitudes for planets", plus all modern astronomical almanacs and websites like JPL's HORIZONS and IMCCE uses this algorithm by default.
I don't added new option to GUI and I think it's shouldn't be added because GUI of the Stellarium are bloated already and this option is proposed for advanced users, who can yourself edit config.ini and know what they are doing.
Alexander Wolf (alexwolf) wrote : | # |
> In principle the idea is very good, given that historical research from early
> 20th century was based on Mueller, and many people nowadays seem to prefer
> comparing instrumental magnitudes. I'd lke to know Planesa's original sources,
> was that some original contribution to Stellarium? (Fabien?)
Sorry, I don't have Planesas original sources (this algorithm was in the code and I just uncommented it).
> However, currently it seems to me this is a property of each planet, which
> seems confusing.
Yes, but I don't know how to avoid crash without applied of this property for all planets.
> I assume users will want a global algorithm setting for all planets.
Huh? It's problematic, because we don't have empirical algorithms for each other planets. Or I just wrongly understood you?
> It should either go into SolarSystem or be a static property of the
> Planet class.
Are you mean the line 121 in Planet.cpp?
> There could be a selector combo in the Config/Information panel:
> Planesas (Stellarium original)
> Mueller (visual mag, [Expl.Suppl. 1961])
> Harris (V mag [Astron. Almanach 1984])
>
> with details in the README. But I don't insist on that.
I'm agree with proposal for README (who read it - maybe we should add it into Help?). But I disagree with proposal for GUI because this feature in really required for little group of the advanced peoples, who make research in archaeoastronomy (or history of astronomy). I hope those peoples can change settings without GUI and we can use the simple GUI yet.
gzotti (georg-zotti) wrote : | # |
> Planesas
I think Fabien may know more on this history. Private communication on known sources (which?), original work, or where is this from?
> Are you mean the line 121 in Planet.cpp?
Ah sorry, I had overlooked this. Yes, then it's fine for me.
At least the wiki manual must be updated to notify users of the possibility to change values, and of possible values for this setting.
- 7113. By Alexander Wolf
-
a tiny fixation
Preview Diff
1 | === modified file 'src/core/modules/Planet.cpp' | |||
2 | --- src/core/modules/Planet.cpp 2014-10-27 16:19:19 +0000 | |||
3 | +++ src/core/modules/Planet.cpp 2014-11-01 17:59:05 +0000 | |||
4 | @@ -55,6 +55,9 @@ | |||
5 | 55 | Planet::RingPlanetShaderVars Planet::ringPlanetShaderVars; | 55 | Planet::RingPlanetShaderVars Planet::ringPlanetShaderVars; |
6 | 56 | QOpenGLShaderProgram* Planet::moonShaderProgram=NULL; | 56 | QOpenGLShaderProgram* Planet::moonShaderProgram=NULL; |
7 | 57 | Planet::MoonShaderVars Planet::moonShaderVars; | 57 | Planet::MoonShaderVars Planet::moonShaderVars; |
8 | 58 | |||
9 | 59 | QMap<Planet::PlanetType, QString> Planet::pTypeMap; | ||
10 | 60 | QMap<Planet::ApparentMagnitudeAlgorithm, QString> Planet::vMagAlgorithmMap; | ||
11 | 58 | 61 | ||
12 | 59 | Planet::Planet(const QString& englishName, | 62 | Planet::Planet(const QString& englishName, |
13 | 60 | int flagLighting, | 63 | int flagLighting, |
14 | @@ -101,9 +104,10 @@ | |||
15 | 101 | 104 | ||
16 | 102 | // Initialize pType with the key found in pTypeMap, or mark planet type as undefined. | 105 | // Initialize pType with the key found in pTypeMap, or mark planet type as undefined. |
17 | 103 | // The latter condition should obviously never happen. | 106 | // The latter condition should obviously never happen. |
19 | 104 | pType=pTypeMap.key(pTypeStr, Planet::isUNDEFINED); | 107 | pType = pTypeMap.key(pTypeStr, Planet::isUNDEFINED); |
20 | 108 | vMagAlgorithm = Planet::UndefinedAlgorithm; | ||
21 | 105 | 109 | ||
23 | 106 | eclipticPos=Vec3d(0.,0.,0.); | 110 | eclipticPos = Vec3d(0.,0.,0.); |
24 | 107 | rotLocalToParent = Mat4d::identity(); | 111 | rotLocalToParent = Mat4d::identity(); |
25 | 108 | texMap = StelApp::getInstance().getTextureManager().createTextureThread(StelFileMgr::getInstallationDir()+"/textures/"+texMapName, StelTexture::StelTextureParams(true, GL_LINEAR, GL_REPEAT)); | 112 | texMap = StelApp::getInstance().getTextureManager().createTextureThread(StelFileMgr::getInstallationDir()+"/textures/"+texMapName, StelTexture::StelTextureParams(true, GL_LINEAR, GL_REPEAT)); |
26 | 109 | normalMap = StelApp::getInstance().getTextureManager().createTextureThread(StelFileMgr::getInstallationDir()+"/textures/"+normalMapName, StelTexture::StelTextureParams(true, GL_LINEAR, GL_REPEAT)); | 113 | normalMap = StelApp::getInstance().getTextureManager().createTextureThread(StelFileMgr::getInstallationDir()+"/textures/"+normalMapName, StelTexture::StelTextureParams(true, GL_LINEAR, GL_REPEAT)); |
27 | @@ -116,8 +120,6 @@ | |||
28 | 116 | flagLabels = true; | 120 | flagLabels = true; |
29 | 117 | } | 121 | } |
30 | 118 | 122 | ||
31 | 119 | QMap<Planet::PlanetType, QString> Planet::pTypeMap; | ||
32 | 120 | |||
33 | 121 | // called in SolarSystem::init() before first planet is created. Loads pTypeMap. | 123 | // called in SolarSystem::init() before first planet is created. Loads pTypeMap. |
34 | 122 | void Planet::init() | 124 | void Planet::init() |
35 | 123 | { | 125 | { |
36 | @@ -133,7 +135,17 @@ | |||
37 | 133 | pTypeMap.insert(Planet::isAsteroid, "asteroid"); | 135 | pTypeMap.insert(Planet::isAsteroid, "asteroid"); |
38 | 134 | pTypeMap.insert(Planet::isPlutoid, "plutoid"); | 136 | pTypeMap.insert(Planet::isPlutoid, "plutoid"); |
39 | 135 | pTypeMap.insert(Planet::isComet, "comet"); | 137 | pTypeMap.insert(Planet::isComet, "comet"); |
41 | 136 | pTypeMap.insert(Planet::isUNDEFINED, "UNDEFINED"); // something must be broken before we ever see this! | 138 | pTypeMap.insert(Planet::isUNDEFINED,"UNDEFINED"); // something must be broken before we ever see this! |
42 | 139 | |||
43 | 140 | if (vMagAlgorithmMap.count() > 0) | ||
44 | 141 | { | ||
45 | 142 | qDebug() << "Planet::init(): Non-empty static map. This is a programming error, but we can fix that."; | ||
46 | 143 | vMagAlgorithmMap.clear(); | ||
47 | 144 | } | ||
48 | 145 | vMagAlgorithmMap.insert(Planet::Planesas, "planesas"); | ||
49 | 146 | vMagAlgorithmMap.insert(Planet::Mueller, "mueller"); | ||
50 | 147 | vMagAlgorithmMap.insert(Planet::Harris, "harris"); | ||
51 | 148 | vMagAlgorithmMap.insert(Planet::UndefinedAlgorithm, ""); | ||
52 | 137 | } | 149 | } |
53 | 138 | 150 | ||
54 | 139 | Planet::~Planet() | 151 | Planet::~Planet() |
55 | @@ -760,108 +772,135 @@ | |||
56 | 760 | { | 772 | { |
57 | 761 | const double phaseDeg=phase*180./M_PI; | 773 | const double phaseDeg=phase*180./M_PI; |
58 | 762 | const double d = 5. * log10(sqrt(observerPlanetRq*planetRq)); | 774 | const double d = 5. * log10(sqrt(observerPlanetRq*planetRq)); |
59 | 763 | //double f1 = phaseDeg/100.; | ||
60 | 764 | 775 | ||
61 | 765 | /* | ||
62 | 766 | // Algorithm provided by Pere Planesas (Observatorio Astronomico Nacional) | ||
63 | 767 | if (englishName=="Mercury") | ||
64 | 768 | { | ||
65 | 769 | if ( phaseDeg > 150. ) f1 = 1.5; | ||
66 | 770 | return -0.36 + d + 3.8*f1 - 2.73*f1*f1 + 2*f1*f1*f1; | ||
67 | 771 | } | ||
68 | 772 | if (englishName=="Venus") | ||
69 | 773 | return -4.29 + d + 0.09*f1 + 2.39*f1*f1 - 0.65*f1*f1*f1; | ||
70 | 774 | if (englishName=="Mars") | ||
71 | 775 | return -1.52 + d + 0.016*phaseDeg; | ||
72 | 776 | if (englishName=="Jupiter") | ||
73 | 777 | return -9.25 + d + 0.005*phaseDeg; | ||
74 | 778 | if (englishName=="Saturn") | ||
75 | 779 | { | ||
76 | 780 | // TODO re-add rings computation | ||
77 | 781 | // double rings = -2.6*sinx + 1.25*sinx*sinx; | ||
78 | 782 | return -8.88 + d + 0.044*phaseDeg;// + rings; | ||
79 | 783 | } | ||
80 | 784 | if (englishName=="Uranus") | ||
81 | 785 | return -7.19 + d + 0.0028*phaseDeg; | ||
82 | 786 | if (englishName=="Neptune") | ||
83 | 787 | return -6.87 + d; | ||
84 | 788 | if (englishName=="Pluto") | ||
85 | 789 | return -1.01 + d + 0.041*phaseDeg; | ||
86 | 790 | */ | ||
87 | 791 | // GZ: I prefer the values given by Meeus, Astronomical Algorithms (1992). | 776 | // GZ: I prefer the values given by Meeus, Astronomical Algorithms (1992). |
88 | 792 | // There are two solutions: | 777 | // There are two solutions: |
89 | 793 | // (1) G. Mueller, based on visual observations 1877-91. [Expl.Suppl.1961] | 778 | // (1) G. Mueller, based on visual observations 1877-91. [Expl.Suppl.1961] |
90 | 794 | // (2) Astronomical Almanac 1984 and later. These give V (instrumental) magnitudes. | 779 | // (2) Astronomical Almanac 1984 and later. These give V (instrumental) magnitudes. |
91 | 795 | // The structure is almost identical, just the numbers are different! | 780 | // The structure is almost identical, just the numbers are different! |
92 | 796 | // I activate (1) for now, because we want to simulate the eye's impression. (Esp. Venus!) | 781 | // I activate (1) for now, because we want to simulate the eye's impression. (Esp. Venus!) |
161 | 797 | // (1) | 782 | // AW: (2) activated by default |
162 | 798 | if (englishName=="Mercury") | 783 | |
163 | 799 | { | 784 | switch (core->getCurrentPlanet()->getApparentMagnitudeAlgorithm()) |
164 | 800 | double ph50=phaseDeg-50.0; | 785 | { |
165 | 801 | return 1.16 + d + 0.02838*ph50 + 0.0001023*ph50*ph50; | 786 | case Planesas: |
166 | 802 | } | 787 | { |
167 | 803 | if (englishName=="Venus") | 788 | // Algorithm provided by Pere Planesas (Observatorio Astronomico Nacional) |
168 | 804 | return -4.0 + d + 0.01322*phaseDeg + 0.0000004247*phaseDeg*phaseDeg*phaseDeg; | 789 | double f1 = phaseDeg/100.; |
169 | 805 | if (englishName=="Mars") | 790 | |
170 | 806 | return -1.3 + d + 0.01486*phaseDeg; | 791 | if (englishName=="Mercury") |
171 | 807 | if (englishName=="Jupiter") | 792 | { |
172 | 808 | return -8.93 + d; | 793 | if ( phaseDeg > 150. ) f1 = 1.5; |
173 | 809 | if (englishName=="Saturn") | 794 | return -0.36 + d + 3.8*f1 - 2.73*f1*f1 + 2*f1*f1*f1; |
174 | 810 | { | 795 | } |
175 | 811 | // add rings computation | 796 | if (englishName=="Venus") |
176 | 812 | // GZ: implemented from Meeus, Astr.Alg.1992 | 797 | return -4.29 + d + 0.09*f1 + 2.39*f1*f1 - 0.65*f1*f1*f1; |
177 | 813 | const double jd=core->getJDay(); | 798 | if (englishName=="Mars") |
178 | 814 | const double T=(jd-2451545.0)/36525.0; | 799 | return -1.52 + d + 0.016*phaseDeg; |
179 | 815 | const double i=((0.000004*T-0.012998)*T+28.075216)*M_PI/180.0; | 800 | if (englishName=="Jupiter") |
180 | 816 | const double Omega=((0.000412*T+1.394681)*T+169.508470)*M_PI/180.0; | 801 | return -9.25 + d + 0.005*phaseDeg; |
181 | 817 | SolarSystem *ssystem=GETSTELMODULE(SolarSystem); | 802 | if (englishName=="Saturn") |
182 | 818 | const Vec3d saturnEarth=getHeliocentricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos(); | 803 | { |
183 | 819 | double lambda=atan2(saturnEarth[1], saturnEarth[0]); | 804 | // add rings computation |
184 | 820 | double beta=atan2(saturnEarth[2], sqrt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1])); | 805 | // implemented from Meeus, Astr.Alg.1992 |
185 | 821 | const double sinB=sin(i)*cos(beta)*sin(lambda-Omega)-cos(i)*sin(beta); | 806 | const double jd=core->getJDay(); |
186 | 822 | double rings = -2.6*fabs(sinB) + 1.25*sinB*sinB; // sinx=sinB, saturnicentric latitude of earth. longish, see Meeus. | 807 | const double T=(jd-2451545.0)/36525.0; |
187 | 823 | return -8.68 + d + 0.044*phaseDeg + rings; | 808 | const double i=((0.000004*T-0.012998)*T+28.075216)*M_PI/180.0; |
188 | 824 | } | 809 | const double Omega=((0.000412*T+1.394681)*T+169.508470)*M_PI/180.0; |
189 | 825 | if (englishName=="Uranus") | 810 | static SolarSystem *ssystem=GETSTELMODULE(SolarSystem); |
190 | 826 | return -6.85 + d; | 811 | const Vec3d saturnEarth=getHeliocentricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos(); |
191 | 827 | if (englishName=="Neptune") | 812 | double lambda=atan2(saturnEarth[1], saturnEarth[0]); |
192 | 828 | return -7.05 + d; | 813 | double beta=atan2(saturnEarth[2], sqrt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1])); |
193 | 829 | if (englishName=="Pluto") | 814 | const double sinx=sin(i)*cos(beta)*sin(lambda-Omega)-cos(i)*sin(beta); |
194 | 830 | return -1.0 + d; | 815 | double rings = -2.6*sinx + 1.25*sinx*sinx; |
195 | 831 | /* | 816 | return -8.88 + d + 0.044*phaseDeg + rings; |
196 | 832 | // (2) | 817 | } |
197 | 833 | if (englishName=="Mercury") | 818 | if (englishName=="Uranus") |
198 | 834 | return 0.42 + d + .038*phaseDeg - 0.000273*phaseDeg*phaseDeg + 0.000002*phaseDeg*phaseDeg*phaseDeg; | 819 | return -7.19 + d + 0.0028*phaseDeg; |
199 | 835 | if (englishName=="Venus") | 820 | if (englishName=="Neptune") |
200 | 836 | return -4.40 + d + 0.0009*phaseDeg + 0.000239*phaseDeg*phaseDeg - 0.00000065*phaseDeg*phaseDeg*phaseDeg; | 821 | return -6.87 + d; |
201 | 837 | if (englishName=="Mars") | 822 | if (englishName=="Pluto") |
202 | 838 | return -1.52 + d + 0.016*phaseDeg; | 823 | return -1.01 + d + 0.041*phaseDeg; |
203 | 839 | if (englishName=="Jupiter") | 824 | |
204 | 840 | return -9.40 + d + 0.005*phaseDeg; | 825 | break; |
205 | 841 | if (englishName=="Saturn") | 826 | } |
206 | 842 | { | 827 | case Mueller: |
207 | 843 | // add rings computation | 828 | { |
208 | 844 | // GZ: implemented from Meeus, Astr.Alg.1992 | 829 | // (1) |
209 | 845 | const double jd=core->getJDay(); | 830 | if (englishName=="Mercury") |
210 | 846 | const double T=(jd-2451545.0)/36525.0; | 831 | { |
211 | 847 | const double i=((0.000004*T-0.012998)*T+28.075216)*M_PI/180.0; | 832 | double ph50=phaseDeg-50.0; |
212 | 848 | const double Omega=((0.000412*T+1.394681)*T+169.508470)*M_PI/180.0; | 833 | return 1.16 + d + 0.02838*ph50 + 0.0001023*ph50*ph50; |
213 | 849 | static SolarSystem *ssystem=GETSTELMODULE(SolarSystem); | 834 | } |
214 | 850 | const Vec3d saturnEarth=getHeliocentricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos(); | 835 | if (englishName=="Venus") |
215 | 851 | double lambda=atan2(saturnEarth[1], saturnEarth[0]); | 836 | return -4.0 + d + 0.01322*phaseDeg + 0.0000004247*phaseDeg*phaseDeg*phaseDeg; |
216 | 852 | double beta=atan2(saturnEarth[2], sqrt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1])); | 837 | if (englishName=="Mars") |
217 | 853 | const double sinB=sin(i)*cos(beta)*sin(lambda-Omega)-cos(i)*sin(beta); | 838 | return -1.3 + d + 0.01486*phaseDeg; |
218 | 854 | double rings = -2.6*fabs(sinB) + 1.25*sinB*sinB; // sinx=sinB, saturnicentric latitude of earth. longish, see Meeus. | 839 | if (englishName=="Jupiter") |
219 | 855 | return -8.88 + d + 0.044*phaseDeg + rings; | 840 | return -8.93 + d; |
220 | 856 | } | 841 | if (englishName=="Saturn") |
221 | 857 | if (englishName=="Uranus") | 842 | { |
222 | 858 | return -7.19f + d; | 843 | // add rings computation |
223 | 859 | if (englishName=="Neptune") | 844 | // implemented from Meeus, Astr.Alg.1992 |
224 | 860 | return -6.87f + d; | 845 | const double jd=core->getJDay(); |
225 | 861 | if (englishName=="Pluto") | 846 | const double T=(jd-2451545.0)/36525.0; |
226 | 862 | return -1.00f + d; | 847 | const double i=((0.000004*T-0.012998)*T+28.075216)*M_PI/180.0; |
227 | 863 | */ | 848 | const double Omega=((0.000412*T+1.394681)*T+169.508470)*M_PI/180.0; |
228 | 864 | // TODO: decide which set of formulae is best? | 849 | SolarSystem *ssystem=GETSTELMODULE(SolarSystem); |
229 | 850 | const Vec3d saturnEarth=getHeliocentricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos(); | ||
230 | 851 | double lambda=atan2(saturnEarth[1], saturnEarth[0]); | ||
231 | 852 | double beta=atan2(saturnEarth[2], sqrt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1])); | ||
232 | 853 | const double sinB=sin(i)*cos(beta)*sin(lambda-Omega)-cos(i)*sin(beta); | ||
233 | 854 | double rings = -2.6*fabs(sinB) + 1.25*sinB*sinB; // sinx=sinB, saturnicentric latitude of earth. longish, see Meeus. | ||
234 | 855 | return -8.68 + d + 0.044*phaseDeg + rings; | ||
235 | 856 | } | ||
236 | 857 | if (englishName=="Uranus") | ||
237 | 858 | return -6.85 + d; | ||
238 | 859 | if (englishName=="Neptune") | ||
239 | 860 | return -7.05 + d; | ||
240 | 861 | if (englishName=="Pluto") | ||
241 | 862 | return -1.0 + d; | ||
242 | 863 | |||
243 | 864 | break; | ||
244 | 865 | } | ||
245 | 866 | case Harris: | ||
246 | 867 | case UndefinedAlgorithm: // activated by default | ||
247 | 868 | { | ||
248 | 869 | // (2) | ||
249 | 870 | if (englishName=="Mercury") | ||
250 | 871 | return 0.42 + d + .038*phaseDeg - 0.000273*phaseDeg*phaseDeg + 0.000002*phaseDeg*phaseDeg*phaseDeg; | ||
251 | 872 | if (englishName=="Venus") | ||
252 | 873 | return -4.40 + d + 0.0009*phaseDeg + 0.000239*phaseDeg*phaseDeg - 0.00000065*phaseDeg*phaseDeg*phaseDeg; | ||
253 | 874 | if (englishName=="Mars") | ||
254 | 875 | return -1.52 + d + 0.016*phaseDeg; | ||
255 | 876 | if (englishName=="Jupiter") | ||
256 | 877 | return -9.40 + d + 0.005*phaseDeg; | ||
257 | 878 | if (englishName=="Saturn") | ||
258 | 879 | { | ||
259 | 880 | // add rings computation | ||
260 | 881 | // implemented from Meeus, Astr.Alg.1992 | ||
261 | 882 | const double jd=core->getJDay(); | ||
262 | 883 | const double T=(jd-2451545.0)/36525.0; | ||
263 | 884 | const double i=((0.000004*T-0.012998)*T+28.075216)*M_PI/180.0; | ||
264 | 885 | const double Omega=((0.000412*T+1.394681)*T+169.508470)*M_PI/180.0; | ||
265 | 886 | static SolarSystem *ssystem=GETSTELMODULE(SolarSystem); | ||
266 | 887 | const Vec3d saturnEarth=getHeliocentricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos(); | ||
267 | 888 | double lambda=atan2(saturnEarth[1], saturnEarth[0]); | ||
268 | 889 | double beta=atan2(saturnEarth[2], sqrt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1])); | ||
269 | 890 | const double sinB=sin(i)*cos(beta)*sin(lambda-Omega)-cos(i)*sin(beta); | ||
270 | 891 | double rings = -2.6*fabs(sinB) + 1.25*sinB*sinB; // sinx=sinB, saturnicentric latitude of earth. longish, see Meeus. | ||
271 | 892 | return -8.88 + d + 0.044*phaseDeg + rings; | ||
272 | 893 | } | ||
273 | 894 | if (englishName=="Uranus") | ||
274 | 895 | return -7.19f + d; | ||
275 | 896 | if (englishName=="Neptune") | ||
276 | 897 | return -6.87f + d; | ||
277 | 898 | if (englishName=="Pluto") | ||
278 | 899 | return -1.00f + d; | ||
279 | 900 | |||
280 | 901 | break; | ||
281 | 902 | } | ||
282 | 903 | } | ||
283 | 865 | } | 904 | } |
284 | 866 | 905 | ||
285 | 867 | // This formula seems to give wrong results | 906 | // This formula seems to give wrong results |
286 | @@ -1707,3 +1746,8 @@ | |||
287 | 1707 | labelsFader.update(deltaTime); | 1746 | labelsFader.update(deltaTime); |
288 | 1708 | orbitFader.update(deltaTime); | 1747 | orbitFader.update(deltaTime); |
289 | 1709 | } | 1748 | } |
290 | 1749 | |||
291 | 1750 | void Planet::setApparentMagnitudeAlgorithm(QString algorithm) | ||
292 | 1751 | { | ||
293 | 1752 | vMagAlgorithm = vMagAlgorithmMap.key(algorithm.toLower(), Planet::UndefinedAlgorithm); | ||
294 | 1753 | } | ||
295 | 1710 | 1754 | ||
296 | === modified file 'src/core/modules/Planet.hpp' | |||
297 | --- src/core/modules/Planet.hpp 2014-08-31 10:34:41 +0000 | |||
298 | +++ src/core/modules/Planet.hpp 2014-11-01 17:59:05 +0000 | |||
299 | @@ -76,6 +76,7 @@ | |||
300 | 76 | friend class SolarSystem; | 76 | friend class SolarSystem; |
301 | 77 | 77 | ||
302 | 78 | Q_ENUMS(PlanetType) | 78 | Q_ENUMS(PlanetType) |
303 | 79 | Q_ENUMS(ApparentMagnitudeAlgorithm) | ||
304 | 79 | //! numeric typecodes for the type descriptions in ssystem.ini | 80 | //! numeric typecodes for the type descriptions in ssystem.ini |
305 | 80 | // GZ: Until 0.13 QStrings were used for types. | 81 | // GZ: Until 0.13 QStrings were used for types. |
306 | 81 | // GZ: Enums are slightly faster than string comparisons in time-critical comparisons. | 82 | // GZ: Enums are slightly faster than string comparisons in time-critical comparisons. |
307 | @@ -91,6 +92,14 @@ | |||
308 | 91 | isUNDEFINED // ssystem.ini: type=<anything else> | 92 | isUNDEFINED // ssystem.ini: type=<anything else> |
309 | 92 | }; | 93 | }; |
310 | 93 | 94 | ||
311 | 95 | enum ApparentMagnitudeAlgorithm | ||
312 | 96 | { | ||
313 | 97 | Planesas, // Algorithm provided by Pere Planesas (Observatorio Astronomico Nacional) | ||
314 | 98 | Mueller, // G. Mueller, based on visual observations 1877-91. [Expl.Suppl.1961] | ||
315 | 99 | Harris, // Astronomical Almanac 1984 and later. These give V (instrumental) magnitudes (D.L. Harris) | ||
316 | 100 | UndefinedAlgorithm | ||
317 | 101 | }; | ||
318 | 102 | |||
319 | 94 | Planet(const QString& englishName, | 103 | Planet(const QString& englishName, |
320 | 95 | int flagLighting, | 104 | int flagLighting, |
321 | 96 | double radius, | 105 | double radius, |
322 | @@ -170,6 +179,10 @@ | |||
323 | 170 | const QString getPlanetTypeString() const {return pTypeMap.value(pType);} | 179 | const QString getPlanetTypeString() const {return pTypeMap.value(pType);} |
324 | 171 | PlanetType getPlanetType() const {return pType;} | 180 | PlanetType getPlanetType() const {return pType;} |
325 | 172 | 181 | ||
326 | 182 | ApparentMagnitudeAlgorithm getApparentMagnitudeAlgorithm() const { return vMagAlgorithm; } | ||
327 | 183 | const QString getApparentMagnitudeAlgorithmString() const { return vMagAlgorithmMap.value(vMagAlgorithm); } | ||
328 | 184 | void setApparentMagnitudeAlgorithm(QString algorithm); | ||
329 | 185 | |||
330 | 173 | // Compute the z rotation to use from equatorial to geographic coordinates | 186 | // Compute the z rotation to use from equatorial to geographic coordinates |
331 | 174 | double getSiderealTime(double jd) const; | 187 | double getSiderealTime(double jd) const; |
332 | 175 | Mat4d getRotEquatorialToVsop87(void) const; | 188 | Mat4d getRotEquatorialToVsop87(void) const; |
333 | @@ -313,13 +326,15 @@ | |||
334 | 313 | bool flagLabels; // Define whether labels should be displayed | 326 | bool flagLabels; // Define whether labels should be displayed |
335 | 314 | bool hidden; // useful for fake planets used as observation positions - not drawn or labeled | 327 | bool hidden; // useful for fake planets used as observation positions - not drawn or labeled |
336 | 315 | bool atmosphere; // Does the planet have an atmosphere? | 328 | bool atmosphere; // Does the planet have an atmosphere? |
340 | 316 | bool halo; // Does the planet have a halo? | 329 | bool halo; // Does the planet have a halo? |
341 | 317 | // QString pTypeStr; // Type of body, old version just had a string here. | 330 | PlanetType pType; // Type of body |
342 | 318 | PlanetType pType; // GZ this is now a proper type... | 331 | |
343 | 332 | ApparentMagnitudeAlgorithm vMagAlgorithm; | ||
344 | 319 | 333 | ||
345 | 320 | static Vec3f labelColor; | 334 | static Vec3f labelColor; |
346 | 321 | static StelTextureSP hintCircleTex; | 335 | static StelTextureSP hintCircleTex; |
348 | 322 | static QMap<PlanetType, QString> pTypeMap; // GZ: maps fast type to english name. | 336 | static QMap<PlanetType, QString> pTypeMap; // Maps fast type to english name. |
349 | 337 | static QMap<ApparentMagnitudeAlgorithm, QString> vMagAlgorithmMap; | ||
350 | 323 | 338 | ||
351 | 324 | // Shader-related variables | 339 | // Shader-related variables |
352 | 325 | struct PlanetShaderVars { | 340 | struct PlanetShaderVars { |
353 | 326 | 341 | ||
354 | === modified file 'src/core/modules/SolarSystem.cpp' | |||
355 | --- src/core/modules/SolarSystem.cpp 2014-08-31 10:34:41 +0000 | |||
356 | +++ src/core/modules/SolarSystem.cpp 2014-11-01 17:59:05 +0000 | |||
357 | @@ -136,6 +136,9 @@ | |||
358 | 136 | setFlagOrbits(conf->value("astro/flag_planets_orbits").toBool()); | 136 | setFlagOrbits(conf->value("astro/flag_planets_orbits").toBool()); |
359 | 137 | setFlagLightTravelTime(conf->value("astro/flag_light_travel_time", false).toBool()); | 137 | setFlagLightTravelTime(conf->value("astro/flag_light_travel_time", false).toBool()); |
360 | 138 | setFlagMarkers(conf->value("astro/flag_planets_markers", true).toBool()); | 138 | setFlagMarkers(conf->value("astro/flag_planets_markers", true).toBool()); |
361 | 139 | // Set the algorithm from Astronomical Almanac for computation of apparent magnitudes for | ||
362 | 140 | // planets in case observer on the Earth by default | ||
363 | 141 | setApparentMagnitudeAlgorithmOnEarth(conf->value("astro/apparent_magnitude_algorithm", "Harris").toString()); | ||
364 | 139 | 142 | ||
365 | 140 | recreateTrails(); | 143 | recreateTrails(); |
366 | 141 | 144 | ||
367 | @@ -1520,3 +1523,15 @@ | |||
368 | 1520 | // Restore translations | 1523 | // Restore translations |
369 | 1521 | updateI18n(); | 1524 | updateI18n(); |
370 | 1522 | } | 1525 | } |
371 | 1526 | |||
372 | 1527 | // Set the algorithm for computation of apparent magnitudes for planets in case observer on the Earth | ||
373 | 1528 | void SolarSystem::setApparentMagnitudeAlgorithmOnEarth(QString algorithm) | ||
374 | 1529 | { | ||
375 | 1530 | getEarth()->setApparentMagnitudeAlgorithm(algorithm); | ||
376 | 1531 | } | ||
377 | 1532 | |||
378 | 1533 | // Get the algorithm used for computation of apparent magnitudes for planets in case observer on the Earth | ||
379 | 1534 | QString SolarSystem::getApparentMagnitudeAlgorithmOnEarth() const | ||
380 | 1535 | { | ||
381 | 1536 | return getEarth()->getApparentMagnitudeAlgorithmString(); | ||
382 | 1537 | } | ||
383 | 1523 | 1538 | ||
384 | === modified file 'src/core/modules/SolarSystem.hpp' | |||
385 | --- src/core/modules/SolarSystem.hpp 2014-08-30 16:58:25 +0000 | |||
386 | +++ src/core/modules/SolarSystem.hpp 2014-11-01 17:59:05 +0000 | |||
387 | @@ -261,6 +261,24 @@ | |||
388 | 261 | //! @return a phase | 261 | //! @return a phase |
389 | 262 | float getPhaseForPlanet(QString planetName) const; | 262 | float getPhaseForPlanet(QString planetName) const; |
390 | 263 | 263 | ||
391 | 264 | //! Set the algorithm for computation of apparent magnitudes for planets in case observer on the Earth. | ||
392 | 265 | //! Possible values: | ||
393 | 266 | //! * Planesas (algorithm provided by Pere Planesas (Observatorio Astronomico Nacional)) | ||
394 | 267 | //! * Mueller (G. Mueller, based on visual observations 1877-91. [Expl.Suppl.1961]) | ||
395 | 268 | //! * Harris (Astronomical Almanac 1984 and later. These give V (instrumental) magnitudes) | ||
396 | 269 | //! Details: | ||
397 | 270 | //! J. Meeus "Astronomical Algorithms" (2nd ed., with corrections as of August 10, 2009) p.283-286. | ||
398 | 271 | //! O. Montenbruck, T. Pfleger "Astronomy on the Personal Computer" (4th ed.) p.143-145. | ||
399 | 272 | //! Daniel L. Harris "Photometry and Colorimetry of Planets and Satellites" http://adsabs.harvard.edu/abs/1961plsa.book..272H | ||
400 | 273 | //! Hint: Default option in config.ini: astro/apparent_magnitude_algorithm = Harris | ||
401 | 274 | //! @param algorithm the case in-sensitive algorithm name | ||
402 | 275 | //! @note: The structure of algorithms is almost identical, just the numbers are different! You should activate | ||
403 | 276 | //! Mueller's algorithm for simulate the eye's impression. (Esp. Venus!) | ||
404 | 277 | void setApparentMagnitudeAlgorithmOnEarth(QString algorithm); | ||
405 | 278 | |||
406 | 279 | //! Get the algorithm used for computation of apparent magnitudes for planets in case observer on the Earth | ||
407 | 280 | QString getApparentMagnitudeAlgorithmOnEarth() const; | ||
408 | 281 | |||
409 | 264 | public: | 282 | public: |
410 | 265 | /////////////////////////////////////////////////////////////////////////// | 283 | /////////////////////////////////////////////////////////////////////////// |
411 | 266 | // Other public methods | 284 | // Other public methods |
In principle the idea is very good, given that historical research from early 20th century was based on Mueller, and many people nowadays seem to prefer comparing instrumental magnitudes. I'd lke to know Planesa's original sources, was that some original contribution to Stellarium? (Fabien?)
However, currently it seems to me this is a property of each planet, which seems confusing. I assume users will want a global algorithm setting for all planets. It should either go into SolarSystem or be a static property of the Planet class. There is also a small typo, see below (lowercasing - ah, it's auto-corrected ...).
There could be a selector combo in the Config/Information panel:
Planesas (Stellarium original)
Mueller (visual mag, [Expl.Suppl. 1961])
Harris (V mag [Astron. Almanach 1984])
with details in the README. But I don't insist on that.