Magnetic field models for the Milky Way

At the moment, two models of the coherent component of Galactic magnetic field are available. Typically, the coherence length of the turbulent component is too small to induce large scale photon-ALP oscillations at gamma-ray energies and hence only the coherent components are considered here.

The three models are the ones described in detail in [Pshirkov2011], [Jansson2012] and [Unger2024]. For the Jansson & Farrar model [Jansson2012], also the updates from measurements with the Planck satellite are available [Planck2016].

Reference / API

class gammaALPs.bfields.gmf.GMF(model='jansson12')[source]

Bases: object

Class with analytical functions that describe the galactic magnetic field according to the model of Jannson & Farrar (2012)

Only the regular field components are implemented. The striated field component is absent.

Rsun

Assumed position of the sun along the x axis in kpc

Type:

float

bring

field strength in ring at 3 kpc < rho < 5 kpc

Type:

float

bring_unc

associated uncertainty of field strength in ring at 3 kpc < rho < 5 kpc

Type:

float

hdisk

disk/halo transition height

Type:

float hdisk_unc: float,

hdisk_unc

associated uncertainty disk/halo transition height

Type:

float

wdisk

transition width

Type:

float

wdisk_unc

associated uncertainty of transition width

Type:

float, wdisk_unc: floats,

b

arrays with field strengths of spiral arms at 5 kpc

Type:

ndarray

b_unc

associated uncertainties with field strengths of spiral arms at 5 kpc

Type:

ndarray

f_cov

relative cross-sectional areas of the spirals (for a fixed radius)

Type:

ndarray

rx

dividing lines of spiral arms, coordinates of neg. x-axes that intersect with arm

Type:

ndarray

idisk

spiral arms opening angle

Type:

float

bn, bn_unc

field strength northern halo

Type:

float

bn_unc

associated uncertainty of field strength northern halo

Type:

float

Bs

field strength southern halo

Type:

float

Bs_unc

associated uncertainty of field strength southern halo

Type:

float

rhon

transition radius in northern hemisphere

Type:

float

rhon_unc

associated uncertainty of transition radius in northern hemisphere

Type:

float

rhos

transition radius in southern heisphere

Type:

float

rhos_unc

associated uncertainty of transition radius in southern hemisphere

Type:

float

whalo

transition width

Type:

float

whalo_unc

associated uncertainty of transition width

Type:

float

z0

vertical scale height

Type:

float

z0_unc

associated uncertainty of vertical scale height

Type:

float

BX0

field strength at origin of X component

Type:

float

BX0_unc

associated uncertainty of field strength at origin of X component

Type:

float

ThetaX0

elev. angle at z = 0, rho > rhoXc

Type:

float

ThetaX0_unc

associated uncertainty of elev. angle at z = 0, rho > rhoXc

Type:

float

rhoXc

radius where thetaX = thetaX0

Type:

float

rhoXc_unc

associated uncertainty of radius where thetaX = thetaX0

Type:

float

rhoX

exponential scale length

Type:

float,

rhoX_unc

associated uncertainty of exponential scale length

Type:

float,

gamma

striation and / or rel. elec. number dens. rescaling

Type:

float

gamma_unc

associated uncertainty striation and / or rel. elec. number dens. rescaling

Type:

float

Notes

see http://adsabs.harvard.edu/abs/2012ApJ…757…14J Jansson & Farrar (2012)

BX(rho, z)[source]

X (out of plane) component of galactic magnetic field in galactocentric cylindrical coordinates (rho,phi,z)

BX is purely poloidal, i.e. phi component = 0

Parameters:
  • rho (array-like) – N-dim array with distance from origin in GC cylindrical coordinates, is in kpc

  • z (array-like) – N-dim array with height in kpc in GC cylindrical coordinates

Returns:

BX, BX_abs – tuple containing the magnetic field of the X component as a (3,N)-dim array with (rho,phi,z) components of disk field for each coordinate tuple and absolute value of the field as N-dim array

Return type:

tuple of ndarray

Bdisk(rho, phi, z)[source]

Disk component of galactic magnetic field in galactocentric cylindrical coordinates (rho,phi,z)

Parameters:
  • rho (array-like) – N-dim array with distance from origin in GC cylindrical coordinates, is in kpc

  • z (array-like) – N-dim array with height in kpc in GC cylindrical coordinates

  • phi (array-like) – N-dim array with polar angle in GC cylindircal coordinates, in radian

