Skip to content

Interstellar medium

mlpoppyns.simulator.interstellar_medium.e_density_model

Model for the free electron density to compute the DM values and the scattering timescales.

We use the library pygedm available from astropy (see also Price et al. 2021) See https://pygedm.readthedocs.io/en/latest/pygedm.html for the related documentation.

Authors:

 Michele Ronchi (ronchi@ice.csic.es)

compute_DM(l_gal, b_gal, d, ed_model)

Given a specified electron density model (either 'ymw16' or 'ne2001') compute the dispersion measures DMs related to the given heliocentric distances.

Parameters:

Name Type Description Default
l_gal ndarray

Galactic longitude in [deg] defined between [-180, 180] deg.

required
b_gal ndarray

Galactic latitude in [deg] defined between [-90, 90] deg.

required
d ndarray

Heliocentric distance in [kpc].

required
ed_model str

Free electron density model, either 'ymw16' or 'ne2001'.

required

Returns:

Type Description
ndarray

Values of the DM in [pc cm^-3].

Source code in mlpoppyns/simulator/interstellar_medium/e_density_model.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
def compute_DM(
    l_gal: np.ndarray,
    b_gal: np.ndarray,
    d: np.ndarray,
    ed_model: str,
) -> np.ndarray:
    """
    Given a specified electron density model (either 'ymw16' or 'ne2001') compute
    the dispersion measures DMs related to the given heliocentric distances.

    Args:
        l_gal (np.ndarray): Galactic longitude in [deg] defined between [-180, 180] deg.
        b_gal (np.ndarray): Galactic latitude in [deg] defined between [-90, 90] deg.
        d (np.ndarray): Heliocentric distance in [kpc].
        ed_model (str): Free electron density model, either 'ymw16' or 'ne2001'.

    Returns:
        (np.ndarray): Values of the DM in [pc cm^-3].
    """
    # Store the number of objects that need computation of DM.
    n = len(l_gal)

    DM = np.zeros(n)

    # Convert distance from [kpc] to [pc].
    d_pc = d * 1000

    for i in range(n):
        # The function dist_to_dm accepts only floats as input and the distance must be in [pc].
        dm, _ = pygedm.dist_to_dm(l_gal[i], b_gal[i], d_pc[i], method=ed_model)

        DM[i] = dm.value

    return DM

compute_tau_sc_327(DM)

Given a value of DM compute the scattering timescale. We use the empirical fit performed by Krishnakumar et al. (2015), who fitted the scattering times obtained at a frequency of 327 MHz (see Section 3, p. 5, right column).

Parameters:

Name Type Description Default
DM ndarray

Dispersion measure in [pc cm^-3].

required

Returns:

Type Description
ndarray

Values of the scattering timescale in [s].

Source code in mlpoppyns/simulator/interstellar_medium/e_density_model.py
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
def compute_tau_sc_327(DM: np.ndarray) -> np.ndarray:
    """
    Given a value of DM compute the scattering timescale.
    We use the empirical fit performed by Krishnakumar et al. (2015), who fitted the scattering times
    obtained at a frequency of 327 MHz (see Section 3, p. 5, right column).

    Args:
        DM (np.ndarray): Dispersion measure in [pc cm^-3].

    Returns:
        (np.ndarray): Values of the scattering timescale in [s].
    """
    # Compute the average tau scattering in [s] at 327 MHz from the empirical formula in Krishnakumar et al. (2015).
    tau_sc_mean = 3.6e-9 * DM**2.2 * (1.0 + 1.94e-3 * DM**2.0)

    # We pick the values of tau_sc from a Gaussian distribution centered on np.log10(tau_sc_mean)
    # with a fiducial sigma of 0.5 in log10 to roughly reproduce the scatter in the data as in Fig. 3 in
    # Krishnakumar et al. (2015).
    tau_sc = 10 ** np.random.normal(np.log10(tau_sc_mean), 0.5)

    return tau_sc

compute_tau_sc_f(tau_sc, f)

Rescaling the scattering timescale at the given specified observation frequency. To rescale to any frequency we assume a Kolmogorov spectrum tau(f) ~ f^-4.4.

Parameters:

Name Type Description Default
tau_sc ndarray

Scattering timescale at 327 MHz in [s].

required
f ndarray

Frequency at which the scattering timescale is computed [Hz].

required

Returns:

Type Description
ndarray

Values of the scattering timescale at the frequency nu in [s].

Source code in mlpoppyns/simulator/interstellar_medium/e_density_model.py
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
def compute_tau_sc_f(tau_sc: np.ndarray, f: float) -> np.ndarray:
    """
    Rescaling the scattering timescale at the given specified observation frequency.
    To rescale to any frequency we assume a Kolmogorov spectrum tau(f) ~ f^-4.4.

    Args:
        tau_sc (np.ndarray): Scattering timescale at 327 MHz in [s].
        f (np.ndarray): Frequency at which the scattering timescale is computed [Hz].

    Returns:
        (np.ndarray): Values of the scattering timescale at the frequency nu in [s].
    """
    tau_sc_f = tau_sc * (f / 327.0e6) ** (-4.4)

    return tau_sc_f