parmed.unit.Quantity

class parmed.unit.Quantity(value=None, unit=None)[source]

Physical quantity, such as 1.3 meters per second.

Quantities contain both a value, such as 1.3; and a unit, such as ‘meters per second’.

Supported value types include:

1 - numbers (float, int, long) 2 - lists of numbers, e.g. [1,2,3] 3 - tuples of numbers, e.g. (1,2,3)

Note - unit conversions will cause tuples to be converted to lists

4 - lists of tuples of numbers, lists of lists of … etc. of numbers 5 - numpy.arrays

Methods

in_unit_system(system)

Returns a new Quantity equal to this one, expressed in a particular unit system.

in_units_of(other_unit)

Returns an equal Quantity expressed in different units.

max(*args, **kwargs)

Computes the maximum value of the sequence, with the result having the same unit as the current sequence.

mean(*args, **kwargs)

Computes the mean of a sequence, with the result having the same unit as the current sequence.

min(*args, **kwargs)

Computes the minimum value of the sequence, with the result having the same unit as the current sequence.

reduce_unit([guide_unit])

Combine similar component units and scale, to form an equal Quantity in simpler units.

reshape(shape[, order])

Same as numpy.ndarray.reshape, except the result is a Quantity with the same units as the current object rather than a plain numpy.ndarray

sqrt()

Returns square root of a Quantity.

std(*args, **kwargs)

Computes the square root of the variance of a sequence, with the result having the same unit as the current sequence.

sum(*args, **kwargs)

Computes the sum of a sequence, with the result having the same unit as the current sequence.

value_in_unit(unit)

Returns underlying value, in the specified units.

value_in_unit_system(system)

Returns the underlying value type, after conversion to a particular unit system.

append

count

extend

format

index

insert

pop

remove

__init__(value=None, unit=None)[source]

Create a new Quantity from a value and a unit.

Parameters
  • value: (any type, usually a number) Measure of this quantity

  • unit: (Unit) the physical unit, e.g. simtk.unit.meters.

Methods

__init__([value, unit])

Create a new Quantity from a value and a unit.

append(item)

count(item)

extend(rhs)

format(format_spec)

in_unit_system(system)

Returns a new Quantity equal to this one, expressed in a particular unit system.

in_units_of(other_unit)

Returns an equal Quantity expressed in different units.

index(item)

insert(index, item)

max(*args, **kwargs)

Computes the maximum value of the sequence, with the result having the same unit as the current sequence.

mean(*args, **kwargs)

Computes the mean of a sequence, with the result having the same unit as the current sequence.

min(*args, **kwargs)

Computes the minimum value of the sequence, with the result having the same unit as the current sequence.

pop(*args)

reduce_unit([guide_unit])

Combine similar component units and scale, to form an equal Quantity in simpler units.

remove(item)

reshape(shape[, order])

Same as numpy.ndarray.reshape, except the result is a Quantity with the same units as the current object rather than a plain numpy.ndarray

sqrt()

Returns square root of a Quantity.

std(*args, **kwargs)

Computes the square root of the variance of a sequence, with the result having the same unit as the current sequence.

sum(*args, **kwargs)

Computes the sum of a sequence, with the result having the same unit as the current sequence.

value_in_unit(unit)

Returns underlying value, in the specified units.

value_in_unit_system(system)

Returns the underlying value type, after conversion to a particular unit system.