naturedynamics 1.1__tar.gz → 1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. {naturedynamics-1.1 → naturedynamics-1.2}/PKG-INFO +1 -1
  2. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/__init__.py +1 -1
  3. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/astrophysics/atmospheric.py +10 -0
  4. naturedynamics-1.2/naturedynamics/astrophysics/orbital.py +161 -0
  5. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/astrophysics/photometry.py +11 -0
  6. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics.egg-info/PKG-INFO +1 -1
  7. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics.egg-info/SOURCES.txt +1 -0
  8. {naturedynamics-1.1 → naturedynamics-1.2}/pyproject.toml +1 -1
  9. {naturedynamics-1.1 → naturedynamics-1.2}/LICENSE +0 -0
  10. {naturedynamics-1.1 → naturedynamics-1.2}/README.md +0 -0
  11. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/applications/__init__.py +0 -0
  12. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/applications/energy.py +0 -0
  13. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/applications/engineering.py +0 -0
  14. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/applications/environmental.py +0 -0
  15. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/applications/medical.py +0 -0
  16. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/astrophysics/__init__.py +0 -0
  17. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/astrophysics/cosmology.py +0 -0
  18. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/astrophysics/galactic.py +0 -0
  19. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/astrophysics/magnetism.py +0 -0
  20. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/astrophysics/planetary.py +0 -0
  21. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/astrophysics/stellar.py +0 -0
  22. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/astrophysics/tidal.py +0 -0
  23. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/biophysics/__init__.py +0 -0
  24. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/biophysics/biomechanics.py +0 -0
  25. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/biophysics/diffusion.py +0 -0
  26. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/biophysics/membrane.py +0 -0
  27. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/biophysics/neuroscience.py +0 -0
  28. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/biophysics/photosynthesis.py +0 -0
  29. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/computational/__init__.py +0 -0
  30. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/computational/finite_elements.py +0 -0
  31. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/computational/monte_carlo.py +0 -0
  32. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/computational/numerical_methods.py +0 -0
  33. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/computational/optimization.py +0 -0
  34. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/constants.py +0 -0
  35. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/data/CIE_CMF.py +0 -0
  36. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/data/__init__.py +0 -0
  37. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/data/materials/__init__.py +0 -0
  38. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/data/materials/materials.py +0 -0
  39. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/data/spectroscopic_data/__init__.py +0 -0
  40. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/data/spectroscopic_data/spectra.py +0 -0
  41. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/electromagnetism/__init__.py +0 -0
  42. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/electromagnetism/circuits.py +0 -0
  43. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/electromagnetism/electrostatics.py +0 -0
  44. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/electromagnetism/magnetostatics.py +0 -0
  45. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/electromagnetism/maxwell.py +0 -0
  46. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/electromagnetism/optics.py +0 -0
  47. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/electromagnetism/waves.py +0 -0
  48. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/experimental/__init__.py +0 -0
  49. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/experimental/data_analysis.py +0 -0
  50. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/experimental/error_analysis.py +0 -0
  51. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/experimental/instrumentation.py +0 -0
  52. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/experimental/measurement.py +0 -0
  53. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/laws/__init__.py +0 -0
  54. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/laws/conservation.py +0 -0
  55. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/laws/electromagnetic.py +0 -0
  56. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/laws/momentum.py +0 -0
  57. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/laws/newtons_laws.py +0 -0
  58. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/laws/work_energy.py +0 -0
  59. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mathematical/__init__.py +0 -0
  60. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mathematical/complex_analysis.py +0 -0
  61. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mathematical/differential_equations.py +0 -0
  62. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mathematical/group_theory.py +0 -0
  63. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mathematical/mathematical_neuroscience.py +0 -0
  64. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mathematical/special_functions.py +0 -0
  65. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mathematical/tensor_calculus.py +0 -0
  66. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mechanics/__init__.py +0 -0
  67. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mechanics/continuum.py +0 -0
  68. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mechanics/dynamics.py +0 -0
  69. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mechanics/fluid_mechanics.py +0 -0
  70. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mechanics/kinematics.py +0 -0
  71. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mechanics/lagrangian.py +0 -0
  72. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mechanics/rotational_mechanics.py +0 -0
  73. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mechanics/sound.py +0 -0
  74. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mechanics/statics.py +0 -0
  75. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/mechanics/stress_strain.py +0 -0
  76. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/nuclear/__init__.py +0 -0
  77. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/nuclear/binding_energy.py +0 -0
  78. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/nuclear/decay.py +0 -0
  79. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/nuclear/fission_fusion.py +0 -0
  80. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/nuclear/particles.py +0 -0
  81. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/nuclear/reactions.py +0 -0
  82. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/oscillations/__init__.py +0 -0
  83. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/oscillations/acoustics.py +0 -0
  84. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/oscillations/coupled_oscillators.py +0 -0
  85. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/oscillations/shm.py +0 -0
  86. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/oscillations/vibrations.py +0 -0
  87. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/oscillations/wave_oscillation.py +0 -0
  88. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/plasma/__init__.py +0 -0
  89. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/plasma/basic.py +0 -0
  90. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/plasma/kinetic.py +0 -0
  91. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/plasma/magnetohydrodynamics.py +0 -0
  92. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/plasma/waves.py +0 -0
  93. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/quantum/__init__.py +0 -0
  94. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/quantum/harmonic_oscillator.py +0 -0
  95. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/quantum/hydrogen_atom.py +0 -0
  96. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/quantum/operators.py +0 -0
  97. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/quantum/perturbation.py +0 -0
  98. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/quantum/spin.py +0 -0
  99. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/quantum/statistics.py +0 -0
  100. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/quantum/tunneling.py +0 -0
  101. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/quantum/wave_functions.py +0 -0
  102. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/relativity/__init__.py +0 -0
  103. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/relativity/cosmology.py +0 -0
  104. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/relativity/general.py +0 -0
  105. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/relativity/spacetime.py +0 -0
  106. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/relativity/special.py +0 -0
  107. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/solidstate/__init__.py +0 -0
  108. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/solidstate/crystal_structure.py +0 -0
  109. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/solidstate/electronic.py +0 -0
  110. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/solidstate/magnetic.py +0 -0
  111. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/solidstate/phonons.py +0 -0
  112. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/solidstate/superconductivity.py +0 -0
  113. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/solutions/__init__.py +0 -0
  114. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/solutions/atomic.py +0 -0
  115. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/solutions/field_theory.py +0 -0
  116. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/solutions/molecular.py +0 -0
  117. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/solutions/operators.py +0 -0
  118. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/solutions/statistical.py +0 -0
  119. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/statistical_mechanics/__init__.py +0 -0
  120. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/statistical_mechanics/critical_phenomena.py +0 -0
  121. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/statistical_mechanics/distributions.py +0 -0
  122. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/statistical_mechanics/partition_functions.py +0 -0
  123. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/statistical_mechanics/quantum_statistics.py +0 -0
  124. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/thermodynamics/__init__.py +0 -0
  125. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/thermodynamics/heat_engines.py +0 -0
  126. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/thermodynamics/heat_transfer.py +0 -0
  127. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/thermodynamics/laws.py +0 -0
  128. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/thermodynamics/phase_transitions.py +0 -0
  129. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/tools/__init__.py +0 -0
  130. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/tools/calculators.py +0 -0
  131. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/tools/exporters.py +0 -0
  132. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/tools/simulators.py +0 -0
  133. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/tools/visualizers.py +0 -0
  134. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/utils/__init__.py +0 -0
  135. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/utils/conversions.py +0 -0
  136. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/utils/decorators.py +0 -0
  137. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/utils/plotting.py +0 -0
  138. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/utils/units.py +0 -0
  139. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics/utils/validators.py +0 -0
  140. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics.egg-info/dependency_links.txt +0 -0
  141. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics.egg-info/requires.txt +0 -0
  142. {naturedynamics-1.1 → naturedynamics-1.2}/naturedynamics.egg-info/top_level.txt +0 -0
  143. {naturedynamics-1.1 → naturedynamics-1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: naturedynamics
3
- Version: 1.1
3
+ Version: 1.2
4
4
  Summary: A comprehensive physics library providing constants, equations, and formulas
5
5
  Author-email: Fabian Schober <reach@fabianschober.com>
6
6
  License: MIT
@@ -2,4 +2,4 @@
2
2
 
3
3
  from . import constants
4
4
 
5
- __version__ = "1.1"
5
+ __version__ = "1.2"
@@ -75,3 +75,13 @@ def mixture_refractivity(composition, refractivity_table):
75
75
  percent / total * refractivity_table[species]
76
76
  for species, percent in composition.items()
77
77
  )
