Skip to content

Commit

Permalink
Style updates
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoSanchez committed Jun 23, 2022
1 parent aaea709 commit 03ebdf2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
30 changes: 15 additions & 15 deletions properimage/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,21 +197,21 @@ def subtract(
D_hat_r = fourier_shift(psf_new_hat * ref.interped_hat, (-dx_new, -dy_new))
D_hat_n = fourier_shift(psf_ref_hat * new.interped_hat, (-dx_ref, -dy_ref))

norm_b = ref.var ** 2 * psf_new_hat * psf_new_hat_conj
norm_a = new.var ** 2 * psf_ref_hat * psf_ref_hat_conj
norm_b = ref.var**2 * psf_new_hat * psf_new_hat_conj
norm_a = new.var**2 * psf_ref_hat * psf_ref_hat_conj

new_back = sep.Background(new.interped).back()
ref_back = sep.Background(ref.interped).back()
gamma = new_back - ref_back
b = n_zp / r_zp
norm = np.sqrt(norm_a + norm_b * b ** 2)
norm = np.sqrt(norm_a + norm_b * b**2)
if beta:
if shift: # beta==True & shift==True

def cost(vec):
b, dx, dy = vec
gammap = gamma / np.sqrt(new.var ** 2 + b ** 2 * ref.var ** 2)
norm = np.sqrt(norm_a + norm_b * b ** 2)
gammap = gamma / np.sqrt(new.var**2 + b**2 * ref.var**2)
norm = np.sqrt(norm_a + norm_b * b**2)
dhn = D_hat_n / norm
dhr = D_hat_r / norm
b_n = (
Expand Down Expand Up @@ -257,8 +257,8 @@ def cost(vec):
bi = b

def F(b):
gammap = gamma / np.sqrt(new.var ** 2 + b ** 2 * ref.var ** 2)
norm = np.sqrt(norm_a + norm_b * b ** 2)
gammap = gamma / np.sqrt(new.var**2 + b**2 * ref.var**2)
norm = np.sqrt(norm_a + norm_b * b**2)
b_n = (
_ifftwn(D_hat_n / norm, norm="ortho")
- gammap
Expand Down Expand Up @@ -291,8 +291,8 @@ def F(b):
bi = b

def F(b):
gammap = gamma / np.sqrt(new.var ** 2 + b ** 2 * ref.var ** 2)
norm = np.sqrt(norm_a + norm_b * b ** 2)
gammap = gamma / np.sqrt(new.var**2 + b**2 * ref.var**2)
norm = np.sqrt(norm_a + norm_b * b**2)
b_n = (
_ifftwn(D_hat_n / norm, norm="ortho")
- gammap
Expand Down Expand Up @@ -322,8 +322,8 @@ def F(b):
else:
if shift: # beta==False & shift==True
bi = n_zp / r_zp
gammap = gamma / np.sqrt(new.var ** 2 + b ** 2 * ref.var ** 2)
norm = np.sqrt(norm_a + norm_b * b ** 2)
gammap = gamma / np.sqrt(new.var**2 + b**2 * ref.var**2)
norm = np.sqrt(norm_a + norm_b * b**2)
dhn = D_hat_n / norm
dhr = D_hat_r / norm

Expand Down Expand Up @@ -369,7 +369,7 @@ def cost(vec):
dx = 0.0
dy = 0.0

norm = norm_a + norm_b * b ** 2
norm = norm_a + norm_b * b**2

if dx == 0.0 and dy == 0.0:
D_hat = (D_hat_n - b * D_hat_r) / np.sqrt(norm)
Expand All @@ -382,7 +382,7 @@ def cost(vec):
if np.any(np.isnan(D.real)):
pass

d_zp = b / np.sqrt(ref.var ** 2 * b ** 2 + new.var ** 2)
d_zp = b / np.sqrt(ref.var**2 * b**2 + new.var**2)
P_hat = (psf_ref_hat * psf_new_hat * b) / (np.sqrt(norm) * d_zp)

P = _ifftwn(P_hat, norm="ortho").real
Expand All @@ -408,13 +408,13 @@ def cost(vec):

V_en = _ifftwn(
_fftwn(new.data.filled(0) + 1.0, norm="ortho")
* _fftwn(kn ** 2, s=new.data.shape),
* _fftwn(kn**2, s=new.data.shape),
norm="ortho",
)

V_er = _ifftwn(
_fftwn(ref.data.filled(0) + 1.0, norm="ortho")
* _fftwn(kr ** 2, s=ref.data.shape),
* _fftwn(kr**2, s=ref.data.shape),
norm="ortho",
)

Expand Down
2 changes: 1 addition & 1 deletion properimage/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def autopsf_coef(
img = ax.imshow(a, **imshow_kw)
fig.colorbar(img, ax=ax, **cmap_kw)

title = title_tpl.format(j=idx + 1, sum=np.sqrt(np.sum(a ** 2)))
title = title_tpl.format(j=idx + 1, sum=np.sqrt(np.sum(a**2)))
ax.set_title(title)

return axs
6 changes: 3 additions & 3 deletions properimage/single_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def check_margin(stamp, rms=self._bkg.globalrms):
xcm = np.array([xcm[0], ycm[0]])

delta = xcm - np.asarray(new_shape) / 2.0
if np.sqrt(np.sum(delta ** 2)) > new_shape[0] / 5.0:
if np.sqrt(np.sum(delta**2)) > new_shape[0] / 5.0:
to_del.append(jj)
jj += 1
continue
Expand Down Expand Up @@ -634,7 +634,7 @@ def check_margin(stamp, rms=self._bkg.globalrms):
ymax, xmax, thmax = outl_cat[0]
xcm = np.array([xmax, ymax])
delta = xcm - np.asarray(new_shape) / 2.0
if np.sqrt(np.sum(delta ** 2)) > new_shape[0] / 5.0:
if np.sqrt(np.sum(delta**2)) > new_shape[0] / 5.0:
to_del.append(jj)
jj += 1
continue
Expand Down Expand Up @@ -998,7 +998,7 @@ def s_hat_comp(self):
conv = fourier_shift(conv, (+dx, +dy))
np.add(conv, s_hat, out=s_hat)

self._s_hat_comp = (self.zp / (var ** 2)) * s_hat
self._s_hat_comp = (self.zp / (var**2)) * s_hat
self._s_hat_inf_loss = self.inf_loss

return self._s_hat_comp
Expand Down
2 changes: 1 addition & 1 deletion tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def test_plot_autopsf_coef(random_4psf_simage, fig_test, fig_ref):
img = ax.imshow(a, vmax=med + 2 * std, vmin=med - 2 * std)
fig_ref.colorbar(img, ax=ax, **cmap_kw)

title = title_tpl.format(j=idx + 1, sum=np.sqrt(np.sum(a ** 2)))
title = title_tpl.format(j=idx + 1, sum=np.sqrt(np.sum(a**2)))
ax.set_title(title)

# fig test
Expand Down

0 comments on commit 03ebdf2

Please sign in to comment.