-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
41 lines (33 loc) · 1.14 KB
/
config.py
File metadata and controls
41 lines (33 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
Configuration, constants, and YAML config loader for STAMP.
"""
import os
import logging
import yaml
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
)
logger = logging.getLogger(__name__)
COLOR_SCALES = [
'Viridis', 'Plasma', 'Inferno', 'Magma', 'Cividis',
'Turbo', 'Hot', 'Spectral', 'RdYlBu', 'Picnic',
]
def load_config(config_file='config.yaml'):
"""Load settings from a YAML config file. Returns {} on failure."""
try:
cfg_path = (
config_file
if os.path.isabs(config_file)
else os.path.join(BASE_DIR, config_file)
)
with open(cfg_path, 'r') as f:
return yaml.safe_load(f) or {}
except Exception as e:
logger.warning(f"Error loading configuration: {str(e)}. Using default values.")
return {}
CONFIG = load_config()
DATA_DIR = CONFIG.get('data_dir', 'Data')
GRIDS_DIR = os.environ.get('GRIDS_DIR', os.path.join(BASE_DIR, 'model_grids'))
DEMO_DATA_DIR = os.environ.get('DEMO_DATA_DIR', os.path.join(BASE_DIR, 'static', 'demo_data'))