tabsim 0.0.1__py3-none-any.whl
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/__init__.py +0 -0
- tabsim/config.py +904 -0
- tabsim/dask/__init__.py +0 -0
- tabsim/dask/coordinates.py +469 -0
- tabsim/dask/extras.py +60 -0
- tabsim/dask/interferometry.py +572 -0
- tabsim/dask/observation.py +969 -0
- tabsim/data/EDA2.itrf.txt +256 -0
- tabsim/data/MWA.itrf.txt +128 -0
- tabsim/data/MeerKAT.itrf.txt +64 -0
- tabsim/data/__init__.py +0 -0
- tabsim/data/aux_data/calibrator.skymodel +2 -0
- tabsim/data/aux_data/norad_satellite.rfimodel +61711 -0
- tabsim/data/aux_data/satellite.ole +3 -0
- tabsim/data/aux_data/satellite.rfimodel +3 -0
- tabsim/data/aux_data/stationary.loc +4 -0
- tabsim/data/aux_data/stationary.rfimodel +4 -0
- tabsim/data/config_files/sim_config_base.yaml +172 -0
- tabsim/data/config_files/tab_config_base.yaml +86 -0
- tabsim/jax/__init__.py +0 -0
- tabsim/jax/coordinates.py +1082 -0
- tabsim/jax/interferometry.py +667 -0
- tabsim/jax/utils.py +90 -0
- tabsim/plot.py +323 -0
- tabsim/scripts/__init__.py +1 -0
- tabsim/scripts/ast_region.py +56 -0
- tabsim/scripts/flag_data.py +195 -0
- tabsim/scripts/sim_vis.py +136 -0
- tabsim/scripts/tle_sat_region.py +191 -0
- tabsim/sky.py +137 -0
- tabsim/tle.py +753 -0
- tabsim/tools.py +111 -0
- tabsim/write.py +715 -0
- tabsim-0.0.1.dist-info/METADATA +991 -0
- tabsim-0.0.1.dist-info/RECORD +39 -0
- tabsim-0.0.1.dist-info/WHEEL +5 -0
- tabsim-0.0.1.dist-info/entry_points.txt +5 -0
- tabsim-0.0.1.dist-info/licenses/LICENSE +674 -0
- tabsim-0.0.1.dist-info/top_level.txt +1 -0
tabsim/tools.py
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import os
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
import jax.numpy as jnp
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
pkg_dir = Path(__file__).parent.absolute()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
import signal
|
|
12
|
+
from contextlib import contextmanager
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TimeoutException(Exception):
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@contextmanager
|
|
20
|
+
def time_limit(seconds):
|
|
21
|
+
def signal_handler(signum, frame):
|
|
22
|
+
raise TimeoutException("Timed out!")
|
|
23
|
+
|
|
24
|
+
signal.signal(signal.SIGALRM, signal_handler)
|
|
25
|
+
signal.alarm(seconds)
|
|
26
|
+
try:
|
|
27
|
+
yield
|
|
28
|
+
finally:
|
|
29
|
+
signal.alarm(0)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def beam_size(diameter: float, frequency: float, fwhp: bool = True):
|
|
33
|
+
"""
|
|
34
|
+
Calculate the beam size of an antenna or an array. For an array use
|
|
35
|
+
fwhp = True. This assumes an Airy disk primary beam pattern.
|
|
36
|
+
|
|
37
|
+
Parameters:
|
|
38
|
+
-----------
|
|
39
|
+
diameter: float
|
|
40
|
+
Diameter of the dish or baseline in metres.
|
|
41
|
+
frequency: float
|
|
42
|
+
Observation frequency in Hertz.
|
|
43
|
+
fwhp: bool
|
|
44
|
+
True if you want the field of view to be the full width at half power
|
|
45
|
+
and False if you want the first null.
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
--------
|
|
49
|
+
beam_width: float
|
|
50
|
+
beam_width in degrees.
|
|
51
|
+
"""
|
|
52
|
+
diameter = jnp.asarray(diameter)
|
|
53
|
+
frequency = jnp.asarray(frequency)
|
|
54
|
+
|
|
55
|
+
c = 299792458.0
|
|
56
|
+
lamda = c / frequency
|
|
57
|
+
beam_width = 1.02 * lamda / diameter if fwhp else 1.22 * lamda / diameter
|
|
58
|
+
|
|
59
|
+
return jnp.rad2deg(beam_width)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def load_antennas(telescope: str = "MeerKAT"):
|
|
63
|
+
"""
|
|
64
|
+
Load the ENU coordinates for a telescope. Currently only MeerKAT is
|
|
65
|
+
included.
|
|
66
|
+
|
|
67
|
+
Parameters:
|
|
68
|
+
-----------
|
|
69
|
+
telescope: str
|
|
70
|
+
The name of the telescope.
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
--------
|
|
74
|
+
enu: array_like (n_ant, 3)
|
|
75
|
+
The East, North, Up coordinates of each antenna relative to a reference
|
|
76
|
+
position.
|
|
77
|
+
"""
|
|
78
|
+
if telescope == "MeerKAT":
|
|
79
|
+
enu = np.loadtxt(os.path.join(pkg_dir, "../data/Meerkat.enu.txt"))
|
|
80
|
+
else:
|
|
81
|
+
print("Only MeerKAT antennas are currentyl available.")
|
|
82
|
+
enu = None
|
|
83
|
+
return enu
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def str2bool(v: str):
|
|
87
|
+
"""
|
|
88
|
+
Convert string to boolean.
|
|
89
|
+
|
|
90
|
+
Parameters:
|
|
91
|
+
-----------
|
|
92
|
+
v: str
|
|
93
|
+
String to convert to boolean.
|
|
94
|
+
|
|
95
|
+
Raises:
|
|
96
|
+
-------
|
|
97
|
+
argparse.ArgumentTypeError: If the string is not a boolean.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
--------
|
|
101
|
+
bool: bool
|
|
102
|
+
The boolean value of the string.
|
|
103
|
+
"""
|
|
104
|
+
if isinstance(v, bool):
|
|
105
|
+
return v
|
|
106
|
+
if v.lower() in ("yes", "true", "t", "y", "1"):
|
|
107
|
+
return True
|
|
108
|
+
elif v.lower() in ("no", "false", "f", "n", "0"):
|
|
109
|
+
return False
|
|
110
|
+
else:
|
|
111
|
+
raise argparse.ArgumentTypeError("Boolean value expected.")
|