kerrpy package

Submodules

kerrpy.camera module

class kerrpy.camera.Camera(r, theta, phi, focalLength, sensorShape, sensorSize, roll=0, pitch=0, yaw=0)[source]

Bases: object

Pinhole camera placed near a Kerr black hole.

This class contains the necessary data to define a camera that is located on the coordinate system of a Kerr black hole.

r

double – Distance to the coordinate origin; i.e., distance to the black hole centre.

r2

double – Square of r.

theta

double – Inclination of the camera with respect to the black hole.

phi

double – Azimuth of the camera with respect to the black hole.

focalLength

double – Distance between the focal point (where every ray that reaches the camera has to pass through) and the focal plane (where the actual sensor/film is placed).

sensorSize

tuple – 2-tuple that defines the physical dimensions of the sensor in the following way: (Height, Width).

sensorShape

tuple – 2-tuple that defines the number of pixels of the sensor in the following way: (Number of rows, Number of columns).

pixelWidth

double – Width of one single pixel in physical units. It is computed as Number of columns / Sensor width.

pixelHeight

double – Height of one single pixel in physical units. It is computed as Number of rows / Sensor height.

speed

double – Speed of the camera, that follows a circular orbit around the black hole in the equatorial plane. It is computed using the formula (A.7) of Thorne’s paper.

roll

double – The roll angle of the CCD; i.e., the rotation angle of the CCD on its plane. Defaults to zero, that means the CCD is facing the black hole centre.

pitch

double – The pitch angle of the CCD; i.e., the above/below direction of looking. Defaults to zero, that means the CCD is facing the black hole centre.

yaw

double – The yaw angle of the CCD; i.e., the left/right direction of lookin. Defaults to zero, that means the CCD is facing the black hole centre.

__del__()[source]
__dict__ = mappingproxy({'_update': <function Camera._update>, '__del__': <function Camera.__del__>, 'slicedShoot': <function Camera.slicedShoot>, '_compute_metric_value': <function Camera._compute_metric_value>, '_compute_pixel_size': <function Camera._compute_pixel_size>, '__init__': <function Camera.__init__>, '__module__': 'kerrpy.camera', '_compute_speed': <function Camera._compute_speed>, 'phi': <property object>, '__dict__': <attribute '__dict__' of 'Camera' objects>, 'sensorShape': <property object>, '__weakref__': <attribute '__weakref__' of 'Camera' objects>, 'shoot': <function Camera.shoot>, '__doc__': "Pinhole camera placed near a Kerr black hole.\n\n This class contains the necessary data to define a camera that is located\n on the coordinate system of a Kerr black hole.\n\n Attributes:\n r (double): Distance to the coordinate origin; i.e., distance to the\n black hole centre.\n r2 (double): Square of `r`.\n theta (double): Inclination of the camera with respect to the black\n hole.\n phi (double): Azimuth of the camera with respect to the black hole.\n focalLength (double): Distance between the focal point (where every ray\n that reaches the camera has to pass through) and the focal plane\n (where the actual sensor/film is placed).\n sensorSize (tuple): 2-tuple that defines the physical dimensions of the\n sensor in the following way: `(Height, Width)`.\n sensorShape (tuple): 2-tuple that defines the number of pixels of the\n sensor in the following way: `(Number of rows, Number of columns)`.\n pixelWidth (double): Width of one single pixel in physical units. It is\n computed as `Number of columns / Sensor width`.\n pixelHeight (double): Height of one single pixel in physical units. It\n is computed as `Number of rows / Sensor height`.\n speed (double): Speed of the camera, that follows a circular orbit\n around the black hole in the equatorial plane. It is computed using\n the formula (A.7) of Thorne's paper.\n roll (double): The roll angle of the CCD; i.e., the rotation angle\n of the CCD on its plane. Defaults to zero, that means the CCD is\n facing the black hole centre.\n pitch (double): The pitch angle of the CCD; i.e., the above/below\n direction of looking. Defaults to zero, that means the CCD is\n facing the black hole centre.\n yaw (double): The yaw angle of the CCD; i.e., the left/right\n direction of lookin. Defaults to zero, that means the CCD is\n facing the black hole centre.\n ", 'r': <property object>, 'sensorSize': <property object>, 'theta': <property object>})
__init__(r, theta, phi, focalLength, sensorShape, sensorSize, roll=0, pitch=0, yaw=0)[source]

Builds the camera defined by focalLength, sensorShape and sensorSize and locates it at the passed coordinates \((r_c, \theta_c, \phi_c)\)