Returns:

Bdisk, Bdisk_abs – tuple containing the magnetic field of the disk as a (3,N)-dim array with (rho,phi,z) components of disk field for each coordinate tuple and absolute value of the field as N-dim array

Return type:

tuple of ndarray

Bhalo(rho, z)[source]

Halo component of galactic magnetic field in galactocentric cylindrical coordinates (rho,phi,z)

Bhalo is purely azimuthal (toroidal), i.e. has only a phi component

Parameters:
  • rho (array-like) – N-dim array with distance from origin in GC cylindrical coordinates, is in kpc

  • z (array-like) – N-dim array with height in kpc in GC cylindrical coordinates

Returns:

Bhalo, Bhalo_abs – tuple containing the magnetic field of the halo as a (3,N)-dim array with (rho,phi,z) components of disk field for each coordinate tuple and absolute value of the field as N-dim array

Return type:

tuple of ndarray

L(z, h, w)[source]

Transition function, see Jansson & Farrar Eq. 5

Parameters:
  • z (float or array-like) – array with positions (height above disk, z; distance from center, rho)

  • h (float) – height parameter

  • w (float) – width parameter

Returns:

L – array or float (depending on z input) with transition function values

Return type:

ndarray

__init__(model='jansson12')[source]

Init the GMF class, all B-field values are in muG

Parameters:

model (str) – either jansson12, jansson12b, or jansson12c, where jansson12 is the original model and the other two options are the modifications of the model with Planck data, see http://arxiv.org/abs/1601.00546

r_log_spiral(phi)[source]

return distance from center for angle phi of logarithmic spiral

Parameters:

phi (scalar or array-like) – polar angle values

Returns:

result – logarithmic spiral result with r(phi) = rx * exp(b * phi) as an array

Return type:

ndarray

Notes

see http://en.wikipedia.org/wiki/Logarithmic_spiral

class gammaALPs.bfields.gmf.GMFPshirkov(model='ASS')[source]

Bases: object

Class with analytical functions that describe the galactic magnetic field according to the model of Pshirkov et al. (2011)

Only the regular field components are implemented.

Rsun

position of the sun in kpc along x axis

Type:

float

p

pitch angle, dictionary with entries ‘ASS’ and ‘BSS’, in radian

Type:

dict

z0

height of disk in kpc

Type:

float

d

value if field reversal in kpc

Type:

float

B0

Value of B field at position of the sun, in muG

Type:

float

z0n

position of northern halo in kpc

Type:

float

Bn

northern halo field in muG

Type:

float

r0n

northern halo

Type:

float

z1n

scale height of halo toward galactic plane, |z| < z0n

Type:

float

z2n

scale height of northern halo away from galactic plane, |z| >= z0n

Type:

float

z0s

position of southern halo in kpc

Type:

float

Bs

southern halo field in muG

Type:

float

r0s

southern halo

Type:

float

z1s

scale height of southern halo toward galactic plane, |z| < z0s

Type:

float

z2s

scale height of southern halo away from galactic plane, |z| >= z0n

Type:

float

Notes

Paper: http://adsabs.harvard.edu/abs/2011ApJ…738..192P Pshirkov et al. (2011)

Bdisk(rho, phi, z)[source]

Disk component of galactic magnetic field in galactocentric cylindrical coordinates (rho,phi,z)

Parameters:
  • rho (array-like) – N-dim array with distance from origin in GC cylindrical coordinates, is in kpc

  • phi (array-like) – N-dim array with polar angle in GC cylindircal coordinates, in radian

  • z (array-like) – N-dim array with height in kpc in GC cylindrical coordinates

Returns:

Bdisk, Bdisk_abs – tuple containing the magnetic field of the disk as a (3,N)-dim array with (rho,phi,z) components of disk field for each coordinate tuple and absolute value of the field as N-dim array

Return type:

tuple of ndarray

Notes

See Pshirkov et al. Eq. (3) - (5)

Bhalo(rho, z)[source]

Halo component of galactic magnetic field in galactocentric cylindrical coordinates (rho,phi,z)

Bhalo is purely azimuthal (toroidal), i.e. has only a phi component

Parameters:
  • rho (array-like) – N-dim array with distance from origin in GC cylindrical coordinates, is in kpc

  • z (array-like) – N-dim array with height in kpc in GC cylindrical coordinates

Returns:

Bhalo, Bhalo_abs – tuple containing the magnetic field of the halo as a (3,N)-dim array with (rho,phi,z) components of disk field for each coordinate tuple and absolute value of the field as N-dim array

Return type:

tuple of ndarray

__init__(model='ASS')[source]

Init the GMF class, all B-field values are in muG

Parameters:

model (string,) – either ASS or BSS for axissymmetric or bisymmetric model, respectively.

class gammaALPs.bfields.gmf.UF23(model='base')[source]

Bases: object

Class with analytical functions that describe the galactic magnetic field according to the model of Unger & Farrar (2023/2024)

2 components are implemented for the spiral field: The spur_field is only used in the ‘spur’ model. The other 7 models use the spiral_field.

3 components are implemented for the halo field: The twisted_halo_field is only used for the ‘twistX’ model. The other 7 models use the sum of poloidal_halo_field and toroidal_halo_field.

Rsun

distance of sun from center of milky way in kpc

Type:

float

poloidal_A

coasting radius for poloidal halo (a_c)

Type:

float

r_ref

reference radius, for spiral field 5 kpc for spur field sun radius (8.2 kpc) (r_0)

Type:

float

r_inner

inner boundary (radius) of spiral field (r_1)

Type:

float

w_inner

inner boundary (transition width) of spiral field (w_1)

Type:

float

r_outer

outer boundary (radius) of spiral field (r_2)

Type:

float

w_outer

outer boundary (transition width) of spiral field (w_2)

Type:

float

disk_b1, disk_b2, disk_b3

magnetic field strength of mode 1, 2, 3 (B_m)

Type:

floats

disk_h

transition height (z_d)

Type:

float

disk_phase1, disk_phase2, disk_phase3

phase of mode 1, 2, 3 (phi_m)

Type:

floats

disk_pitch

pitch angle (alpha)

Type:

float

disk_w

vertical transition width (w_d)

Type:

float

poloidal_B

magnetic field strength normalization constant (B_p)

Type:

float

poloidal_P

field line exponent (p)

Type:

float

poloidal_R

radial scale or transition radius (r_p)

Type:

float

poloidal_W

transition width (w_p)

Type:

float

poloidal_Z

scale height (z_p)

Type:

float

toroidal_BN

northern magnetic field strength

Type:

float

toroidal_BS

southern magnetic field strength

Type:

float

toroidal_R

transition radius (r_t)

Type:

float

toroidal_W

radial transition width (w_t)

Type:

float

toroidal_Z

vertical scale height (z_t)

Type:

float

twisting_time

twisting time

Type:

float

spur_center

central azimuth in degree

Type:

float

spur_length

half angular length in degree

Type:

float

spur_width

gaussian width in degrees

Type:

float

Notes

see: Michael Unger and Glennys R. Farrar Astrophys.J. 970 (2024) 95 https://doi.org/10.3847/1538-4357/ad4a54 and https://doi.org/10.5281/zenodo.11321212

Bdisk(rho, phi, z)[source]

Returns disk component of milky way magnetic field depending on model in galactocentric cylindrical coordinates (rho, phi, z)

Parameters:
  • rho (array-like) – N-dim array with distance from origin in GC cylindrical coordinates, is in kpc

  • phi (array-like) – N-dim array with polar angle in GC cylindircal coordinates, in radian

  • z (array-like) – N-dim array with height in kpc in GC cylindrical coordinates

Returns:

Bdisk, Bdisk_abs – tuple containing the magnetic field of the disk as a (3,N)-dim array with (rho,phi,z) components of disk field for each coordinate tuple and absolute value of the field as N-dim array

Return type:

tuple of ndarray

Bhalo(rho, z)[source]

Returns halo component of milky way magnetic field depending on model in galactocentric cylindrical coordinates (rho, phi, z)

Parameters:
  • rho (array-like) – N-dim array with distance from origin in GC cylindrical coordinates, is in kpc

  • z (array-like) – N-dim array with height in kpc in GC cylindrical coordinates

Returns:

Bhalo, Bhalo_abs – tuple containing the magnetic field of the disk as a (3,N)-dim array with (rho,phi,z) components of disk field for each coordinate tuple and absolute value of the field as N-dim array

Return type:

tuple of ndarray

__init__(model='base')[source]

Initialize the UF23 class for 8 different models

Parameters:

