magnus.globaldefs
globaldefs.py
Contains physical constants and unit-conversion constants.
This module contains values of physical constants and unit-conversion
factors used by the various modules of Magnus: unit conversions (km,
cm, GeV, etc., to natural units of eV), fundamental constants (G_F,
particle masses, Avogadro’s number), Earth/Sun radii and reference
densities, flavor index constants (NUE, NUMU, NUTAU, NUS), predefined
oscillation/NSI/LIV parameter sets (e.g., NuFit 6.0), and ANSI terminal
color codes (class cstyle) used to format warning/error messages.
Routine listings
cstyle - ANSI terminal color-code constants
- set_color_output - Enables or disables ANSI color in the warning
and error message prefixes
- load_nufit_params - Loads one NuFit release/ordering/category as a
dict of standard oscillation parameters
The remaining module-level names are physical constants and unit-conversion factors, not routines; see the module source for the full list.
Attributes
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Module-level constant |
|
Classes
ANSI escape-code constants for colored/styled terminal output. |
Functions
|
Enables or disables ANSI color in the warning/error/tolerance message prefixes. |
|
Load standard three-flavor mixing parameters from a NuFit global fit. |
Module Contents
- class magnus.globaldefs.cstyle[source]
ANSI escape-code constants for colored/styled terminal output.
Used to format the warning/error/tolerance messages printed by
oscprob.py(e.g.,gd.WARNING_MSG_IN_COLOR,gd.ERROR_MSG_IN_COLOR). Has no effect on Windows terminals unlessos.system("")has been called first, which this module does at import time.Added in version 1.0.0.
- magnus.globaldefs.set_color_output(enabled: bool) None[source]
Enables or disables ANSI color in the warning/error/tolerance message prefixes.
The
*_IN_COLORconstants above wrap their text in ANSI escape codes, which read correctly in a terminal but appear as literal escape-code noise anywhere that does not interpret them – a captured log file, a Jupyter notebook rendered to HTML, or thejupyter-executecells in this package’s own documentation. Calling this function withFalserebinds every*_IN_COLORconstant to its plain-text counterpart, so the existing call sites (which all reference the*_IN_COLORnames) print unadorned text with no further change. Calling it withTruerestores the colored versions.Added in version 1.0.0.
- Parameters:
enabled (bool) – True to emit ANSI-colored message prefixes (the default at import time), False to emit plain text.
- Return type:
None
Examples
import magnus.globaldefs as gd gd.set_color_output(False) gd.WARNING_MSG_IN_COLOR
'Warning:'
- magnus.globaldefs.MAGNUS_MAX_PREDEFINED_NUM_FLAVORS = 5[source]
Module-level constant
Maximum number of flavors for which we have hard-coded routines in the oscprob module. Units: [Adimensional]
- Type:
- magnus.globaldefs.CONV_KM_TO_INV_EV = 5067730000.0[source]
Module-level constant
Multiplicative conversion factor from km to \(\text{eV}^{-1}\). Units: [\(\text{km}^{-1}~\text{eV}^{-1}\)].
- Type:
- magnus.globaldefs.UNIT_KM = 5067730000.0[source]
Module-level constant
Multiplicative conversion factor from km to \(\text{eV}^{-1}\). Alias for CONV_KM_TO_INV_EV. Units: [\(\text{km}^{-1}~\text{eV}^{-1}\)].
- Type:
- magnus.globaldefs.CONV_CM_TO_INV_EV = 50677.3[source]
Module-level constant
Multiplicative conversion factor from cm to \(\text{eV}^{-1}\). Units: [\(\text{cm}^{-1}~\text{eV}^{-1}\)]
- Type:
- magnus.globaldefs.UNIT_CM = 50677.3[source]
Module-level constant
Multiplicative conversion factor from cm to \(\text{eV}^{-1}\). Alias for CONV_CM_TO_INV_EV. Units: [\(\text{cm}^{-1}~\text{eV}^{-1}\)]
- Type:
- magnus.globaldefs.CONV_CM3_TO_INV_EV3[source]
Module-level constant
Multiplicative conversion factor from \(\text{cm}^{3}\) to \(\text{eV}^{-3}\). Units: [\(\text{cm}^{-3}~\text{eV}^{-3}\)]
- Type:
- magnus.globaldefs.UNIT_CM3[source]
Module-level constant
Multiplicative conversion factor from \(\text{cm}^{3}\) to \(\text{eV}^{-3}\). Alias for CONV_CM3_TO_INV_EV3. Units: [\(\text{cm}^{-3}~\text{eV}^{-3}\)]
- Type:
- magnus.globaldefs.CONV_INV_EV_TO_CM = 1.9732700834495916e-05[source]
Module-level constant
Multiplicative conversion factor from \(\text{eV}^{-1}\) to cm. Units: [eV cm]
- Type:
- magnus.globaldefs.UNIT_PER_CM3[source]
Module-level constant
Multiplicative conversion factor from \(\text{cm}^{-3}\) to \(\text{eV}^{3}\). Units: [\(\text{cm}^{3}~\text{eV}^{3}\)]
- Type:
- magnus.globaldefs.CONV_EV_TO_G = 1.783e-33[source]
Module-level constant
Multiplicative conversion factor from \(\text{eV}^{-1}\) to grams. Units: [\(\text{g eV}^{-1}\)]
- Type:
- magnus.globaldefs.CONV_G_TO_EV = 5.608524957936063e+32[source]
Module-level constant
Multiplicative conversion factor from grams to \(\text{eV}^{-1}\). Units: [\(\text{eV g}^{-1}\)]
- Type:
- magnus.globaldefs.UNIT_G_PER_CM3[source]
Module-level constant
Multiplicative conversion factor from \(\text{g cm}^{-3}\) to \(\text{eV}^{4}\). Units: [\(\text{g}^{-1}~\text{cm}^{3}~\text{eV}^{4}\)]
- Type:
- magnus.globaldefs.SQRT_OF_2[source]
Module-level constant
Square root of 2.. Units: [Adimensional]
- Type:
- magnus.globaldefs.GF = 1.1663787e-23[source]
Module-level constant
Fermi constant. Units: [\(\text{eV}^{-2}\)]
- Type:
- magnus.globaldefs.MASS_ELECTRON = 510998.9461[source]
Module-level constant
Electron mass. Units: [eV]
- Type:
- magnus.globaldefs.MASS_PROTON = 938272046.0[source]
Module-level constant
Proton mass. Units: [eV]
- Type:
- magnus.globaldefs.MASS_NEUTRON = 939565379.0[source]
Module-level constant
Neutron mass. Units: [eV]
- Type:
- magnus.globaldefs.ELECTRON_FRACTION_EARTH_CRUST = 0.5[source]
Module-level constant
Electron fraction in the Earth’s crust. Units: [Adimensional]
- Type:
- magnus.globaldefs.DENSITY_MATTER_CRUST_G_PER_CM3 = 3.0[source]
Module-level constant
Average matter density in the Earth’s crust. Units: [\(\text{g cm}^{-3}\)]
- Type:
- magnus.globaldefs.N_AV = 6.02214076e+23[source]
Module-level constant
Avogadro constant Units: [\(\text{mol}^{-1}\)]
- Type:
- magnus.globaldefs.NUM_DENSITY_E_EARTH_CRUST[source]
Module-level constant
Electron number density in the Earth’s crust Units: [\(\text{eV}^{3}\)]
- Type:
- magnus.globaldefs.VCC_EARTH_CRUST[source]
Module-level constant
Charged-current matter potential in the Earth’s crust. Units: [eV]
- Type:
- magnus.globaldefs.EARTH_RADIUS = 6371.0[source]
Module-level constant
Average Earth radius. Units: [km]
- Type:
- magnus.globaldefs.SUN_RADIUS = 694700.0[source]
Module-level constant
Average solar radius. Units: [km]
- Type:
- magnus.globaldefs.NUM_DENSITY_E_SUN_CENTRAL[source]
Module-level constant
Normalization of the standard exponential fit to the solar electron number density, \(n_e(r) = 245\,N_A\,\exp(-10.54\,r/R_\odot)\ \text{cm}^{-3}\).
This is the \(r \to 0\) intercept of that fit, not the central density of a solar model. The two differ by more than a factor of two: the BS2005-AGS,OP table gives \(n_e = 102.7\,N_A\ \text{cm}^{-3}\) at its innermost point \(r = 0.0016\,R_\odot\), against the fit’s 245, because the real profile flattens towards the centre while an exponential does not. Measured against that table across the whole star:
\(r/R_\odot\)
largest departure from it
0.00 – 0.05
fit high by 2.4x
0.05 – 0.10
fit high by 1.6x
0.10 – 0.20
21 %
0.20 – 0.30
2.5 %
0.30 – 0.70
11 %
0.70 – 1.00
up to 89 %
So the fit is a few-percent description only in a band around \(0.2\,R_\odot\), and the scale height
L_SCALE_SUN– the span the package’s own diagnostics use as a trajectory – lies at \(0.095\,R_\odot\), where the fit is high by about 30 %. It is still the right constant for the exponential profile it normalizes; what would be wrong is reading it as a measurement of the Sun’s central density, or the exponential as a stand-in for a tabulated model in the core.Units: [\(\text{eV}^{3}\)]
- Type:
- magnus.globaldefs.L_SCALE_SUN = 334018219259962.06[source]
Module-level constant
Scale height of the solar electron number density, \(R_\odot/10.54\), the decay length of the exponential fit normalized by
NUM_DENSITY_E_SUN_CENTRAL.Units: [\(\text{eV}^{-1}\)]
- Type:
- magnus.globaldefs.NUE = 0[source]
Module-level constant
Index used to denote nu_e flavor when computing probabilities. Units: [Adimensional]
- Type:
- magnus.globaldefs.NUMU = 1[source]
Module-level constant
Index used to denote nu_mu flavor when computing probabilities. Units: [Adimensional]
- Type:
- magnus.globaldefs.NUTAU = 2[source]
Module-level constant
Index used to denote nu_tau flavor when computing probabilities. Units: [Adimensional]
- Type:
- magnus.globaldefs.NUS = 3[source]
Module-level constant
Index used to denote the sterile flavor in when computing four-neutrino (3+1) probabilities. Units: [Adimensional]
- Type:
- magnus.globaldefs.NUS1 = 3[source]
Module-level constant
Index used to denote the first sterile flavor in when computing five-neutrino (3+2) probabilities. Units: [Adimensional]
- Type:
- magnus.globaldefs.NUS2 = 4[source]
Module-level constant
Index used to denote the second sterile flavor in when computing five-neutrino (3+2) probabilities. Units: [Adimensional]
- Type:
- magnus.globaldefs.S12_NO_BF_NUFIT_6_0[source]
Module-level constant
Lepton mixing angle \(\sin\theta_{12}\), best fit from NuFit 6.0, assuming normal ordering with SK atmospheric data. Units: [Adimensional]
- Type:
- magnus.globaldefs.S23_NO_BF_NUFIT_6_0[source]
Module-level constant
Lepton mixing angle \(\sin\theta_{23}\), best fit from NuFit 6.0, assuming normal ordering with SK atmospheric data. Units: [Adimensional]
- Type:
- magnus.globaldefs.S13_NO_BF_NUFIT_6_0[source]
Module-level constant
Lepton mixing angle \(\sin\theta_{13}\), best fit from NuFit 6.0, assuming normal ordering with SK atmospheric data. Units: [Adimensional]
- Type:
- magnus.globaldefs.DCP_NO_BF_NUFIT_6_0[source]
Module-level constant
Lepton CP-violation phase \(\delta_\text{CP}\), best fit from NuFit 6.0, assuming normal ordering with SK atmospheric data. Units: [radian]
- Type:
- magnus.globaldefs.D21_NO_BF_NUFIT_6_0 = 7.49e-05[source]
Module-level constant
Mass-squared difference \(\Delta m_{21}^2\), best fit from NuFit 6.0, assuming normal ordering with SK atmospheric data. Units: [\(\text{eV}^{2}\)]
- Type:
- magnus.globaldefs.D31_NO_BF_NUFIT_6_0 = 0.002513[source]
Module-level constant
Mass-squared difference \(\Delta m_{31}^2\), best fit from NuFit 6.0, assuming normal ordering with SK atmospheric data. Units: [\(\text{eV}^{2}\)]
- Type:
- magnus.globaldefs.S12_IO_BF_NUFIT_6_0[source]
Module-level constant
Lepton mixing angle \(\sin\theta_{12}\), best fit from NuFit 6.0, assuming inverted ordering with SK atmospheric data. Units: [Adimensional]
- Type:
- magnus.globaldefs.S23_IO_BF_NUFIT_6_0[source]
Module-level constant
Lepton mixing angle \(\sin\theta_{23}\), best fit from NuFit 6.0, assuming inverted ordering with SK atmospheric data. Units: [Adimensional]
- Type:
- magnus.globaldefs.S13_IO_BF_NUFIT_6_0[source]
Module-level constant
Lepton mixing angle \(\sin\theta_{13}\), best fit from NuFit 6.0, assuming inverted ordering with SK atmospheric data. Units: [Adimensional]
- Type:
- magnus.globaldefs.DCP_IO_BF_NUFIT_6_0[source]
Module-level constant
Lepton CP-violation phase \(\delta_\text{CP}\), best fit from NuFit 6.0, assuming inverted ordering with SK atmospheric data. Units: [radian]
- Type:
- magnus.globaldefs.D21_IO_BF_NUFIT_6_0 = 7.49e-05[source]
Module-level constant
Mass-squared difference \(\Delta m_{21}^2\), best fit from NuFit 6.0, assuming normal ordering with SK atmospheric data. Units: [\(\text{eV}^{2}\)]
- Type:
- magnus.globaldefs.D32_IO_BF_NUFIT_6_0 = -0.002484[source]
Module-level constant
Mass-squared difference \(\Delta m_{32}^2\), best fit from NuFit 6.0, assuming normal ordering with SK atmospheric data. Units: [\(\text{eV}^{2}\)]
- Type:
- magnus.globaldefs.D31_IO_BF_NUFIT_6_0 = -0.0024091[source]
Module-level constant
Mass-squared difference \(\Delta m_{31}^2\), best fit from NuFit 6.0, assuming inverted ordering with SK atmospheric data. Units: [\(\text{eV}^{2}\)]
- Type:
- magnus.globaldefs.EPS_EE = 0.06[source]
Module-level constant
Total NSI strength parameter eps_ee computed using values of the u and d quark parameters compatible at 2sigma with LMA+coherent from 1805.04530. Units: [Adimensional]
- Type:
- magnus.globaldefs.EPS_EM = -0.06[source]
Module-level constant
Total NSI strength parameter eps_em computed using values of the u and d quark parameters compatible at 2sigma with LMA+coherent from 1805.04530. Units: [Adimensional]
- Type:
- magnus.globaldefs.EPS_ET = 0.0[source]
Module-level constant
Total NSI strength parameter eps_et computed using values of the u and d quark parameters compatible at 2sigma with LMA+coherent from 1805.04530. Units: [Adimensional]
- Type:
- magnus.globaldefs.EPS_MM = 1.2[source]
Module-level constant
Total NSI strength parameter eps_mm computed using values of the u and d quark parameters compatible at 2sigma with LMA+coherent from 1805.04530. Units: [Adimensional]
- Type:
- magnus.globaldefs.EPS_MT = 0.0[source]
Module-level constant
Total NSI strength parameter eps_mt computed using values of the u and d quark parameters compatible at 2sigma with LMA+coherent from 1805.04530. Units: [Adimensional]
- Type:
- magnus.globaldefs.EPS_TT = 0.0[source]
Module-level constant
Total NSI strength parameter eps_tt computed using values of the u and d quark parameters compatible at 2sigma with LMA+coherent from 1805.04530. Units: [Adimensional]
- Type:
- magnus.globaldefs.EPS_2[source]
Module-level constant
Vector of total NSI strength parameters for two-neutrino oscillations. Units: [Adimensional]
- Type:
- magnus.globaldefs.EPS_3[source]
Module-level constant
Vector of total NSI strength parameters for three-neutrino oscillations. Units: [Adimensional]
- Type:
- magnus.globaldefs.SXI12 = 0.0[source]
Module-level constant
LIV lepton mixing angle sin(xi_12). Units: [Adimensional]
- Type:
- magnus.globaldefs.SXI23 = 0.0[source]
Module-level constant
LIV lepton mixing angle sin(xi_23). Units: [Adimensional]
- Type:
- magnus.globaldefs.SXI13 = 0.0[source]
Module-level constant
LIV lepton mixing angle sin(xi_13). Units: [Adimensional]
- Type:
- magnus.globaldefs.DXICP = 0.0[source]
Module-level constant
LIV CP-violation phase. Units: [radian]
- Type:
- magnus.globaldefs.LAMBDA = 1000000000000.0[source]
Module-level constant
LIV energy scale Lambda. Units: [eV]
- Type:
- magnus.globaldefs.load_nufit_params(version='NuFIT 6.1', ordering='NO', category=None)[source]
Load standard three-flavor mixing parameters from a NuFit global fit.
Looks up
NUFIT_GLOBAL_FITSfor the requested release, mass ordering, and (release-specific) secondary category, and returns them as a plain dict with the same parameter names used throughout Magnus (s12,s23,s13,dCP,D21,D31), so the result can be passed directly as keyword arguments to anyosc_prob_3nu_*function (or tomagnus.hamiltonians.hamiltonians3nu()and other functions that take the same standard-oscillation parameter names).- Parameters:
version (str, optional) – NuFit release to load, e.g.
'NuFIT 6.1','NuFIT 5.2','NuFIT 1.0'. SeeNUFIT_GLOBAL_FITS.keys()for the full list of available releases (v1.0 through v6.1). Default:'NuFIT 6.1'(the latest release at the time of writing).ordering (str, optional) – Neutrino mass ordering:
'NO'(normal) or'IO'(inverted). Default:'NO'.category (str or None, optional) – Release-specific secondary category (e.g.
'with_SK'/'without_SK'for v4.0+,'LEM'/'LID'for v2.1,'free_fluxes_rsbl'/'huber_fluxes_no_rsbl'for v1.0-v1.3). IfNone(default), the release’s preferred/primary category is used (for releases with awith_SK/without_SKsplit, this is'with_SK'). SeeNUFIT_GLOBAL_FITS[version]['categories'].keys()for the categories available for a given release.
- Returns:
Dict with keys
s12,s23,s13(\(\sin\theta_{ij}\), adimensional),dCP(radian),D21andD31(\(\text{eV}^{2}\)).- Return type:
- Raises:
ValueError – If
versionis not a known NuFit release, iforderingis not'NO'or'IO', or ifcategoryis not one of the categories available forversion.
Examples
Load a release and feed it straight into a probability function (the code below runs when these docs are built, so the output shown is always current):
import magnus.globaldefs as gd import magnus.oscprob as oscprob params = gd.load_nufit_params('NuFIT 6.1', ordering='NO') sorted(params.keys())
['D21', 'D31', 'dCP', 's12', 's13', 's23']
oscprob.osc_prob_3nu_vacuum(1.0 * gd.UNIT_GEV, 100.0 * gd.UNIT_KM, **params)
array([[0.99147795, 0.00323398, 0.00528806], [0.0034939 , 0.90719742, 0.08930869], [0.00502815, 0.0895686 , 0.90540325]])Comparing normal- and inverted-ordering best fits from an older release:
no = gd.load_nufit_params('NuFIT 4.0', ordering='NO', category='with_SK') io = gd.load_nufit_params('NuFIT 4.0', ordering='IO', category='with_SK') no['D31'] > 0 and io['D31'] < 0
True
Added in version 1.0.0.