Skip to content

Celtic Tree Calendar

A Celtic tree calendar (Ogham tree zodiac) engine that deterministically classifies a birth date into one of thirteen tree signs by fixed date ranges. The scheme is Robert Graves' 20th-century reconstruction, not an attested ancient calendar; Graves' nameless day (23 December) is folded into Ruis (Elder).

from fortune_telling_core import Querent, ReadingRequest
from fortune_telling_core.traditions.celtic_tree import (
    CELTIC_TREE_DECK,
    CELTIC_TREE_SPREAD,
    build_engine,
)

request = ReadingRequest(
    deck_id=CELTIC_TREE_DECK.id,
    spread_id=CELTIC_TREE_SPREAD.id,
    querent=Querent(
        id="sample",
        display_name="Sample",
        attributes={"birth_datetime": "1990-07-01T00:00:00+00:00"},
    ),
)
reading = build_engine().cast(request)

celtic_tree

CELTIC_TREE_DECK module-attribute

CELTIC_TREE_DECK = Deck(
    id="celtic_tree.deck.signs.v1",
    symbols=tuple(
        (
            Symbol(
                id=sign.symbol_id,
                name=sign.tree,
                attributes={
                    "slug": sign.slug,
                    "ogham": sign.ogham,
                    "tree": sign.tree,
                    "cycle_index": str(sign.index),
                    "date_range": sign.date_range,
                },
            )
        )
        for sign in SIGNS
    ),
)

CELTIC_TREE_SPREAD module-attribute

CELTIC_TREE_SPREAD = Spread(
    id="celtic_tree.spread.birth.v1",
    name="Celtic Tree",
    positions=(
        Position(
            "tree_sign",
            "Tree Sign",
            "Ogham tree sign for the birth date.",
        ),
    ),
)

CelticTreeEngine

Bases: AbstractEngine

Celtic tree calendar (Ogham tree zodiac) engine.

The engine deterministically classifies a querent's birth date into one of thirteen Ogham tree signs by fixed (month, day) date ranges. The scheme is Robert Graves' 20th-century reconstruction; 23 December (Graves' nameless day) is folded into Ruis (Elder) so every date classifies.

id class-attribute instance-attribute

id = 'celtic_tree.engine'

version class-attribute instance-attribute

version = '0.1.0'

deck

deck(request: ReadingRequest) -> Deck

Return the Celtic tree deck.

Parameters:

Name Type Description Default
request ReadingRequest

Reading request whose deck_id must match CELTIC_TREE_DECK.id.

required

Returns:

Type Description
Deck

The bundled Celtic tree deck.

Raises:

Type Description
ValidationError

If the requested deck is unsupported.

Source code in src/fortune_telling_core/traditions/celtic_tree/engine.py
def deck(self, request: ReadingRequest) -> Deck:
    """Return the Celtic tree deck.

    Args:
        request: Reading request whose ``deck_id`` must match
            ``CELTIC_TREE_DECK.id``.

    Returns:
        The bundled Celtic tree deck.

    Raises:
        ValidationError: If the requested deck is unsupported.
    """

    if request.deck_id != CELTIC_TREE_DECK.id:
        raise ValidationError(f"unsupported Celtic tree deck: {request.deck_id}")
    return CELTIC_TREE_DECK

spread

spread(request: ReadingRequest) -> Spread

Return the Celtic tree spread.

Parameters:

Name Type Description Default
request ReadingRequest

Reading request whose spread_id must match CELTIC_TREE_SPREAD.id.

required

Returns:

Type Description
Spread

The bundled Celtic tree spread.

Raises:

Type Description
ValidationError

If the requested spread is unsupported.

Source code in src/fortune_telling_core/traditions/celtic_tree/engine.py
def spread(self, request: ReadingRequest) -> Spread:
    """Return the Celtic tree spread.

    Args:
        request: Reading request whose ``spread_id`` must match
            ``CELTIC_TREE_SPREAD.id``.

    Returns:
        The bundled Celtic tree spread.

    Raises:
        ValidationError: If the requested spread is unsupported.
    """

    if request.spread_id != CELTIC_TREE_SPREAD.id:
        raise ValidationError(f"unsupported Celtic tree spread: {request.spread_id}")
    return CELTIC_TREE_SPREAD

draw

draw(request: ReadingRequest, rng: Rng) -> Draw

Classify the birth date into a tree sign as a deterministic draw.

Parameters:

Name Type Description Default
request ReadingRequest

Reading request with birth_datetime in options or querent attributes.

required
rng Rng

Ignored. The argument is present for Engine compatibility.

required

Returns:

Type Description
Draw

A draw with the single tree-sign selection.

Raises:

Type Description
ValidationError

If required birth data is invalid.

Source code in src/fortune_telling_core/traditions/celtic_tree/engine.py
def draw(self, request: ReadingRequest, rng: Rng) -> Draw:
    """Classify the birth date into a tree sign as a deterministic draw.

    Args:
        request: Reading request with ``birth_datetime`` in options or
            querent attributes.
        rng: Ignored. The argument is present for ``Engine`` compatibility.

    Returns:
        A draw with the single tree-sign selection.

    Raises:
        ValidationError: If required birth data is invalid.
    """

    del rng
    birth = parse_birth_data(request)
    return draw_from_sign(classify(birth.birth_datetime.date()))

cast

cast(request: ReadingRequest) -> Reading

Compute a Celtic tree reading without a caller RNG.

Parameters:

Name Type Description Default
request ReadingRequest

Reading request containing birth data.

required

Returns:

Type Description
Reading

A reading with the tree-sign placement and summary.

Raises:

Type Description
ValidationError

If required birth data is invalid.

Source code in src/fortune_telling_core/traditions/celtic_tree/engine.py
def cast(self, request: ReadingRequest) -> Reading:
    """Compute a Celtic tree reading without a caller RNG.

    Args:
        request: Reading request containing birth data.

    Returns:
        A reading with the tree-sign placement and summary.

    Raises:
        ValidationError: If required birth data is invalid.
    """

    draw = self.draw(request, _NULL_RNG)
    return self._interpret(request, draw, rng=None)

build_engine

build_engine() -> CelticTreeEngine

Create a Celtic tree engine.

Returns:

Type Description
CelticTreeEngine

A new CelticTreeEngine instance.

Source code in src/fortune_telling_core/traditions/celtic_tree/engine.py
def build_engine() -> CelticTreeEngine:
    """Create a Celtic tree engine.

    Returns:
        A new ``CelticTreeEngine`` instance.
    """

    return CelticTreeEngine()