storypy 0.1.7__tar.gz
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.
- storypy-0.1.7/LICENSE +21 -0
- storypy-0.1.7/PKG-INFO +170 -0
- storypy-0.1.7/README.md +128 -0
- storypy-0.1.7/pyproject.toml +72 -0
- storypy-0.1.7/setup.cfg +4 -0
- storypy-0.1.7/storypy/__init__.py +62 -0
- storypy-0.1.7/storypy/compute/__init__.py +29 -0
- storypy-0.1.7/storypy/compute/_compute_driver.py +692 -0
- storypy-0.1.7/storypy/compute/_mlr.py +162 -0
- storypy-0.1.7/storypy/compute/_regres.py +604 -0
- storypy-0.1.7/storypy/compute/_stippling.py +455 -0
- storypy-0.1.7/storypy/confi.py +7 -0
- storypy-0.1.7/storypy/data/__init__.py +51 -0
- storypy-0.1.7/storypy/data/_read_data.py +304 -0
- storypy-0.1.7/storypy/data/drivers/monerie23_drivers.nc +0 -0
- storypy-0.1.7/storypy/data/drivers/zs17_drivers.nc +0 -0
- storypy-0.1.7/storypy/data/regression_output/pr/R2.nc +0 -0
- storypy-0.1.7/storypy/data/regression_output/pr/regression_coefficients.nc +0 -0
- storypy-0.1.7/storypy/data/regression_output/pr/regression_coefficients_pvalues.nc +0 -0
- storypy-0.1.7/storypy/data/regression_output/pr/regression_coefficients_relative_importance.nc +0 -0
- storypy-0.1.7/storypy/data/regression_output/ua/R2.nc +0 -0
- storypy-0.1.7/storypy/data/regression_output/ua/regression_coefficients.nc +0 -0
- storypy-0.1.7/storypy/data/regression_output/ua/regression_coefficients_pvalues.nc +0 -0
- storypy-0.1.7/storypy/data/regression_output/ua/regression_coefficients_relative_importance.nc +0 -0
- storypy-0.1.7/storypy/data/remote_drivers/drivers.csv +37 -0
- storypy-0.1.7/storypy/data/remote_drivers/scaled_drivers.csv +37 -0
- storypy-0.1.7/storypy/data/remote_drivers/scaled_standardized_drivers.csv +37 -0
- storypy-0.1.7/storypy/data/targets/mindlin20_target_pr_DJF.nc +0 -0
- storypy-0.1.7/storypy/data/targets/mindlin20_target_pr_JJA.nc +0 -0
- storypy-0.1.7/storypy/data/targets/monerie23_target_pr_JAS.nc +0 -0
- storypy-0.1.7/storypy/data/targets/zs17_target_pr_NDJFM.nc +0 -0
- storypy-0.1.7/storypy/data/targets/zs17_target_u850_NDJFM.nc +0 -0
- storypy-0.1.7/storypy/evaluate/__init__.py +0 -0
- storypy-0.1.7/storypy/evaluate/plot/__init__.py +42 -0
- storypy-0.1.7/storypy/evaluate/plot/_plotting.py +608 -0
- storypy-0.1.7/storypy/evaluate/plot/_storylines.py +722 -0
- storypy-0.1.7/storypy/preprocess/__init__.py +24 -0
- storypy-0.1.7/storypy/preprocess/_diagnostics.py +204 -0
- storypy-0.1.7/storypy/preprocess/_esmval_processor.py +511 -0
- storypy-0.1.7/storypy/preprocess/_netcdf_processor.py +675 -0
- storypy-0.1.7/storypy/utils.py +65 -0
- storypy-0.1.7/storypy.egg-info/PKG-INFO +170 -0
- storypy-0.1.7/storypy.egg-info/SOURCES.txt +45 -0
- storypy-0.1.7/storypy.egg-info/dependency_links.txt +1 -0
- storypy-0.1.7/storypy.egg-info/requires.txt +22 -0
- storypy-0.1.7/storypy.egg-info/top_level.txt +1 -0
- storypy-0.1.7/tests/test_data.py +188 -0
storypy-0.1.7/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 LIM Climate Causality
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
storypy-0.1.7/PKG-INFO
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: storypy
|
|
3
|
+
Version: 0.1.7
|
|
4
|
+
Summary: A Python package to compute climate storylines
|
|
5
|
+
Author-email: Richard Alawode <richard.alawode@uni-leipzig.de>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://storypy.readthedocs.io/en/latest/
|
|
8
|
+
Project-URL: Documentation, https://storypy.readthedocs.io/en/latest/
|
|
9
|
+
Project-URL: Source, https://github.com/LIM-Climate-Causality/storypy
|
|
10
|
+
Project-URL: Issues, https://github.com/LIM-Climate-Causality/storypy/issues
|
|
11
|
+
Keywords: climate,storylines,CMIP6,regional climate,uncertainty
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Intended Audience :: Science/Research
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: numpy
|
|
23
|
+
Requires-Dist: pandas
|
|
24
|
+
Requires-Dist: xarray
|
|
25
|
+
Requires-Dist: netcdf4
|
|
26
|
+
Requires-Dist: regionmask
|
|
27
|
+
Requires-Dist: scipy
|
|
28
|
+
Requires-Dist: statsmodels
|
|
29
|
+
Requires-Dist: scikit-learn
|
|
30
|
+
Requires-Dist: matplotlib
|
|
31
|
+
Requires-Dist: cartopy
|
|
32
|
+
Requires-Dist: shapely
|
|
33
|
+
Requires-Dist: tqdm
|
|
34
|
+
Provides-Extra: performance
|
|
35
|
+
Requires-Dist: dask; extra == "performance"
|
|
36
|
+
Provides-Extra: paper
|
|
37
|
+
Requires-Dist: adjustText; extra == "paper"
|
|
38
|
+
Provides-Extra: dev
|
|
39
|
+
Requires-Dist: pytest; extra == "dev"
|
|
40
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
41
|
+
Dynamic: license-file
|
|
42
|
+
|
|
43
|
+
# StoryPy
|
|
44
|
+
**StoryPy is an advanced toolkit that facilitates analyzing dynamical storylines by providing efficient and user-friendly tools that is flexible and adaptable for various storyline research and policy applications.**
|
|
45
|
+
|
|
46
|
+
StoryPy implements the dynamical storyline framework, presented in [Zappa&Shepherd, 2017](https://journals.ametsoc.org/doi/10.1175/JCLI-D-16-0807.1), using CMIP model output. It provides
|
|
47
|
+
|
|
48
|
+
- a set of functions to analyze multi-model ensembles by focusing on the identification of dynamical storylines.
|
|
49
|
+
|
|
50
|
+
- customizable options for selecting remote drivers ($X$), target seasons, and climate variables or climatic-impact drivers ($C_x$).
|
|
51
|
+
|
|
52
|
+
We designed two options for processing CMIP data:
|
|
53
|
+
|
|
54
|
+
1. Option A: Using ESMValTool (via ESMValTool recipes) to download and preprocess the CMIP datasets, including regridding.
|
|
55
|
+
|
|
56
|
+
Requirements:
|
|
57
|
+
- ESMValTool installation and a working ESMValTool environment.
|
|
58
|
+
- ESMValTool recipes/configuration compatible with target variables and drivers.
|
|
59
|
+
- ESMValTool preprocessing can generate large intermediate files. Ensure sufficient disk space in the working directory.
|
|
60
|
+
|
|
61
|
+
2. Option B: Using a local CMIP database where StoryPy reads CMIP-style NetCDF files directly from a local directory. Provided that:
|
|
62
|
+
- CMIP datasets already available locally (or accessible via a mounted filesystem).
|
|
63
|
+
- It follows the naming and grid conventions as described below.
|
|
64
|
+
|
|
65
|
+
``` <data_dir>/
|
|
66
|
+
├── <var_name>/
|
|
67
|
+
│ ├── <mon>/
|
|
68
|
+
│ │ ├── <g025>/
|
|
69
|
+
│ │ │ ├── <var_name>_<period>_<model>_<experiment>_<member>_<grid>.nc
|
|
70
|
+
│ │ │ └── ...
|
|
71
|
+
│ │ └── ...
|
|
72
|
+
│ └── ...
|
|
73
|
+
└── ...```
|
|
74
|
+
|
|
75
|
+
## Methodology
|
|
76
|
+
Following the pattern scaling assumption described in Tebaldi & Arblaster (2014), the end-of-century climate change response $\Delta C_{xm}$ in a field $C$ at location $x$ and for model $m$ is expressed as a linear function of global warming $\Delta T_m$ and the climate response pattern $P_{xm}$:
|
|
77
|
+
|
|
78
|
+
$$
|
|
79
|
+
\Delta C_{xm} = \Delta T_m \, P_{xm}
|
|
80
|
+
$$
|
|
81
|
+
|
|
82
|
+
The pattern response formulation ($P_{xm}$ at location $x$ and model $m$), proposed in Zappa & Shepherd (2017) and adopted in several storyline studies (e.g., Mindlin et al., 2020; Ghosh et al., 2023; Monerie et al., 2023), is used to quantify the influence of multiple sources of uncertainty. This is represented as a linear combination of remote-driver responses scaled by global warming $\Delta T$:
|
|
83
|
+
|
|
84
|
+
$$
|
|
85
|
+
P_{xm} = a_x
|
|
86
|
+
+ b_x \left(\frac{\Delta T_{\text{driver1}}}{\Delta T}\right)'_m
|
|
87
|
+
+ c_x \left(\frac{\Delta T_{\text{driver2}}}{\Delta T}\right)'_m
|
|
88
|
+
+ d_x \left(\frac{\Delta T_{\text{driver3}}}{\Delta T}\right)'_m
|
|
89
|
+
+ e_{xm}
|
|
90
|
+
$$
|
|
91
|
+
|
|
92
|
+
## Installing
|
|
93
|
+
Storypy can be installed via PyPi. Simply run the following commands:
|
|
94
|
+
|
|
95
|
+
```pip install storypy``` or ```pip3 install storypy```
|
|
96
|
+
|
|
97
|
+
It can also be installed directly from source using pip
|
|
98
|
+
|
|
99
|
+
```git clone git@github.com:LIM-Climate-Causality/storypy.git```
|
|
100
|
+
|
|
101
|
+
```cd storypy```
|
|
102
|
+
|
|
103
|
+
```pip install .```
|
|
104
|
+
|
|
105
|
+
### If installing to be used with Esmvaltool recipe
|
|
106
|
+
Before installing the storypy package, users need to setup Esmvaltool on their machine. After the setup of Esmvaltool, activate the esmvaltool environment. Then, pip install the storypy package. This is because Esmvaltool uses some dependencies which are only available in conda.
|
|
107
|
+
|
|
108
|
+
### Configuration and input parameter
|
|
109
|
+
Preprocessing CMIP data is a crucial step in the analysis of dynamical storylines, as it ensures that the data is in a consistent format and resolution for analysis. StoryPy provides two options for preprocessing CMIP data (as already described), either using ESMValTool or by reading from a local CMIP database. The choice between these options depends on the user's preferences and the availability of data. Given CMIP data, user can preprocess the data by calling the methods and using the following steps for example:
|
|
110
|
+
|
|
111
|
+
Main user configuration
|
|
112
|
+
|
|
113
|
+
user_config = dict(
|
|
114
|
+
work_dir='/climca/people/ralawode/esmvaltool_output/zappa_shepherd_CMIP6_20260304_135924/work',
|
|
115
|
+
plot_dir='/climca/people/ralawode/esmvaltool_output/zappa_shepherd_CMIP6_20260304_135924/plots',
|
|
116
|
+
var_name=['pr'],
|
|
117
|
+
exp_name='ssp585',
|
|
118
|
+
freq='mon',
|
|
119
|
+
grid='g025',
|
|
120
|
+
region_method='box',
|
|
121
|
+
period1 = ['1960', '1990'],
|
|
122
|
+
period2 = ['2070', '2099'],
|
|
123
|
+
region_id=18,
|
|
124
|
+
season=(12, 1, 2),
|
|
125
|
+
region_extents=[(30, 45, -10, 40), (45, 55, 5, 20)],
|
|
126
|
+
# region_extents=[(25, 90, -180, 180)],
|
|
127
|
+
box=([-25, 45, 30, 65]),
|
|
128
|
+
titles=["Region A", "Region B"]
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
driver configuration
|
|
132
|
+
|
|
133
|
+
driver_config = dict(
|
|
134
|
+
var_name=['psl'], # <- actual variable names in NetCDF
|
|
135
|
+
short_name=['test_ubi'], # <- names for regression/CSV outputs
|
|
136
|
+
period1=['1960', '1979'],
|
|
137
|
+
period2=['2070', '2099'],
|
|
138
|
+
season=[12,1,2],
|
|
139
|
+
box={'lat_min': 50, 'lat_max': 70, 'lon_min': 40, 'lon_max': 70},
|
|
140
|
+
work_dir='/climca/people/ralawode/esmvaltool_output/zappa_shepherd_CMIP6_20260304_135924/work'
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
Parsing the ESMValTool configuration/metadata
|
|
144
|
+
|
|
145
|
+
>>>from storypy.preprocess import parse_config
|
|
146
|
+
>>>esmval_config= parse_config(path/settings.yml)
|
|
147
|
+
|
|
148
|
+
Running the analysis to generate climate variables $C_{xm}$ and remote drivers $X$
|
|
149
|
+
|
|
150
|
+
>>> from storypy.preprocess import ESMValProcessor, ModelDataPreprocessor
|
|
151
|
+
>>> processor_target = ESMValProcessor(esmval_config, user_config, driver_config)
|
|
152
|
+
OR
|
|
153
|
+
>>> processor_target = ModelDataPreprocessor(user_config, driver_config)
|
|
154
|
+
>>> processor_target.process_var()
|
|
155
|
+
>>> processor_target.process_driver()
|
|
156
|
+
|
|
157
|
+
Users can compute the driver indices and regression coefficients for a desired study region, for example:
|
|
158
|
+
|
|
159
|
+
For the driver indices
|
|
160
|
+
|
|
161
|
+
>>> from storypy.compute import compute_drivers
|
|
162
|
+
>>> df_raw, df_scaled, df_standardized = compute_drivers(driver_config)
|
|
163
|
+
|
|
164
|
+
For the regression coefficients
|
|
165
|
+
|
|
166
|
+
>>> from storypy.compute import run_regression
|
|
167
|
+
>>> outputs = run_regression(user_config)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
storypy-0.1.7/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# StoryPy
|
|
2
|
+
**StoryPy is an advanced toolkit that facilitates analyzing dynamical storylines by providing efficient and user-friendly tools that is flexible and adaptable for various storyline research and policy applications.**
|
|
3
|
+
|
|
4
|
+
StoryPy implements the dynamical storyline framework, presented in [Zappa&Shepherd, 2017](https://journals.ametsoc.org/doi/10.1175/JCLI-D-16-0807.1), using CMIP model output. It provides
|
|
5
|
+
|
|
6
|
+
- a set of functions to analyze multi-model ensembles by focusing on the identification of dynamical storylines.
|
|
7
|
+
|
|
8
|
+
- customizable options for selecting remote drivers ($X$), target seasons, and climate variables or climatic-impact drivers ($C_x$).
|
|
9
|
+
|
|
10
|
+
We designed two options for processing CMIP data:
|
|
11
|
+
|
|
12
|
+
1. Option A: Using ESMValTool (via ESMValTool recipes) to download and preprocess the CMIP datasets, including regridding.
|
|
13
|
+
|
|
14
|
+
Requirements:
|
|
15
|
+
- ESMValTool installation and a working ESMValTool environment.
|
|
16
|
+
- ESMValTool recipes/configuration compatible with target variables and drivers.
|
|
17
|
+
- ESMValTool preprocessing can generate large intermediate files. Ensure sufficient disk space in the working directory.
|
|
18
|
+
|
|
19
|
+
2. Option B: Using a local CMIP database where StoryPy reads CMIP-style NetCDF files directly from a local directory. Provided that:
|
|
20
|
+
- CMIP datasets already available locally (or accessible via a mounted filesystem).
|
|
21
|
+
- It follows the naming and grid conventions as described below.
|
|
22
|
+
|
|
23
|
+
``` <data_dir>/
|
|
24
|
+
├── <var_name>/
|
|
25
|
+
│ ├── <mon>/
|
|
26
|
+
│ │ ├── <g025>/
|
|
27
|
+
│ │ │ ├── <var_name>_<period>_<model>_<experiment>_<member>_<grid>.nc
|
|
28
|
+
│ │ │ └── ...
|
|
29
|
+
│ │ └── ...
|
|
30
|
+
│ └── ...
|
|
31
|
+
└── ...```
|
|
32
|
+
|
|
33
|
+
## Methodology
|
|
34
|
+
Following the pattern scaling assumption described in Tebaldi & Arblaster (2014), the end-of-century climate change response $\Delta C_{xm}$ in a field $C$ at location $x$ and for model $m$ is expressed as a linear function of global warming $\Delta T_m$ and the climate response pattern $P_{xm}$:
|
|
35
|
+
|
|
36
|
+
$$
|
|
37
|
+
\Delta C_{xm} = \Delta T_m \, P_{xm}
|
|
38
|
+
$$
|
|
39
|
+
|
|
40
|
+
The pattern response formulation ($P_{xm}$ at location $x$ and model $m$), proposed in Zappa & Shepherd (2017) and adopted in several storyline studies (e.g., Mindlin et al., 2020; Ghosh et al., 2023; Monerie et al., 2023), is used to quantify the influence of multiple sources of uncertainty. This is represented as a linear combination of remote-driver responses scaled by global warming $\Delta T$:
|
|
41
|
+
|
|
42
|
+
$$
|
|
43
|
+
P_{xm} = a_x
|
|
44
|
+
+ b_x \left(\frac{\Delta T_{\text{driver1}}}{\Delta T}\right)'_m
|
|
45
|
+
+ c_x \left(\frac{\Delta T_{\text{driver2}}}{\Delta T}\right)'_m
|
|
46
|
+
+ d_x \left(\frac{\Delta T_{\text{driver3}}}{\Delta T}\right)'_m
|
|
47
|
+
+ e_{xm}
|
|
48
|
+
$$
|
|
49
|
+
|
|
50
|
+
## Installing
|
|
51
|
+
Storypy can be installed via PyPi. Simply run the following commands:
|
|
52
|
+
|
|
53
|
+
```pip install storypy``` or ```pip3 install storypy```
|
|
54
|
+
|
|
55
|
+
It can also be installed directly from source using pip
|
|
56
|
+
|
|
57
|
+
```git clone git@github.com:LIM-Climate-Causality/storypy.git```
|
|
58
|
+
|
|
59
|
+
```cd storypy```
|
|
60
|
+
|
|
61
|
+
```pip install .```
|
|
62
|
+
|
|
63
|
+
### If installing to be used with Esmvaltool recipe
|
|
64
|
+
Before installing the storypy package, users need to setup Esmvaltool on their machine. After the setup of Esmvaltool, activate the esmvaltool environment. Then, pip install the storypy package. This is because Esmvaltool uses some dependencies which are only available in conda.
|
|
65
|
+
|
|
66
|
+
### Configuration and input parameter
|
|
67
|
+
Preprocessing CMIP data is a crucial step in the analysis of dynamical storylines, as it ensures that the data is in a consistent format and resolution for analysis. StoryPy provides two options for preprocessing CMIP data (as already described), either using ESMValTool or by reading from a local CMIP database. The choice between these options depends on the user's preferences and the availability of data. Given CMIP data, user can preprocess the data by calling the methods and using the following steps for example:
|
|
68
|
+
|
|
69
|
+
Main user configuration
|
|
70
|
+
|
|
71
|
+
user_config = dict(
|
|
72
|
+
work_dir='/climca/people/ralawode/esmvaltool_output/zappa_shepherd_CMIP6_20260304_135924/work',
|
|
73
|
+
plot_dir='/climca/people/ralawode/esmvaltool_output/zappa_shepherd_CMIP6_20260304_135924/plots',
|
|
74
|
+
var_name=['pr'],
|
|
75
|
+
exp_name='ssp585',
|
|
76
|
+
freq='mon',
|
|
77
|
+
grid='g025',
|
|
78
|
+
region_method='box',
|
|
79
|
+
period1 = ['1960', '1990'],
|
|
80
|
+
period2 = ['2070', '2099'],
|
|
81
|
+
region_id=18,
|
|
82
|
+
season=(12, 1, 2),
|
|
83
|
+
region_extents=[(30, 45, -10, 40), (45, 55, 5, 20)],
|
|
84
|
+
# region_extents=[(25, 90, -180, 180)],
|
|
85
|
+
box=([-25, 45, 30, 65]),
|
|
86
|
+
titles=["Region A", "Region B"]
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
driver configuration
|
|
90
|
+
|
|
91
|
+
driver_config = dict(
|
|
92
|
+
var_name=['psl'], # <- actual variable names in NetCDF
|
|
93
|
+
short_name=['test_ubi'], # <- names for regression/CSV outputs
|
|
94
|
+
period1=['1960', '1979'],
|
|
95
|
+
period2=['2070', '2099'],
|
|
96
|
+
season=[12,1,2],
|
|
97
|
+
box={'lat_min': 50, 'lat_max': 70, 'lon_min': 40, 'lon_max': 70},
|
|
98
|
+
work_dir='/climca/people/ralawode/esmvaltool_output/zappa_shepherd_CMIP6_20260304_135924/work'
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
Parsing the ESMValTool configuration/metadata
|
|
102
|
+
|
|
103
|
+
>>>from storypy.preprocess import parse_config
|
|
104
|
+
>>>esmval_config= parse_config(path/settings.yml)
|
|
105
|
+
|
|
106
|
+
Running the analysis to generate climate variables $C_{xm}$ and remote drivers $X$
|
|
107
|
+
|
|
108
|
+
>>> from storypy.preprocess import ESMValProcessor, ModelDataPreprocessor
|
|
109
|
+
>>> processor_target = ESMValProcessor(esmval_config, user_config, driver_config)
|
|
110
|
+
OR
|
|
111
|
+
>>> processor_target = ModelDataPreprocessor(user_config, driver_config)
|
|
112
|
+
>>> processor_target.process_var()
|
|
113
|
+
>>> processor_target.process_driver()
|
|
114
|
+
|
|
115
|
+
Users can compute the driver indices and regression coefficients for a desired study region, for example:
|
|
116
|
+
|
|
117
|
+
For the driver indices
|
|
118
|
+
|
|
119
|
+
>>> from storypy.compute import compute_drivers
|
|
120
|
+
>>> df_raw, df_scaled, df_standardized = compute_drivers(driver_config)
|
|
121
|
+
|
|
122
|
+
For the regression coefficients
|
|
123
|
+
|
|
124
|
+
>>> from storypy.compute import run_regression
|
|
125
|
+
>>> outputs = run_regression(user_config)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
# All bare keys of [project] must stay above the [project.*] sub-tables.
|
|
6
|
+
[project]
|
|
7
|
+
name = "storypy"
|
|
8
|
+
version = "0.1.7"
|
|
9
|
+
description = "A Python package to compute climate storylines"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
license = "MIT"
|
|
13
|
+
license-files = ["LICENSE"]
|
|
14
|
+
authors = [
|
|
15
|
+
{ name = "Richard Alawode", email = "richard.alawode@uni-leipzig.de" }
|
|
16
|
+
]
|
|
17
|
+
keywords = ["climate", "storylines", "CMIP6", "regional climate", "uncertainty"]
|
|
18
|
+
dependencies = [
|
|
19
|
+
# core data model + I/O
|
|
20
|
+
"numpy",
|
|
21
|
+
"pandas",
|
|
22
|
+
"xarray",
|
|
23
|
+
"netcdf4",
|
|
24
|
+
"regionmask",
|
|
25
|
+
# statistics
|
|
26
|
+
"scipy",
|
|
27
|
+
"statsmodels",
|
|
28
|
+
"scikit-learn",
|
|
29
|
+
# plotting
|
|
30
|
+
"matplotlib",
|
|
31
|
+
"cartopy",
|
|
32
|
+
"shapely",
|
|
33
|
+
# progress reporting
|
|
34
|
+
"tqdm",
|
|
35
|
+
]
|
|
36
|
+
classifiers = [
|
|
37
|
+
"Programming Language :: Python :: 3",
|
|
38
|
+
"Programming Language :: Python :: 3.10",
|
|
39
|
+
"Programming Language :: Python :: 3.11",
|
|
40
|
+
"Programming Language :: Python :: 3.12",
|
|
41
|
+
"Operating System :: OS Independent",
|
|
42
|
+
"Intended Audience :: Science/Research",
|
|
43
|
+
"Topic :: Scientific/Engineering :: Atmospheric Science",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[project.optional-dependencies]
|
|
47
|
+
performance = ["dask"]
|
|
48
|
+
paper = ["adjustText"]
|
|
49
|
+
dev = ["pytest", "pytest-cov"]
|
|
50
|
+
|
|
51
|
+
[project.urls]
|
|
52
|
+
Homepage = "https://storypy.readthedocs.io/en/latest/"
|
|
53
|
+
Documentation = "https://storypy.readthedocs.io/en/latest/"
|
|
54
|
+
Source = "https://github.com/LIM-Climate-Causality/storypy"
|
|
55
|
+
Issues = "https://github.com/LIM-Climate-Causality/storypy/issues"
|
|
56
|
+
|
|
57
|
+
[tool.setuptools.packages.find]
|
|
58
|
+
where = ["."]
|
|
59
|
+
include = ["storypy*"]
|
|
60
|
+
|
|
61
|
+
[tool.setuptools.package-data]
|
|
62
|
+
storypy = [
|
|
63
|
+
"*.yml",
|
|
64
|
+
"*.nc",
|
|
65
|
+
"*.json",
|
|
66
|
+
"*.csv",
|
|
67
|
+
"data/regression_output/pr/*",
|
|
68
|
+
"data/regression_output/ua/*",
|
|
69
|
+
"data/remote_drivers/*.csv",
|
|
70
|
+
"data/targets/*.nc",
|
|
71
|
+
"data/drivers/*.nc",
|
|
72
|
+
]
|
storypy-0.1.7/setup.cfg
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""
|
|
2
|
+
storypy
|
|
3
|
+
|
|
4
|
+
A Python package to compute and visualize climate storylines.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
__version__ = "0.1.4"
|
|
8
|
+
__author__ = "Richard Alawode, Julia Mindlin, Marlene Kretschmer"
|
|
9
|
+
__credits__ = "LIM - Climate Causality"
|
|
10
|
+
|
|
11
|
+
# # Import core functionality from the package modules
|
|
12
|
+
# from .main import main_direct, main_esmval
|
|
13
|
+
# from .plotting import (
|
|
14
|
+
# plot_precipitation_change,
|
|
15
|
+
# plot_function, create_three_panel_figure,
|
|
16
|
+
# create_five_panel_figure,
|
|
17
|
+
# hemispheric_plot,
|
|
18
|
+
# make_symmetric_colorbar,
|
|
19
|
+
# plot_ellipse,
|
|
20
|
+
# confidence_ellipse
|
|
21
|
+
# )
|
|
22
|
+
# from .processing import (
|
|
23
|
+
# seasonal_data_months,
|
|
24
|
+
# apply_region_mask,
|
|
25
|
+
# create_arc,
|
|
26
|
+
# adjust_longitudes
|
|
27
|
+
# )
|
|
28
|
+
# from .diagnostics import clim_change, test_mean_significance
|
|
29
|
+
# #from .plot_ellipse import plot_ellipse, confidence_ellipse
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# #optional, we can import the commonly used libraries here
|
|
33
|
+
# #import numpy as np
|
|
34
|
+
# #import xarray as xr
|
|
35
|
+
# #import matplotlib.pyplot as plt
|
|
36
|
+
# #import cartopy.crs as ccrs
|
|
37
|
+
# #from scipy import stats
|
|
38
|
+
|
|
39
|
+
# # Explicitly define the public API of the package
|
|
40
|
+
# __all__ = [
|
|
41
|
+
# "main_direct",
|
|
42
|
+
# "main_esmval",
|
|
43
|
+
# "plot_precipitation_change",
|
|
44
|
+
# "plot_function",
|
|
45
|
+
# "seasonal_data_months",
|
|
46
|
+
# "apply_region_mask",
|
|
47
|
+
# "clim_change",
|
|
48
|
+
# "test_mean_significance",
|
|
49
|
+
# "confidence_ellipse",
|
|
50
|
+
# "plot_ellipse",
|
|
51
|
+
# "create_three_panel_figure",
|
|
52
|
+
# "create_five_panel_figure",
|
|
53
|
+
# "hemispheric_plot",
|
|
54
|
+
# "make_symmetric_colorbar",
|
|
55
|
+
# "create_arc",
|
|
56
|
+
# "adjust_longitudes",
|
|
57
|
+
# # "np",
|
|
58
|
+
# # "xr",
|
|
59
|
+
# # "plt",
|
|
60
|
+
# # "ccrs",
|
|
61
|
+
# # "stats",
|
|
62
|
+
# ]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from ._compute_driver import (
|
|
2
|
+
stand_numpy,
|
|
3
|
+
stand_pandas,
|
|
4
|
+
compute_drivers,
|
|
5
|
+
driver_indices,
|
|
6
|
+
_collect_scalar_drivers,
|
|
7
|
+
_build_drivers_dataset,
|
|
8
|
+
_select_one_file_per_var
|
|
9
|
+
)
|
|
10
|
+
from ._mlr import compute_regression
|
|
11
|
+
from ._stippling import StipplingComputer
|
|
12
|
+
from ._regres import (
|
|
13
|
+
SpatialRegression,
|
|
14
|
+
stand,
|
|
15
|
+
stand_detr,
|
|
16
|
+
filtro,
|
|
17
|
+
replace_nans_with_zero,
|
|
18
|
+
figure
|
|
19
|
+
)
|
|
20
|
+
from ._leave_one_out import (
|
|
21
|
+
run_loo_sensitivity,
|
|
22
|
+
loo_summary_table,
|
|
23
|
+
load_loo_results,
|
|
24
|
+
loo_sensitivity_masks,
|
|
25
|
+
)
|
|
26
|
+
from ._jet_index import (
|
|
27
|
+
compute_jet_target,
|
|
28
|
+
eddy_driven_jet_index,
|
|
29
|
+
)
|