78
+
79
+
80
+ def scale_height(temperature, molar_mass, gravity):
81
+ """Isothermal atmospheric scale height H = R T / (M g): the height over
82
+ which pressure and density fall by a factor of e.
83
+
84
+ Args: temperature (K), mean molar mass (kg/mol), gravity (m/s^2).
85
+ Returns: H (m). Earth at 288 K: ~8.4 km.
86
+ """
87
+ return GAS_CONSTANT * temperature / (molar_mass * gravity)
@@ -0,0 +1,161 @@
1
+ """Two-body orbits: where a body is, given its orbital elements.
2
+
3
+ Conventions follow Murray & Dermott, *Solar System Dynamics* (Cambridge
4
+ University Press, 1999), chapter 2, https://doi.org/10.1017/CBO9781139174817:
5
+ angles in radians; the reference plane is the x-y plane and the reference
6
+ direction +x; the longitude of the ascending node (raan) is measured in the
7
+ reference plane from +x, the argument of periapsis in the orbital plane from
8
+ the ascending node, and the true anomaly from periapsis.
9
+ """
10
+
11
+ import math
12
+
13
+
14
+ def conic_radius(semi_major_axis, eccentricity, true_anomaly):
15
+ """
16
+ Distance from the focus at a point of an elliptical orbit.
17
+
18
+ r = a (1 - e^2) / (1 + e cos f), Murray & Dermott eq. 2.20.
19
+
20
+ Args:
21
+ semi_major_axis (float): a (any length unit)
22
+ eccentricity (float): e, 0 <= e < 1
23
+ true_anomaly (float): f, angle from periapsis (rad)
24
+
25
+ Returns:
26
+ float: r, in the unit of semi_major_axis
27
+ """
28
+ return (
29
+ semi_major_axis
30
+ * (1 - eccentricity**2)
31
+ / (1 + eccentricity * math.cos(true_anomaly))
32
+ )
33
+
34
+
35
+ def orbital_position(
36
+ semi_major_axis,
37
+ eccentricity,
38
+ inclination,
39
+ raan,
40
+ argument_of_periapsis,
41
+ true_anomaly,
42
+ ):
43
+ """
44
+ Position of an orbiting body relative to the focus, in the reference frame.
45
+
46
+ Murray & Dermott eq. 2.122: the perifocal position rotated by the
47
+ argument of periapsis, the inclination and the ascending node in turn.
48
+
49
+ Args:
50
+ semi_major_axis (float): a (any length unit)
51
+ eccentricity (float): e, 0 <= e < 1
52
+ inclination (float): i, tilt of the orbital plane (rad)
53
+ raan (float): longitude of the ascending node, Omega (rad)
54
+ argument_of_periapsis (float): omega (rad)
55
+ true_anomaly (float): f (rad)
56
+
57
+ Returns:
58
+ tuple: (x, y, z) in the unit of semi_major_axis
59
+ """
60
+ r = conic_radius(semi_major_axis, eccentricity, true_anomaly)
61
+ u = argument_of_periapsis + true_anomaly
62
+ return (
63
+ r * (math.cos(raan) * math.cos(u) - math.sin(raan) * math.sin(u) * math.cos(inclination)),
64
+ r * (math.sin(raan) * math.cos(u) + math.cos(raan) * math.sin(u) * math.cos(inclination)),
65
+ r * math.sin(u) * math.sin(inclination),
66
+ )
67
+
68
+
69
+ def orbit_normal(inclination, raan):
70
+ """
71
+ Unit vector along the orbit's angular momentum (its north pole).
72
+
73
+ Murray & Dermott eq. 2.125, divided by the angular momentum's magnitude.
74
+
75
+ Args:
76
+ inclination (float): i (rad)
77
+ raan (float): Omega (rad)
78
+
79
+ Returns:
80
+ tuple: (x, y, z), unit length
81
+ """
82
+ return (
83
+ math.sin(raan) * math.sin(inclination),
84
+ -math.cos(raan) * math.sin(inclination),
85
+ math.cos(inclination),
86
+ )
87
+
88
+
89
+ def mean_from_eccentric_anomaly(eccentric_anomaly, eccentricity):
90
+ """
91
+ Kepler's equation, M = E - e sin E (Murray & Dermott eq. 2.52).
92
+
93
+ Args:
94
+ eccentric_anomaly (float): E (rad)
95
+ eccentricity (float): e, 0 <= e < 1
96
+
97
+ Returns:
98
+ float: mean anomaly M (rad)
99
+ """
100
+ return eccentric_anomaly - eccentricity * math.sin(eccentric_anomaly)
101
+
102
+
103
+ def eccentric_anomaly(mean_anomaly, eccentricity, tolerance=1e-12):
104
+ """
105
+ Solve Kepler's equation M = E - e sin E for E by Newton's method.
106
+
107
+ Starts from E = M, or from pi for e > 0.8, where E = M can overshoot
108
+ (Danby, *Fundamentals of Celestial Mechanics*, 2nd ed., 1988, §6.6;
109
+ Murray & Dermott §2.4). Converges to 1e-12 rad in a handful of steps for
110
+ any bound orbit.
111
+
112
+ Args:
113
+ mean_anomaly (float): M (rad), any value; reduced to (-pi, pi]
114
+ eccentricity (float): e, 0 <= e < 1
115
+ tolerance (float): stop once a Newton step is smaller than this (rad)
116
+
117
+ Returns:
118
+ float: E (rad), on the same turn as the reduced M
119
+ """
120
+ reduced = math.remainder(mean_anomaly, 2 * math.pi)
121
+ anomaly = reduced if eccentricity <= 0.8 else math.copysign(math.pi, reduced)
122
+ for _ in range(100):
123
+ step = (anomaly - eccentricity * math.sin(anomaly) - reduced) / (
124
+ 1 - eccentricity * math.cos(anomaly)
125
+ )
126
+ anomaly -= step
127
+ if abs(step) < tolerance:
128
+ return anomaly + (mean_anomaly - reduced)
129
+ raise ArithmeticError(
130
+ "Kepler's equation did not converge for M={}, e={}".format(
131
+ mean_anomaly, eccentricity
132
+ )
133
+ )
134
+
135
+
136
+ def true_from_eccentric_anomaly(eccentric_anomaly, eccentricity):
137
+ """
138
+ True anomaly from eccentric anomaly (Murray & Dermott eq. 2.46), in the
139
+ half-angle form that keeps the quadrant: tan(f/2) = sqrt((1+e)/(1-e)) tan(E/2).
140
+
141
+ Returns:
142
+ float: f (rad), on the same turn as E
143
+ """
144
+ return 2 * math.atan2(
145
+ math.sqrt(1 + eccentricity) * math.sin(eccentric_anomaly / 2),
146
+ math.sqrt(1 - eccentricity) * math.cos(eccentric_anomaly / 2),
147
+ )
148
+
149
+
150
+ def eccentric_from_true_anomaly(true_anomaly, eccentricity):
151
+ """
152
+ Eccentric anomaly from true anomaly, the inverse of
153
+ true_from_eccentric_anomaly.
154
+
155
+ Returns:
156
+ float: E (rad), on the same turn as f
157
+ """
158
+ return 2 * math.atan2(
159
+ math.sqrt(1 - eccentricity) * math.sin(true_anomaly / 2),
160
+ math.sqrt(1 + eccentricity) * math.cos(true_anomaly / 2),
161
+ )
@@ -131,6 +131,17 @@ def srgb_gamma(channel):
131
131
  return 1.055 * (channel ** (1 / 2.4)) - 0.055
