-
Notifications
You must be signed in to change notification settings - Fork 1
/
calc_BTD.py
43 lines (32 loc) · 1.09 KB
/
calc_BTD.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
import numpy as np
import scipy
def bt_ch07_temp_conv(var):
fk1 = 2.00774e05
fk2 = 3.68909e03
bc1 = 0.50777
bc2 = 0.99929
return (fk2/(np.log((fk1/var)+1))-bc1)/bc2 - 273.15
def bt_ch14_temp_conv(var):
fk1 = 8.48310e03
fk2 = 1.28490e03
bc1 = 0.25361
bc2 = 0.9991
return (fk2/(np.log((fk1/var)+1))-bc1)/bc2 - 273.15
def find_bt_temp_conv(ch):
if ch == 7:
return bt_ch07_temp_conv
else:
return bt_ch14_temp_conv
# Always returns second_ch - first_ch
def main_func(rad_1, rad_2, first_ch, second_ch):
func1 = find_bt_temp_conv(first_ch)
func2 = find_bt_temp_conv(second_ch)
return func2(rad_2) - func1(rad_1)
def main_func_norm(rad_1, rad_2, first_ch, second_ch):
func1 = find_bt_temp_conv(first_ch)
func2 = find_bt_temp_conv(second_ch)
BTD = func2(rad_2) - func1(rad_1)
kernel_size = (120,120)
BTD_local_mean = scipy.ndimage.filters.generic_filter(BTD, np.nanmean, kernel_size)
BTD_local_SD = scipy.ndimage.filters.generic_filter(BTD, np.nanstd, kernel_size)
return (BTD-BTD_local_mean)/BTD_local_SD