Code Duplication    Length = 42-45 lines in 2 locations

src/eppaurora/electrons.py 2 locations

@@ 56-97 (lines=42) @@
53
]
54
55
56
def rr1987(energy, flux, scale_height, rho):
57
	"""Atmospheric electron energy dissipation Roble and Ridley, 1987 [#]_
58
59
	Equations (typo corrected) taken from Fang et al., 2008.
60
61
	Parameters
62
	----------
63
	energy: array_like (M,...)
64
		Characteristic energy E_0 [keV] of the Maxwellian distribution.
65
	flux: array_like (M,...)
66
		Integrated energy flux Q_0 [keV / cm² / s¹]
67
	scale_height: array_like (N,...)
68
		The atmospheric scale heights [cm].
69
	rho: array_like (N,...)
70
		The atmospheric mass density [g / cm³]
71
72
	Returns
73
	-------
74
	en_diss: array_like (M,N)
75
		The dissipated energy profiles [keV].
76
77
	References
78
	----------
79
	.. [#] Roble and Ridley, Ann. Geophys., 5A(6), 369--382, 1987
80
	"""
81
	_c1 = 2.11685
82
	_c2 = 2.97035
83
	_c3 = 2.09710
84
	_c4 = 0.74054
85
	_c5 = 0.58795
86
	_c6 = 1.72746
87
	_c7 = 1.37459
88
	_c8 = 0.93296
89
90
	beta = (rho * scale_height / (4 * 1e-6))**(1 / 1.65)  # RR 1987, p. 371
91
	y = beta / energy  # Corrected in Fang et al. 2008 (4)
92
	f_y = (_c1 * (y**_c2) * np.exp(-_c3 * (y**_c4)) +
93
		_c5 * (y**_c6) * np.exp(-_c7 * (y**_c8)))
94
	# Corrected in Fang et al. 2008 (2)
95
	en_diss = 0.5 * flux / scale_height * f_y
96
	return en_diss
97
98
99
def rr1987_mod(energy, flux, scale_height, rho):
100
	"""Atmospheric electron energy dissipation Roble and Ridley, 1987 [#]_
@@ 99-143 (lines=45) @@
96
	return en_diss
97
98
99
def rr1987_mod(energy, flux, scale_height, rho):
100
	"""Atmospheric electron energy dissipation Roble and Ridley, 1987 [#]_
101
102
	Equations (typo corrected) taken from Fang et al., 2008.
103
	Modified polynomial values to get closer to Fang et al., 2008,
104
	origin unknown.
105
106
	Parameters
107
	----------
108
	energy: array_like (M,...)
109
		Characteristic energy E_0 [keV] of the Maxwellian distribution.
110
	flux: array_like (M,...)
111
		Integrated energy flux Q_0 [keV / cm² / s¹]
112
	scale_height: array_like (N,...)
113
		The atmospheric scale heights [cm].
114
	rho: array_like (N,...)
115
		The atmospheric mass density [g / cm³]
116
117
	Returns
118
	-------
119
	en_diss: array_like (M,N)
120
		The dissipated energy profiles [keV].
121
122
	References
123
	----------
124
	.. [#] Roble and Ridley, Ann. Geophys., 5A(6), 369--382, 1987
125
	"""
126
	# Modified polynomial, origin unknown
127
	_c1 = 3.233
128
	_c2 = 2.56588
129
	_c3 = 2.2541
130
	_c4 = 0.7297198
131
	_c5 = 1.106907
132
	_c6 = 1.71349
133
	_c7 = 1.8835444
134
	_c8 = 0.86472135
135
136
	# Fang et al., 2008, Eq. (4)
137
	y = (rho * scale_height / (4.6 * 1e-6))**(1 / 1.65) / energy
138
	f_y = (_c1 * (y**_c2) * np.exp(-_c3 * (y**_c4)) +
139
		_c5 * (y**_c6) * np.exp(-_c7 * (y**_c8)))
140
	# energy dissipated [keV]
141
	en_diss = 0.5 * flux / scale_height * f_y
142
	return en_diss
143
144
145
def _fang_f_y(_c, _y):
146
	"""Polynomial evaluation helper