-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathrotBroadInt.py
57 lines (43 loc) · 2.47 KB
/
rotBroadInt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import numpy as np
'''The code is relatively straightforward and offers many advantages to the popular convolution-based methods. Chief among these are that the computation time is linear with the length of the input vectors, rather than exponential, and it can be computed on an irregularly spaced wavelength grid. The latter benefit allows computation on non-linearized grids, which might be sampled in constant velocity intervals.
Please make sure to cite our RNAAS: Carvalho & Johns-Krull (2023)
from: https://github.com/Adolfo1519/RotBroadInt
'''
def rot_int_cmj(w, s, vsini, eps=0.6, nr=10, ntheta=100, dif = 0.0):
'''
A routine to quickly rotationally broaden a spectrum in linear time.
INPUTS:
s - input spectrum
w - wavelength scale of the input spectrum
vsini (km/s) - projected rotational velocity
OUTPUT:
ns - a rotationally broadened spectrum on the wavelength scale w
OPTIONAL INPUTS:
eps (default = 0.6) - the coefficient of the limb darkening law
nr (default = 10) - the number of radial bins on the projected disk
ntheta (default = 100) - the number of azimuthal bins in the largest radial annulus
note: the number of bins at each r is int(r*ntheta) where r < 1
dif (default = 0) - the differential rotation coefficient, applied according to the law
Omeg(th)/Omeg(eq) = (1 - dif/2 - (dif/2) cos(2 th)). Dif = .675 nicely reproduces the law
proposed by Smith, 1994, A&A, Vol. 287, p. 523-534, to unify WTTS and CTTS. Dif = .23 is
similar to observed solar differential rotation. Note: the th in the above expression is
the stellar co-latitude, not the same as the integration variable used below. This is a
disk integration routine.
'''
ns = np.copy(s)*0.0
tarea = 0.0
dr = 1./nr
for j in range(0, nr):
r = dr/2.0 + j*dr
area = ((r + dr/2.0)**2 - (r - dr/2.0)**2)/int(ntheta*r) * (1.0 - eps + eps*np.cos(np.arcsin(r)))
for k in range(0,int(ntheta*r)):
th = np.pi/int(ntheta*r) + k * 2.0*np.pi/int(ntheta*r)
if dif != 0:
vl = vsini * r * np.sin(th) * (1.0 - dif/2.0 - dif/2.0*np.cos(2.0*np.arccos(r*np.cos(th))))
ns += area * np.interp(w + w*vl/2.9979e5, w, s)
tarea += area
else:
vl = r * vsini * np.sin(th)
ns += area * np.interp(w + w*vl/2.9979e5, w, s)
tarea += area
return ns/tarea