Skip to content

Index

Bbox

Bases: NamedTuple

Bounding box named tuple, defining extent in cartesian coordinates.

Usage:

Bbox(left, bottom, right, top)

Attributes:

Name Type Description
left float

Left coordinate (xmin)

bottom float

Bottom coordinate (ymin)

right float

Right coordinate (xmax)

top float

Top coordinate (ymax)

Source code in src/dolphin/_types.py
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class Bbox(NamedTuple):
    """Bounding box named tuple, defining extent in cartesian coordinates.

    Usage:

        Bbox(left, bottom, right, top)

    Attributes
    ----------
    left : float
        Left coordinate (xmin)
    bottom : float
        Bottom coordinate (ymin)
    right : float
        Right coordinate (xmax)
    top : float
        Top coordinate (ymax)

    """

    left: float
    bottom: float
    right: float
    top: float

GeneralPath

Bases: Protocol

A protocol to handle paths that can be either local or S3 paths.

Source code in src/dolphin/_types.py
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
@runtime_checkable
class GeneralPath(Protocol):
    """A protocol to handle paths that can be either local or S3 paths."""

    def parent(self): ...

    def suffix(self): ...

    def resolve(self): ...

    def exists(self): ...

    def read_text(self): ...

    def __truediv__(self, other): ...

    def __str__(self) -> str: ...

    def __fspath__(self) -> str:
        return str(self)

HalfWindow

Bases: NamedTuple

Half-window size in the y (row) and x (column) directions.

Source code in src/dolphin/_types.py
64
65
66
67
68
class HalfWindow(NamedTuple):
    """Half-window size in the y (row) and x (column) directions."""

    y: int
    x: int

Strides

Bases: NamedTuple

Decimation/striding factor in the y (row) and x (column) directions.

Source code in src/dolphin/_types.py
57
58
59
60
61
class Strides(NamedTuple):
    """Decimation/striding factor in the y (row) and x (column) directions."""

    y: int
    x: int

TropoModel

Bases: str, Enum

Enumeration representing different tropospheric models.

Source code in src/dolphin/_types.py
81
82
83
84
85
86
87
88
89
90
91
92
class TropoModel(str, Enum):
    """Enumeration representing different tropospheric models."""

    ECMWF = "ECMWF"
    ERA5 = "ERA5"
    HRES = "HRES"
    ERAINT = "ERAINT"
    ERAI = "ERAI"
    MERRA = "MERRA"
    NARR = "NARR"
    HRRR = "HRRR"
    GMAO = "GMAO"

TropoType

Bases: str, Enum

Type of tropospheric delay.

Source code in src/dolphin/_types.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
class TropoType(str, Enum):
    """Type of tropospheric delay."""

    WET = "wet"
    """Wet tropospheric delay."""
    DRY = "dry"
    """Dry delay (same as hydrostatic, named "dry" in PyAPS)"""
    HYDROSTATIC = "hydrostatic"
    """Hydrostatic (same as dry, named differently in raider)"""
    COMB = "comb"
    """Combined wet + dry delay."""

COMB = 'comb' class-attribute instance-attribute

Combined wet + dry delay.

DRY = 'dry' class-attribute instance-attribute

Dry delay (same as hydrostatic, named "dry" in PyAPS)

HYDROSTATIC = 'hydrostatic' class-attribute instance-attribute

Hydrostatic (same as dry, named differently in raider)

WET = 'wet' class-attribute instance-attribute

Wet tropospheric delay.

log_runtime(f)

Decorate a function to time how long it takes to run.

Usage

@log_runtime def test_func(): return 2 + 4

Source code in src/dolphin/_log.py
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
def log_runtime(f: Callable[P, T]) -> Callable[P, T]:
    """Decorate a function to time how long it takes to run.

    Usage
    -----
    @log_runtime
    def test_func():
        return 2 + 4
    """
    logger = logging.getLogger("dolphin")

    @wraps(f)
    def wrapper(*args: P.args, **kwargs: P.kwargs):
        t1 = time.time()

        result = f(*args, **kwargs)

        t2 = time.time()
        elapsed_seconds = t2 - t1
        elapsed_minutes = elapsed_seconds / 60.0
        time_string = (
            f"Total elapsed time for {f.__module__}.{f.__name__} : "
            f"{elapsed_minutes:.2f} minutes ({elapsed_seconds:.2f} seconds)"
        )

        logger.info(time_string)

        return result

    return wrapper

show_versions()

Print useful debugging information.

Examples:

python -c "import dolphin; dolphin.show_versions()"

Source code in src/dolphin/_show_versions.py
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
def show_versions() -> None:
    """Print useful debugging information.

    Examples
    --------
    > python -c "import dolphin; dolphin.show_versions()"

    """
    print(f"dolphin version: {dolphin.__version__}")
    print("\nPython deps:")
    _print_info_dict(_get_deps_info())
    print("\nSystem:")
    _print_info_dict(_get_sys_info())
    print("Unwrapping packages:")
    _print_info_dict(_get_unwrapping_options())
    print("optional GPU info:")
    _print_info_dict(_get_gpu_info())