Curves module

Curves.

physicslab.curves.black_body_radiation(frequency, T)[source]

UNIT = W/sr/m^2/Hz

To express the law per unit wavelength, input frequency = c / wavelength (UNIT = W/sr/m^3).

Parameters
Returns

Spectral radiance

Return type

numpy.ndarray

physicslab.curves.gaussian_curve(x, expected_value, variance, amplitude=None, zero=0)[source]

Gauss curve function of given parameters.

Parameters
  • x (numpy.ndarray) – Free variable

  • expected_value (float) – Center

  • variance (float) – Variance (not FWHM)

  • amplitude (float, optional) – Amplitude (value at maximum relative to the baseline). None normalize as probability, defaults to None

  • zero (int) – Baseline, defaults to 0

Returns

Gaussian curve values

Return type

numpy.ndarray

physicslab.curves.gaussian_curve_FWHM(variance)[source]

Find FWHM from variance of a Gaussian curve.

Parameters

variance (float) – Variance

Returns

Full Width at Half Maximum

Return type

float

physicslab.curves.spontaneous_magnetization(T, M0, TC, a, b, zero)[source]

An empirical interpolation of the low temperature and the critical temperature regimes.

Parameters
  • T (numpy.ndarray) – Temperature

  • M0 (float) – Spontaneous magnetization at absolute zero

  • TC (float) – Curie temperature

  • a (float) – Magnetization stays close to M0 at higher temperatures

  • b (float) – Critical exponent. Magnetization stays close to zero lower below TC

  • zero (float) – Baseline

Returns

Magnetization

Return type

numpy.ndarray

physicslab.curves.magnetic_hysteresis_branch(H, saturation, remanence, coercivity, rising_branch=True)[source]

One branch of magnetic hysteresis loop.

Parameters
  • H (numpy.ndarray) – external magnetic field strength.

  • saturation (float) – \(max(B)\)

  • remanence (float) – \(B(H=0)\)

  • coercivity (float) – \(H(B=0)\)

  • rising_branch (bool, optional) – Rising (True) or falling (False) branch, defaults to True

Raises
Returns

Resulting magnetic field induction \(B\)

Return type

numpy.ndarray

physicslab.curves.magnetic_hysteresis_loop(H, saturation, remanence, coercivity)[source]

Magnetic hysteresis loop.

If more control is needed, use magnetic_hysteresis_branch(). To check whether the data starts with rising or falling part, first and middle element are compared.

Parameters
  • H (numpy.ndarray) – external magnetic field strength. The array is split in half for individual branches.

  • saturation (float) – \(max(B)\)

  • remanence (float) – \(B(H=0)\)

  • coercivity (float) – \(H(B=0)\)

Returns

Resulting magnetic field induction \(B\)

Return type

numpy.ndarray

class physicslab.curves.Line(constant=0, slope=0)[source]

Represents a line function: \(y=a_0+a_1x\).

Call the instance to enumerate it at the given x. You can do arithmetic with Line, find zeros, etc.

Parameters
  • constant (int, optional) – Constant term (\(a_0\)), defaults to 0

  • slope (int, optional) – Linear term (\(a_1\)), defaults to 0

__call__(x)[source]

Find function values of self.

Parameters

x (numpy.ndarray) – Free variable

Returns

Function value

Return type

numpy.ndarray

zero()[source]

Find free variable (x) value which evaluates to zero.

Raises

ValueError – If slope is zero.

root()[source]

Alias for zero().

invert()[source]

Return inverse function of self.

Returns

Inverted function

Return type

Line

static Intersection(line1, line2)[source]

Find intersection coordinates of the two given Line.

Parameters
  • line1 (Line) – First line

  • line2 (Line) – Second line

Returns

Coordinates of the intersection of the two lines

Return type

tuple