Skip to content

Commit d54c1a4

Browse files
committed
Merge branch 'dev' of https://github.com/achael/eht-imaging into dev
2 parents cbf6686 + 82cb91f commit d54c1a4

File tree

2 files changed

+80
-27
lines changed

2 files changed

+80
-27
lines changed

ehtim/model.py

+31-2
Original file line numberDiff line numberDiff line change
@@ -1235,10 +1235,10 @@ def sample_1model_grad_uv(u, v, model_type, params, pol='I', fit_pol=False, fit_
12351235
[grad.append(np.zeros_like(grad[0])) for _ in range(2*len(params['beta_list']))]
12361236

12371237
if pol=='P' and fit_pol:
1238-
# Add derivatives of the beta terms
1238+
# Add derivatives of the beta_pol terms
12391239
num_coeff = len(params['beta_list_pol'])
12401240
for m in range(-(num_coeff-1)//2,(num_coeff+1)//2):
1241-
beta_grad_re = params['F0'] * alpha_factor * sps.jv( m, z) * np.exp( 1j * m * (phi - np.pi/2.))
1241+
beta_grad_re = params['F0'] * alpha_factor * sps.jv( m, z) * np.exp( 1j * m * (phi - np.pi/2.)) * np.exp(1j * 2.0 * np.pi * (u * params['x0'] + v * params['y0']))
12421242
beta_grad_im = 1j * beta_grad_re
12431243
if COMPLEX_BASIS == 're-im':
12441244
grad.append(beta_grad_re)
@@ -1253,6 +1253,35 @@ def sample_1model_grad_uv(u, v, model_type, params, pol='I', fit_pol=False, fit_
12531253
elif pol!='P' and fit_pol:
12541254
[grad.append(np.zeros_like(grad[0])) for _ in range(2*len(params['beta_list_pol']))]
12551255

1256+
if pol=='V' and fit_cpol:
1257+
# Add derivatives of the beta_cpol terms
1258+
num_coeff = len(params['beta_list_cpol']) - 1
1259+
1260+
# First do the beta0 mode (real)
1261+
beta_grad_re = params['F0'] * alpha_factor * sps.jv( 0, z)
1262+
grad.append(beta_grad_re)
1263+
1264+
# Now do the remaining modes (complex)
1265+
for m in range(1,num_coeff+1):
1266+
beta_grad_re = params['F0'] * alpha_factor * (
1267+
sps.jv( m, z) * np.exp( 1j * m * (phi - np.pi/2.)) + sps.jv(-m, z) * np.exp(-1j * m * (phi - np.pi/2.))
1268+
* np.exp(1j * 2.0 * np.pi * (u * params['x0'] + v * params['y0'])))
1269+
beta_grad_im = 1j * params['F0'] * alpha_factor * (
1270+
sps.jv( m, z) * np.exp( 1j * m * (phi - np.pi/2.)) - sps.jv(-m, z) * np.exp(-1j * m * (phi - np.pi/2.))
1271+
* np.exp(1j * 2.0 * np.pi * (u * params['x0'] + v * params['y0'])))
1272+
if COMPLEX_BASIS == 're-im':
1273+
grad.append(beta_grad_re)
1274+
grad.append(beta_grad_im)
1275+
elif COMPLEX_BASIS == 'abs-arg':
1276+
beta_abs = np.abs(params['beta_list_cpol'][m])
1277+
beta_arg = np.angle(params['beta_list_cpol'][m])
1278+
grad.append(beta_grad_re * np.cos(beta_arg) + beta_grad_im * np.sin(beta_arg))
1279+
grad.append(-beta_abs * np.sin(beta_arg) * beta_grad_re + beta_abs * np.cos(beta_arg) * beta_grad_im)
1280+
else:
1281+
raise Exception('COMPLEX_BASIS ' + COMPLEX_BASIS + ' not recognized!')
1282+
elif pol!='V' and fit_cpol:
1283+
[grad.append(np.zeros_like(grad[0])) for _ in range(2*len(params['beta_list_cpol'])-1)]
1284+
12561285
val = np.array(grad)
12571286
elif model_type == 'thick_mring_floor': # F0, d, [alpha], ff, x0, y0, beta1_re/abs, beta1_im/arg, beta2_re/abs, beta2_im/arg, ...
12581287
# We need to stich together the two gradients for the mring and the disk; we also need to add the gradient for the floor fraction ff

0 commit comments

Comments
 (0)