viscube 0.3.0__tar.gz → 0.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. {viscube-0.3.0/viscube.egg-info → viscube-0.4.2}/PKG-INFO +1 -1
  2. viscube-0.4.2/docs/source/api.rst +43 -0
  3. {viscube-0.3.0 → viscube-0.4.2}/docs/source/intro.md +1 -0
  4. {viscube-0.3.0 → viscube-0.4.2}/docs/source/notebooks/casa_io_basic.ipynb +1 -1
  5. {viscube-0.3.0 → viscube-0.4.2}/docs/source/notebooks/casa_io_large_ms_bychan.ipynb +10 -0
  6. {viscube-0.3.0 → viscube-0.4.2}/docs/source/notebooks/combining_low_high_res_casa.ipynb +24 -16
  7. {viscube-0.3.0 → viscube-0.4.2}/docs/source/notebooks/example_basic.ipynb +54 -10
  8. viscube-0.4.2/docs/source/notebooks/xradio_uvw_continuum.ipynb +957 -0
  9. {viscube-0.3.0 → viscube-0.4.2}/readthedocs.yaml +0 -2
  10. viscube-0.4.2/viscube/__init__.py +50 -0
  11. {viscube-0.3.0 → viscube-0.4.2}/viscube/__meta__.py +2 -1
  12. viscube-0.4.2/viscube/deapodization.py +534 -0
  13. viscube-0.4.2/viscube/grid_cube.py +1373 -0
  14. viscube-0.4.2/viscube/gridder.py +403 -0
  15. {viscube-0.3.0 → viscube-0.4.2}/viscube/sigma_per_baseline.py +19 -0
  16. viscube-0.4.2/viscube/windows.py +293 -0
  17. {viscube-0.3.0 → viscube-0.4.2/viscube.egg-info}/PKG-INFO +1 -1
  18. {viscube-0.3.0 → viscube-0.4.2}/viscube.egg-info/SOURCES.txt +3 -0
  19. viscube-0.4.2/viscube.egg-info/scm_file_list.json +38 -0
  20. viscube-0.4.2/viscube.egg-info/scm_version.json +8 -0
  21. viscube-0.3.0/docs/source/api.rst +0 -10
  22. viscube-0.3.0/docs/source/notebooks/xradio_uvw_continuum.ipynb +0 -1007
  23. viscube-0.3.0/viscube/__init__.py +0 -14
  24. viscube-0.3.0/viscube/grid_cube.py +0 -720
  25. viscube-0.3.0/viscube/gridder.py +0 -138
  26. viscube-0.3.0/viscube/windows.py +0 -136
  27. {viscube-0.3.0 → viscube-0.4.2}/.github/workflows/PyPI.yaml +0 -0
  28. {viscube-0.3.0 → viscube-0.4.2}/.gitignore +0 -0
  29. {viscube-0.3.0 → viscube-0.4.2}/LICENSE +0 -0
  30. {viscube-0.3.0 → viscube-0.4.2}/README.md +0 -0
  31. {viscube-0.3.0 → viscube-0.4.2}/Viscube_logo.svg +0 -0
  32. {viscube-0.3.0 → viscube-0.4.2}/docs/Makefile +0 -0
  33. {viscube-0.3.0 → viscube-0.4.2}/docs/requirements.txt +0 -0
  34. {viscube-0.3.0 → viscube-0.4.2}/docs/source/_config.yml +0 -0
  35. {viscube-0.3.0 → viscube-0.4.2}/docs/source/_toc.yml +0 -0
  36. {viscube-0.3.0 → viscube-0.4.2}/docs/source/extracting_ms_to_py.md +0 -0
  37. {viscube-0.3.0 → viscube-0.4.2}/docs/source/install.md +0 -0
  38. {viscube-0.3.0 → viscube-0.4.2}/docs/source/notebooks/casa_io_basic_old.ipynb +0 -0
  39. {viscube-0.3.0 → viscube-0.4.2}/docs/source/notebooks/casa_io_casacore_table.ipynb +0 -0
  40. {viscube-0.3.0 → viscube-0.4.2}/docs/source/notebooks/casa_io_large_ms.ipynb +0 -0
  41. {viscube-0.3.0 → viscube-0.4.2}/docs/source/notebooks/example_basic_old.ipynb +0 -0
  42. {viscube-0.3.0 → viscube-0.4.2}/docs/source/statistics.md +0 -0
  43. {viscube-0.3.0 → viscube-0.4.2}/pyproject.toml +0 -0
  44. {viscube-0.3.0 → viscube-0.4.2}/requirements.txt +0 -0
  45. {viscube-0.3.0 → viscube-0.4.2}/setup.cfg +0 -0
  46. {viscube-0.3.0 → viscube-0.4.2}/setup.py +0 -0
  47. {viscube-0.3.0 → viscube-0.4.2}/viscube.egg-info/dependency_links.txt +0 -0
  48. {viscube-0.3.0 → viscube-0.4.2}/viscube.egg-info/requires.txt +0 -0
  49. {viscube-0.3.0 → viscube-0.4.2}/viscube.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: viscube
