kerrz-python 0.2.4__tar.gz → 0.2.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kerrz_python
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Python wrapper for kerrz. Avoid installing directly, use kerrz[py] unless you know what you are doing.
5
5
  Home-page: https://codeberg.org/astro-group/kerrz-py
6
6
  Author: Fergus Baker
@@ -13,7 +13,7 @@ Classifier: Operating System :: POSIX :: Linux
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Requires-Python: >=3.6
15
15
  Description-Content-Type: text/markdown
16
- Requires-Dist: kerrz_lib==0.2.4
16
+ Requires-Dist: kerrz_lib==0.2.5
17
17
  Dynamic: author
18
18
  Dynamic: author-email
19
19
  Dynamic: classifier
@@ -0,0 +1 @@
1
+ 0.2.5
@@ -5,7 +5,7 @@ import enum
5
5
 
6
6
  import kerrz_lib.bindings as bindings
7
7
 
8
- __all__ = ["Status", "FourVector", "KerrMetric", "TraceResult", "NullGeodesic"]
8
+ __all__ = ["Status", "FourVector", "KerrMetric", "TraceResult", "NullGeodesic", "circular_orbit_velocity"]
9
9
 
10
10
  PROTECTED_ATTRIBUTE_NAMES = {"lambda": "lambda_"}
11
11
 
@@ -56,6 +56,10 @@ class FourVector:
56
56
  """Construct a new four-vector in the Boyer-Lindquist coordinates."""
57
57
  self._vec = bindings.krz_FourVector(t=t, r=r, th=theta, ph=phi)
58
58
 
59
+ def from_krz(vec: bindings.krz_FourVector) -> "FourVector":
60
+ """Construct a new four-vector in the Boyer-Lindquist coordinates."""
61
+ return FourVector(vec.t, vec.r, vec.th, vec.ph)
62
+
59
63
  def __repr__(self) -> str:
60
64
  return f"FourVector(t={self.t},r={self.r},theta={self.theta},phi={self.phi})"
61
65
 
@@ -115,6 +119,10 @@ class TraceResult(AttributeExtender):
115
119
  def __init__(self, result: bindings.krz_TraceResult):
116
120
  self._result = result
117
121
  super().__init__(self._result)
122
+ self.t = self.x_final.t
123
+ self.r = self.x_final.r
124
+ self.theta = self.x_final.th
125
+ self.phi = self.x_final.ph
118
126
 
119
127
  def __getattr__(self, name: str):
120
128
  if name == "status":
@@ -133,28 +141,53 @@ class NullGeodesic(AttributeExtender):
133
141
  def __init__(
134
142
  self,
135
143
  metric: KerrMetric,
136
- x_init: FourVector = FourVector(r=1e4, theta=0.2),
137
- alpha=1.0,
138
- beta=2.0,
144
+ ic: bindings.krz_InitialConditions,
139
145
  ):
140
- self.x_init = x_init
141
146
  self.metric = metric
142
- self.alpha = alpha
143
- self.beta = beta
147
+ self._initial_conditions = ic
144
148
 
145
149
  # Private attributes
146
150
  self._path_builder = None
147
- self._initial_conditions = bindings.krz_InitialConditions()
148
- bindings.krz_fromImpactParameters(
149
- ctypes.byref(self._initial_conditions),
150
- self.metric._metric,
151
- self.x_init._vec,
152
- self.alpha,
153
- self.beta,
154
- )
155
151
 
156
152
  super().__init__(self._initial_conditions)
157
153
 
154
+ @staticmethod
155
+ def from_impact_parameters(
156
+ metric: KerrMetric,
157
+ alpha: float,
158
+ beta: float,
159
+ x_init: FourVector = FourVector(r=1e4, theta=0.2),
160
+ ) -> "NullGeodesic":
161
+ ic = bindings.krz_fromImpactParameters(
162
+ metric._metric,
163
+ x_init._vec,
164
+ alpha,
165
+ beta,
166
+ )
167
+ return NullGeodesic(metric, ic)
168
+
169
+ @staticmethod
170
+ def from_local_angles(
171
+ metric: KerrMetric,
172
+ theta: float,
173
+ phi: float,
174
+ x: FourVector = FourVector(r=10.0, theta=0.2),
175
+ v: FourVector = None,
176
+ ) -> "NullGeodesic":
177
+ if v is None:
178
+ frame = bindings.krz_stationaryFrame(metric._metric, x._vec)
179
+ else:
180
+ frame = bindings.krz_frame(metric._metric, x._vec, v._vec)
181
+
182
+ ic = bindings.krz_fromSkyAngles(
183
+ metric._metric,
184
+ frame,
185
+ theta,
186
+ phi,
187
+ )
188
+
189
+ return NullGeodesic(metric, ic)
190
+
158
191
  def _get_pathbuilder(self):
159
192
  if self._path_builder is None:
160
193
  pb = bindings.krz_PathBuilder()
@@ -169,3 +202,18 @@ class NullGeodesic(AttributeExtender):
169
202
  ctypes.byref(self._get_pathbuilder()), mino_time
170
203
  )
171
204
  return TraceResult(result)
205
+
206
+ def trace_to_angle(self, angle: float) -> TraceResult:
207
+ result = bindings.krz_traceToAngle(
208
+ self.metric._metric, self._initial_conditions, angle,
209
+ )
210
+ return TraceResult(result)
211
+
212
+ def trace_to_radius(self, radius: float) -> TraceResult:
213
+ result = bindings.krz_traceToRadius(
214
+ self.metric._metric, self._initial_conditions, radius,
215
+ )
216
+ return TraceResult(result)
217
+
218
+ def circular_orbit_velocity(metric: KerrMetric, radius: float) -> FourVector:
219
+ return FourVector.from_krz(bindings.krz_circularOrbitVelocity(metric._metric, radius))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kerrz_python
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Python wrapper for kerrz. Avoid installing directly, use kerrz[py] unless you know what you are doing.
5
5
  Home-page: https://codeberg.org/astro-group/kerrz-py
6
6
  Author: Fergus Baker
@@ -13,7 +13,7 @@ Classifier: Operating System :: POSIX :: Linux
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Requires-Python: >=3.6
15
15
  Description-Content-Type: text/markdown
16
- Requires-Dist: kerrz_lib==0.2.4
16
+ Requires-Dist: kerrz_lib==0.2.5
17
17
  Dynamic: author
18
18
  Dynamic: author-email
19
19
  Dynamic: classifier
@@ -0,0 +1 @@
1
+ kerrz_lib==0.2.5
@@ -1 +0,0 @@
1
- 0.2.4
@@ -1 +0,0 @@
1
- kerrz_lib==0.2.4
File without changes
File without changes
File without changes