-> % jupytext --to ipynb --execute pyro.md
[jupytext] Reading pyro.md in format md
[jupytext] Executing notebook with kernel python3
Traceback (most recent call last):
File "/home/matthew/src/MPoL/.venv/lib/python3.13/site-packages/jupyter_core/utils/__init__.py", line 154, in wrapped
asyncio.get_running_loop()
~~~~~~~~~~~~~~~~~~~~~~~~^^
RuntimeError: no running event loop
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/matthew/src/MPoL/.venv/bin/jupytext", line 10, in <module>
sys.exit(jupytext())
~~~~~~~~^^
File "/home/matthew/src/MPoL/.venv/lib/python3.13/site-packages/jupytext/cli.py", line 497, in jupytext
exit_code += jupytext_single_file(nb_file, args, log)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "/home/matthew/src/MPoL/.venv/lib/python3.13/site-packages/jupytext/cli.py", line 741, in jupytext_single_file
exec_proc.preprocess(notebook, resources=resources)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/matthew/src/MPoL/.venv/lib/python3.13/site-packages/nbconvert/preprocessors/execute.py", line 103, in preprocess
self.preprocess_cell(cell, resources, index)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/matthew/src/MPoL/.venv/lib/python3.13/site-packages/nbconvert/preprocessors/execute.py", line 124, in preprocess_cell
cell = self.execute_cell(cell, index, store_history=True)
File "/home/matthew/src/MPoL/.venv/lib/python3.13/site-packages/jupyter_core/utils/__init__.py", line 158, in wrapped
return loop.run_until_complete(inner)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
File "/usr/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/home/matthew/src/MPoL/.venv/lib/python3.13/site-packages/nbclient/client.py", line 1062, in async_execute_cell
await self._check_raise_for_error(cell, cell_index, exec_reply)
File "/home/matthew/src/MPoL/.venv/lib/python3.13/site-packages/nbclient/client.py", line 918, in _check_raise_for_error
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
------------------
img, beam = make_dirty_image(np.real(data), np.imag(data))
# set plot dimensions
xx = 8 # in
cax_width = 0.2 # in
cax_sep = 0.1 # in
mmargin = 1.2
lmargin = 0.7
rmargin = 0.7
tmargin = 0.3
bmargin = 0.5
npanels = 2
# the size of image axes + cax_sep + cax_width
block_width = (xx - lmargin - rmargin - mmargin * (npanels - 1) )/npanels
ax_width = block_width - cax_width - cax_sep
ax_height = ax_width
yy = bmargin + ax_height + tmargin
fig = plt.figure(figsize=(xx, yy))
ax = []
cax = []
for i in range(npanels):
ax.append(fig.add_axes([(lmargin + i * (block_width + mmargin))/xx, bmargin/yy, ax_width/xx, ax_height/yy]))
cax.append(fig.add_axes([(lmargin + i * (block_width + mmargin) + ax_width + cax_sep)/xx, bmargin/yy, cax_width/xx, ax_height/yy]))
# single-channel image cube
chan = 0
im_beam = ax[0].imshow(beam[chan], **kw)
cbar = plt.colorbar(im_beam, cax=cax[0])
ax[0].set_title("beam")
# zoom in a bit
r = 0.3
ax[0].set_xlim(r, -r)
ax[0].set_ylim(-r, r)
im = ax[1].imshow(img[chan], **kw)
ax[1].set_title("dirty image")
cbar = plt.colorbar(im, cax=cax[1])
cbar.set_label(r"Jy/$\mathrm{arcsec}^2$")
for a in ax:
a.set_xlabel(r"$\Delta \alpha \cos \delta$ [${}^{\prime\prime}$]")
a.set_ylabel(r"$\Delta \delta$ [${}^{\prime\prime}$]")
------------------
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[7], line 1
----> 1 img, beam = make_dirty_image(np.real(data), np.imag(data))
3 # set plot dimensions
4 xx = 8 # in
Cell In[6], line 35, in make_dirty_image(data_real, data_imag, robust)
14 """
15 Make a plot of the dirty beam and dirty image (in units of Jy/arcsec^2).
16
(...) 23 beam, image numpy arrays
24 """
26 imager = gridding.DirtyImager(
27 coords=coords,
28 uu=uu,
(...) 32 data_im=data_imag,
33 )
---> 35 return imager.get_dirty_image(weighting="briggs", robust=robust, unit="Jy/arcsec^2")
File ~/src/MPoL/.venv/lib/python3.13/site-packages/mpol/gridding.py:1172, in DirtyImager.get_dirty_image(self, weighting, robust, taper_function, unit, check_visibility_scatter, max_scatter, **beam_kwargs)
1167 # for units of Jy/arcsec^2, we could just leave out the C constant *if* we were
1168 # doing uniform weighting. The relationships get more complex for robust or
1169 # natural weighting, however, so it's safer to calculate the number of
1170 # arcseconds^2 per beam
1171 if unit == "Jy/arcsec^2":
-> 1172 beam_area_per_chan = self.get_dirty_beam_area(**beam_kwargs) # [arcsec^2]
1174 # convert image
1175 # (Jy/1 arcsec^2) = (Jy/ 1 beam) * (1 beam/ n arcsec^2)
1176 # beam_area_per_chan is the n of arcsec^2 per 1 beam
1178 img /= beam_area_per_chan[:, np.newaxis, np.newaxis]
File ~/src/MPoL/.venv/lib/python3.13/site-packages/mpol/gridding.py:1067, in DirtyImager.get_dirty_beam_area(self, ntheta, single_channel_estimate)
1042 def get_dirty_beam_area(
1043 self, ntheta: int = 24, single_channel_estimate: bool = True
1044 ) -> npt.NDArray[np.floating[Any]]:
1045 r"""
1046 Compute the effective area of the dirty beam for each channel. Assumes that the
1047 beam has already been generated by running
(...) 1065 :math:`[\mathrm{arcsec}^{2}]`
1066 """
-> 1067 nulled = self._null_dirty_beam(
1068 ntheta=ntheta, single_channel_estimate=single_channel_estimate
1069 )
1070 area: npt.NDArray[np.floating[Any]] = self.coords.cell_size**2 * np.sum(
1071 nulled, axis=(1, 2)
1072 ) # arcsec^2
1073 return area
File ~/src/MPoL/.venv/lib/python3.13/site-packages/mpol/gridding.py:1027, in DirtyImager._null_dirty_beam(self, ntheta, single_channel_estimate)
1024 ind_neg_and_az = ind_neg & ind_azimuth
1026 # find the smallest r within this slice
-> 1027 min_r = np.min(rr[ind_neg_and_az])
1029 # null all pixels within this slice with radii r or greater
1030 ind_r = rr >= min_r
File ~/src/MPoL/.venv/lib/python3.13/site-packages/numpy/_core/fromnumeric.py:3302, in min(a, axis, out, keepdims, initial, where)
3190 @array_function_dispatch(_min_dispatcher)
3191 def min(a, axis=None, out=None, keepdims=np._NoValue, initial=np._NoValue,
3192 where=np._NoValue):
3193 """
3194 Return the minimum of an array or minimum along an axis.
3195
(...) 3300 6
3301 """
-> 3302 return _wrapreduction(a, np.minimum, 'min', axis, None, out,
3303 keepdims=keepdims, initial=initial, where=where)
File ~/src/MPoL/.venv/lib/python3.13/site-packages/numpy/_core/fromnumeric.py:86, in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
83 else:
84 return reduction(axis=axis, out=out, **passkwargs)
---> 86 return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
ValueError: zero-size array to reduction operation minimum which has no identity
Details
I am working through the examples for my review but attempting to run example 3 errors quickly with an reference to a missing
notebook_setupscript trying to be run (see full error).Details
I see that
notebook_setup.pyexists in thelarge-tutorialsdirectory. Pointing the pyro.md file there via%run ../large-tutorials/notebook_setupthough also produces an issue when making the dirty image.Details
Additionally, all the mermaid inclusions appear to be broken in the mardown file.