summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-02-23 20:37:16 +0100
committerAnton Khirnov <anton@khirnov.net>2023-06-28 15:52:38 +0200
commit9c1cc48ff9fbfd789b5031c772a40b5bb413f9d8 (patch)
tree4df1b507f7a338cbfe7408664f4cff6df9150a42
parent0d4fd526bcf810b9a82af3857dede65c21d2ede6 (diff)
doublenull: shorten names
Breaks compatibility.
-rw-r--r--doublenull.py22
-rw-r--r--test/test_doublenull.py12
2 files changed, 17 insertions, 17 deletions
diff --git a/doublenull.py b/doublenull.py
index 241a3a5..622f156 100644
--- a/doublenull.py
+++ b/doublenull.py
@@ -17,7 +17,7 @@ def _photon_dXdt(t, coord, sign, gXX, gtt, gXt):
return ((-gXt_val + sign * np.sqrt((gXt_val ** 2) - gtt_val * gXX_val)) / gXX_val).flatten()[0]
# terminate integration on reaching the outer boundaries
-def _events_bnd_null_curves(spatial_coords):
+def _events_bnd(spatial_coords):
def event_x_bound_upper(t, x, sign, *args):
return x[0] - spatial_coords[-1]
event_x_bound_upper.terminal = True
@@ -30,7 +30,7 @@ def _events_bnd_null_curves(spatial_coords):
return [event_x_bound_upper, event_x_bound_lower]
-def _calc_null_kernel_time(times, origin, sign, gXX, gXt, gtt, events):
+def _kernel_time(times, origin, sign, gXX, gXt, gtt, events):
idx = np.where(times == origin)[0][0]
t_fwd = times[idx:]
@@ -58,7 +58,7 @@ def _calc_null_kernel_time(times, origin, sign, gXX, gXt, gtt, events):
return np.concatenate((ray_back[::-1][:-1], ray_fwd))
-def _calc_null_kernel_space(times, origin, sign, gXX, gXt, gtt, events):
+def _kernel_space(times, origin, sign, gXX, gXt, gtt, events):
sol = solve_ivp(_photon_dXdt, (times[0], times[-1]), (origin,),
method = 'RK45', t_eval = times, args = (sign, gXX, gtt, gXt),
dense_output = True, events = events, rtol = 1e-6, atol = 1e-8)
@@ -88,8 +88,8 @@ class Curves(Enum):
to form the resulting curve
"""
-def calc_null_curves(times, spatial_coords, gXX, gXt, gtt,
- kind = Curves.SPATIAL_FORWARD):
+def null_curves(times, spatial_coords, gXX, gXt, gtt,
+ kind = Curves.SPATIAL_FORWARD):
"""
Compute null curves along a given axis.
@@ -117,14 +117,14 @@ def calc_null_curves(times, spatial_coords, gXX, gXt, gtt,
gtt_interp = RectBivariateSpline(times, spatial_coords, gtt)
if kind == Curves.TEMPORAL:
- kernel = _calc_null_kernel_time
+ kernel = _kernel_time
origins = times
else:
- kernel = _calc_null_kernel_space
+ kernel = _kernel_space
origins = spatial_coords
ray_times = times[::-1] if kind == Curves.SPATIAL_BACK else times
- events = _events_bnd_null_curves(spatial_coords)
+ events = _events_bnd(spatial_coords)
rays_pos = np.empty((origins.shape[0], times.shape[0]))
rays_neg = np.empty_like(rays_pos)
@@ -136,8 +136,8 @@ def calc_null_curves(times, spatial_coords, gXX, gXt, gtt,
return (ray_times, rays_pos, rays_neg)
-def calc_null_coordinates(times, spatial_coords, u_rays, v_rays,
- gXX, gXt, gtt, kind = Curves.SPATIAL_FORWARD):
+def null_coordinates(times, spatial_coords, u_rays, v_rays,
+ gXX, gXt, gtt, kind = Curves.SPATIAL_FORWARD):
"""
Compute double-null coordinates (u, v) as functions of
position and time.
@@ -160,7 +160,7 @@ def calc_null_coordinates(times, spatial_coords, u_rays, v_rays,
v as functions of t and X. u/v[i, j] is the value of u/v at
t=times[i], X=spatial_coords[j].
"""
- _, X_of_ut, X_of_vt = calc_null_curves(times, spatial_coords, gXX, gXt, gtt, kind = kind)
+ _, X_of_ut, X_of_vt = null_curves(times, spatial_coords, gXX, gXt, gtt, kind = kind)
u_of_tx = np.empty((times.shape[0], spatial_coords.shape[0]))
v_of_tx = np.empty_like(u_of_tx)
diff --git a/test/test_doublenull.py b/test/test_doublenull.py
index e50003e..a61af33 100644
--- a/test/test_doublenull.py
+++ b/test/test_doublenull.py
@@ -15,9 +15,9 @@ class TestDoubleNull(TestCase):
self.data = np.load(datafile)
def test_null_curves(self):
- rays = doublenull.calc_null_curves(self.data['t'], self.data['x'],
- self.data['gxx'], np.zeros_like(self.data['gxx']),
- -(self.data['alpha'] ** 2))
+ rays = doublenull.null_curves(self.data['t'], self.data['x'],
+ self.data['gxx'], np.zeros_like(self.data['gxx']),
+ -(self.data['alpha'] ** 2))
assert_allclose(rays[0], self.data['ray_times'], 1e-12)
assert_allclose(rays[1], self.data['rays_pos'], 1e-12)
@@ -29,8 +29,8 @@ class TestDoubleNull(TestCase):
gxx = self.data['gxx']
uv = 0.5 * array_utils.array_reflect(invars.dist_proper(x[idx:], gxx[0, idx:]), -1)
- coords = doublenull.calc_null_coordinates(self.data['t'], x, uv, uv,
- gxx, np.zeros_like(gxx),
- -(self.data['alpha'] ** 2))
+ coords = doublenull.null_coordinates(self.data['t'], x, uv, uv,
+ gxx, np.zeros_like(gxx),
+ -(self.data['alpha'] ** 2))
assert_allclose(coords[0], self.data['uxt'], 1e-12)
assert_allclose(coords[1], self.data['vxt'], 1e-12)