pyEDITH 1.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyEDITH/__init__.py +148 -0
- pyEDITH/astrophysical_scene.py +874 -0
- pyEDITH/cli.py +275 -0
- pyEDITH/components/coronagraphs.py +698 -0
- pyEDITH/components/detectors.py +444 -0
- pyEDITH/components/telescopes.py +280 -0
- pyEDITH/exposure_time_calculator.py +1418 -0
- pyEDITH/observation.py +175 -0
- pyEDITH/observatory.py +576 -0
- pyEDITH/parse_input.py +484 -0
- pyEDITH/units.py +257 -0
- pyEDITH/utils.py +943 -0
- pyedith-1.6.0.dist-info/METADATA +336 -0
- pyedith-1.6.0.dist-info/RECORD +18 -0
- pyedith-1.6.0.dist-info/WHEEL +5 -0
- pyedith-1.6.0.dist-info/entry_points.txt +2 -0
- pyedith-1.6.0.dist-info/licenses/LICENSE +21 -0
- pyedith-1.6.0.dist-info/top_level.txt +1 -0
pyEDITH/__init__.py
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# src/pyEDITH/__init__.py
|
|
2
|
+
import sys
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import logging
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# ANSI color codes for your palette
|
|
11
|
+
class ColorCodes:
|
|
12
|
+
WARNING = "\033[38;2;226;147;0m" # #E29300 - Orange for warnings
|
|
13
|
+
ERROR = "\033[38;2;156;29;16m" # #9C1D10 - Dark red for errors
|
|
14
|
+
RESET = "\033[0m"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# Custom formatter with colors for WARNING and ERROR only
|
|
18
|
+
class ColoredFormatter(logging.Formatter):
|
|
19
|
+
"""Custom formatter that colors entire log line except message for WARNING and ERROR levels."""
|
|
20
|
+
|
|
21
|
+
def format(self, record): # pragma: no cover
|
|
22
|
+
# Format the record first
|
|
23
|
+
formatted = super().format(record)
|
|
24
|
+
|
|
25
|
+
# Add color to the entire line for WARNING and ERROR
|
|
26
|
+
if record.levelno == logging.WARNING:
|
|
27
|
+
# Split at the message to only color the prefix
|
|
28
|
+
# Format is: [name] LEVEL [timestamp] message
|
|
29
|
+
# Color everything before the message
|
|
30
|
+
parts = formatted.split(
|
|
31
|
+
"] ", 2
|
|
32
|
+
) # Split into [name, LEVEL [timestamp, message]
|
|
33
|
+
if len(parts) == 3:
|
|
34
|
+
colored_prefix = (
|
|
35
|
+
f"{ColorCodes.WARNING}{parts[0]}] {parts[1]}]{ColorCodes.RESET}"
|
|
36
|
+
)
|
|
37
|
+
formatted = f"{colored_prefix} {parts[2]}"
|
|
38
|
+
else:
|
|
39
|
+
# Fallback: color entire line
|
|
40
|
+
formatted = f"{ColorCodes.WARNING}{formatted}{ColorCodes.RESET}"
|
|
41
|
+
|
|
42
|
+
elif record.levelno >= logging.ERROR: # ERROR and CRITICAL
|
|
43
|
+
parts = formatted.split("] ", 2)
|
|
44
|
+
if len(parts) == 3:
|
|
45
|
+
colored_prefix = (
|
|
46
|
+
f"{ColorCodes.ERROR}{parts[0]}] {parts[1]}]{ColorCodes.RESET}"
|
|
47
|
+
)
|
|
48
|
+
formatted = f"{colored_prefix} {parts[2]}"
|
|
49
|
+
else:
|
|
50
|
+
# Fallback: color entire line
|
|
51
|
+
formatted = f"{ColorCodes.ERROR}{formatted}{ColorCodes.RESET}"
|
|
52
|
+
|
|
53
|
+
return formatted
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# Create a handler ONLY for pyEDITH
|
|
57
|
+
handler = logging.StreamHandler()
|
|
58
|
+
formatter = ColoredFormatter(
|
|
59
|
+
"[%(name)s] %(levelname)s [%(asctime)s] %(message)s",
|
|
60
|
+
)
|
|
61
|
+
handler.setFormatter(formatter)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# Create pyEDITH logger
|
|
65
|
+
pyedith_logger = logging.getLogger("pyEDITH")
|
|
66
|
+
pyedith_logger.addHandler(handler)
|
|
67
|
+
pyedith_logger.propagate = True
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def set_verbosity(level="warning"):
|
|
71
|
+
"""
|
|
72
|
+
Set the verbosity level for pyEDITH+yippy logging.
|
|
73
|
+
|
|
74
|
+
Parameters
|
|
75
|
+
----------
|
|
76
|
+
level : str, optional
|
|
77
|
+
Verbosity level. Options are:
|
|
78
|
+
- 'error' or 'quiet': Only show errors
|
|
79
|
+
- 'warning' or 'default': Show warnings and errors (default)
|
|
80
|
+
- 'info' or 'verbose': Show info, warnings, and errors
|
|
81
|
+
- 'debug': Show all messages including debug
|
|
82
|
+
"""
|
|
83
|
+
level_map = {
|
|
84
|
+
"error": logging.ERROR,
|
|
85
|
+
"quiet": logging.ERROR,
|
|
86
|
+
"warning": logging.WARNING,
|
|
87
|
+
"default": logging.WARNING,
|
|
88
|
+
"info": logging.INFO,
|
|
89
|
+
"verbose": logging.INFO,
|
|
90
|
+
"debug": logging.DEBUG,
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
log_level = level_map.get(level.lower(), logging.WARNING)
|
|
94
|
+
|
|
95
|
+
# Set pyEDITH logger level
|
|
96
|
+
pyedith_logger.setLevel(log_level)
|
|
97
|
+
pyedith_logger.info(f"Logging level set to: {logging.getLevelName(log_level)}")
|
|
98
|
+
|
|
99
|
+
# Set yippy logger level AND its handlers
|
|
100
|
+
yippy_logger = logging.getLogger("yippy")
|
|
101
|
+
|
|
102
|
+
yippy_logger.setLevel(log_level)
|
|
103
|
+
yippy_logger.info(f"Logging level set to: {logging.getLevelName(log_level)}")
|
|
104
|
+
|
|
105
|
+
yippy_logger.propagate = False # Don't send to root logger
|
|
106
|
+
for h in yippy_logger.handlers:
|
|
107
|
+
h.setLevel(log_level)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
from .astrophysical_scene import AstrophysicalScene
|
|
111
|
+
from .observation import Observation
|
|
112
|
+
from .observatory import Observatory
|
|
113
|
+
from .components.coronagraphs import Coronagraph
|
|
114
|
+
from .components.telescopes import Telescope
|
|
115
|
+
from .components.detectors import Detector
|
|
116
|
+
|
|
117
|
+
# Import main functions
|
|
118
|
+
from .exposure_time_calculator import calculate_exposure_time_or_snr
|
|
119
|
+
from .components.coronagraphs import generate_radii
|
|
120
|
+
from . import parse_input
|
|
121
|
+
from .utils import *
|
|
122
|
+
from .units import *
|
|
123
|
+
|
|
124
|
+
# Import CLI functions
|
|
125
|
+
from .cli import main, calculate_texp, calculate_snr
|
|
126
|
+
|
|
127
|
+
# Set a __all__ variable to control what gets imported with "from pyEDITH import *"
|
|
128
|
+
__all__ = [
|
|
129
|
+
"AstrophysicalScene",
|
|
130
|
+
"Observation",
|
|
131
|
+
"Observatory",
|
|
132
|
+
"Telescope",
|
|
133
|
+
"Coronagraph",
|
|
134
|
+
"Detector",
|
|
135
|
+
"calculate_exposure_time_or_snr",
|
|
136
|
+
"main",
|
|
137
|
+
"calculate_texp",
|
|
138
|
+
"calculate_snr",
|
|
139
|
+
"parse_input",
|
|
140
|
+
"generate_radii",
|
|
141
|
+
"average_over_bandpass",
|
|
142
|
+
"interpolate_over_bandpass",
|
|
143
|
+
"validate_attributes",
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
__version__ = "1.5.1"
|
|
147
|
+
|
|
148
|
+
set_verbosity(level="warning")
|