solprop.sol#

The session namespace: everything a person types at a prompt, behind one import.

For a terminal or a notebook, not for library code:

import solprop.sol as sol          # or: from solprop.sol import *

sol.capillary_params(125e-6, "He", 1.0, energy=275e-6, fwhm=7.5e-15,
                     wavelength=800e-9)
run = sol.prop_capillary(125e-6, 1.0, "He", 1.0, lambda0=800e-9, ...)
sol.prop_2d(run)
sol.compress_taylor(run)

This is the one module of the package whose import has side effects, which is its whole purpose. Importing it calls start_session(), which

  1. configures logging at INFO through solprop.log.configure_logging(), so that a run reports its set-up and draws its progress bar; and

  2. silences MaterialRangeWarning. Every capillary run asks its gas and its cladding for an index over a band wider than any published fit covers, so at a prompt the notice is noise. A script that imports from the home modules keeps it: the library’s default is unchanged, and material_warnings() turns it back on here.

Both are idempotent, and end_session() undoes them. Nothing is printed, and matplotlib’s backend and interactive mode are left alone.

The names are flat and explicit. Where two home modules use one name, the processing function keeps it and the plot takes a plot_ prefix: energy measures, plot_energy draws; likewise plot_stats. The names are this package’s snake case, such as prop_2d; docs/guide/workflows/interactive.md has the table. numpy and matplotlib.pyplot are deliberately not re-exported, so a star import never shadows your own np and plt.

solprop.sol.start_session(level=20)[source]#

Configure logging and silence the material-range warnings.

What importing solprop.sol does. Calling it again changes nothing: one handler, one filter.

Parameters:
levelint or str, optional

Level of the package’s log output.

solprop.sol.end_session()[source]#

Undo start_session(): remove the log handler and show the warnings.

For a test, or a long-lived process that wants the library’s defaults back. The handler installed by solprop.log.configure_logging() is removed and the package logger returns to inheriting its level.

solprop.sol.set_log_level(level)[source]#

Set the level of the package’s log output for this session.

Parameters:
levelint or str

A logging level or its name: "DEBUG" for the translation summaries, "WARNING" for a quiet session.

solprop.sol.material_warnings(enabled)[source]#

Turn the material-range warnings on or off for this session.

Off installs one "ignore" filter for MaterialRangeWarning; on removes exactly that entry, so whatever was in force before this module was imported is in force again – Python’s default, or a stricter filter of your own, which is never touched or shadowed. (An "ignore" filter of your own for the same category is the same entry, and goes with it.)

Parameters:
enabledbool

True to see the warnings again; False to silence them, as importing this module does.

Examples

>>> import warnings
>>> from solprop import sol
>>> from solprop.exceptions import MaterialRangeWarning
>>> with warnings.catch_warnings():
...     sol.material_warnings(False)
...     warnings.warn("outside the fit", MaterialRangeWarning)