Module csw.TYPLevel

Classes

class CalibrationLevel (*args, **kwds)
Expand source code
class CalibrationLevel(Enum):
    Raw = 0
    Uncalibrated = 1
    Calibrated = 2
    ScienceProduct = 3
    AfterAnalysisScienceProduct = 4

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

Color.RED

  • value lookup:

Color(1)

  • name lookup:

Color['RED']

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

Ancestors

  • enum.Enum

Class variables

var AfterAnalysisScienceProduct

The type of the None singleton.

var Calibrated

The type of the None singleton.

var Raw

The type of the None singleton.

var ScienceProduct

The type of the None singleton.

var Uncalibrated

The type of the None singleton.

class TYP (entryName: str, description: str)
Expand source code
@dataclass
class TYP:
    """
    Defines constants for the available subsystems
    """
    entryName: str
    description: str

    def longName(self) -> str:
        """
        Represents a string with entryName and description of a TYP
        """
        return f"{self.entryName} - {self.description}"

    def name(self) -> str:
        """
        Represents the name of the TYP e.g SCI
        """
        return self.entryName

Defines constants for the available subsystems

Instance variables

var description : str

The type of the None singleton.

var entryName : str

The type of the None singleton.

Methods

def longName(self) ‑> str
Expand source code
def longName(self) -> str:
    """
    Represents a string with entryName and description of a TYP
    """
    return f"{self.entryName} - {self.description}"

Represents a string with entryName and description of a TYP

def name(self) ‑> str
Expand source code
def name(self) -> str:
    """
    Represents the name of the TYP e.g SCI
    """
    return self.entryName

Represents the name of the TYP e.g SCI

class TYPLevel (typ: TYPs,
calibrationLevel: CalibrationLevel)
Expand source code
@dataclass
class TYPLevel:
    typ: TYPs
    calibrationLevel: CalibrationLevel

    def __str__(self):
        return f"{self.typ.name}{self.calibrationLevel.value}"

    def calibrationLevelNumber(self) -> int:
        return self.calibrationLevel.value

    @classmethod
    def parseCalibrationLevel(cls, calibrationLevel: str) -> CalibrationLevel:
        try:
            return CalibrationLevel(int(calibrationLevel))
        except Exception as ex:
            raise ValueError(
                f"Failed to parse calibration level {calibrationLevel}: {repr(ex)}. Calibration level should be a digit.")

    @classmethod
    def make(cls, typLevel: str) -> Self:
        if not (len(typLevel) == 4):
            raise ValueError("requirement failed: TYPLevel must be a 3 character TYP followed by a calibration level")
        typ = typLevel[:3]
        calibrationLevel = typLevel[3:]
        level = cls.parseCalibrationLevel(calibrationLevel)
        return TYPLevel(TYPs.fromString(typ), level)

TYPLevel(typ: csw.TYPLevel.TYPs, calibrationLevel: csw.TYPLevel.CalibrationLevel)

Static methods

def make(typLevel: str) ‑> Self
def parseCalibrationLevel(calibrationLevel: str) ‑> CalibrationLevel

Instance variables

var calibrationLevelCalibrationLevel

The type of the None singleton.

var typTYPs

The type of the None singleton.

Methods

def calibrationLevelNumber(self) ‑> int
Expand source code
def calibrationLevelNumber(self) -> int:
    return self.calibrationLevel.value
class TYPs (*args, **kwds)
Expand source code
class TYPs(UpperCaseEnum):
    SCI = TYP("SCI", "Science exposure")
    CAL = TYP("CAL", "Calibration exposure")
    ARC = TYP("ARC", "Wavelength calibration")
    IDP = TYP("IDP", "Instrumental dispersion")
    DRK = TYP("DRK", "Dark")
    MDK = TYP("MDK", "Master dark")
    FFD = TYP("FFD", "Flat field")
    NFF = TYP("NFF", "Normalized flat field")
    BIA = TYP("BIA", "Bias exposure")
    TEL = TYP("TEL", "Telluric standard")
    FLX = TYP("FLX", "Flux standard")
    SKY = TYP("SKY", "Sky background exposure")

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

Color.RED

  • value lookup:

Color(1)

  • name lookup:

Color['RED']

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

Ancestors

Class variables

var ARC

The type of the None singleton.

var BIA

The type of the None singleton.

var CAL

The type of the None singleton.

var DRK

The type of the None singleton.

var FFD

The type of the None singleton.

var FLX

The type of the None singleton.

var IDP

The type of the None singleton.

var MDK

The type of the None singleton.

var NFF

The type of the None singleton.

var SCI

The type of the None singleton.

var SKY

The type of the None singleton.

var TEL

The type of the None singleton.