Skip to content

Signatures

siapy.entities.signatures

Signals dataclass

Signals(_data: DataFrame)

df property

df: DataFrame

load_from_parquet classmethod

load_from_parquet(filepath: str | Path) -> Signals
PARAMETER DESCRIPTION
filepath

TYPE: str | Path

Source code in siapy/entities/signatures.py
22
23
24
25
@classmethod
def load_from_parquet(cls, filepath: str | Path) -> "Signals":
    df = pd.read_parquet(filepath)
    return cls(df)

to_numpy

to_numpy() -> ndarray
Source code in siapy/entities/signatures.py
31
32
def to_numpy(self) -> np.ndarray:
    return self.df.to_numpy()

mean

mean() -> ndarray
Source code in siapy/entities/signatures.py
34
35
def mean(self) -> np.ndarray:
    return np.nanmean(self.to_numpy(), axis=0)

save_to_parquet

save_to_parquet(filepath: str | Path) -> None
PARAMETER DESCRIPTION
filepath

TYPE: str | Path

Source code in siapy/entities/signatures.py
37
38
def save_to_parquet(self, filepath: str | Path) -> None:
    self.df.to_parquet(filepath, index=True)

SignaturesFilter dataclass

SignaturesFilter(pixels: Pixels, signals: Signals)
PARAMETER DESCRIPTION
pixels

TYPE: Pixels

signals

TYPE: Signals

Source code in siapy/entities/signatures.py
43
44
45
def __init__(self, pixels: Pixels, signals: Signals):
    self.pixels = pixels
    self.signals = signals

pixels instance-attribute

pixels = pixels

signals instance-attribute

signals = signals

build

build() -> Signatures
Source code in siapy/entities/signatures.py
47
48
def build(self) -> "Signatures":
    return Signatures._create(self.pixels, self.signals)

rows

rows(rows: list[int] | slice | list[bool]) -> SignaturesFilter
PARAMETER DESCRIPTION
rows

TYPE: list[int] | slice | list[bool]

Source code in siapy/entities/signatures.py
50
51
52
53
54
55
def rows(self, rows: list[int] | slice | list[bool]) -> "SignaturesFilter":
    filtered_pixels_df = self.pixels.df.iloc[rows]
    filtered_signals_df = self.signals.df.iloc[rows]
    filtered_pixels = Pixels(pd.DataFrame(filtered_pixels_df))
    filtered_signals = Signals(pd.DataFrame(filtered_signals_df))
    return SignaturesFilter(filtered_pixels, filtered_signals)

cols

cols(cols: list[int] | slice | list[bool]) -> SignaturesFilter
PARAMETER DESCRIPTION
cols

TYPE: list[int] | slice | list[bool]

Source code in siapy/entities/signatures.py
57
58
59
60
def cols(self, cols: list[int] | slice | list[bool]) -> "SignaturesFilter":
    filtered_signals_df = self.signals.df.iloc[:, cols]
    filtered_signals = Signals(pd.DataFrame(filtered_signals_df))
    return SignaturesFilter(self.pixels, filtered_signals)

Signatures dataclass

Signatures(*args: Any, **kwargs: Any)
PARAMETER DESCRIPTION
*args

TYPE: Any DEFAULT: ()

**kwargs

TYPE: Any DEFAULT: {}

Source code in siapy/entities/signatures.py
68
69
def __init__(self, *args: Any, **kwargs: Any):
    raise DirectInitializationError(Signatures)

pixels property

pixels: Pixels

signals property

signals: Signals

from_array_and_pixels classmethod

from_array_and_pixels(image: ndarray, pixels: Pixels) -> Signatures
PARAMETER DESCRIPTION
image

TYPE: ndarray

pixels

TYPE: Pixels

Source code in siapy/entities/signatures.py
78
79
80
81
82
83
84
@classmethod
def from_array_and_pixels(cls, image: np.ndarray, pixels: Pixels) -> "Signatures":
    u = pixels.u()
    v = pixels.v()
    signals_list = image[v, u, :]
    signals = Signals(pd.DataFrame(signals_list))
    return cls._create(pixels, signals)

from_dataframe classmethod

from_dataframe(dataframe: DataFrame) -> Signatures
PARAMETER DESCRIPTION
dataframe

TYPE: DataFrame

Source code in siapy/entities/signatures.py
86
87
88
89
90
91
92
93
94
95
96
97
@classmethod
def from_dataframe(cls, dataframe: pd.DataFrame) -> "Signatures":
    if not all(
        coord in dataframe.columns for coord in [Pixels.coords.U, Pixels.coords.V]
    ):
        raise InvalidInputError(
            dataframe.columns.tolist(),
            f"DataFrame must include columns for both '{Pixels.coords.U}' and '{Pixels.coords.V}' coordinates.",
        )
    pixels = Pixels(dataframe[[Pixels.coords.U, Pixels.coords.V]])
    signals = Signals(dataframe.drop(columns=[Pixels.coords.U, Pixels.coords.V]))
    return cls._create(pixels, signals)

load_from_parquet classmethod

load_from_parquet(filepath: str | Path) -> Signatures
PARAMETER DESCRIPTION
filepath

TYPE: str | Path

Source code in siapy/entities/signatures.py
 99
100
101
102
@classmethod
def load_from_parquet(cls, filepath: str | Path) -> "Signatures":
    df = pd.read_parquet(filepath)
    return cls.from_dataframe(df)

to_dataframe

to_dataframe() -> DataFrame
Source code in siapy/entities/signatures.py
112
113
def to_dataframe(self) -> pd.DataFrame:
    return pd.concat([self.pixels.df, self.signals.df], axis=1)

to_numpy

to_numpy() -> ndarray
Source code in siapy/entities/signatures.py
115
116
def to_numpy(self) -> np.ndarray:
    return self.to_dataframe().to_numpy()

filter

filter() -> SignaturesFilter
Source code in siapy/entities/signatures.py
118
119
def filter(self) -> SignaturesFilter:
    return SignaturesFilter(self.pixels, self.signals)

save_to_parquet

save_to_parquet(filepath: str | Path) -> None
PARAMETER DESCRIPTION
filepath

TYPE: str | Path

Source code in siapy/entities/signatures.py
121
122
def save_to_parquet(self, filepath: str | Path) -> None:
    self.to_dataframe().to_parquet(filepath, index=True)