-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfluence.py
More file actions
25 lines (21 loc) · 809 Bytes
/
fluence.py
File metadata and controls
25 lines (21 loc) · 809 Bytes
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
import numpy as np
#------------------Fluence values----------------------
def fluence_calc(d,e):
"""
Return calculated value of FRB fluence, for giant flares
occurring within the range of FRB distances.
Args:
- d: distance to the source
- e: energy
Returns: FRB fluence value in erg/cm^2
"""
#Convert flare energy to joules
fluence_val = (e/(4*np.pi*((d*100)**2)))
return fluence_val
#------------------------------------------------------
def generate_fluence(dirname):
energy_data = np.loadtxt(f'{dirname}/energy.txt')
distance_data = np.loadtxt(f'{dirname}/distance.txt')
fluence = list(map(fluence_calc, distance_data, energy_data))
arr_f = np.array(fluence)
np.savetxt(f'{dirname}/fluence.txt', arr_f)