Coverage for astrocalc/__init__.py : 45%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from __future__ import division
2from . import cl_utils
3from past.utils import old_div
6def luminosity_to_flux(lumErg_S, dist_Mpc):
7 """
8 *Convert luminosity to a flux*
10 **Key Arguments**
12 - ``lumErg_S`` -- luminosity in ergs/sec
13 - ``dist_Mpc`` -- distance in Mpc
16 **Return**
18 - ``fluxErg_cm2_S`` -- flux in ergs/cm2/s
20 """
21 ## STANDARD LIB ##
22 ## THIRD PARTY ##
23 import numpy as np
24 import math
25 ## LOCAL APPLICATION ##
27 ################ > VARIABLE SETTINGS ######
29 ################ >ACTION(S) ################
30 # Convert the distance to cm
31 distCm = dist_Mpc * MPC_2_CMS
32 fluxErg_cm2_S = old_div(lumErg_S, (4 * np.pi * distCm ** 2))
34 return fluxErg_cm2_S
36##########################################################################
37# PRIVATE (HELPER) FUNCTIONS #
38##########################################################################
39if __name__ == '__main__':
40 main()