EnergyRange

class gdt.core.data_primitives.EnergyRange(emin, emax)[source]

Bases: Range

A primitive class defining an energy range

Parameters:
  • emin (float) – The low end of the energy range

  • emax (float) – The high end of the energy range

Attributes Summary

center

The center of the range

emax

The high end of the energy range

emin

The low end of the energy range

log_center

The logarithmic center of the energy range

width

The width of the range

Methods Summary

as_tuple()

Return the range as a tuple.

contains(value[, inclusive])

Determine if the range contains a value.

intersection(range1, range2)

Return a new Range that is the intersection of two input Ranges.

translate(value)

Returns a new Range that is the translated (shifted) by the given value

union(range1, range2)

Return a new Range that is the union of two input Ranges

Attributes Documentation

center

The center of the range

Type:

(float)

emax

The high end of the energy range

Type:

(float)

emin

The low end of the energy range

Type:

(float)

log_center

The logarithmic center of the energy range

Type:

log_center (float)

width

The width of the range

Type:

(float)

Methods Documentation

as_tuple()

Return the range as a tuple.

Returns:

(float, float)

contains(value, inclusive=True)

Determine if the range contains a value.

Parameters:
  • value (float) – The input value to check

  • inclusive (bool, optional) – If True, then includes the edges of the range for the check, otherwise it is edge-exclusive. Default is True.

Returns:

bool – True if the value is in the range, False otherwise

classmethod intersection(range1, range2)

Return a new Range that is the intersection of two input Ranges. If the input Ranges do not intersect, then None is returned.

Parameters:
  • range1 (Range) – A range used to calculate the intersection

  • range2 (Range) – Another range used to calculate the intersection

Returns:

Range – The intersected range

translate(value)

Returns a new Range that is the translated (shifted) by the given value

Parameters:

value (float) – The value to shift the range by

Returns:

Range – The shifted range

classmethod union(range1, range2)

Return a new Range that is the union of two input Ranges

Parameters:
  • range1 (Range) – A range used to calculate the union

  • range2 (Range) – Another range used to calculate the union

Returns:

Range – The unionized range