"""
Implementation of Science Operations data models.

* SchedulingBlock Model
* ...
"""

__all__ = [
    "ObservingMode",
    "SchedulingBlockType",
    "PointingMode",
    "TrackingMode",
    "SkyQuality",
    "SkyBrightness",
]

from enum import StrEnum, auto, nonmember

_NAMESPACE = "CTAO.SciOps"


class ObservingMode(StrEnum):
    """How pointing changes within a ScheduleingBlock."""

    _namespace = nonmember(_NAMESPACE)

    WOBBLE = auto()  #: regular offsets from central point
    ONOFF = auto()  #: On-source data taken pre- or proceeding Off-source
    GRID = auto()  #: regular pointings on a grid covering a region
    CUSTOM = auto()  #: Other


class SchedulingBlockType(StrEnum):
    """Purpose of this scheduling block."""

    _namespace = nonmember(_NAMESPACE)

    OBSERVATION = auto()  #: Scientific data acquisition
    CALIBRATION = auto()  #: Calibration activities
    ENGINEERING = auto()  #: Engineerng activities


class PointingMode(StrEnum):
    """How telecopes within the subarray are pointed relative to each other."""

    _namespace = nonmember(_NAMESPACE)

    PARALLEL = auto()  #: Telescopes aligned to same pointing
    VERGENT = auto()  #: Telescopes diverging or converging on a point


class TrackingMode(StrEnum):
    """Coordinate system tracked by the nominal pointing position."""

    _namespace = nonmember(_NAMESPACE)

    FIXED_ICRS = auto()  #: Follows a Right-ascension/Declination coordinate
    FIXED_HORIZONTAL = auto()  #: Follows an Azimuth/Elevation coordinate
    OTHER = auto()  #: Other


# from cite{ctao-sciops-concept}
class SkyBrightness(StrEnum):
    r"""
    Average level of night-sky-background light  during an observation.

    *Dark*: corresponding to moon below the horizon and
    sun elevation of less than −18 degrees for an ambient brightness of ≈ $0.24
    ph\,ns^{−1}\,cm^{−2}\,sr^{−1}$ away from the Galactic plane. *Grey*:
    corresponding to moon above the horizon for an increase in ambient NSB of up
    to 5x the dark sky case. *Bright*: corresponding to moon above the horizon
    for an increase in ambient NSB of up to 30x the dark sky case.
    """

    _namespace = nonmember(_NAMESPACE)
    DARK = auto()
    GRAY = auto()
    BRIGHT = auto()


# from cite{ctao-sciops-concept}
class SkyQuality(StrEnum):
    """
    Broad categorisation of sky quality.

    For the purposes of scheduling or rough observation selection. *A*: no
    clouds detectable within observable sky, very low aerosol optical depth
    (AOD<0.1). *B*: intermediate aerosol optical depth (0.1<AOD<0.2) and/or
    clouds visible in the sky but not within the target field of view (FoV).
    *C*: clouds detectable within the FoV or AOD>0.2.
    """

    _namespace = nonmember(_NAMESPACE)
    A = auto()
    B = auto()
    C = auto()
