• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

GFZ / EL_PASO / 26297372401

22 May 2026 03:41PM UTC coverage: 59.902% (-2.9%) from 62.79%
26297372401

Pull #53

github

web-flow
Merge f3fb329e0 into 23c1195a2
Pull Request #53: Major refactor

1186 of 2005 new or added lines in 59 files covered. (59.15%)

14 existing lines in 5 files now uncovered.

2804 of 4681 relevant lines covered (59.9%)

0.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

41.38
/el_paso/processing/compute_equatorial_plasmaspheric_density.py
1
# SPDX-FileCopyrightText: 2025 GFZ Helmholtz Centre for Geosciences
2
# SPDX-FileContributor: Bernhard Haas
3
#
4
# SPDX-License-Identifier: Apache-2.0
5

6
import logging
1✔
7
import typing
1✔
8
from typing import Literal
1✔
9

10
import astropy.units as u
1✔
11
import numpy as np
1✔
12

13
import el_paso as ep
1✔
14
from el_paso.utils import timed_function
1✔
15

16
if typing.TYPE_CHECKING:
17
    from numpy.typing import NDArray
18

19
logger = logging.getLogger(__name__)
1✔
20

21
DENTON_DENSITY_UPPER_LIMIT = 1500
1✔
22
MAX_ALPHA = 5
1✔
23

24

25
@timed_function("Density mapping")
1✔
26
def compute_equatorial_plasmaspheric_density(
1✔
27
    density_var: ep.Variable,
28
    xgeo_local_var: ep.Variable,
29
    xgeo_equatorial_var: ep.Variable,
30
    method: Literal["Denton_average"] = "Denton_average",
31
) -> ep.Variable:
32
    r"""Maps the plasma density from a local measurement point to the magnetic equator.
33

34
    This function uses a simple empirical model to map plasma density measured
35
    at a specific local position to the magnetic equator. The mapping is based
36
    on a power-law density profile, $n(r) = n_{eq} (r / r_{eq})^{-\alpha}$,
37
    where the exponent $\alpha$ is determined by the chosen method.
38

39
    Args:
40
        density_var (ep.Variable): The input variable containing the local
41
            plasma density data, expected in units convertible to $cm^{-3}$.
42
        xgeo_local_var (ep.Variable): The variable containing the GEO coordinates
43
            corresponding to the density measurements.
44
        xgeo_equatorial_var (ep.Variable): The variable containing the GEO
45
            coordinates of the corresponding magnetic field line foot-point
46
            at the magnetic equator.
47
        method (Literal["Denton_average"], optional): The method used
48
            to calculate the power-law exponent $\alpha$.
49
            - "Denton_average" (default): Uses a fixed average $\\alpha$: $2.5$ inside the
50
              plasmasphere (density $\ge 10 \cdot (6.6 / r_{eq})^4$) and $0.5$
51
              outside the plasmasphere. This is an approximation based on Sheeley et al. (2001).
52

53
    Returns:
54
        ep.Variable: A new variable containing the plasma density mapped to the
55
            magnetic equator, with units of $cm^{-3}$.
56
    """
57
    logger.info("Computing equatorial plasmaspheric density...")
×
58

59
    r_local = np.linalg.norm(xgeo_local_var.get_data(ep.units.RE).astype(np.float64), ord=2, axis=1)
×
60
    r_eq = np.linalg.norm(xgeo_equatorial_var.get_data(ep.units.RE).astype(np.float64), ord=2, axis=1)
×
61
    r_local = typing.cast("NDArray[np.float32]", r_local)
×
62
    r_eq = typing.cast("NDArray[np.float32]", r_eq)
×
63

NEW
64
    density_data = density_var.get_data(u.cm ** (-3)).astype(np.float64)
×
65

NEW
66
    mapped_density_var = ep.Variable(original_unit=u.cm ** (-3))
×
67
    mapped_density_var.metadata.source_files = density_var.metadata.source_files
×
68

69
    match method:
×
70
        case "Denton_average":
×
71
            inside_pp = density_data >= 10 * (6.6 / r_eq) ** 4
×
72

73
            alpha = np.full_like(density_data, 0.5)
×
74
            alpha[inside_pp] = 2.5
×
75

76
            density_eq_data = density_data / (r_eq / r_local) ** alpha
×
77

78
            mapped_density_var.metadata.add_processing_note(
×
79
                "Mapped to the equator using 'compute_equatorial_plasmaspheric_density' assuming the Denton average "
80
                "approximation with alpha=2.5 inside the plasmasphere (according to the criterion used in "
81
                "Sheeley et al. 2001) and alpha=1 outside the plasmasphere."
82
            )
83

NEW
84
    mapped_density_var.set_data(density_eq_data, u.cm ** (-3))
×
85

86
    return mapped_density_var
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc