copy_variable#
- pypillometry.copy_variable(old, new, eyes=[], overwrite=False)#
Pipeline step for
copy_variable()(d | pp.copy_variable(...)).Copy a variable (of all eyes or of eyes) to a new name.
Values, mask layers and the parameters of
scale()are copied; so are the limits of an uncertainty band (<eye>_<old>_lowerand_upper). Typical use: keep the original before a step replaces the variable, e.g.,d.copy_variable("pupil", "pupilraw")before storing a reconstruction as"pupil". For the channels inaux, seeEyeDataDict.copy_key.- Parameters:
old (
str) – the variable (e.g.,"pupil")new (
str) – the name of the copy (e.g.,"pupilraw")eyes (
str|list) – only these eyes; default all eyes with the variableoverwrite (
bool) – replace the variable new if it exists (else an error)inplace (bool or None, optional) – if True, make change in-place and return the object; if False, make and return copy before making changes; if None, use the object-level setting (specified in the constructor)
- Return type:
- Returns:
the object with the copy (self or a copy, depending on inplace)
- Raises:
KeyError – if the variable does not exist (for an eye in eyes)
ValueError – if new exists (and not overwrite)
See also
rename_variablerename the variable instead
Examples
>>> import pypillometry as pp >>> d = pp.get_example_data("rlmw_002_short") >>> d = d.copy_variable("pupil", "pupilraw", inplace=False) >>> d.data.variables ['x', 'y', 'pupil', 'pupilraw']