-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.py
70 lines (58 loc) · 2.41 KB
/
util.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
58
59
60
61
62
63
64
65
66
67
68
69
70
# -*- coding: utf-8 -*-
"""
v1: Created on May 31, 2016
author: Daniel Garrett (dg622@cornell.edu)
"""
import numpy as np
def maxdmag(s, ranges, x):
"""Calculates the maximum difference in magnitude for a given population
and apparent separation value
Args:
s (ndarray):
Apparent separation (AU)
ranges (tuple):
pmin (float): minimum geometric albedo
Rmin (float): minimum planetary radius (km)
rmax (float): maximum distance from star (AU)
x (float):
Conversion factor for AU to km
Returns:
maxdmag (ndarray):
Maximum difference in magnitude for given population and separation
"""
pmin, Rmin, rmax = ranges
PhiL = lambda b: (1./np.pi)*(np.sin(b) + (np.pi - b)*np.cos(b))
maxdmag = -2.5*np.log10(pmin*(Rmin*x/rmax)**2*PhiL(np.pi - np.arcsin(s/rmax)))
return maxdmag
def mindmag(s, ranges, x):
"""Calculates the minimum difference in magnitude for a given population
and apparent separation value
Args:
s (ndarray):
Apparent separation (AU)
ranges (tuple):
pmax (float): maximum geometric albedo
Rmax (float): maximum planetary radius (km)
rmin (float): minimum distance from star (AU)
rmax (float): maximum distance from star (AU)
x (float):
Conversion factor for AU to km
Returns:
mindmag (ndarray):
Minimum difference in magnitude for given population and separation
"""
pmax, Rmax, rmin, rmax = ranges
bstar = 1.104728818644543
PhiL = lambda b: (1./np.pi)*(np.sin(b) + (np.pi - b)*np.cos(b))
if type(s) == np.ndarray:
mindmag = -2.5*np.log10(pmax*(Rmax*x*np.sin(bstar)/s)**2*PhiL(bstar))
mindmag[s < rmin*np.sin(bstar)] = -2.5*np.log10(pmax*(Rmax*x/rmin)**2*PhiL(np.arcsin(s[s < rmin*np.sin(bstar)]/rmin)))
mindmag[s > rmax*np.sin(bstar)] = -2.5*np.log10(pmax*(Rmax*x/rmax)**2*PhiL(np.arcsin(s[s > rmax*np.sin(bstar)]/rmax)))
else:
if s < rmin*np.sin(bstar):
mindmag = -2.5*np.log10(pmax*(Rmax*x/rmin)**2*PhiL(np.arcsin(s/rmin)))
elif s > rmax*np.sin(bstar):
mindmag = -2.5*np.log10(pmax*(Rmax*x/rmax)**2*PhiL(np.arcsin(s/rmax)))
else:
mindmag = -2.5*np.log10(pmax*(Rmax*x*np.sin(bstar)/s)**2*PhiL(bstar))
return mindmag