Parameters:
  • r (double) – Distance to the coordinate origin; i.e., distance to the black hole centre.
  • theta (double) – Inclination of the camera with respect to the black hole.
  • phi (double) – Azimuth of the camera with respect to the black hole.
  • focalLength (double) – Distance between the focal point (where every row that reaces the camera has to pass through) and the focal plane (where the actual sensor/film is placed).
  • sensorShape (tuple) – 2-tuple that defines the number of pixels of the sensor in the following way: (Number of rows, Number of columns).
  • sensorSize (tuple) – 2-tuple that defines the physical dimensions of the sensor in the following way: (Height, Width).
  • roll (double) – The roll angle of the CCD; i.e., the rotation angle of the CCD on the plane of the CCD. Defaults to zero, that means the CCD is facing the black hole centre.
  • pitch (double) – The pitch angle of the CCD; i.e., the above/below direction of looking. Defaults to zero, that means the CCD is facing the black hole centre.
  • yaw (double) – The yaw angle of the CCD; i.e., the left/right direction of lookin. Defaults to zero, that means the CCD is facing the black hole centre.
__module__ = 'kerrpy.camera'
__weakref__

list of weak references to the object (if defined)

phi
r
sensorShape
sensorSize
shoot(finalTime=-150, diskPath=None, spherePath=None, dashed_texture=False)[source]
slicedShoot(finalTime=-150, slicesNum=100)[source]
theta

kerrpy.geodesics module

class kerrpy.geodesics.Congruence(status, coordinates)[source]

Bases: object

__dict__ = mappingproxy({'__module__': 'kerrpy.geodesics', '__dict__': <attribute '__dict__' of 'Congruence' objects>, 'snapshot': <function Congruence.snapshot>, '__weakref__': <attribute '__weakref__' of 'Congruence' objects>, 'geodesic': <function Congruence.geodesic>, '__doc__': None, '__init__': <function Congruence.__init__>, 'plot': <function Congruence.plot>})
__init__(status, coordinates)[source]
__module__ = 'kerrpy.geodesics'
__weakref__

list of weak references to the object (if defined)

geodesic(row, col)[source]
plot()[source]
snapshot(instant)[source]
class kerrpy.geodesics.CongruenceSnapshot(status, coordinates, texels=None)[source]

Bases: object

__dict__ = mappingproxy({'__module__': 'kerrpy.geodesics', '__dict__': <attribute '__dict__' of 'CongruenceSnapshot' objects>, 'plot': <function CongruenceSnapshot.plot>, '__weakref__': <attribute '__weakref__' of 'CongruenceSnapshot' objects>, '__doc__': None, '__init__': <function CongruenceSnapshot.__init__>, 'save': <function CongruenceSnapshot.save>})
__init__(status, coordinates, texels=None)[source]
__module__ = 'kerrpy.geodesics'
__weakref__

list of weak references to the object (if defined)

plot()[source]
save(path)[source]
class kerrpy.geodesics.Geodesic(status, coordinates, colour='royalBlue')[source]

Bases: object

__dict__ = mappingproxy({'__module__': 'kerrpy.geodesics', '__dict__': <attribute '__dict__' of 'Geodesic' objects>, 'plot': <function Geodesic.plot>, '__weakref__': <attribute '__weakref__' of 'Geodesic' objects>, '__doc__': None, '__init__': <function Geodesic.__init__>})
__init__(status, coordinates, colour='royalBlue')[source]
__module__ = 'kerrpy.geodesics'
__weakref__

list of weak references to the object (if defined)

plot(ax=None)[source]

kerrpy.raytracer module

class kerrpy.raytracer.RayTracer(camera, debug=False)[source]

Bases: object

Relativistic spacetime ray tracer.

This class generates images of what an observer would see near a rotating black hole.

This is an abstraction layer over the CUDA kernel that integrates the ODE system specified in equations (A.15) of Thorne’s paper. It integrates, backwards in time, a set of rays near a Kerr black hole, computing its trajectories from the focal point of a camera located near the black hole.

The RayTracer class hides all the black magic behind the CUDA code, giving a nice and simple interface to the user that just wants some really cool, and scientifically accurate, images.

Given a scene composed by a camera, a Kerr metric and a black hole, the RayTracer just expects a time \(x_{end}\) to solve the system.

Example

Define the characteristics of the black hole and build it:

spin = 0.9999999999
innerDiskRadius = 9
outerDiskRadius = 20
blackHole = BlackHole(spin, innerDiskRadius, outerDiskRadius)

Define the specifications of the camera and build it:

camR = 30
camTheta = 1.511
camPhi = 0
camFocalLength = 3
camSensorShape = (1000, 1000)  # (Rows, Columns)
camSensorSize = (2, 2)         # (Height, Width)
camera = Camera(camR, camTheta, camPhi,
                camFocalLength, camSensorShape, camSensorSize)

Create a Kerr metric with the previous two objects:

kerr = KerrMetric(camera, blackHole)

Set the speed of the camera once the Kerr metric and the black hole are created: it needs some info from both of these objects:

camera.setSpeed(kerr, blackHole)

Finally, build the raytracer with the camera, the metric and the black hole...:

rayTracer = RayTracer(camera, kerr, blackHole)

...and generate the image!:

rayTracer.rayTrace(-90)
rayTracer.synchronise()
rayTracer.plotImage()
__dict__ = mappingproxy({'_kernelRendering': <function RayTracer._kernelRendering>, 'slicedRayTrace': <function RayTracer.slicedRayTrace>, '__init__': <function RayTracer.__init__>, 'rayTrace': <function RayTracer.rayTrace>, '__module__': 'kerrpy.raytracer', 'synchronise': <function RayTracer.synchronise>, 'callKernel': <function RayTracer.callKernel>, '_setUpInitCond': <function RayTracer._setUpInitCond>, '__dict__': <attribute '__dict__' of 'RayTracer' objects>, '__weakref__': <attribute '__weakref__' of 'RayTracer' objects>, '__doc__': "Relativistic spacetime ray tracer.\n\n This class generates images of what an observer would see near a rotating\n black hole.\n\n This is an abstraction layer over the CUDA kernel that integrates the ODE\n system specified in equations (A.15) of Thorne's paper. It integrates,\n backwards in time, a set of rays near a Kerr black hole, computing its\n trajectories from the focal point of a camera located near the black hole.\n\n The RayTracer class hides all the black magic behind the CUDA code, giving\n a nice and simple interface to the user that just wants some really cool,\n and scientifically accurate, images.\n\n Given a scene composed by a camera, a Kerr metric and a black hole, the\n RayTracer just expects a time :math:`x_{end}` to solve the system.\n\n Example:\n Define the characteristics of the black hole and build it::\n\n spin = 0.9999999999\n innerDiskRadius = 9\n outerDiskRadius = 20\n blackHole = BlackHole(spin, innerDiskRadius, outerDiskRadius)\n\n Define the specifications of the camera and build it::\n\n camR = 30\n camTheta = 1.511\n camPhi = 0\n camFocalLength = 3\n camSensorShape = (1000, 1000) # (Rows, Columns)\n camSensorSize = (2, 2) # (Height, Width)\n camera = Camera(camR, camTheta, camPhi,\n camFocalLength, camSensorShape, camSensorSize)\n\n Create a Kerr metric with the previous two objects::\n\n kerr = KerrMetric(camera, blackHole)\n\n Set the speed of the camera once the Kerr metric and the black hole are\n created: it needs some info from both of these objects::\n\n camera.setSpeed(kerr, blackHole)\n\n Finally, build the raytracer with the camera, the metric and the black\n hole...::\n\n rayTracer = RayTracer(camera, kerr, blackHole)\n\n ...and generate the image!::\n\n rayTracer.rayTrace(-90)\n rayTracer.synchronise()\n rayTracer.plotImage()\n ", 'texturedImage': <function RayTracer.texturedImage>, 'dashed_textured_image': <function RayTracer.dashed_textured_image>})
__init__(camera, debug=False)[source]
__module__ = 'kerrpy.raytracer'
__weakref__

list of weak references to the object (if defined)

callKernel(x, xEnd)[source]
dashed_textured_image()[source]
rayTrace(xEnd, kernelCalls=1)[source]
Parameters:
  • xEnd (float) – Time in which the system will be integrated. After this method finishes, the value of the rays at t=xEnd will be known
  • stepsPerKernel (integer) – The number of steps each kernel call will compute; i.e., the host will call the kernel xEnd / (resolution*stepsPerKernel) times.
  • resolution (float) – The size of the interval that will be used to compute one solver step between successive calls to the collision detection method.
slicedRayTrace(xEnd, numSteps=100)[source]
synchronise()[source]
texturedImage(disk, sphere)[source]

Image should be a 2D array where each entry is a 3-tuple of Reals between 0.0 and 1.0

kerrpy.raytracer.spher2cart(points)[source]

kerrpy.universe module

class kerrpy.universe.Universe(spin=0.999, innerDiskRadius=9, outerDiskRadius=20)[source]

Bases: object

__dict__ = mappingproxy({'__dict__': <attribute '__dict__' of 'Universe' objects>, 'update': <function Universe.update>, 'spin': <property object>, '_b0': <function Universe._b0>, '__weakref__': <attribute '__weakref__' of 'Universe' objects>, 'computeHorizonRadius': <function Universe.computeHorizonRadius>, '__init__': <function Universe.__init__>, '__module__': 'kerrpy.universe', 'computeTrappedOrbits': <function Universe.computeTrappedOrbits>, 'computeBConstants': <function Universe.computeBConstants>, '__doc__': None})
__init__(spin=0.999, innerDiskRadius=9, outerDiskRadius=20)[source]
__module__ = 'kerrpy.universe'
__weakref__

list of weak references to the object (if defined)

computeBConstants()[source]
computeHorizonRadius()[source]
computeTrappedOrbits()[source]
spin
update()[source]

Module contents