132
132
 
133
133
 
134
+ def srgb_to_linear(channel):
135
+ """sRGB -> linear light, the inverse of srgb_gamma, for one channel in 0-1.
136
+
137
+ IEC 61966-2-1 (sRGB). Renderers such as Blender take colours as linear
138
+ light, so an sRGB colour must pass through this before it lights anything.
139
+ """
140
+ if channel <= 0.04045:
141
+ return channel / 12.92
142
+ return ((channel + 0.055) / 1.055) ** 2.4
143
+
144
+
134
145
  def visible_wavelengths(step_nm=CIE_LAMBDA_STEP):
135
146
  """Wavelengths (nm) spanning the CIE band, for building spectra on."""
136
147
  steps = int((CIE_LAMBDA_MAX - CIE_LAMBDA_MIN) / step_nm) + 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: naturedynamics
3
- Version: 1.1
3
+ Version: 1.2
4
4
  Summary: A comprehensive physics library providing constants, equations, and formulas
5
5
  Author-email: Fabian Schober <reach@fabianschober.com>
6
6
  License: MIT
@@ -18,6 +18,7 @@ naturedynamics/astrophysics/atmospheric.py
18
18
  naturedynamics/astrophysics/cosmology.py
19
19
  naturedynamics/astrophysics/galactic.py
20
20
  naturedynamics/astrophysics/magnetism.py
21
+ naturedynamics/astrophysics/orbital.py
21
22
  naturedynamics/astrophysics/photometry.py
22
23
  naturedynamics/astrophysics/planetary.py
23
24
  naturedynamics/astrophysics/stellar.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "naturedynamics"
7
- version = "1.1"
7
+ version = "1.2"
8
8
  authors = [{name = "Fabian Schober", email = "reach@fabianschober.com"}]
9
9
  description = "A comprehensive physics library providing constants, equations, and formulas"
10
10
  readme = "README.md"
File without changes
File without changes
File without changes