dimanche 26 juin 2016

Mapping fields on Python


I'm trying to re-map a certain field in Python, but not sure how to go about it. The topic is regarding gravitational lensing. So what i've done upto now is obtain a deflection field, which tells you how light is bent around masses.Deflection Field Map

Using this, I obtained something called a magnification map, which shows you the regions that would produce the brightest images. The redder the color, the brighter the image.Magnification Map Now, I want to subtract the deflection field from the magnification map to obtain another mapping in a different plane.

I'm not sure how to go about this, since my deflection field is a 2d vector, so I have the deflection_x and deflection_y as 2 arrays. My magnification meanwhile is just values assigned to each grid point in a 2d X-Y grid. Another way to re-phrase what I'm trying to do is as follows. Let the magnification be I.

So right now I have I(x,y). I want to obtain I(x - (deflection_x), y -(deflection_y)). Basically it takes the curve in orange and makes it into another curve in the new x and y positions but with the same magnitude. I've given my current code below:

x = np.linspace(-50,50,100)
y = np.linspace(-50,50,100)
X, Y = np.meshgrid(x,y)
zeta_a = (-3,0)
zeta_b = (3,0)
def get_dist_squared(x_array, y_array):
return x_array**2 + y_array**2 
M_a= 150
M_b= 150
G = 1
c = 1
zeta_min_zeta_a_x = X - zeta_a[0] 
zeta_min_zeta_a_y = Y - zeta_a[1]
zeta_min_zeta_b_x = X - zeta_b[0]
zeta_min_zeta_b_y = Y - zeta_b[1]
dist_zeta_min_zeta_a = get_dist_squared(zeta_min_zeta_a_x,zeta_min_zeta_a_y)
dist_zeta_min_zeta_b = get_dist_squared(zeta_min_zeta_b_x,zeta_min_zeta_b_y)
alpha_x = M_a * zeta_min_zeta_a_x / dist_zeta_min_zeta_a
alpha_x  += M_b * zeta_min_zeta_b_x / dist_zeta_min_zeta_b 
alpha_x *= 4 * G / (c**2) 
alpha_y = M_a * zeta_min_zeta_a_y / dist_zeta_min_zeta_a
alpha_y += M_b * zeta_min_zeta_b_y / dist_zeta_min_zeta_b
alpha_y *= 4 * G / (c**2)
alpha_x_y, alpha_x_x = np.gradient(alpha_x,edge_order=1)
alpha_y_y, alpha_y_x = np.gradient(alpha_y,edge_order=1)
det_A = 1 - alpha_y_y - alpha_x_x + (alpha_x_x)*(alpha_y_y) - (alpha_x_y)*(alpha_y_x)
abs = np.absolute(det_A)
I = abs**(-1.)

The magnification is given by I. Don't worry about the calculation part of the code, what I want after this step is to subtract alpha_x and alpha_y from I. alpha_x and alpha_y are the deflections in the x and y axes.

From what I've tried, simply doing I - alpha_x and I - alpha_y and plotting this does not help. It is not the value of the magnification that should be subtracted, but simply the positions of the magnifications.

Thanks! I would really appreciate any advice.


Aucun commentaire:

Enregistrer un commentaire