Skip to content

Commit

Permalink
Back working
Browse files Browse the repository at this point in the history
  • Loading branch information
samaloney committed May 23, 2024
1 parent 337ed97 commit 394ceae
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
12 changes: 6 additions & 6 deletions docs/tutorials/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ measured visibilities in f can the original map a be recovered?
if noisy:
data = data + np.random.normal(loc=0.0, scale=0.005, size=(65, 65));

return data/u.arcsec**2
return data

data = make_data()

Expand Down Expand Up @@ -103,13 +103,13 @@ measured visibilities in f can the original map a be recovered?
f, (r1, r2) = plt.subplots(2, 3, figsize=(12,8))

im_plot(r1[0], data.value, text=r'$I(l, m)$', label='a )')
im_plot(r1[1], psf1.value, text=r'$B(l, m)$', label='b )')
im_plot(r1[2], sub_res.value, text=r'$I(l, m) *B(l, m)$', label='c )')
im_plot(r2[0], v.value, text=r'$V(u, v)$', norm=LogNorm(0.1), label='d )')
im_plot(r1[0], data, text=r'$I(l, m)$', label='a )')
im_plot(r1[1], psf1, text=r'$B(l, m)$', label='b )')
im_plot(r1[2], sub_res, text=r'$I(l, m) *B(l, m)$', label='c )')
im_plot(r2[0], v, text=r'$V(u, v)$', norm=LogNorm(0.1), label='d )')
im_plot(r2[1], np.ones((65,65)), text=r'$S(u, v)$', label='e )', extent=(-1, 1, -1, 1))
r2[1].plot(x.flatten(), y.flatten(), 'w.', ms=2.5)
im_plot(r2[2], s_v.value, text=r'$S(u,v)V(u, v)$', label='f )', extent=(-1, 1, -1, 1), norm=LogNorm(0.1))
im_plot(r2[2], s_v, text=r'$S(u,v)V(u, v)$', label='f )', extent=(-1, 1, -1, 1), norm=LogNorm(0.1))
f.subplots_adjust(hspace=0.05, wspace=0.025)
plt.show()
Expand Down
6 changes: 2 additions & 4 deletions xrayvision/imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ def image_to_vis(
pixel_size = validate_and_expand_kwarg(pixel_size, "pixel_size")
if not (apu.get_physical_type((1 / u).unit) == ANGLE and apu.get_physical_type((1 / v).unit) == ANGLE):
raise ValueError("u and v must be inverse angle (e.g. 1/deg or 1/arcsec")
vis = dft_map(
image * apu.pix**2 * pixel_size[0] * pixel_size[1], u=u, v=v, phase_centre=phase_centre, pixel_size=pixel_size
)
vis = dft_map(image, u=u, v=v, phase_centre=phase_centre, pixel_size=pixel_size)
return Visibility(vis, u=u, v=v, offset=phase_centre)


Expand Down Expand Up @@ -166,7 +164,7 @@ def vis_to_image(
vis.vis, u=vis.u, v=vis.v, shape=shape, weights=weights, pixel_size=pixel_size, phase_centre=vis.phase_centre
)

return bp_arr / (pixel_size[0] * apu.pix * pixel_size[1] * apu.pix)
return bp_arr


@apu.quantity_input
Expand Down
2 changes: 1 addition & 1 deletion xrayvision/tests/test_imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_vis_to_image_against_idft(uv):
)
vis = Visibility(obs_vis, u=u, v=v)
res = vis_to_image(vis, shape=[65, 65] * apu.pixel, pixel_size=2 * apu.arcsec / apu.pix, scheme="uniform")
assert np.allclose(bp_calc, res * 4 * apu.arcsec**2)
assert np.allclose(bp_calc, res)


def test_image_to_vis():
Expand Down
2 changes: 1 addition & 1 deletion xrayvision/tests/test_mem.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_mem():
sub_uv = np.vstack([x.flatten(), y.flatten()]) / u.arcsec
# sub_uv = np.hstack([sub_uv, np.zeros((2, 1))]) / u.arcsec

vis = image_to_vis(data / u.arcsec**2, u=sub_uv[0, :], v=sub_uv[1, :], pixel_size=2 * u.arcsec / u.pix)
vis = image_to_vis(data * u.dimensionless_unscaled, u=sub_uv[0, :], v=sub_uv[1, :], pixel_size=2 * u.arcsec / u.pix)
setattr(vis, "amplitude_error", np.sqrt(np.abs(vis.vis)))
setattr(vis, "label", [str(x) for x in np.sqrt(x**2 + y**2).flatten()])

Expand Down

0 comments on commit 394ceae

Please sign in to comment.