model (str) – one of [‘base’, ‘expX’, ‘neCl’, ‘twistX’, ‘nebCor’, ‘cre10’, ‘synCG’, ‘spur’]

poloidal_halo_field(rho, z)[source]

calculates poloidal halo field component (phi-component = 0) in galactocentric cylindrical coordinates (rho, phi, z)

Parameters:
  • rho (array-like) – N-dim array with distance from origin in GC cylindrical coordinates, is in kpc

  • z (array-like) – N-dim array with height in kpc in GC cylindrical coordinates

Returns:

b_cyl, b_cyl_abs – tuple containing the magnetic field of the disk as a (3,N)-dim array with (rho,phi,z) components of disk field for each coordinate tuple and absolute value of the field as N-dim array

Return type:

tuple of ndarray

Notes

See Unger & Farrar (2024) Section 5.3.2, p. 11

spiral_field(rho, phi, z)[source]

calculates fourier-spiral disk component in galactocentric cylindrical coordinates (rho, phi, z)

Parameters:
  • rho (array-like) – N-dim array with distance from origin in GC cylindrical coordinates, is in kpc

  • phi (array-like) – N-dim array with polar angle in GC cylindircal coordinates, in radian

  • z (array-like) – N-dim array with height in kpc in GC cylindrical coordinates

Returns:

b_cyl, b_cyl_abs – tuple containing the magnetic field of the disk as a (3,N)-dim array with (rho,phi,z) components of disk field for each coordinate tuple and absolute value of the field as N-dim array

Return type:

tuple of ndarray

Notes

See Unger & Farrar (2024) Section 5.2.2, p. 9

spur_field(rho, phi, z)[source]

calculates spiral-spur disk component in galactocentric cylindrical coordinates (rho, phi, z)

Parameters:
  • rho (array-like) – N-dim array with distance from origin in GC cylindrical coordinates, is in kpc

  • phi (array-like) – N-dim array with polar angle in GC cylindircal coordinates, in radian

  • z (array-like) – N-dim array with height in kpc in GC cylindrical coordinates

Returns:

b_cyl, b_cyl_abs – tuple containing the magnetic field of the disk as a (3,N)-dim array with (rho,phi,z) components of disk field for each coordinate tuple and absolute value of the field as N-dim array

Return type:

tuple of ndarray

Notes

See Unger & Farrar (2024) Section 5.2.3, p. 9

toroidal_halo_field(rho, z)[source]

calculates toroidal halo field component (has only phi component) in galactocentric cylindrical coordinates (rho, phi, z)

Parameters:
  • rho (array-like) – N-dim array with distance from origin in GC cylindrical coordinates, is in kpc

  • z (array-like) – N-dim array with height in kpc in GC cylindrical coordinates

Returns:

b_cyl, b_cyl_abs – tuple containing the magnetic field of the disk as a (3,N)-dim array with (rho,phi,z) components of disk field for each coordinate tuple and absolute value of the field as N-dim array

Return type:

tuple of ndarray

Notes

See Unger & Farrar (2024) Section 5.3.1, p. 11

twisted_halo_field(rho, z)[source]

calculates twisted halo field for twistX model with twisting time not 0 in galactocentric cylindrical coordinates (rho, phi, z)

Parameters:
  • rho (array-like) – N-dim array with distance from origin in GC cylindrical coordinates, is in kpc

  • z (array-like) – N-dim array with height in kpc in GC cylindrical coordinates

Returns:

b_cyl_x, b_cyl_x_abs – tuple containing the magnetic field of the disk as a (3,N)-dim array with (rho,phi,z) components of disk field for each coordinate tuple and absolute value of the field as N-dim array

Return type:

tuple of ndarray

Notes

See Unger & Farrar (2024) Section 5.3.3, p. 12

gammaALPs.bfields.gmf.delta_phi(phi0, phi1)[source]

Calculates the angle between v0 = (cos(phi0), sin(phi0)) and v1 = (cos(phi1), sin(phi1)). Arguments: phi0 : float

First angle in radians

phi1float

Second angle in radians

Returns: The angle between v0 and v1 in radians.

gammaALPs.bfields.gmf.sigmoid(x, x0, w)[source]

Calculates the logistic sigmoid function. Arguments: x : float

The input value

x0float

The midpoint of the sigmoid

wfloat

The width of the sigmoid

Returns: The result of the sigmoid function

gammaALPs.bfields.gmf.signum(x)[source]

Return the sign of each entry of an array