Skip to content
Snippets Groups Projects
Commit 0835c4b2 authored by David Schäfer's avatar David Schäfer
Browse files

[FIX] significantly speedup positional backward translation

parent 6a743994
No related branches found
No related tags found
No related merge requests found
Pipeline #30570 passed with stage
in 2 minutes and 6 seconds
......@@ -4,6 +4,7 @@ from __future__ import annotations
from typing import Tuple
import numpy as np
import pandas as pd
from saqc.core.flags import (
......@@ -91,12 +92,11 @@ class PositionalTranslator(Translator):
# Concatenate the single flag values. There are faster and more
# complicated approaches (see former `PositionalFlagger`), but
# this method shouldn't be called that often
tflags = (
thist.astype(int).astype(str).apply(lambda x: x.sum(), axis="columns")
)
out[field] = "9"
if not tflags.empty:
# take care for the default columns
out[field] += tflags.str.slice(start=1)
ncols = thist.shape[-1] - 1
init = 9 * 10 ** ncols
bases = 10 ** np.arange(ncols, -1, -1)
tflags = init + (thist * bases).sum(axis=1)
out[field] = tflags
return pd.DataFrame(out).fillna(-9999).astype(int)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment