Skip to content

solar

solar #

Angular separation between two solar positions on the celestial sphere.

Spreads captures across sun angles — morning, noon, evening, golden hour.

SolarDistanceFunction #

Bases: DistanceFunction[SolarPosition]

Angular distance between solar positions, normalized by sigma_deg.

Source code in capturegraph-lib/capturegraph/scheduling/distance/solar.py
class SolarDistanceFunction(DistanceFunction[SolarPosition]):
    """Angular distance between solar positions, normalized by ``sigma_deg``."""

    def __init__(self, sigma_deg: float = 1.0) -> None:
        """Normalize the angular separation by ``sigma_deg``."""
        self.sigma_deg = sigma_deg

    def extract(self, values: cg.Array) -> np.ndarray:
        """Each position's altitude and azimuth, in radians."""
        return np.radians(numeric(values, "altitude", "azimuth"))

    def pairwise(self, features_a: np.ndarray, features_b: np.ndarray) -> np.ndarray:
        """The angular separations between two sets of solar positions."""
        arcs = haversine_radians(
            features_a[:, 0],
            features_a[:, 1],
            features_b[:, 0],
            features_b[:, 1],
        )
        return np.degrees(arcs) / self.sigma_deg

__init__(sigma_deg=1.0) #

Normalize the angular separation by sigma_deg.

Source code in capturegraph-lib/capturegraph/scheduling/distance/solar.py
def __init__(self, sigma_deg: float = 1.0) -> None:
    """Normalize the angular separation by ``sigma_deg``."""
    self.sigma_deg = sigma_deg

extract(values) #

Each position's altitude and azimuth, in radians.

Source code in capturegraph-lib/capturegraph/scheduling/distance/solar.py
def extract(self, values: cg.Array) -> np.ndarray:
    """Each position's altitude and azimuth, in radians."""
    return np.radians(numeric(values, "altitude", "azimuth"))

pairwise(features_a, features_b) #

The angular separations between two sets of solar positions.

Source code in capturegraph-lib/capturegraph/scheduling/distance/solar.py
def pairwise(self, features_a: np.ndarray, features_b: np.ndarray) -> np.ndarray:
    """The angular separations between two sets of solar positions."""
    arcs = haversine_radians(
        features_a[:, 0],
        features_a[:, 1],
        features_b[:, 0],
        features_b[:, 1],
    )
    return np.degrees(arcs) / self.sigma_deg

solar(sigma_deg=1.0) #

Create a distance function based on solar angular separation.

Parameters:

Name Type Description Default
sigma_deg float

Normalization factor in degrees. The returned distance is angle_deg / sigma_deg, so sessions within sigma_deg angular separation have distance < 1.0.

1.0

Returns:

Type Description
SolarDistanceFunction

A distance function (position_a, position_b) -> float.

Source code in capturegraph-lib/capturegraph/scheduling/distance/solar.py
def solar(sigma_deg: float = 1.0) -> SolarDistanceFunction:
    """Create a distance function based on solar angular separation.

    Args:
        sigma_deg: Normalization factor in degrees. The returned distance is
            `angle_deg / sigma_deg`, so sessions within sigma_deg angular
            separation have distance < 1.0.

    Returns:
        A distance function `(position_a, position_b) -> float`.
    """
    return SolarDistanceFunction(sigma_deg)