safe_write_tac =============================================== .. py:function:: petpal.utils.time_activity_curve.safe_write_tac(filename: str, tac_data: numpy.ndarray, col_names: list[str] = None) Writes the data in a time-activity curve (TAC) to a file. Assumes the TAC data consists of a contiguous numpy array with two or three columns: time, activity, and (optionally) uncertainty. :param filename: Path to the file the data will be saved as. :type filename: str :param tac_data: Numpy array containing the data for the TAC. Assumes the TAC data consists of a contiguous numpy array with two or three columns: time, activity, and (optionally) uncertainty. :type tac_data: np.ndarray :param col_names: List of column names assigned to the time, activity, and uncertainty columns in the TAC data, respectively. Must match number of columns in `tac_data`. :type col_names: list[str] :raises ValueError: If the number of columns in tac_data is not two or three, or the number of columns in tac_data does not match the number of columns in col_names. .. rubric:: Example .. code-block:: python import numpy as np from petpal.utils.time_activity_curve import safe_load_tac, safe_write_tac my_tac = safe_load_tac(filename='/path/to/tac.tsv') my_tac_modified = np.zeros_like(my_tac) my_tac_modified[0] = my_tac[0] / 60 # convert time units to hours my_tac_modified[1] = my_tac[1] / 37000 # convert activity units to mCi my_tac_modified[2] = my_tac[2] / 37000 # convert uncertainties like activity safe_write_tac(filename='/path/to/new_tac.tsv', tac_data=my_tac_modified)