diff --git a/boule/_ellipsoid.py b/boule/_ellipsoid.py index cd09085f..b50cc26b 100644 --- a/boule/_ellipsoid.py +++ b/boule/_ellipsoid.py @@ -89,7 +89,16 @@ class Ellipsoid: ... ), ... ) >>> print(ellipsoid) # doctest: +ELLIPSIS - Ellipsoid(name='WGS84', ...) + WGS84 - World Geodetic System 1984 + Oblate ellipsoid: + Semimajor axis: 6378137 m + Flattening: 0.0033528106647474805 + GM: 398600441800000.0 m³/s² + Angular velocity: 7.292115e-05 rad/s + Source: + Hofmann-Wellenhof, B., & Moritz, H. (2006). Physical Geodesy (2nd, + corr. ed. 2006 edition ed.). Wien ; New York: Springer. + >>> print(ellipsoid.long_name) World Geodetic System 1984 @@ -401,11 +410,17 @@ def __str__(self): str += f" Semimajor axis: {self.semimajor_axis} m\n" str += f" Flattening: {self.flattening}\n" str += f" GM: {self.geocentric_grav_const} m³/s²\n" - str += f" Angular velocity: {self.angular_velocity} rad/s\n" - str += "Source:\n" - str += textwrap.fill( - self.reference, width=72, initial_indent=" ", subsequent_indent=" " - ) + str += f" Angular velocity: {self.angular_velocity} rad/s" + if self.reference is not None: + str += "\nSource:\n" + str += textwrap.fill( + self.reference, width=72, initial_indent=" ", subsequent_indent=" " + ) + if self.comments is not None: + str += "\nComments:\n" + str += textwrap.fill( + self.comments, width=72, initial_indent=" ", subsequent_indent=" " + ) return str def geocentric_radius(self, latitude, geodetic=True): diff --git a/boule/_sphere.py b/boule/_sphere.py index 0ae9a085..3759f5e5 100644 --- a/boule/_sphere.py +++ b/boule/_sphere.py @@ -82,7 +82,12 @@ class Sphere: ... angular_velocity=0.5, ... ) >>> print(sphere) # doctest: +ELLIPSIS - Sphere(name='Moon', ...) + Moon - That's no moon + Spheroid: + Radius: 1 m + GM: 2 m³/s² + Angular velocity: 0.5 rad/s + >>> print(sphere.long_name) That's no moon @@ -286,11 +291,17 @@ def __str__(self): str += "Spheroid:\n" str += f" Radius: {self.radius} m\n" str += f" GM: {self.geocentric_grav_const} m³/s²\n" - str += f" Angular velocity: {self.angular_velocity} rad/s\n" - str += "Source:\n" - str += textwrap.fill( - self.reference, width=72, initial_indent=" ", subsequent_indent=" " - ) + str += f" Angular velocity: {self.angular_velocity} rad/s" + if self.reference is not None: + str += "\nSource:\n" + str += textwrap.fill( + self.reference, width=72, initial_indent=" ", subsequent_indent=" " + ) + if self.comments is not None: + str += "\nComments:\n" + str += textwrap.fill( + self.comments, width=72, initial_indent=" ", subsequent_indent=" " + ) return str def normal_gravity(self, latitude, height, si_units=False): diff --git a/boule/_triaxialellipsoid.py b/boule/_triaxialellipsoid.py index 82c01a20..08af73bd 100644 --- a/boule/_triaxialellipsoid.py +++ b/boule/_triaxialellipsoid.py @@ -85,22 +85,37 @@ class TriaxialEllipsoid: We can define an ellipsoid by setting the 5 key numerical parameters: >>> ellipsoid = TriaxialEllipsoid( - ... name="VESTA", + ... name="Vesta", ... long_name="Vesta Triaxial Ellipsoid", - ... semimajor_axis=286_300, - ... semimedium_axis=278_600, - ... semiminor_axis=223_200, - ... geocentric_grav_const=1.729094e10, - ... angular_velocity=326.71050958367e-6, + ... semimajor_axis=280_413, + ... semimedium_axis=274_572, + ... semiminor_axis=231_253, + ... geocentric_grav_const=17.288e9, + ... angular_velocity=3.267e-4, + ... semimajor_axis_longitude=8.29, ... reference=( - ... "Russell, C. T., Raymond, C. A., Coradini, A., McSween, " - ... "H. Y., Zuber, M. T., Nathues, A., et al. (2012). Dawn at " - ... "Vesta: Testing the Protoplanetary Paradigm. Science. " - ... "doi:10.1126/science.1219381" + ... "Karimi, R., Azmoudeh Ardalan, A., & Vasheghani Farahani, S. " + ... "(2017). The size, shape and orientation of the asteroid " + ... "Vesta based on data from the Dawn mission. Earth and " + ... "Planetary Science Letters, 475, 71–82. " + ... "https://doi.org/10.1016/j.epsl.2017.07.033" ... ), ... ) >>> print(ellipsoid) # doctest: +ELLIPSIS - TriaxialEllipsoid(name='VESTA', ...) + Vesta - Vesta Triaxial Ellipsoid + Triaxial ellipsoid: + Semimajor axis: 280413 m + Semimedium axis: 274572 m + Semiminor axis: 231253 m + Semiminor axis longitude: 8.29 + GM: 17288000000.0 m³/s² + Angular velocity: 0.0003267 rad/s + Source: + Karimi, R., Azmoudeh Ardalan, A., & Vasheghani Farahani, S. (2017). + The size, shape and orientation of the asteroid Vesta based on data + from the Dawn mission. Earth and Planetary Science Letters, 475, + 71–82. https://doi.org/10.1016/j.epsl.2017.07.033 + >>> print(ellipsoid.long_name) Vesta Triaxial Ellipsoid @@ -108,21 +123,21 @@ class TriaxialEllipsoid: parameters: >>> print(f"{ellipsoid.mean_radius:.0f} m") - 259813 m + 260344 m >>> print(f"{ellipsoid.semiaxes_mean_radius:.0f} m") - 262700 m + 262079 m >>> print(f"{ellipsoid.area:.10e} m²") - 8.6562393883e+11 m² + 8.6210266337e+11 m² >>> print(f"{ellipsoid.area_equivalent_radius:0.0f} m") - 262458 m + 261924 m >>> print(f"{ellipsoid.volume_equivalent_radius:.0f} m") - 261115 m + 261124 m >>> print(f"{ellipsoid.mass:.10e} kg") - 2.5906746775e+20 kg + 2.5902341819e+20 kg >>> print(f"{ellipsoid.mean_density:.0f} kg/m³") - 3474 kg/m³ + 3473 kg/m³ >>> print(f"{ellipsoid.volume * 1e-9:.0f} km³") - 74573626 km³ + 74581373 km³ """ @@ -332,12 +347,19 @@ def __str__(self): str += f" Semimajor axis: {self.semimajor_axis} m\n" str += f" Semimedium axis: {self.semimedium_axis} m\n" str += f" Semiminor axis: {self.semiminor_axis} m\n" + str += f" Semiminor axis longitude: {self.semimajor_axis_longitude}\n" str += f" GM: {self.geocentric_grav_const} m³/s²\n" - str += f" Angular velocity: {self.angular_velocity} rad/s\n" - str += "Source:\n" - str += textwrap.fill( - self.reference, width=72, initial_indent=" ", subsequent_indent=" " - ) + str += f" Angular velocity: {self.angular_velocity} rad/s" + if self.reference is not None: + str += "\nSource:\n" + str += textwrap.fill( + self.reference, width=72, initial_indent=" ", subsequent_indent=" " + ) + if self.comments is not None: + str += "\nComments:\n" + str += textwrap.fill( + self.comments, width=72, initial_indent=" ", subsequent_indent=" " + ) return str def geocentric_radius(self, longitude, latitude):