magnus.cli

cli.py

Command-line calculator for Mag$nu$s: computes a single neutrino oscillation probability (or probability matrix) from the command line, without writing any Python. Wraps the same osc_prob_{2,3,4,5}nu_* functions used by the Python API (see magnus.oscprob and Command-line calculator), dispatching to the right one based on --flavors, --environment, --scenario and --density-profile.

Installed as the magnus console script (see [project.scripts] in pyproject.toml) and also runnable as python -m magnus. Its one subcommand, prob, is the default: magnus --flavors 3 ... runs magnus prob --flavors 3 ... (issue #138).

Routine listings

  • main - Entry point: parses argv, dispatches, prints the result

  • build_parser - Builds the argparse.ArgumentParser

  • SUBCOMMANDS - The subcommands build_parser registers; the first is the default

  • FLAVOR_NAME_TO_INDEX - Maps flavor names (e, mu, tau, s, s1, s2)

    to their globaldefs index

  • ENERGY_UNITS, LENGTH_UNITS - Unit-name to \(\text{eV}\) / \(\text{eV}^{-1}\)

    conversion factors

  • FLAVOR_LABELS - Row and column names used by the printed table

  • ALWAYS_FORWARD - Numerics keywords forwarded to every wrapper

  • DENSITY_PROFILES - Values --density-profile accepts: ‘constant’, ‘exp’, and

    every tabulated solar model in magnus.solarmodels

Attributes

ENERGY_UNITS

LENGTH_UNITS

FLAVOR_NAME_TO_INDEX

FLAVOR_LABELS

ALWAYS_FORWARD

DENSITY_PROFILES

SUBCOMMANDS

Module-level constant

Functions

build_parser(→ argparse.ArgumentParser)

Builds the magnus command-line argument parser.

main(→ int)

Entry point for the magnus console script / python -m magnus.

Module Contents

magnus.cli.ENERGY_UNITS[source]
magnus.cli.LENGTH_UNITS[source]
magnus.cli.FLAVOR_NAME_TO_INDEX[source]
magnus.cli.FLAVOR_LABELS[source]
magnus.cli.ALWAYS_FORWARD[source]
magnus.cli.DENSITY_PROFILES = ('constant', 'exp', 'BP2000', 'BP04', 'BS05-OP', 'BS05-AGS-OP', 'B16-GS98', 'B16-AGSS09met',...[source]
magnus.cli.SUBCOMMANDS = ('prob',)[source]

Module-level constant

The subcommands build_parser() registers. The first, prob, is the default: a command line that names none runs it (issue #138).

Added in version 1.2.0.

Type:

tuple of str

magnus.cli.build_parser() → argparse.ArgumentParser[source]

Builds the magnus command-line argument parser.

Added in version 1.0.0.

Returns:

  • argparse.ArgumentParser – The top-level parser, with the prob subcommand attached (also kept as its default_subparser attribute). Its epilog says that prob is the default subcommand, which main() supplies when none is given, and its -h prints the help of prob after its own.

  • .. versionchanged:: 1.2.0 – The epilog names prob as the default subcommand, and magnus -h also prints the options of prob (issue #138).

  • .. versionchanged:: 1.2.0 – The –magnus-exp-order help states that ‘gl’ takes the even orders from 2 to 8 (issue #160 §5).

magnus.cli.main(argv=None) → int[source]

Entry point for the magnus console script / python -m magnus.

A command line that names no subcommand runs prob, the only one: magnus --flavors 3 ... is magnus prob --flavors 3 ....

Added in version 1.0.0.

Changed in version 1.2.0: prob is optional (issue #138).

Parameters:

argv (list of str, optional) – Arguments to parse instead of sys.argv[1:] (mainly for testing).

Returns:

Always 0. Every failure leaves through SystemExit instead, so this function has no non-zero return.

Return type:

int

Raises:

SystemExit – Exit code 2 for an argparse error or a value the library rejects, and 1 for a combination of flags that _env_kwargs or _wrapper_name refuses.