Gravitational Lensing by Binary Star
Project description
BinaryLens: Gravitational Lensing by Binary Star
BinaryLens(q, d, phi=0):
q = binary mass ratio m1/m2
d = binary separation / Einstein radius rE
rE = (4GM/c^2 d_L(d_S-d_L)/d_L)^{1/2}
d_L,d_S = distances to lens and source
phi = angle between x-axis and binary axis / radian
return BinaryLens-Object
-------------------------------------------------------------
methods in BinaryLens-Object:
map(z):
mapping from lens plane to source plane
z = point on lens plane (complex number)
return w = point on source plane (complex number)
ray from w through z is deflected to observer
det_invmap(z):
magnification factor of image at z
(including sign of image parity)
z = point on lens plane (complex number)
return det(jacobian of inverse lens mapping)
crit(N=100):
critical curve on lens plane
return z = points on lens plane (complex number)
at which magnification diverge
z.shape = (N,4)
caustic(N=100):
critical curve on source plane
return w = points on source plane (complex number)
at which magnification diverge
w.shape = (N,4)
image(w):
inverse of lens mapping
w = source position (complex number)
assume w is scalar or 1d-array
return z = image position (complex number)
if w is scalar, z.shape = (number of images,)
if w is 1d-array, z.shape = (len(w), 5)
if the number of images is less than 5,
z is padded with nan in shape (len(w),5)
mag(w, r=0, atol=1e-3, rtol=1e-3):
magnification factor of source at w
w = source position (complex number)
r = source radius of disk shape
return mu = magnification factor
(sum of |det_invmap| over all images)
if r>0, mu is averaged over finite source size
assuming uniform brightness over disk
atol = tolerance for absolute error in averaging
rtol = tolerance for relative error in averaging
atol and rtol are used only if r>0
w is vectorized so that mu.shape = w.shape
(w can be array of any shape)
-------------------------------------------------------------
reference:
P. Schneider, J. Ehlers and E. E. Falco
"Gravitational Lenses" section 8.3
example code:
import numpy as np
import matplotlib.pyplot as plt
from BinaryLens import BinaryLens
q,d = 0.5, 0.7
w0,r1,r2 = 0.1, 0.1, 0.05
N = 400
w1 = w0 + r1*np.exp(1j*np.linspace(0, 2*np.pi, N))
w2 = w0 + r2*np.exp(1j*np.linspace(0, 2*np.pi, N))
b = BinaryLens(q,d)
zc = b.crit()
wc = b.map(zc)
z1 = b.image(w1)
z2 = b.image(w2)
plt.figure(figsize=(8,4))
plt.subplot(1,2,1)
plt.axis('equal')
plt.axis([-1.5,1.5,-1.5,1.5])
plt.plot(np.real(wc), np.imag(wc), 'k:')
plt.plot(np.real(w1), np.imag(w1), 'r')
plt.plot(np.real(w2), np.imag(w2), 'b')
plt.title('source plane')
plt.subplot(1,2,2)
plt.axis('equal')
plt.axis([-1.5,1.5,-1.5,1.5])
plt.plot(np.real(zc), np.imag(zc), 'k:')
plt.plot(np.real(z1), np.imag(z1), 'r')
plt.plot(np.real(z2), np.imag(z2), 'b')
plt.plot(np.real(b.z), np.imag(b.z), '+')
plt.title('lens plane')
plt.show()
example code:
import numpy as np
import matplotlib.pyplot as plt
from BinaryLens import BinaryLens
q,d = 0.789, 1.213
u0 = 0.35
phi = (133.66 + 90)/180*np.pi
x1,x2,y1,y2 = -1,1,-1,1
b = BinaryLens(q,d)
x,y = np.meshgrid(np.r_[x1:x2:128j], np.r_[y1:y2:128j])
w = x + 1j*y
m = b.mag(w)
plt.imshow(np.log(m), cmap='gray', extent=(x1,x2,y1,y2))
w = (u0 + 1j*np.linspace(-1.4, 1.4, 2))*np.exp(1j*phi)
plt.plot(np.real(w), np.imag(w), 'w', lw=0.5)
plt.axis([x1,x2,y1,y2])
plt.title('OGLE-2003BLG170')
plt.show()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
BinaryLens-0.0.1.tar.gz
(4.7 kB
view details)
Built Distribution
File details
Details for the file BinaryLens-0.0.1.tar.gz
.
File metadata
- Download URL: BinaryLens-0.0.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4813b19b5fcfb69142a95fa30ab80c61ae943c95f63298fd8a76a72c9b54f11 |
|
MD5 | e3c838ecff3aa0c616228a5133ca45d5 |
|
BLAKE2b-256 | 632be6c2884bf8c3d9510f395b81d1b0071304792d9ffc1301db2dd51ca2f6c9 |
File details
Details for the file BinaryLens-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: BinaryLens-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce4f4f5433e0ebfe3d7932d0d32ac9887dd79888c8805b39c38db72de8ee4418 |
|
MD5 | 2d7596b48e7e533554c613526a37a26c |
|
BLAKE2b-256 | b6f7f2619b925746dc948281185ed8befb7823675e8567e8144905dd8b43e285 |