runtraj.transforms.weigh#

runtraj.transforms.weigh(particles, factor)[source]#

Return a copy of the particles with weight multiplied by factor.

A table without a weight column starts from 1 at every row.

Parameters:
  • particles (DataFrame) – The particle table.

  • factor (ArrayLike) – The factor for each row, aligned with particles.

Returns:

A new table; particles is unchanged.

Return type:

DataFrame

Examples

>>> import pandas as pd
>>> from runtraj.transforms import weigh
>>> p = pd.DataFrame({"particle": [1, 2]})
>>> weigh(weigh(p, [0.5, 1.0]), [0.5, 0.5])["weight"].tolist()
[0.25, 0.5]