Several routines within the program (e.g. Geometric.calculate_nearfield, NearFieldSource.tx_from_rx) use a relativistic correction. The source code implemeting this routine is duplicated, so it should be isolated and unit tested.
As a minimum, the code that should be isolated is:
# Calculate relativistic correction
r01 = xsta_bcrf_rx - xsrc_bcrf_tx # (N, 3)
r01_mag = np.linalg.norm(r01, axis=-1) # (N,)
r0b = xsrc_bcrf_tx[None, :, :] - xbodies_bcrf_tx # (M, N, 3)
r0b_mag = np.linalg.norm(r0b, axis=-1) # (M, N)
r01b_mag = np.linalg.norm(r1b - r0b, axis=-1) # (M, N)
gmc = 2.0 * bodies_gm[:, None] / (CLIGHT * CLIGHT) # (M, 1)
rlt_01 = np.sum(
(gmc / CLIGHT)
* np.log(
(r0b_mag + r1b_mag + r01b_mag + gmc)
/ (r0b_mag + r1b_mag - r01b_mag + gmc)
),
axis=0,
)
although it is probably possible to also include the computation of some of the involved variables in the function, as they are only needed to compute the correction.
Isolating the function would also allow for better documentation, with a docstring that details the different components of the equation, its source, its accuracy... The source of this expression is Duev 2012
Several routines within the program (e.g.
Geometric.calculate_nearfield,NearFieldSource.tx_from_rx) use a relativistic correction. The source code implemeting this routine is duplicated, so it should be isolated and unit tested.As a minimum, the code that should be isolated is:
although it is probably possible to also include the computation of some of the involved variables in the function, as they are only needed to compute the correction.
Isolating the function would also allow for better documentation, with a docstring that details the different components of the equation, its source, its accuracy... The source of this expression is Duev 2012