3
- Version: 0.3.0
3
+ Version: 0.4.2
4
4
  Summary: Visibility-space gridder for image cubes
5
5
  Home-page:
6
6
  Author: Michael James Yantovski Barth
@@ -0,0 +1,43 @@
1
+ VisCube API
2
+ ===========
3
+
4
+ The complete VisCube application programming interface, organized by
5
+ module. Everything documented here (except the low-level gridding engines
6
+ and window functions) is also re-exported at the package top level, so
7
+ ``from viscube import grid_cube_all_stats_nonoverlap`` and
8
+ ``viscube.grid_cube.grid_cube_all_stats_nonoverlap`` are equivalent.
9
+
10
+ High-level gridding: ``viscube.grid_cube``
11
+ ------------------------------------------
12
+
13
+ .. automodule:: viscube.grid_cube
14
+ :members:
15
+ :member-order: bysource
16
+
17
+ Low-level gridding engines: ``viscube.gridder``
18
+ -----------------------------------------------
19
+
20
+ .. automodule:: viscube.gridder
21
+ :members:
22
+ :member-order: bysource
23
+
24
+ Gridding kernels: ``viscube.windows``
25
+ -------------------------------------
26
+
27
+ .. automodule:: viscube.windows
28
+ :members:
29
+ :member-order: bysource
30
+
31
+ Noise estimation: ``viscube.sigma_per_baseline``
32
+ ------------------------------------------------
33
+
34
+ .. automodule:: viscube.sigma_per_baseline
35
+ :members:
36
+ :member-order: bysource
37
+
38
+ Image-plane tapers: ``viscube.deapodization``
39
+ ---------------------------------------------
40
+
41
+ .. automodule:: viscube.deapodization
42
+ :members:
43
+ :member-order: bysource
@@ -13,6 +13,7 @@ To learn how to use VisCube, I suggest following the documentation in the follow
13
13
  1. Run the ["Beginner's Guide"](https://viscube.readthedocs.io/en/latest/notebooks/example_basic.html) on your local machine to get acquainted with VisCube's functionality and make sure your installation is functional
14
14
  2. Read through the ["How-to Guide: Extracting data from Measurement Sets"](https://viscube.readthedocs.io/en/latest/extracting_ms_to_py.html) to learn how to prepare your own measurement sets for VisCube
15
15
  3. Once you have learnt one of the methods taught in the "extraction How-to Guides", you can run the code from the Beginner's guide on your own data (with modifications as needed).
16
+ 4. For the full list of functions and their parameters (gridding variants, kernels, noise estimation, image-plane tapers), consult the [API reference](https://viscube.readthedocs.io/en/latest/api.html).
16
17
 
17
18
  This project is a spinoff of a continuum-only gridder I worked on with Noé Dia and Alexandre Adam; that gridder has been released as part of the [IRIS interferometric imaging pipeline.](https://github.com/enceladecandy/iris)
18
19
 
@@ -224,7 +224,7 @@
224
224
  "id": "bc68bc83-c0cf-4914-bfda-73cdf45c21d5",
225
225
  "metadata": {},
226
226
  "source": [
227
- "**Helpful tip: If you find that your kernel is dying during the above cell due to memory limitations, it may be helpful to iterate through the measurement set using `ms.selectchannel(nchan=nch, start=ch0, width=1, inc=1)` and a for loop over `nch`**. For a tutorial on how to do that, visit [this page]()"
227
+ "**Helpful tip: If you find that your kernel is dying during the above cell due to memory limitations, it may be helpful to iterate through the measurement set using `ms.selectchannel(nchan=nch, start=ch0, width=1, inc=1)` and a for loop over `nch`**. For a tutorial on how to do that, visit [this page](https://viscube.readthedocs.io/en/latest/notebooks/casa_io_large_ms_bychan.html)"
228
228
  ]
229
229
  },
230
230
  {
@@ -365,6 +365,16 @@
365
365
  "print(\" weight:\", weight_all.shape, weight_all.dtype)"
366
366
  ]
367
367
  },
368
+ {
369
+ "cell_type": "markdown",
370
+ "id": "be21175e",
371
+ "metadata": {},
372
+ "source": [
373
+ "### Next step: per-visibility uncertainties\n",
374
+ "\n",
375
+ "The file saved above contains no `sigma_re`/`sigma_im` arrays, but VisCube's gridding functions require per-visibility inverse variances (`invvar_group_re`/`invvar_group_im`) for their hybrid uncertainty estimation. To compute them, also extract the `TIME` and `SCAN_NUMBER` columns (add them to the static per-row read above — they are per-row, so they fit in memory even for large measurement sets) and run `viscube.sigma_by_baseline_scan_time_diff` on the extracted cube, exactly as in Step 9 of the [intro CASA tutorial](https://viscube.readthedocs.io/en/latest/notebooks/casa_io_basic.html)."
376
+ ]
377
+ },
368
378
  {
369
379
  "cell_type": "code",
370
380
  "execution_count": null,
@@ -899,22 +899,36 @@
899
899
  },
900
900
  {
901
901
  "cell_type": "code",
902
- "execution_count": 22,
902
+ "execution_count": null,
903
903
  "id": "c7eccc3d-a81d-4600-9df8-aa36bc7a48e8",
904
904
  "metadata": {},
905
905
  "outputs": [],
906
906
  "source": [
907
- "frequencies, u0, v0, vis0, weight0 = load_and_mask(freq, u_raw, v_raw, vis_raw, weight_raw, mask)"
907
+ "# Approximate per-visibility noise from the MS weights (weight = 1/sigma^2).\n",
908
+ "# For a data-driven, publication-grade estimate, extract TIME/SCAN_NUMBER as\n",
909
+ "# well and use viscube.sigma_by_baseline_scan_time_diff instead (see Step 9 of\n",
910
+ "# the intro CASA tutorial).\n",
911
+ "sigma_est = 1.0 / np.sqrt(np.maximum(weight_raw, 1e-30))\n",
912
+ "\n",
913
+ "frequencies, u0, v0, vis0, weight0, sigma_re0, sigma_im0 = load_and_mask(\n",
914
+ " freq, u_raw, v_raw, vis_raw, weight_raw, sigma_est, sigma_est, mask\n",
915
+ ")"
908
916
  ]
909
917
  },
910
918
  {
911
919
  "cell_type": "code",
912
- "execution_count": 23,
920
+ "execution_count": null,
913
921
  "id": "0f96f8ce-6965-4a70-8b27-9633f36f0be4",
914
922
  "metadata": {},
915
923
  "outputs": [],
916
924
  "source": [
917
- "uu, vv, vis_re, vis_imag, wt = hermitian_augment(u0, v0, vis0, weight0)"
925
+ "uu, vv, vis_re, vis_imag, wt, sigma_re_aug, sigma_im_aug = hermitian_augment(\n",
926
+ " u0, v0, vis0, weight0, sigma_re0, sigma_im0\n",
927
+ ")\n",
928
+ "\n",
929
+ "# Inverse variances for the low-info std fallback\n",
930
+ "invvar_group_re = 1.0 / np.maximum(sigma_re_aug, 1e-12)**2\n",
931
+ "invvar_group_im = 1.0 / np.maximum(sigma_im_aug, 1e-12)**2"
918
932
  ]
919
933
  },
920
934
  {
@@ -973,23 +987,17 @@
973
987
  },
974
988
  {
975
989
  "cell_type": "code",
976
- "execution_count": 27,
990
+ "execution_count": null,
977
991
  "id": "d39887e5-da1b-40d7-b545-61ba5421ba01",
978
992
  "metadata": {},
979
- "outputs": [
980
- {
981
- "name": "stderr",
982
- "output_type": "stream",
983
- "text": [
984
- "100%|████████████| 80/80 [12:53<00:00, 9.66s/channel, coarse_std_im=74, coarse_std_re=74]\n"
985
- ]
986
- }
987
- ],
993
+ "outputs": [],
988
994
  "source": [
989
995
  "mean_re, mean_im, std_re, std_im, counts, u_edges, v_edges = grid_cube_all_stats(\n",
990
996
  " frequencies=freq, uu=uu, vv=vv, vis_re=vis_re, vis_imag=vis_imag, weight=wt,\n",
991
- " npix = npix, window_name=\"kaiser_bessel\",\n",
992
- " window_kwargs={\"m\": 6} # only KB will use beta; m/normalize optional\n",
997
+ " invvar_group_re=invvar_group_re,\n",
998
+ " invvar_group_im=invvar_group_im,\n",
999
+ " npix=npix, window_name=\"kaiser_bessel\",\n",
1000
+ " window_kwargs={\"m\": 6},\n",
993
1001
  ")"
994
1002
  ]
995
1003
  },
@@ -25,7 +25,7 @@
25
25
  },
26
26
  {
27
27
  "cell_type": "code",
28
- "execution_count": 12,
28
+ "execution_count": 2,
29
29
  "id": "f71e6ac3-4a0e-4d6e-82b0-3a30192d35ea",
30
30
  "metadata": {},
31
31
  "outputs": [],
@@ -53,7 +53,7 @@
53
53
  },
54
54
  {
55
55
  "cell_type": "code",
56
- "execution_count": 13,
56
+ "execution_count": 3,
57
57
  "id": "3691fd24-4111-41f9-bf53-7af8b271caaf",
58
58
  "metadata": {},
59
59
  "outputs": [],
@@ -80,7 +80,7 @@
80
80
  },
81
81
  {
82
82
  "cell_type": "code",
83
- "execution_count": 14,
83
+ "execution_count": 5,
84
84
  "id": "48998306-1637-493a-8d75-296036baae84",
85
85
  "metadata": {},
86
86
  "outputs": [],
@@ -103,7 +103,7 @@
103
103
  },
104
104
  {
105
105
  "cell_type": "code",
106
- "execution_count": 15,
106
+ "execution_count": 6,
107
107
  "id": "470ae46e-bc02-4f55-9463-2e64be61d97f",
108
108
  "metadata": {},
109
109
  "outputs": [],
@@ -135,12 +135,14 @@
135
135
  "\n",
136
136
  "`counts`: number of visibilities in each grid cell (can be useful for creating a mask also)\n",
137
137
  "\n",
138
- "`u_edges, v_edges`: the edges of the grid in U,V coordinates"
138
+ "`u_edges, v_edges`: the edges of the grid in U,V coordinates\n",
139
+ "\n",
140
+ "VisCube also provides `grid_cube_all_stats_nonoverlap`, a much faster drop-in alternative in which each visibility lands in exactly one uv cell — see the optional alternative step below. For the full list of gridding options and their parameters, see the [API reference](https://viscube.readthedocs.io/en/latest/api.html)."
139
141
  ]
140
142
  },
