Closed MarkWieczorek closed 1 month ago
Suggestion:
In [1]: print(boule.WGS84)
Class: Ellipsoid
- name = 'WGS84'
- long name = 'World Geodetic System (1984)'
- semimajor axis = 6378137 km
- flattening = 0.0033528106647474805
- geocentric gravitational constant = 398600441800000.0
- angular velocity = 7.292115e-05
- reference = 'Hofmann-Wellenhof, B., & Moritz, H. (2006). Physical Geodesy (2nd, corr. ed. 2006 edition ed.). Wien\u202f; New York: Springer.'
Three other things:
Completely agree that we need a better print(bl.WGS84)
. The __repr__
is created automatically by attrs
and I'd prefer to leave it as is, since __repr__
is supposed to allow eval(a.__repr__) == a
which is what ours currently does (see this stackoverflow answer). But there is also __str__
which is used to make a nice representation of an object. If __str__
is defined, then print(a)
will call a.__str__
instead of __repr__
.
If implementing __str__
, we can make the output nicer by not needing the key : value
format:
>>> print(bl.WGS49)
World Geodetic System (1984) - WGS84
Oblate ellipsoid:
• Semi-major axis: 6378137 m
• Flattening: 0.0033528106647474805
• GM: 398600441800000.0 m³/s²
• Angular velocity: 7.292115e-05 rad/s
From: Hofmann-Wellenhof, B., & Moritz, H. (2006). Physical Geodesy
(2nd, corr. ed. 2006 edition ed.). Wien; New York: Springer.
Another thing we can add in the future is a __repr_html__
to display the ellipsoid using HTML in Jupyter. But that's for another PR when we have this one implemented.
I agree with the ouput format proposed by @leouieda . The only "problem" I see is that formatting the reference in a nice way can be tricky as we don't know where is what. Option can be
For point 2:
reference = {
"author": "Hofmann-Wellenhof, B., & Moritz, H.",
"title": "Physical Geodesy",
"edition": "2nd, corr. ed. 2006",
"publisher": "Springer",
"year": 2006,
"location": "Wien; New York"
}
or using a small class
Reference(
author="Hofmann-Wellenhof, B., & Moritz, H.",
title="Physical Geodesy",
edition="2nd, corr. ed. 2006",
publisher="Springer",
year=2006,
location="Wien; New York"
)
Another problem is that the new ellipsoids can have up to 4 references (one for each of the input parameters). One possible solution would be not to print the reference string at all for __str__
.
What do you think of this layout for __str__
and print
?
Callisto2024 - Callisto spheroid (2024)
Spheroid:
Radius: 2410300 m
GM: 7179292000000.0 m³/s²
Angular velocity: 4.357108150919352e-06 rad/s
Source:
Radius, GM: Anderson, J. D., et al. (2001). Shape, mean radius,
gravity field, and interior structure of Callisto. Icarus, 153(1),
157–161. https://doi.org/10.1006/icar.2001.6664; Angular velocity:
Satellites and the Orientation of the Pole of Jupiter, personal
communication to Horizons/NAIF. Accessed via JPL Solar System
Dynamics, https://ssd.jpl.nasa.gov, JUP365.
Mars2009 - Mars ellipsoid (2009)
Oblate ellipsoid:
Semimajor axis: 3395428 m
Flattening: 0.005227617843759314
GM: 42828372000000.0 m³/s²
Angular velocity: 7.0882181e-05 rad/s
Source:
Ardalan, A. A., Karimi, R., & Grafarend, E. W. (2009). A New Reference
Equipotential Surface, and Reference Ellipsoid for the Planet Mars.
Earth, Moon, and Planets, 106, 1-13. doi:10.1007/s11038-009-9342-7
Io2024 - Io equilibrium triaxial ellipsoid (2024)
Triaxial ellipsoid:
Semimajor axis: 1829700 m
Semimedium axis: 1819200 m
Semiminor axis: 1815800 m
GM: 5959910000000.0 m³/s²
Angular velocity: 4.125530833185668e-05 rad/s
Source:
Semi-axis: Thomas, P. C., et al. (1998). The Shape of Io from Galileo
Limb Measurements. Icarus, 135(1), 175–180.
https://doi.org/10.1006/icar.1998.5987; GM: Anderson, J. D., et al.
(2001). Io's gravity field and interior structure. J. Geophys. Res.,
106, 32963–32969. https://doi.org/10.1029/2000JE001367; Angular
velocity: R. A. Jacobson (2021), The Orbits of the Regular Jovian
Satellites and the Orientation of the Pole of Jupiter, personal
communication to Horizons/NAIF. Accessed via JPL Solar System
Dynamics, https://ssd.jpl.nasa.gov, JUP365.
The "Source" section is a little long when there are mutliple references, but I don't think that we can do anything about it. The only option would be to remove it altogether, and give a not useful partial reference.
Also, for the bi-axial ellipsoid, we could also provide the semiminor axis, which is derived from the flattening and semimajor axis. I'll make a PR if everyone is happy.
I like the idea of @VascoSch92 to have a dataclass for each reference. This way we can choose to only output the minimal information about each reference like authors' names, year and doi.
Alternatively, the reference
property of ellipsoids could be either a single string or a list of strings. This way we can separate each one of them in the output. I do like wrapping the text to 72 characters to support most of the terminals. If each ellipsoid host a list of references, then we can add some indentation to the wrapped lines for each reference.
For example:
Io2024 - Io equilibrium triaxial ellipsoid (2024)
Triaxial ellipsoid:
• Semimajor axis: 1829700 m
• Semimedium axis: 1819200 m
• Semiminor axis: 1815800 m
• Semimajor axis longitude: 0.0°
• GM: 5959910000000.0 m³/s²
• Angular velocity: 4.125530833185668e-05 rad/s
Source:
Semi-axis: Thomas, P. C., et al. (1998). The Shape of Io from Galileo
Limb Measurements. Icarus, 135(1), 175–180.
https://doi.org/10.1006/icar.1998.5987
GM: Anderson, J. D., et al. (2001). Io's gravity field and interior
structure. J. Geophys. Res., 106, 32963–32969.
https://doi.org/10.1029/2000JE001367
Angular velocity: R. A. Jacobson (2021), The Orbits of the Regular
Jovian Satellites and the Orientation of the Pole of Jupiter,
personal communication to Horizons/NAIF. Accessed via JPL Solar
System Dynamics, https://ssd.jpl.nasa.gov, JUP365.
Comments:
Best-fit equilibrium shape
Description of the desired feature: Printing the contents of a boule ellipsoid gives the following:
As this is a really long string, it is somewhat difficult to read if you a looking for a particular element. I propose that we provide an easier way to print the entirety of the ellipsoid contents for human readibility. This could either be by explicitly defining
__repr__
for each ellispoid class or by providing a simple method such asEllipsoid.info()
. The output would look something like this:If desired, we could also append the units, but if we did this, we should probably define the units for each attribute in the class.
Are you willing to help implement and maintain this feature? After we decide on how to do this, the changes would be trivial to make...