RACS-tools 0.0.0__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.
- racs_tools/__init__.py +0 -0
- racs_tools/au2.py +167 -0
- racs_tools/beamcon_2D.py +839 -0
- racs_tools/beamcon_3D.py +1389 -0
- racs_tools/convolve_uv.py +174 -0
- racs_tools/gaussft.py +84 -0
- racs_tools/getnoise_list.py +277 -0
- racs_tools/logging.py +48 -0
- racs_tools-0.0.0.dist-info/LICENSE +29 -0
- racs_tools-0.0.0.dist-info/METADATA +220 -0
- racs_tools-0.0.0.dist-info/RECORD +13 -0
- racs_tools-0.0.0.dist-info/WHEEL +4 -0
- racs_tools-0.0.0.dist-info/entry_points.txt +5 -0
racs_tools/__init__.py
ADDED
|
File without changes
|
racs_tools/au2.py
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
""" For getting fluxes right in Jy/beam """
|
|
3
|
+
__author__ = "Tessa Vernstrom"
|
|
4
|
+
|
|
5
|
+
import math
|
|
6
|
+
from typing import List, Tuple
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def gaussianDeconvolve(smaj, smin, spa, bmaj, bmin, bpa):
|
|
12
|
+
"""'s' as in 'source', 'b' as in 'beam'. All arguments in
|
|
13
|
+
radians. (Well, major and minor axes can be in any units, so long
|
|
14
|
+
as they're consistent.)
|
|
15
|
+
|
|
16
|
+
Returns dmaj, dmin, dpa, status
|
|
17
|
+
Return units are consistent with the inputs.
|
|
18
|
+
status is one of 'ok', 'pointlike', 'fail'
|
|
19
|
+
|
|
20
|
+
Derived from miriad gaupar.for:GauDfac()
|
|
21
|
+
|
|
22
|
+
We currently don't do a great job of dealing with pointlike
|
|
23
|
+
sources. I've added extra code ensure smaj >= bmaj, smin >= bmin,
|
|
24
|
+
and increased coefficient in front of "limit" from 0.1 to
|
|
25
|
+
0.5. Feel a little wary about that first change.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
spa = np.radians(spa)
|
|
29
|
+
bpa = np.radians(bpa)
|
|
30
|
+
if smaj < bmaj:
|
|
31
|
+
smaj = bmaj
|
|
32
|
+
if smin < bmin:
|
|
33
|
+
smin = bmin
|
|
34
|
+
|
|
35
|
+
alpha = (
|
|
36
|
+
(smaj * np.cos(spa)) ** 2
|
|
37
|
+
+ (smin * np.sin(spa)) ** 2
|
|
38
|
+
- (bmaj * np.cos(bpa)) ** 2
|
|
39
|
+
- (bmin * np.sin(bpa)) ** 2
|
|
40
|
+
)
|
|
41
|
+
beta = (
|
|
42
|
+
(smaj * np.sin(spa)) ** 2
|
|
43
|
+
+ (smin * np.cos(spa)) ** 2
|
|
44
|
+
- (bmaj * np.sin(bpa)) ** 2
|
|
45
|
+
- (bmin * np.cos(bpa)) ** 2
|
|
46
|
+
)
|
|
47
|
+
gamma = 2 * (
|
|
48
|
+
(smin**2 - smaj**2) * np.sin(spa) * np.cos(spa)
|
|
49
|
+
- (bmin**2 - bmaj**2) * np.sin(bpa) * np.cos(bpa)
|
|
50
|
+
)
|
|
51
|
+
# print smaj,smin
|
|
52
|
+
# print alpha,beta,gamma
|
|
53
|
+
s = alpha + beta
|
|
54
|
+
t = np.sqrt((alpha - beta) ** 2 + gamma**2)
|
|
55
|
+
# print s,t
|
|
56
|
+
dmaj = np.sqrt(0.5 * (s + t))
|
|
57
|
+
if s > t:
|
|
58
|
+
dmin = np.sqrt(0.5 * (s - t))
|
|
59
|
+
else:
|
|
60
|
+
dmin = 0
|
|
61
|
+
# print dmaj,dmin
|
|
62
|
+
if alpha < 0 or beta < 0:
|
|
63
|
+
dmaj = dmin = dpa = 0
|
|
64
|
+
|
|
65
|
+
# if(smaj>bmaj):
|
|
66
|
+
# dmaj= sqrt (0.5 * (s + t))
|
|
67
|
+
if abs(gamma) + abs(alpha - beta) == 0:
|
|
68
|
+
dpa = 0
|
|
69
|
+
else:
|
|
70
|
+
dpa = 0.5 * np.arctan2(-gamma, alpha - beta)
|
|
71
|
+
# if((s>=t)&(bmin!=smin)):
|
|
72
|
+
# dmin=sqrt (0.5 * (s - t))
|
|
73
|
+
|
|
74
|
+
return dmaj, dmin, np.degrees(dpa)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def gauss_factor(
|
|
78
|
+
beamConv: List[float], beamOrig: List[float], dx1: float = 1, dy1: float = 1
|
|
79
|
+
) -> Tuple[float, float, float, float, float]:
|
|
80
|
+
"""
|
|
81
|
+
Calculates the scaling factor to be applied after convolving
|
|
82
|
+
a map in Jy/beam with a gaussian to get fluxes in Jy/beam again.
|
|
83
|
+
|
|
84
|
+
This function is a copy of the FORTRAN gaufac function from the Miriad
|
|
85
|
+
package, which determine the Gaussian parameters resulting from
|
|
86
|
+
convolving two gaussians. This function yields the same result as
|
|
87
|
+
the MIRIAD gaufac function.
|
|
88
|
+
|
|
89
|
+
Parameters
|
|
90
|
+
----------
|
|
91
|
+
beamConv : list
|
|
92
|
+
A list of the [major axis, minor axis, position_angle]
|
|
93
|
+
of the gaussion used for convolution.
|
|
94
|
+
beamOrig :
|
|
95
|
+
Same format as beamConv but giving the parameters of the original
|
|
96
|
+
beam of the map. As Default the self.resolution list is used.
|
|
97
|
+
dx1, dy1 : floats
|
|
98
|
+
Being the pixel size in both dimensions of the map.
|
|
99
|
+
By default the ``CDELT1`` and ``CDELT2`` keywords from the
|
|
100
|
+
fits header are used.
|
|
101
|
+
|
|
102
|
+
Returns
|
|
103
|
+
-------
|
|
104
|
+
fac :
|
|
105
|
+
Factor for the output Units.
|
|
106
|
+
amp :
|
|
107
|
+
Amplitude of resultant gaussian.
|
|
108
|
+
bmaj, bmin :
|
|
109
|
+
Major and minor axes of resultant gaussian.
|
|
110
|
+
bpa :
|
|
111
|
+
Position angle of the resulting gaussian.
|
|
112
|
+
"""
|
|
113
|
+
# include 'mirconst.h'
|
|
114
|
+
# Define cosine and Sinus of the position Angles of the
|
|
115
|
+
# Gaussians
|
|
116
|
+
arcsecInGrad = 1 # (1./3600)*(np.pi/180.)
|
|
117
|
+
deg2Grad = np.pi / 180
|
|
118
|
+
bmaj2, bmin2, bpa2 = beamConv
|
|
119
|
+
bmaj2, bmin2, bpa2 = (bmaj2 * arcsecInGrad, bmin2 * arcsecInGrad, bpa2 * deg2Grad)
|
|
120
|
+
# if beamOrig is None:
|
|
121
|
+
bmaj1, bmin1, bpa1 = beamOrig
|
|
122
|
+
bmaj1, bmin1, bpa1 = (bmaj1 * arcsecInGrad, bmin1 * arcsecInGrad, bpa1 * deg2Grad)
|
|
123
|
+
# if dx1 is None:
|
|
124
|
+
dx1 = dx1 * arcsecInGrad
|
|
125
|
+
# if dy1 is None:
|
|
126
|
+
dy1 = dy1 * arcsecInGrad
|
|
127
|
+
cospa1 = math.cos(bpa1)
|
|
128
|
+
cospa2 = math.cos(bpa2)
|
|
129
|
+
sinpa1 = math.sin(bpa1)
|
|
130
|
+
sinpa2 = math.sin(bpa2)
|
|
131
|
+
alpha = (
|
|
132
|
+
(bmaj1 * cospa1) ** 2
|
|
133
|
+
+ (bmin1 * sinpa1) ** 2
|
|
134
|
+
+ (bmaj2 * cospa2) ** 2
|
|
135
|
+
+ (bmin2 * sinpa2) ** 2
|
|
136
|
+
)
|
|
137
|
+
beta = (
|
|
138
|
+
(bmaj1 * sinpa1) ** 2
|
|
139
|
+
+ (bmin1 * cospa1) ** 2
|
|
140
|
+
+ (bmaj2 * sinpa2) ** 2
|
|
141
|
+
+ (bmin2 * cospa2) ** 2
|
|
142
|
+
)
|
|
143
|
+
gamma = 2 * (
|
|
144
|
+
(bmin1**2 - bmaj1**2) * sinpa1 * cospa1
|
|
145
|
+
+ (bmin2**2 - bmaj2**2) * sinpa2 * cospa2
|
|
146
|
+
)
|
|
147
|
+
s = alpha + beta
|
|
148
|
+
t = math.sqrt((alpha - beta) ** 2 + gamma**2)
|
|
149
|
+
bmaj = math.sqrt(0.5 * (s + t))
|
|
150
|
+
bmin = math.sqrt(0.5 * (s - t))
|
|
151
|
+
if (abs(gamma) + abs(alpha - beta)) == 0:
|
|
152
|
+
bpa = 0.0
|
|
153
|
+
else:
|
|
154
|
+
bpa = 0.5 * np.arctan2(-1 * gamma, alpha - beta)
|
|
155
|
+
# print alpha,beta,gamma
|
|
156
|
+
amp = (
|
|
157
|
+
math.pi
|
|
158
|
+
/ (4.0 * math.log(2.0))
|
|
159
|
+
* bmaj1
|
|
160
|
+
* bmin1
|
|
161
|
+
* bmaj2
|
|
162
|
+
* bmin2
|
|
163
|
+
/ math.sqrt(alpha * beta - 0.25 * gamma * gamma)
|
|
164
|
+
)
|
|
165
|
+
fac = ((math.sqrt(dx1**2) * math.sqrt(dy1**2))) / amp
|
|
166
|
+
|
|
167
|
+
return fac, amp, bmaj, bmin, np.degrees(bpa)
|