141
143
  {
142
144
  "cell_type": "code",
143
- "execution_count": 16,
145
+ "execution_count": 7,
144
146
  "id": "69430ae6-82f9-4286-929c-bc6de1c133ec",
145
147
  "metadata": {},
146
148
  "outputs": [],
@@ -153,7 +155,7 @@
153
155
  },
154
156
  {
155
157
  "cell_type": "code",
156
- "execution_count": 17,
158
+ "execution_count": 8,
157
159
  "id": "cd89f0e2-e3bb-4050-bab6-08b148ee20a7",
158
160
  "metadata": {},
159
161
  "outputs": [
@@ -161,7 +163,7 @@
161
163
  "name": "stderr",
162
164
  "output_type": "stream",
163
165
  "text": [
164
- "100%|█| 80/80 [03:45<00:00, 2.82s/channel, fallback_pix_im=744, fallback_pix_re\n"
166
+ "100%|███████████| 80/80 [02:55<00:00, 2.19s/channel, fallback_pix_im=808, fallback_pix_re=808]\n"
165
167
  ]
166
168
  }
167
169
  ],
@@ -184,6 +186,48 @@
184
186
  ")"
185
187
  ]
186
188
  },
189
+ {
190
+ "cell_type": "markdown",
191
+ "id": "7b6da4a7",
192
+ "metadata": {},
193
+ "source": [
194
+ "### Step 3 (alternative): Fast non-overlapping gridding\n",
195
+ "\n",
196
+ "`grid_cube_all_stats_nonoverlap` returns the exact same output tuple as `grid_cube_all_stats`, but each visibility contributes to exactly ONE uv cell (with a within-bin Kaiser–Bessel weighting), which makes it much faster than the kernel-overlap path above. Two things to know:\n",
197
+ "\n",
198
+ "1. Because our inputs are hermitian-augmented, we pass `n_aug` (the number of *original*, pre-augmentation visibilities per channel) so that conjugate copies landing in the DC cell are dropped.\n",
199
+ "2. If you forward-model these gridded visibilities (FFT a model image and compare), multiply your model image by the matching analytic taper from `viscube.make_kb_taper_map` (same `m` and `beta`) before the FFT.\n",
200
+ "\n",
201
+ "It also warns loudly if any visibility falls outside the uv grid (such visibilities are dropped)."
202
+ ]
203
+ },
204
+ {
205
+ "cell_type": "code",
206
+ "execution_count": null,
207
+ "id": "a21e909e",
208
+ "metadata": {},
209
+ "outputs": [],
210
+ "source": [
211
+ "from viscube import grid_cube_all_stats_nonoverlap\n",
212
+ "\n",
213
+ "mean_re_no, mean_im_no, std_re_no, std_im_no, counts_no, u_edges_no, v_edges_no = \\\n",
214
+ " grid_cube_all_stats_nonoverlap(\n",
215
+ " frequencies=freq,\n",
216
+ " uu=uu,\n",
217
+ " vv=vv,\n",
218
+ " vis_re=vis_re,\n",
219
+ " vis_imag=vis_imag,\n",
220
+ " weight=wt,\n",
221
+ " invvar_group_re=invvar_group_re,\n",
222
+ " invvar_group_im=invvar_group_im,\n",
223
+ " npix=501,\n",
224
+ " m=1, # kernel support = one uv cell\n",
225
+ " beta=2.0, # beta=0 would be a plain pillbox\n",
226
+ " std_min_effective=std_min_effective,\n",
227
+ " n_aug=u0.shape[1], # pre-augmentation visibility count per channel\n",
228
+ " )"
229
+ ]
230
+ },
187
231
  {
188
232
  "cell_type": "markdown",
189
233
  "id": "33e43b9b-bfd8-4b12-bc90-18678eaddc56",
@@ -196,7 +240,7 @@
196
240
  },
197
241
  {
198
242
  "cell_type": "code",
199
- "execution_count": 19,
243
+ "execution_count": 9,
200
244
  "id": "ccc6f374-bc87-457e-b048-6b7fa873bfe3",
201
245
  "metadata": {},
202
246
  "outputs": [],
@@ -222,7 +266,7 @@
222
266
  },
223
267
  {
224
268
  "cell_type": "code",
225
- "execution_count": 20,
269
+ "execution_count": 10,
226
270
  "id": "b9bff9b6-86b5-4735-ae8b-b7211a548f65",
227
271
  "metadata": {},
228
272
  "outputs": [