Global Configuration¶
dnois.conf
defines some constants used globally in DNOIS.
They can be modified to change the behavior of DNOIS.
- class dnois.conf.config(**configs)¶
A context manager to temporarily change global configurations.
>>> import dnois >>> with dnois.config(float_print_fmt='.3f'): ... print(dnois.fmt(1.23456789)) 1.235 >>> print(dnois.fmt(1.23456789)) 1.23457
Note
The usage of this class is similar to
torch.no_grad()
, which can serve as a context manager or a decorator.Warning
The temporary changes made by this context manager is not thread-safe.
- Parameters:
configs – Keyword arguments to change global configurations. Each key must be a valid configuration item name.
- dnois.conf.default_aperture_radius: float = 0.005¶
Default radius of apertures in meters.
- dnois.conf.default_pressure: float = 1.0¶
Default pressure of the system in atm (if meaningful).
- dnois.conf.default_temperature: float = 20.0¶
Default temperature of the system in degree Celsius (if meaningful).
- dnois.conf.detection_radius_eps: float = 1e-05¶
Expansion percentage of aperture radius when determining its passing region.
- dnois.conf.detection_wl_eps: float = 1e-05¶
Expansion percentage of wavelength range when determining whether a wavelength is valid for a material.
- dnois.conf.float_print_fmt: str = '.6g'¶
Default format to print float numbers.
- dnois.conf.focal_length_trace_radius: float = 0.0001¶
Radius of beam used to compute focal length using
trace
method.
- dnois.conf.pressure_affect_n: bool = False¶
Whether pressure affects refractive index of air. Note that pressure does not affect common materials.
- dnois.conf.temperature_affect_n: bool = False¶
Whether temperature affects refractive index.