-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalysis.py
More file actions
93 lines (82 loc) · 2.76 KB
/
analysis.py
File metadata and controls
93 lines (82 loc) · 2.76 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"""
Backward-compatible wrapper for analysis.py
This module provides backward compatibility for code using the old import pattern:
from analysis import extract_annual_means
DEPRECATED: This import path is deprecated as of v0.2.0.
Please update to:
from utils_cmip7 import extract_annual_means
This wrapper will be removed in v1.0.
"""
import warnings
import sys
import os
# Add src to path for local imports
_src_path = os.path.join(os.path.dirname(__file__), 'src')
if _src_path not in sys.path:
sys.path.insert(0, _src_path)
# Try importing from new package structure
try:
# Import all public functions from new package
from utils_cmip7.io import stash, stash_nc, decode_month, find_matching_files, try_extract
from utils_cmip7.processing import (
compute_terrestrial_area,
global_total_pgC,
global_mean_pgC,
merge_monthly_results,
compute_monthly_mean,
compute_annual_mean,
load_reccap_mask,
region_mask,
compute_regional_annual_mean,
)
from utils_cmip7.diagnostics import extract_annual_means, extract_annual_mean_raw
from utils_cmip7.config import VAR_CONVERSIONS
# Issue deprecation warning on first import
warnings.warn(
"Importing from 'analysis' is deprecated as of v0.2.0. "
"Please update your imports to:\n"
" from utils_cmip7 import extract_annual_means\n"
"This legacy import path will be removed in v1.0.",
DeprecationWarning,
stacklevel=2
)
# Import private helper functions for backward compatibility
from utils_cmip7.io.extract import (
_msi_from_stash_obj,
_msi_from_numeric_stash_code,
_msi_from_any_attr,
)
__all__ = [
'stash',
'stash_nc',
'decode_month',
'find_matching_files',
'try_extract',
'compute_terrestrial_area',
'global_total_pgC',
'global_mean_pgC',
'merge_monthly_results',
'compute_monthly_mean',
'compute_annual_mean',
'load_reccap_mask',
'region_mask',
'compute_regional_annual_mean',
'extract_annual_means',
'extract_annual_mean_raw',
'VAR_CONVERSIONS',
'_msi_from_stash_obj',
'_msi_from_numeric_stash_code',
'_msi_from_any_attr',
]
except ImportError as e:
# Fall back to legacy implementation if new package not available
warnings.warn(
f"Could not import from utils_cmip7 package ({e}). "
"Falling back to legacy analysis_legacy.py. "
"Install package with 'pip install -e .' to use new structure.",
ImportWarning,
stacklevel=2
)
# Import from legacy file
sys.path.insert(0, os.path.dirname(__file__))
from analysis_legacy import *