tabsim 0.0.5__tar.gz → 0.0.6__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.
- {tabsim-0.0.5 → tabsim-0.0.6}/PKG-INFO +1 -1
- {tabsim-0.0.5 → tabsim-0.0.6}/pyproject.toml +1 -1
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/dask/coordinates.py +34 -26
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/dask/interferometry.py +35 -27
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/dask/observation.py +40 -25
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/jax/coordinates.py +7 -37
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/jax/interferometry.py +10 -38
- tabsim-0.0.6/tabsim/jax/utils.py +11 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/scripts/sim_vis.py +4 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim.egg-info/PKG-INFO +1 -1
- tabsim-0.0.5/tabsim/jax/utils.py +0 -90
- {tabsim-0.0.5 → tabsim-0.0.6}/LICENSE +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/README.md +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/docs/conf.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/setup.cfg +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/__init__.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/config.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/dask/__init__.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/dask/extras.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/data/__init__.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/data/config/sim_config_base.yaml +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/data/config/tab_config_base.yaml +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/data/rfi/norad_satellite.rfimodel +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/data/rfi/satellite.ole +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/data/rfi/satellite.rfimodel +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/data/rfi/stationary.loc +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/data/rfi/stationary.rfimodel +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/data/rfi/tles/2023-02-21-J8HE0T.json +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/data/rfi/tles/2023-02-21-navstar.json +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/data/sky/calibrator.skymodel +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/data/telescopes/EDA2.itrf.txt +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/data/telescopes/MWA.itrf.txt +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/data/telescopes/MeerKAT.itrf.txt +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/data/telescopes/_telescopes.yaml +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/jax/__init__.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/plot.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/read_ms.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/scripts/__init__.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/scripts/ast_region.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/scripts/flag_data.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/scripts/tle_sat_region.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/scripts/write_config_from_ms.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/sky.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/tle.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/tools.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim/write.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim.egg-info/SOURCES.txt +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim.egg-info/dependency_links.txt +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim.egg-info/entry_points.txt +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim.egg-info/requires.txt +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tabsim.egg-info/top_level.txt +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tests/test_basic.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tests/test_sim-vis.py +0 -0
- {tabsim-0.0.5 → tabsim-0.0.6}/tests/test_version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tabsim
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: Trajectory-based Radio Frequency Interference (RFI) simulations for radio interferometeric data.
|
|
5
5
|
Author-email: Chris Finlay <christopher.finlay@epfl.ch>
|
|
6
6
|
Maintainer-email: Chris Finlay <christopher.finlay@epfl.ch>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from tabsim.jax import coordinates as coord
|
|
2
2
|
|
|
3
|
+
from jax import jit
|
|
4
|
+
|
|
3
5
|
import dask.array as da
|
|
4
6
|
from dask.delayed import delayed
|
|
5
7
|
from dask.array.core import Array
|
|
@@ -22,7 +24,7 @@ def radec_to_lmn(ra: Array, dec: Array, phase_centre: Array) -> Array:
|
|
|
22
24
|
{
|
|
23
25
|
"lmn": (
|
|
24
26
|
["src", "lmn_space"],
|
|
25
|
-
da.zeros(
|
|
27
|
+
da.zeros( # type: ignore
|
|
26
28
|
shape=(n_src, 3),
|
|
27
29
|
chunks=(src_chunk, 3),
|
|
28
30
|
dtype=float,
|
|
@@ -32,7 +34,7 @@ def radec_to_lmn(ra: Array, dec: Array, phase_centre: Array) -> Array:
|
|
|
32
34
|
)
|
|
33
35
|
|
|
34
36
|
def _radec_to_lmn(ds):
|
|
35
|
-
lmn = delayed(coord.radec_to_lmn, pure=True)(
|
|
37
|
+
lmn = delayed(jit(coord.radec_to_lmn), pure=True)(
|
|
36
38
|
ds.ra.data, ds.dec.data, ds.phase_centre.data
|
|
37
39
|
).compute()
|
|
38
40
|
ds_out = xr.Dataset({"lmn": (["src", "lmn_space"], lmn)})
|
|
@@ -61,7 +63,7 @@ def radec_to_XYZ(ra: Array, dec: Array) -> Array:
|
|
|
61
63
|
{
|
|
62
64
|
"XYZ": (
|
|
63
65
|
["src", "space"],
|
|
64
|
-
da.zeros(
|
|
66
|
+
da.zeros( # type: ignore
|
|
65
67
|
shape=(n_src, 3),
|
|
66
68
|
chunks=(src_chunk, 3),
|
|
67
69
|
dtype=float,
|
|
@@ -71,7 +73,9 @@ def radec_to_XYZ(ra: Array, dec: Array) -> Array:
|
|
|
71
73
|
)
|
|
72
74
|
|
|
73
75
|
def _radec_to_XYZ(ds):
|
|
74
|
-
XYZ = delayed(coord.radec_to_XYZ, pure=True)(
|
|
76
|
+
XYZ = delayed(jit(coord.radec_to_XYZ), pure=True)(
|
|
77
|
+
ds.ra.data, ds.dec.data
|
|
78
|
+
).compute()
|
|
75
79
|
ds_out = xr.Dataset({"XYZ": (["src", "space"], XYZ)})
|
|
76
80
|
return ds_out
|
|
77
81
|
|
|
@@ -98,7 +102,7 @@ def ENU_to_GEO(geo_ref: Array, ENU: Array) -> Array:
|
|
|
98
102
|
{
|
|
99
103
|
"GEO": (
|
|
100
104
|
["bl", "space"],
|
|
101
|
-
da.zeros(
|
|
105
|
+
da.zeros( # type: ignore
|
|
102
106
|
shape=(n_ant, 3),
|
|
103
107
|
chunks=(ant_chunk, 3),
|
|
104
108
|
dtype=float,
|
|
@@ -108,7 +112,7 @@ def ENU_to_GEO(geo_ref: Array, ENU: Array) -> Array:
|
|
|
108
112
|
)
|
|
109
113
|
|
|
110
114
|
def _ENU_to_GEO(ds):
|
|
111
|
-
GEO = delayed(coord.ENU_to_GEO, pure=True)(
|
|
115
|
+
GEO = delayed(jit(coord.ENU_to_GEO), pure=True)(
|
|
112
116
|
ds.geo_ref.data, ds.ENU.data
|
|
113
117
|
).compute()
|
|
114
118
|
ds_out = xr.Dataset({"GEO": (["ant", "space"], GEO)})
|
|
@@ -137,7 +141,7 @@ def GEO_to_XYZ(geo: Array, times: Array) -> Array:
|
|
|
137
141
|
{
|
|
138
142
|
"XYZ": (
|
|
139
143
|
["time", "space"],
|
|
140
|
-
da.zeros(
|
|
144
|
+
da.zeros( # type: ignore
|
|
141
145
|
shape=(n_time, 3),
|
|
142
146
|
chunks=(time_chunk, 3),
|
|
143
147
|
dtype=float,
|
|
@@ -147,7 +151,9 @@ def GEO_to_XYZ(geo: Array, times: Array) -> Array:
|
|
|
147
151
|
)
|
|
148
152
|
|
|
149
153
|
def _GEO_to_XYZ(ds):
|
|
150
|
-
XYZ = delayed(coord.GEO_to_XYZ, pure=True)(
|
|
154
|
+
XYZ = delayed(jit(coord.GEO_to_XYZ), pure=True)(
|
|
155
|
+
ds.geo.data, ds.times.data
|
|
156
|
+
).compute()
|
|
151
157
|
ds_out = xr.Dataset({"XYZ": (["time", "space"], XYZ)})
|
|
152
158
|
return ds_out
|
|
153
159
|
|
|
@@ -175,7 +181,7 @@ def GEO_to_XYZ_vmap0(geo: Array, times: Array) -> Array:
|
|
|
175
181
|
{
|
|
176
182
|
"XYZ": (
|
|
177
183
|
["src", "time", "space"],
|
|
178
|
-
da.zeros(
|
|
184
|
+
da.zeros( # type: ignore
|
|
179
185
|
shape=(n_src, n_time, 3),
|
|
180
186
|
chunks=(src_chunk, time_chunk, 3),
|
|
181
187
|
dtype=float,
|
|
@@ -185,7 +191,7 @@ def GEO_to_XYZ_vmap0(geo: Array, times: Array) -> Array:
|
|
|
185
191
|
)
|
|
186
192
|
|
|
187
193
|
def _GEO_to_XYZ(ds):
|
|
188
|
-
XYZ = delayed(coord.GEO_to_XYZ_vmap0, pure=True)(
|
|
194
|
+
XYZ = delayed(jit(coord.GEO_to_XYZ_vmap0), pure=True)(
|
|
189
195
|
ds.geo.data, ds.times.data
|
|
190
196
|
).compute()
|
|
191
197
|
ds_out = xr.Dataset({"XYZ": (["src", "time", "space"], XYZ)})
|
|
@@ -214,7 +220,7 @@ def GEO_to_XYZ_vmap1(geo: Array, times: Array) -> Array:
|
|
|
214
220
|
{
|
|
215
221
|
"XYZ": (
|
|
216
222
|
["time", "ant", "space"],
|
|
217
|
-
da.zeros(
|
|
223
|
+
da.zeros( # type: ignore
|
|
218
224
|
shape=(n_time, n_ant, 3),
|
|
219
225
|
chunks=(time_chunk, ant_chunk, 3),
|
|
220
226
|
dtype=float,
|
|
@@ -224,7 +230,7 @@ def GEO_to_XYZ_vmap1(geo: Array, times: Array) -> Array:
|
|
|
224
230
|
)
|
|
225
231
|
|
|
226
232
|
def _GEO_to_XYZ(ds):
|
|
227
|
-
XYZ = delayed(coord.GEO_to_XYZ_vmap1, pure=True)(
|
|
233
|
+
XYZ = delayed(jit(coord.GEO_to_XYZ_vmap1), pure=True)(
|
|
228
234
|
ds.geo.data, ds.times.data
|
|
229
235
|
).compute()
|
|
230
236
|
ds_out = xr.Dataset({"XYZ": (["time", "ant", "space"], XYZ)})
|
|
@@ -255,7 +261,7 @@ def ITRF_to_XYZ(itrf: Array, gsa: Array) -> Array:
|
|
|
255
261
|
{
|
|
256
262
|
"xyz": (
|
|
257
263
|
["time", "ant", "space"],
|
|
258
|
-
da.zeros(
|
|
264
|
+
da.zeros( # type: ignore
|
|
259
265
|
shape=(n_time, n_ant, 3),
|
|
260
266
|
chunks=(time_chunk, ant_chunk, 3),
|
|
261
267
|
dtype=float,
|
|
@@ -265,7 +271,9 @@ def ITRF_to_XYZ(itrf: Array, gsa: Array) -> Array:
|
|
|
265
271
|
)
|
|
266
272
|
|
|
267
273
|
def _ITRF_to_XYZ(ds):
|
|
268
|
-
XYZ = delayed(coord.itrf_to_xyz, pure=True)(
|
|
274
|
+
XYZ = delayed(jit(coord.itrf_to_xyz), pure=True)(
|
|
275
|
+
ds.itrf.data, ds.gsa.data
|
|
276
|
+
).compute()
|
|
269
277
|
ds_out = xr.Dataset({"xyz": (["time", "ant", "space"], XYZ)})
|
|
270
278
|
return ds_out
|
|
271
279
|
|
|
@@ -294,7 +302,7 @@ def ENU_to_ITRF(ENU: Array, lat: Array, lon: Array, el: Array) -> Array:
|
|
|
294
302
|
{
|
|
295
303
|
"ITRF": (
|
|
296
304
|
["ant", "space"],
|
|
297
|
-
da.zeros(
|
|
305
|
+
da.zeros( # type: ignore
|
|
298
306
|
shape=(n_ant, 3),
|
|
299
307
|
chunks=(ant_chunk, 3),
|
|
300
308
|
dtype=float,
|
|
@@ -304,7 +312,7 @@ def ENU_to_ITRF(ENU: Array, lat: Array, lon: Array, el: Array) -> Array:
|
|
|
304
312
|
)
|
|
305
313
|
|
|
306
314
|
def _ENU_to_ITRF(ds):
|
|
307
|
-
ITRF = delayed(coord.enu_to_itrf, pure=True)(
|
|
315
|
+
ITRF = delayed(jit(coord.enu_to_itrf), pure=True)(
|
|
308
316
|
ds.ENU.data,
|
|
309
317
|
ds.lat.data,
|
|
310
318
|
ds.lon.data,
|
|
@@ -335,8 +343,8 @@ def ITRF_to_UVW(
|
|
|
335
343
|
input = xr.Dataset(
|
|
336
344
|
{
|
|
337
345
|
"itrf": (["ant", "space"], itrf),
|
|
338
|
-
"h0": (["time"], da.atleast_1d(h0)),
|
|
339
|
-
"dec": (["cel_space_1"], da.atleast_1d(dec)),
|
|
346
|
+
"h0": (["time"], da.atleast_1d(h0)), # type: ignore
|
|
347
|
+
"dec": (["cel_space_1"], da.atleast_1d(dec)), # type: ignore
|
|
340
348
|
}
|
|
341
349
|
)
|
|
342
350
|
|
|
@@ -344,7 +352,7 @@ def ITRF_to_UVW(
|
|
|
344
352
|
{
|
|
345
353
|
"uvw": (
|
|
346
354
|
["time", "ant", "space"],
|
|
347
|
-
da.zeros(
|
|
355
|
+
da.zeros( # type: ignore
|
|
348
356
|
shape=(n_time, n_ant, 3),
|
|
349
357
|
chunks=(time_chunk, ant_chunk, 3),
|
|
350
358
|
dtype=float,
|
|
@@ -354,7 +362,7 @@ def ITRF_to_UVW(
|
|
|
354
362
|
)
|
|
355
363
|
|
|
356
364
|
def _ITRF_to_UVW(ds):
|
|
357
|
-
uvw = delayed(coord.itrf_to_uvw, pure=True)(
|
|
365
|
+
uvw = delayed(jit(coord.itrf_to_uvw), pure=True)(
|
|
358
366
|
ds.itrf.data,
|
|
359
367
|
ds.h0.data,
|
|
360
368
|
ds.dec.data,
|
|
@@ -381,8 +389,8 @@ def angular_separation(rfi_xyz: Array, ants_xyz: Array, ra: Array, dec: Array) -
|
|
|
381
389
|
{
|
|
382
390
|
"rfi_xyz": (["src", "time", "space"], rfi_xyz),
|
|
383
391
|
"ants_xyz": (["time", "ant", "space"], ants_xyz),
|
|
384
|
-
"ra": (["cel_space_0"], da.from_array([ra])),
|
|
385
|
-
"dec": (["cel_space_1"], da.from_array([dec])),
|
|
392
|
+
"ra": (["cel_space_0"], da.from_array([ra])), # type: ignore
|
|
393
|
+
"dec": (["cel_space_1"], da.from_array([dec])), # type: ignore
|
|
386
394
|
}
|
|
387
395
|
)
|
|
388
396
|
|
|
@@ -390,7 +398,7 @@ def angular_separation(rfi_xyz: Array, ants_xyz: Array, ra: Array, dec: Array) -
|
|
|
390
398
|
{
|
|
391
399
|
"sep": (
|
|
392
400
|
["src", "time", "ant"],
|
|
393
|
-
da.zeros(
|
|
401
|
+
da.zeros( # type: ignore
|
|
394
402
|
shape=(n_src, n_time, n_ant),
|
|
395
403
|
chunks=(src_chunk, time_chunk, ant_chunk),
|
|
396
404
|
dtype=float,
|
|
@@ -400,7 +408,7 @@ def angular_separation(rfi_xyz: Array, ants_xyz: Array, ra: Array, dec: Array) -
|
|
|
400
408
|
)
|
|
401
409
|
|
|
402
410
|
def _angular_separation(ds):
|
|
403
|
-
sep = delayed(coord.angular_separation, pure=True)(
|
|
411
|
+
sep = delayed(jit(coord.angular_separation), pure=True)(
|
|
404
412
|
ds.rfi_xyz.data, ds.ants_xyz.data, ds.ra.data, ds.dec.data
|
|
405
413
|
).compute()
|
|
406
414
|
ds_out = xr.Dataset({"sep": (["src", "time", "ant"], sep)})
|
|
@@ -441,7 +449,7 @@ def orbit_vmap(
|
|
|
441
449
|
{
|
|
442
450
|
"orbit": (
|
|
443
451
|
["src", "time", "space"],
|
|
444
|
-
da.zeros(
|
|
452
|
+
da.zeros( # type: ignore
|
|
445
453
|
shape=(n_src, n_time, 3),
|
|
446
454
|
chunks=(src_chunk, time_chunk, 3),
|
|
447
455
|
dtype=float,
|
|
@@ -451,7 +459,7 @@ def orbit_vmap(
|
|
|
451
459
|
)
|
|
452
460
|
|
|
453
461
|
def _orbit_vmap(ds):
|
|
454
|
-
orbit = delayed(coord.orbit_vmap, pure=True)(
|
|
462
|
+
orbit = delayed(jit(coord.orbit_vmap), pure=True)(
|
|
455
463
|
ds.times.data,
|
|
456
464
|
ds.elevation.data,
|
|
457
465
|
ds.inclination.data,
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
from jax import jit
|
|
2
|
+
|
|
2
3
|
import numpy as np
|
|
3
4
|
import xarray as xr
|
|
5
|
+
|
|
6
|
+
import dask.array as da
|
|
4
7
|
from dask.delayed import delayed
|
|
5
8
|
from dask.array.core import Array
|
|
9
|
+
|
|
6
10
|
from tabsim.jax import interferometry as itf
|
|
7
11
|
|
|
12
|
+
from typing import Optional
|
|
13
|
+
|
|
8
14
|
|
|
9
15
|
def astro_vis(sources: Array, uvw: Array, lmn: Array, freqs: Array) -> Array:
|
|
10
16
|
"""Calculate visibilities from sources, uvw, lmn, and freqs.
|
|
@@ -51,7 +57,7 @@ def astro_vis(sources: Array, uvw: Array, lmn: Array, freqs: Array) -> Array:
|
|
|
51
57
|
{
|
|
52
58
|
"vis": (
|
|
53
59
|
["time", "bl", "freq"],
|
|
54
|
-
da.zeros(
|
|
60
|
+
da.zeros( # type: ignore
|
|
55
61
|
shape=(n_time, n_bl, n_freq),
|
|
56
62
|
chunks=(time_chunk, bl_chunk, freq_chunk),
|
|
57
63
|
dtype=complex,
|
|
@@ -61,7 +67,7 @@ def astro_vis(sources: Array, uvw: Array, lmn: Array, freqs: Array) -> Array:
|
|
|
61
67
|
)
|
|
62
68
|
|
|
63
69
|
def _astro_vis(ds):
|
|
64
|
-
vis = delayed(itf.astro_vis)(
|
|
70
|
+
vis = delayed(jit(itf.astro_vis), pure=True)(
|
|
65
71
|
ds.I.data, ds.uvw.data, ds.lmn.data, ds.freqs.data
|
|
66
72
|
).compute()
|
|
67
73
|
ds_out = xr.Dataset({"vis": (["time", "bl", "freq"], vis)})
|
|
@@ -122,7 +128,7 @@ def astro_vis_gauss(
|
|
|
122
128
|
{
|
|
123
129
|
"vis": (
|
|
124
130
|
["time", "bl", "freq"],
|
|
125
|
-
da.zeros(
|
|
131
|
+
da.zeros( # type: ignore
|
|
126
132
|
shape=(n_time, n_bl, n_freq),
|
|
127
133
|
chunks=(time_chunk, bl_chunk, freq_chunk),
|
|
128
134
|
dtype=complex,
|
|
@@ -132,7 +138,7 @@ def astro_vis_gauss(
|
|
|
132
138
|
)
|
|
133
139
|
|
|
134
140
|
def _astro_vis_gauss(ds):
|
|
135
|
-
vis = delayed(itf.astro_vis_gauss)(
|
|
141
|
+
vis = delayed(jit(itf.astro_vis_gauss), pure=True)(
|
|
136
142
|
ds.I.data,
|
|
137
143
|
ds.major.data,
|
|
138
144
|
ds.minor.data,
|
|
@@ -191,7 +197,7 @@ def astro_vis_exp(
|
|
|
191
197
|
{
|
|
192
198
|
"vis": (
|
|
193
199
|
["time", "bl", "freq"],
|
|
194
|
-
da.zeros(
|
|
200
|
+
da.zeros( # type: ignore
|
|
195
201
|
shape=(n_time, n_bl, n_freq),
|
|
196
202
|
chunks=(time_chunk, bl_chunk, freq_chunk),
|
|
197
203
|
dtype=complex,
|
|
@@ -201,7 +207,7 @@ def astro_vis_exp(
|
|
|
201
207
|
)
|
|
202
208
|
|
|
203
209
|
def _astro_vis_exp(ds):
|
|
204
|
-
vis = delayed(itf.astro_vis_exp)(
|
|
210
|
+
vis = delayed(jit(itf.astro_vis_exp), pure=True)(
|
|
205
211
|
ds.I.data, ds.sigmas.data, ds.uvw.data, ds.lmn.data, ds.freqs.data
|
|
206
212
|
).compute()
|
|
207
213
|
ds_out = xr.Dataset({"vis": (["time", "bl", "freq"], vis)})
|
|
@@ -259,7 +265,7 @@ def rfi_vis(
|
|
|
259
265
|
{
|
|
260
266
|
"vis": (
|
|
261
267
|
["time", "bl", "freq"],
|
|
262
|
-
da.zeros(
|
|
268
|
+
da.zeros( # type: ignore
|
|
263
269
|
shape=(n_time, n_bl, n_freq),
|
|
264
270
|
chunks=(time_chunk, bl_chunk, freq_chunk),
|
|
265
271
|
dtype=complex,
|
|
@@ -269,7 +275,7 @@ def rfi_vis(
|
|
|
269
275
|
)
|
|
270
276
|
|
|
271
277
|
def _rfi_vis(ds):
|
|
272
|
-
vis = delayed(itf.rfi_vis)(
|
|
278
|
+
vis = delayed(jit(itf.rfi_vis), pure=True)(
|
|
273
279
|
ds.app_amplitude.data,
|
|
274
280
|
ds.c_distances.data,
|
|
275
281
|
ds.freqs.data,
|
|
@@ -299,7 +305,7 @@ def ants_to_bl(G: Array, a1: Array, a2: Array) -> Array:
|
|
|
299
305
|
{
|
|
300
306
|
"G_bl": (
|
|
301
307
|
["time", "bl", "freq"],
|
|
302
|
-
da.zeros(
|
|
308
|
+
da.zeros( # type: ignore
|
|
303
309
|
(n_time, n_bl, n_freq), chunks=(time_chunk, bl_chunk, freq_chunk)
|
|
304
310
|
),
|
|
305
311
|
)
|
|
@@ -307,7 +313,9 @@ def ants_to_bl(G: Array, a1: Array, a2: Array) -> Array:
|
|
|
307
313
|
)
|
|
308
314
|
|
|
309
315
|
def _ants_to_bl(ds):
|
|
310
|
-
G_bl = delayed(itf.ants_to_bl)
|
|
316
|
+
G_bl = delayed(jit(itf.ants_to_bl), pure=True)(
|
|
317
|
+
ds.G.data, ds.a1.data, ds.a2.data
|
|
318
|
+
).compute()
|
|
311
319
|
ds_out = xr.Dataset({"G_bl": (["time", "bl", "freq"], G_bl)})
|
|
312
320
|
return ds_out
|
|
313
321
|
|
|
@@ -330,7 +338,7 @@ def airy_beam(theta, freqs, dish_d):
|
|
|
330
338
|
{
|
|
331
339
|
"theta": (["src", "time", "ant"], theta),
|
|
332
340
|
"freqs": (["freq"], freqs),
|
|
333
|
-
"dish_d": (["space_0"], da.from_array([dish_d])),
|
|
341
|
+
"dish_d": (["space_0"], da.from_array([dish_d])), # type: ignore
|
|
334
342
|
}
|
|
335
343
|
)
|
|
336
344
|
|
|
@@ -338,7 +346,7 @@ def airy_beam(theta, freqs, dish_d):
|
|
|
338
346
|
{
|
|
339
347
|
"beam": (
|
|
340
348
|
["src", "time", "ant", "freq"],
|
|
341
|
-
da.zeros(
|
|
349
|
+
da.zeros( # type: ignore
|
|
342
350
|
(n_src, n_time, n_ant, n_freq),
|
|
343
351
|
chunks=(src_chunk, time_chunk, ant_chunk, freq_chunk),
|
|
344
352
|
),
|
|
@@ -347,7 +355,7 @@ def airy_beam(theta, freqs, dish_d):
|
|
|
347
355
|
)
|
|
348
356
|
|
|
349
357
|
def _airy_beam(ds):
|
|
350
|
-
beam = delayed(itf.airy_beam)(
|
|
358
|
+
beam = delayed(itf.airy_beam, pure=True)(
|
|
351
359
|
ds.theta.data, ds.freqs.data, ds.dish_d.data
|
|
352
360
|
).compute()
|
|
353
361
|
ds_out = xr.Dataset({"beam": (["src", "time", "ant", "freq"], beam)})
|
|
@@ -376,7 +384,7 @@ def Pv_to_Sv(Pv, d):
|
|
|
376
384
|
{
|
|
377
385
|
"Sv": (
|
|
378
386
|
["src", "time", "ant", "freq"],
|
|
379
|
-
da.zeros(
|
|
387
|
+
da.zeros( # type: ignore
|
|
380
388
|
(n_src, n_time, n_ant, n_freq),
|
|
381
389
|
chunks=(src_chunk, time_chunk, ant_chunk, freq_chunk),
|
|
382
390
|
),
|
|
@@ -406,7 +414,7 @@ def add_noise(vis: Array, noise_std: float, key: int):
|
|
|
406
414
|
|
|
407
415
|
|
|
408
416
|
def SEFD_to_noise_std(SEFD, chan_width, t_int):
|
|
409
|
-
noise_std = SEFD / da.sqrt(chan_width * t_int)
|
|
417
|
+
noise_std = SEFD / da.sqrt(chan_width * t_int) # type: ignore
|
|
410
418
|
return noise_std
|
|
411
419
|
|
|
412
420
|
|
|
@@ -417,13 +425,13 @@ def SEFD_to_noise_std(SEFD, chan_width, t_int):
|
|
|
417
425
|
# return times_fine
|
|
418
426
|
|
|
419
427
|
|
|
420
|
-
def int_sample_times(times, n_int_samples: int, int_time: float = None):
|
|
428
|
+
def int_sample_times(times, n_int_samples: int, int_time: Optional[float] = None):
|
|
421
429
|
|
|
422
430
|
n_time = len(times)
|
|
423
431
|
time_range = times[-1] - times[0]
|
|
424
432
|
int_time = time_range / (n_time - 1) if not int_time else int_time
|
|
425
433
|
n_time_fine = n_time * n_int_samples
|
|
426
|
-
times_fine = da.linspace(
|
|
434
|
+
times_fine = da.linspace( # type: ignore
|
|
427
435
|
-int_time / 2, time_range + int_time / 2, n_time_fine, endpoint=False
|
|
428
436
|
)
|
|
429
437
|
|
|
@@ -444,7 +452,7 @@ def generate_gains(
|
|
|
444
452
|
times = times[:, None, None] - times[0]
|
|
445
453
|
|
|
446
454
|
# Generate the initial gain values
|
|
447
|
-
G0 = G0_mean * da.exp(
|
|
455
|
+
G0 = G0_mean * da.exp( # type: ignore
|
|
448
456
|
1.0j * rng.uniform(low=-np.pi / 2, high=np.pi / 2, size=(1, n_ant, n_freq))
|
|
449
457
|
) + (
|
|
450
458
|
rng.normal(scale=G0_std, size=(1, n_ant, n_freq))
|
|
@@ -455,9 +463,9 @@ def generate_gains(
|
|
|
455
463
|
gain_amp = rng.normal(scale=Gt_std_amp, size=(1, n_ant, 1)) * times
|
|
456
464
|
gain_phase = rng.normal(scale=Gt_std_phase, size=(1, n_ant, 1)) * times
|
|
457
465
|
# Generate the gain time series
|
|
458
|
-
gain_ants = G0 + gain_amp * da.exp(1.0j * gain_phase)
|
|
466
|
+
gain_ants = G0 + gain_amp * da.exp(1.0j * gain_phase) # type: ignore
|
|
459
467
|
# Set the gain on the last antenna to have zero phase (reference antenna)
|
|
460
|
-
gain_ants[:, -1, :] = da.abs(gain_ants[:, -1, :])
|
|
468
|
+
gain_ants[:, -1, :] = da.abs(gain_ants[:, -1, :]) # type: ignore
|
|
461
469
|
|
|
462
470
|
return gain_ants
|
|
463
471
|
|
|
@@ -479,7 +487,7 @@ def generate_fourier_gains(
|
|
|
479
487
|
times = times_jd[None, :, None, None] * 24
|
|
480
488
|
|
|
481
489
|
# Generate the initial gain values
|
|
482
|
-
G0 = G0_mean * da.exp(
|
|
490
|
+
G0 = G0_mean * da.exp( # type: ignore
|
|
483
491
|
1.0j * rng.uniform(low=-np.pi / 2, high=np.pi / 2, size=(1, n_ant, n_freq))
|
|
484
492
|
) + (
|
|
485
493
|
rng.normal(scale=G0_std / 100, size=(1, n_ant, n_freq))
|
|
@@ -513,9 +521,9 @@ def generate_fourier_gains(
|
|
|
513
521
|
axis=0,
|
|
514
522
|
) * np.sqrt(2 * N)
|
|
515
523
|
# Generate the gain time series
|
|
516
|
-
gain_ants = G0 + gain_amp * da.exp(1.0j * gain_phase)
|
|
524
|
+
gain_ants = G0 + gain_amp * da.exp(1.0j * gain_phase) # type: ignore
|
|
517
525
|
# Set the gain on the last antenna to have zero phase (reference antenna)
|
|
518
|
-
gain_ants[:, -1, :] = da.abs(gain_ants[:, -1, :])
|
|
526
|
+
gain_ants[:, -1, :] = da.abs(gain_ants[:, -1, :]) # type: ignore
|
|
519
527
|
|
|
520
528
|
return gain_ants
|
|
521
529
|
|
|
@@ -545,7 +553,7 @@ def apply_gains(
|
|
|
545
553
|
{
|
|
546
554
|
"vis_obs": (
|
|
547
555
|
["time", "bl", "freq"],
|
|
548
|
-
da.zeros(
|
|
556
|
+
da.zeros( # type: ignore
|
|
549
557
|
(n_time, n_bl, n_freq),
|
|
550
558
|
chunks=(time_chunk, bl_chunk, freq_chunk),
|
|
551
559
|
dtype=vis_ast.dtype,
|
|
@@ -567,6 +575,6 @@ def apply_gains(
|
|
|
567
575
|
|
|
568
576
|
|
|
569
577
|
def time_avg(vis, n_int_samples):
|
|
570
|
-
return da.mean(
|
|
571
|
-
da.reshape(vis, (-1, n_int_samples, vis.shape[1], vis.shape[2])), axis=1
|
|
578
|
+
return da.mean( # type: ignore
|
|
579
|
+
da.reshape(vis, (-1, n_int_samples, vis.shape[1], vis.shape[2])), axis=1 # type: ignore
|
|
572
580
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from jax import
|
|
1
|
+
from jax import Array
|
|
2
2
|
|
|
3
3
|
import dask.array as da
|
|
4
4
|
import numpy as np
|
|
@@ -44,8 +44,6 @@ from tabsim.write import construct_observation_ds, write_ms
|
|
|
44
44
|
from tabsim.dask.extras import get_chunksizes
|
|
45
45
|
from tabsim.tle import get_satellite_positions, ants_pos, sat_distance
|
|
46
46
|
|
|
47
|
-
config.update("jax_enable_x64", True)
|
|
48
|
-
|
|
49
47
|
from astropy.time import Time
|
|
50
48
|
|
|
51
49
|
|
|
@@ -83,23 +81,24 @@ class Telescope(object):
|
|
|
83
81
|
n_ant: Optional[int] = None,
|
|
84
82
|
):
|
|
85
83
|
self.tel_name = tel_name
|
|
86
|
-
self.latitude = da.asarray(latitude)
|
|
87
|
-
self.longitude = da.asarray(longitude)
|
|
88
|
-
self.elevation = da.asarray(elevation)
|
|
89
|
-
self.GEO = da.asarray([latitude, longitude, elevation])
|
|
84
|
+
self.latitude = da.asarray(latitude) # type: ignore
|
|
85
|
+
self.longitude = da.asarray(longitude) # type: ignore
|
|
86
|
+
self.elevation = da.asarray(elevation) # type: ignore
|
|
87
|
+
self.GEO = da.asarray([latitude, longitude, elevation]) # type: ignore
|
|
90
88
|
self.ITRF = None
|
|
91
89
|
self.ENU = None
|
|
92
90
|
self.n_ant = n_ant
|
|
93
91
|
|
|
94
|
-
if ENU_array
|
|
92
|
+
if ENU_array or ENU_path:
|
|
95
93
|
self.createArrayENU(ENU_array, ENU_path)
|
|
96
|
-
if ITRF_array
|
|
94
|
+
if ITRF_array or ITRF_path:
|
|
97
95
|
self.createArrayITRF(ITRF_array, ITRF_path)
|
|
98
96
|
if self.ITRF is None and self.ENU is None:
|
|
99
97
|
raise ValueError(
|
|
100
|
-
"One of
|
|
98
|
+
"One of 'ENU_path' or 'ITRF_path' must be provided to create a Telescope object."
|
|
101
99
|
)
|
|
102
|
-
|
|
100
|
+
else:
|
|
101
|
+
self.n_ant = len(self.ITRF)
|
|
103
102
|
|
|
104
103
|
def __str__(self):
|
|
105
104
|
msg = """\nTelescope Location
|
|
@@ -126,7 +125,7 @@ Elevation : {elevation}\n"""
|
|
|
126
125
|
array or as a csv like file."""
|
|
127
126
|
print(msg)
|
|
128
127
|
return
|
|
129
|
-
self.ENU = da.asarray(self.ENU)
|
|
128
|
+
self.ENU = da.asarray(self.ENU) # type: ignore
|
|
130
129
|
self.ENU_path = ENU_path
|
|
131
130
|
self.GEO_ants = ENU_to_GEO(self.GEO, self.ENU)
|
|
132
131
|
self.ITRF = ENU_to_ITRF(self.ENU, self.latitude, self.longitude, self.elevation)
|
|
@@ -142,8 +141,8 @@ Elevation : {elevation}\n"""
|
|
|
142
141
|
array or as a csv like file."""
|
|
143
142
|
raise ValueError(msg)
|
|
144
143
|
|
|
145
|
-
self.ITRF = da.asarray(self.ITRF)
|
|
146
|
-
self.GEO_ants = da.asarray(itrf_to_geo(self.ITRF.compute()))
|
|
144
|
+
self.ITRF = da.asarray(self.ITRF) # type: ignore
|
|
145
|
+
self.GEO_ants = da.asarray(itrf_to_geo(self.ITRF.compute())) # type: ignore
|
|
147
146
|
|
|
148
147
|
|
|
149
148
|
class Observation(Telescope):
|
|
@@ -474,7 +473,7 @@ Number of stationary RFI : {n_stat}"""
|
|
|
474
473
|
dec: array (n_src,)
|
|
475
474
|
Declination of the sources in degrees.
|
|
476
475
|
"""
|
|
477
|
-
I = da.atleast_2d(I)
|
|
476
|
+
I = da.atleast_2d(I) # type: ignore
|
|
478
477
|
if I.ndim == 2:
|
|
479
478
|
I = da.expand_dims(I, axis=0)
|
|
480
479
|
I = I * da.ones(
|
|
@@ -530,7 +529,7 @@ Number of stationary RFI : {n_stat}"""
|
|
|
530
529
|
dec: Array (n_src,)
|
|
531
530
|
Declination of the sources in degrees.
|
|
532
531
|
"""
|
|
533
|
-
I = da.atleast_2d(I)
|
|
532
|
+
I = da.atleast_2d(I) # type: ignore
|
|
534
533
|
if I.ndim == 2:
|
|
535
534
|
I = da.expand_dims(I, axis=0)
|
|
536
535
|
I = I * da.ones(
|
|
@@ -718,7 +717,7 @@ Number of stationary RFI : {n_stat}"""
|
|
|
718
717
|
tles: Array (n_src, 2)
|
|
719
718
|
TLEs of the satellites corresponding to the NORAD IDs.
|
|
720
719
|
"""
|
|
721
|
-
Pv = da.atleast_2d(Pv)
|
|
720
|
+
Pv = da.atleast_2d(Pv) # type: ignore
|
|
722
721
|
if Pv.ndim == 2:
|
|
723
722
|
Pv = da.expand_dims(Pv, axis=0)
|
|
724
723
|
Pv = (
|
|
@@ -728,10 +727,11 @@ Number of stationary RFI : {n_stat}"""
|
|
|
728
727
|
)
|
|
729
728
|
).rechunk((-1, self.time_fine_chunk, self.freq_chunk))
|
|
730
729
|
norad_ids = da.asarray(da.atleast_1d(norad_ids), chunks=(-1,))
|
|
730
|
+
n_src = len(norad_ids)
|
|
731
731
|
|
|
732
732
|
rfi_xyz = da.asarray(
|
|
733
733
|
get_satellite_positions(tles, mjd_to_jd(self.times_mjd_fine.compute())),
|
|
734
|
-
chunks=(
|
|
734
|
+
chunks=(n_src, self.time_fine_chunk, 3),
|
|
735
735
|
)
|
|
736
736
|
# from tabsim.jax.coordinates import kepler_orbit_many
|
|
737
737
|
# from tabsim.tle import
|
|
@@ -743,7 +743,7 @@ Number of stationary RFI : {n_stat}"""
|
|
|
743
743
|
# self.ants_xyz is shape (n_time_fine,n_ant,3)
|
|
744
744
|
distances = da.linalg.norm(
|
|
745
745
|
self.ants_xyz[None, :, :, :] - rfi_xyz[:, :, None, :], axis=-1
|
|
746
|
-
)
|
|
746
|
+
) # .rechunk(n_src, self.time_chunk, self.n_int_samples, self.n_ant)
|
|
747
747
|
# distances = da.asarray(da.linalg.norm(
|
|
748
748
|
# ants_pos(self.ITRF.compute(), mjd_to_jd(self.times_mjd_fine.compute()))[None, :, :, :] - rfi_xyz[:, :, None, :], axis=-1
|
|
749
749
|
# ), chunks=(-1, self.time_fine_chunk, self.n_ant))
|
|
@@ -751,24 +751,39 @@ Number of stationary RFI : {n_stat}"""
|
|
|
751
751
|
I = Pv_to_Sv(Pv, distances)
|
|
752
752
|
# I is shape (n_src,n_time_fine,n_ant,n_freq)
|
|
753
753
|
|
|
754
|
+
c_distances = (
|
|
755
|
+
(distances + self.ants_uvw[None, :, :, -1])
|
|
756
|
+
.reshape((n_src, self.n_time, self.n_int_samples, self.n_ant))
|
|
757
|
+
.rechunk((n_src, self.time_chunk, self.n_int_samples, self.ant_chunk))
|
|
758
|
+
)
|
|
759
|
+
|
|
754
760
|
angular_seps = angular_separation(rfi_xyz, self.ants_xyz, self.ra, self.dec)
|
|
755
761
|
|
|
756
762
|
# angular_seps is shape (n_src,n_time_fine,n_ant)
|
|
757
763
|
rfi_A_app = da.sqrt(da.abs(I)) * airy_beam(
|
|
758
764
|
angular_seps, self.freqs, self.dish_d
|
|
759
765
|
)
|
|
766
|
+
|
|
767
|
+
rfi_A = rfi_A_app.reshape(
|
|
768
|
+
(n_src, self.n_time, self.n_int_samples, self.n_ant, self.n_freq)
|
|
769
|
+
).rechunk(
|
|
770
|
+
(
|
|
771
|
+
n_src,
|
|
772
|
+
self.time_chunk,
|
|
773
|
+
self.n_int_samples,
|
|
774
|
+
self.ant_chunk,
|
|
775
|
+
self.freq_chunk,
|
|
776
|
+
)
|
|
777
|
+
)
|
|
778
|
+
|
|
760
779
|
# rfi_A_app = da.ones((Pv.shape[0], self.n_time_fine, self.n_ant, self.n_freq), chunks=(-1, self.time_fine_chunk, self.n_ant, self.freq_chunk))
|
|
761
780
|
# self.rfi_A_app is shape (n_src,n_time_fine,n_ant,n_freqs)
|
|
762
781
|
# distances is shape (n_src,n_time_fine,n_ant)
|
|
763
782
|
# self.ants_uvw is shape (n_time_fine,n_ant,3)
|
|
764
783
|
|
|
765
784
|
vis_rfi = rfi_vis(
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
),
|
|
769
|
-
(distances + self.ants_uvw[None, :, :, -1]).reshape(
|
|
770
|
-
(-1, self.n_time, self.n_int_samples, self.n_ant)
|
|
771
|
-
),
|
|
785
|
+
rfi_A,
|
|
786
|
+
c_distances,
|
|
772
787
|
self.freqs,
|
|
773
788
|
self.a1,
|
|
774
789
|
self.a2,
|