texas-psm 0.1.0__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.
Files changed (63) hide show
  1. texas_psm-0.1.0/PKG-INFO +238 -0
  2. texas_psm-0.1.0/README.md +181 -0
  3. texas_psm-0.1.0/pyproject.toml +87 -0
  4. texas_psm-0.1.0/setup.cfg +4 -0
  5. texas_psm-0.1.0/src/TEXAS/__init__.py +92 -0
  6. texas_psm-0.1.0/src/TEXAS/constants.py +19 -0
  7. texas_psm-0.1.0/src/TEXAS/data/__init__.py +20 -0
  8. texas_psm-0.1.0/src/TEXAS/data/builder.py +302 -0
  9. texas_psm-0.1.0/src/TEXAS/data/filter.py +20 -0
  10. texas_psm-0.1.0/src/TEXAS/data/screening.py +937 -0
  11. texas_psm-0.1.0/src/TEXAS/diagnostics.py +83 -0
  12. texas_psm-0.1.0/src/TEXAS/ensemble/__init__.py +10 -0
  13. texas_psm-0.1.0/src/TEXAS/ensemble/detection.py +128 -0
  14. texas_psm-0.1.0/src/TEXAS/ensemble/generator.py +181 -0
  15. texas_psm-0.1.0/src/TEXAS/models/__init__.py +34 -0
  16. texas_psm-0.1.0/src/TEXAS/models/calibration.py +237 -0
  17. texas_psm-0.1.0/src/TEXAS/models/logistics.py +138 -0
  18. texas_psm-0.1.0/src/TEXAS/models/multivariate.py +98 -0
  19. texas_psm-0.1.0/src/TEXAS/plotting/__init__.py +17 -0
  20. texas_psm-0.1.0/src/TEXAS/plotting/prior_plot.py +470 -0
  21. texas_psm-0.1.0/src/TEXAS/plotting/range_utils.py +64 -0
  22. texas_psm-0.1.0/src/TEXAS/predict.py +237 -0
  23. texas_psm-0.1.0/src/TEXAS/stan/__init__.py +24 -0
  24. texas_psm-0.1.0/src/TEXAS/stan/auto.py +95 -0
  25. texas_psm-0.1.0/src/TEXAS/stan/compiler.py +68 -0
  26. texas_psm-0.1.0/src/TEXAS/stan/invT.py +366 -0
  27. texas_psm-0.1.0/src/TEXAS/stan/io.py +264 -0
  28. texas_psm-0.1.0/src/TEXAS/stan/metadata.py +186 -0
  29. texas_psm-0.1.0/src/TEXAS/stan/sampler.py +278 -0
  30. texas_psm-0.1.0/src/TEXAS/stan/utils.py +94 -0
  31. texas_psm-0.1.0/src/TEXAS/stan_models/gen_logi_fixed_Q1_culmeso.stan +40 -0
  32. texas_psm-0.1.0/src/TEXAS/stan_models/gen_logi_fixed_culmeso.stan +42 -0
  33. texas_psm-0.1.0/src/TEXAS/stan_models/gen_logi_fixed_culmesocore.stan +58 -0
  34. texas_psm-0.1.0/src/TEXAS/stan_models/gen_logi_fixed_hier_crtp_multiv.stan +170 -0
  35. texas_psm-0.1.0/src/TEXAS/stan_models/gen_logi_fixed_hier_crtp_multiv_priorApprox.stan +105 -0
  36. texas_psm-0.1.0/src/TEXAS/stan_models/gen_logi_fixed_hier_crtp_univ_priorApprox.stan +48 -0
  37. texas_psm-0.1.0/src/TEXAS/stan_models/gen_logi_fixed_v1_culmeso.stan +40 -0
  38. texas_psm-0.1.0/src/TEXAS/stan_models/invT_gen_logi_fixed_multiv_marginal_hard_constraint.stan +93 -0
  39. texas_psm-0.1.0/src/TEXAS/stan_models/invT_gen_logi_fixed_multiv_marginal_unconstrained.stan +163 -0
  40. texas_psm-0.1.0/src/TEXAS/stan_models/invT_gen_logi_fixed_multiv_unconstrained.stan +65 -0
  41. texas_psm-0.1.0/src/TEXAS/stan_models/invT_gen_logi_fixed_univ_marginal_hard_constraint.stan +35 -0
  42. texas_psm-0.1.0/src/TEXAS/stan_models/invT_gen_logi_fixed_univ_marginal_unconstrained.stan +103 -0
  43. texas_psm-0.1.0/src/TEXAS/stan_models/invT_gen_logi_fixed_univ_unconstrained.stan +35 -0
  44. texas_psm-0.1.0/src/TEXAS/stan_models/invT_logistic_fixed_multiv_marginal_hard_constraint.stan +94 -0
  45. texas_psm-0.1.0/src/TEXAS/stan_models/invT_logistic_fixed_multiv_marginal_unconstrained.stan +93 -0
  46. texas_psm-0.1.0/src/TEXAS/stan_models/invT_logistic_fixed_multiv_unconstrained.stan +58 -0
  47. texas_psm-0.1.0/src/TEXAS/stan_models/invT_logistic_fixed_univ_marginal_hard_constraint.stan +33 -0
  48. texas_psm-0.1.0/src/TEXAS/stan_models/invT_logistic_fixed_univ_marginal_unconstrained.stan +31 -0
  49. texas_psm-0.1.0/src/TEXAS/stan_models/invT_logistic_fixed_univ_unconstrained.stan +28 -0
  50. texas_psm-0.1.0/src/TEXAS/stan_models/linear_model.stan +27 -0
  51. texas_psm-0.1.0/src/TEXAS/utils/__init__.py +8 -0
  52. texas_psm-0.1.0/src/TEXAS/utils/cache_search.py +123 -0
  53. texas_psm-0.1.0/src/TEXAS/utils/hw.py +56 -0
  54. texas_psm-0.1.0/src/TEXAS/utils/paths.py +70 -0
  55. texas_psm-0.1.0/src/TEXAS/utils/system_info.py +308 -0
  56. texas_psm-0.1.0/src/texas_psm.egg-info/PKG-INFO +238 -0
  57. texas_psm-0.1.0/src/texas_psm.egg-info/SOURCES.txt +61 -0
  58. texas_psm-0.1.0/src/texas_psm.egg-info/dependency_links.txt +1 -0
  59. texas_psm-0.1.0/src/texas_psm.egg-info/requires.txt +48 -0
  60. texas_psm-0.1.0/src/texas_psm.egg-info/top_level.txt +1 -0
  61. texas_psm-0.1.0/tests/test_imports.py +52 -0
  62. texas_psm-0.1.0/tests/test_logistics.py +126 -0
  63. texas_psm-0.1.0/tests/test_predictors.py +75 -0
@@ -0,0 +1,238 @@
1
+ Metadata-Version: 2.4
2
+ Name: texas-psm
3
+ Version: 0.1.0
4
+ Summary: Bayesian GDGT–temperature utilities
5
+ Author-email: Ronnakrit Rattanasriampaipong <rattanasriampaipong.r@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/PaleoLipidRR/TEXAS
8
+ Project-URL: Bug Tracker, https://github.com/PaleoLipidRR/TEXAS/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: numpy>=1.18
14
+ Requires-Dist: xarray>=0.16
15
+ Requires-Dist: cmdstanpy>=1.0
16
+ Requires-Dist: typing-extensions>=3.7.4
17
+ Requires-Dist: scipy>=1.7
18
+ Requires-Dist: pandas>=1.3
19
+ Requires-Dist: baysparpy>=0.0.2
20
+ Requires-Dist: baysplinepy>=0.0.1
21
+ Requires-Dist: stanio>=0.4
22
+ Provides-Extra: plotting
23
+ Requires-Dist: matplotlib>=3.5; extra == "plotting"
24
+ Requires-Dist: proplot==0.9.7; extra == "plotting"
25
+ Requires-Dist: cmocean; extra == "plotting"
26
+ Requires-Dist: setuptools<81; extra == "plotting"
27
+ Requires-Dist: plotly; extra == "plotting"
28
+ Provides-Extra: dev
29
+ Requires-Dist: ipykernel; extra == "dev"
30
+ Requires-Dist: pytest; extra == "dev"
31
+ Requires-Dist: mkdocs; extra == "dev"
32
+ Requires-Dist: jupyterlab; extra == "dev"
33
+ Requires-Dist: ipywidgets; extra == "dev"
34
+ Requires-Dist: tqdm; extra == "dev"
35
+ Requires-Dist: anywidget; extra == "dev"
36
+ Requires-Dist: ipylab; extra == "dev"
37
+ Requires-Dist: duckdb; extra == "dev"
38
+ Requires-Dist: pyarrow; extra == "dev"
39
+ Requires-Dist: sqlalchemy; extra == "dev"
40
+ Requires-Dist: pydantic; extra == "dev"
41
+ Provides-Extra: regrid
42
+ Requires-Dist: geopandas; extra == "regrid"
43
+ Requires-Dist: shapely; extra == "regrid"
44
+ Requires-Dist: cartopy; extra == "regrid"
45
+ Requires-Dist: pyproj<3.6; extra == "regrid"
46
+ Requires-Dist: rtree; extra == "regrid"
47
+ Requires-Dist: pyogrio; extra == "regrid"
48
+ Requires-Dist: mapclassify; extra == "regrid"
49
+ Requires-Dist: geopy; extra == "regrid"
50
+ Requires-Dist: xesmf; extra == "regrid"
51
+ Requires-Dist: esmpy; extra == "regrid"
52
+ Requires-Dist: gsw>=3.3; extra == "regrid"
53
+ Provides-Extra: all
54
+ Requires-Dist: texas-psm[plotting]; extra == "all"
55
+ Requires-Dist: texas-psm[dev]; extra == "all"
56
+ Requires-Dist: texas-psm[regrid]; extra == "all"
57
+
58
+ # TEXAS — Temperature Estimation via a Bayesian Approach with Stan
59
+
60
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
61
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/)
62
+
63
+ **TEXAS** (`texas-psm`) is a Python package for **Bayesian GDGT–temperature calibration**. It fits hierarchical generalized-logistic models to isoGDGT proxy data (TEX86 / Ring Index) using Stan, then reconstructs paleotemperatures from new sediment records with full posterior uncertainty.
64
+
65
+ ---
66
+
67
+ ## What it does
68
+
69
+ TEXAS implements a two-stage workflow:
70
+
71
+ | Stage | Description |
72
+ |---|---|
73
+ | **Forward calibration** | Fit a generalized logistic curve (Ring Index → temperature) to culture, mesocosm, and/or coretop data using a hierarchical Bayesian Stan model. Outputs a compressed posterior `.nc` file. |
74
+ | **Inverse reconstruction (invT)** | Predict paleotemperatures from new Ring Index observations by marginalizing over posterior parameter draws. Returns a full posterior temperature distribution per sample. |
75
+
76
+ Optional non-thermal corrections for GDGT-2/3 ratio and NO₃ concentration are supported.
77
+
78
+ ---
79
+
80
+ ## Getting started
81
+
82
+ ### Option A — No-code: Streamlit web app
83
+
84
+ Upload a CSV and get paleotemperature reconstructions in your browser — no Python or Stan installation required.
85
+
86
+ > **Streamlit deployment coming soon.**
87
+
88
+ The app accepts a CSV with Ring Index columns and returns downloadable posterior temperature estimates with uncertainty.
89
+
90
+ ---
91
+
92
+ ### Option B — Docker (recommended for reproducibility)
93
+
94
+ No Stan setup required — CmdStan and all dependencies are pre-installed.
95
+
96
+ ```bash
97
+ # Clone the repo
98
+ git clone https://github.com/PaleoLipidRR/TEXAS.git
99
+ cd TEXAS
100
+
101
+ # Build and start the container
102
+ docker compose up
103
+ ```
104
+
105
+ Then open JupyterLab at `http://localhost:8888` and run the notebooks in `notebooks/manuscripts/`.
106
+
107
+ > **Pre-built image on GHCR coming soon.** Until then, the image is built locally from `docker/Dockerfile`.
108
+
109
+ ---
110
+
111
+ ### Option C — pip install (Python users)
112
+
113
+ ```bash
114
+ pip install texas-psm
115
+ ```
116
+
117
+ **One-time CmdStan install** (required; sets a flag for the conda C++ compiler on Linux/macOS):
118
+
119
+ ```bash
120
+ TBB_CXX_TYPE=gcc python -c "import cmdstanpy; cmdstanpy.install_cmdstan(version='2.36.0')"
121
+ ```
122
+
123
+ TEXAS will search for CmdStan in `~/.cmdstan/`, `/opt/cmdstan/`, or the `CMDSTAN` environment variable.
124
+
125
+ ---
126
+
127
+ ### Option D — conda + pip from source (for development)
128
+
129
+ ```bash
130
+ git clone https://github.com/PaleoLipidRR/TEXAS.git
131
+ cd TEXAS
132
+
133
+ conda env create -f environment.yml
134
+ conda activate texas-env
135
+
136
+ pip install -e .
137
+ ```
138
+
139
+ Then install CmdStan as shown in Option C above.
140
+
141
+ ---
142
+
143
+ ## Example usage
144
+
145
+ ```python
146
+ import numpy as np
147
+ from TEXAS import predict_RI_from_T, predict_T_from_RI
148
+ from TEXAS.stan.sampler import get_posterior
149
+ from TEXAS.stan.io import save_posterior
150
+
151
+ # 1. Forward calibration — fit logistic curve to training data
152
+ posterior, diagnostics = get_posterior(
153
+ data,
154
+ model_name="gen_logi_fixed_hier_crtp_multiv",
155
+ temptype="SST",
156
+ )
157
+ save_posterior(posterior)
158
+
159
+ # 2. Forward prediction — evaluate the calibration curve at 20–30 °C
160
+ result = predict_RI_from_T(
161
+ temperatures=np.linspace(20, 30, 50),
162
+ posterior="gen_logi_fixed_hier_crtp_multiv_SST",
163
+ )
164
+ result["p50"] # median calibration curve
165
+
166
+ # 3. Inverse reconstruction — predict temperature from new Ring Index observations
167
+ result = predict_T_from_RI(
168
+ scaledRI=my_ri_array,
169
+ prior_mu_t=15.0, # prior mean temperature (°C)
170
+ prior_sigma_t=10.0, # prior uncertainty (°C)
171
+ fwd_posterior_name="gen_logi_fixed_hier_crtp_multiv_SST",
172
+ temptype="SST",
173
+ )
174
+ result["p50"] # median temperature reconstruction (°C)
175
+ result["p5"] # 5th percentile
176
+ result["p95"] # 95th percentile
177
+ ```
178
+
179
+ ---
180
+
181
+ ## Repository layout
182
+
183
+ ```
184
+ src/TEXAS/
185
+ predict.py High-level API: predict_RI_from_T / predict_T_from_RI
186
+ stan/ Sampler, compiler, I/O, and invT orchestration
187
+ stan_models/ Stan model files (.stan)
188
+ data/ Input data builders, filters, and screening
189
+ ensemble/ Posterior ensemble generation and model detection
190
+ models/ Logistic curve functions and classical calibrations
191
+ plotting/ Prior/posterior distribution plots and range utilities
192
+ utils/ Path constants, system info
193
+ notebooks/
194
+ manuscripts/ Finalized analysis notebooks for the paper
195
+ streamlit_app/ Drag-and-drop web interface (Streamlit)
196
+ docker/ Dockerfile and compose configuration
197
+ docs/ MkDocs documentation source
198
+ ```
199
+
200
+ ---
201
+
202
+ ## API at a glance
203
+
204
+ | Function | Description |
205
+ |---|---|
206
+ | `predict_RI_from_T(temperatures, posterior, ...)` | Forward prediction: temperature → Ring Index (pure Python, wraps `generate_ensemble_auto`) |
207
+ | `predict_T_from_RI(scaledRI, prior_mu_t, prior_sigma_t, fwd_posterior_name, ...)` | Inverse reconstruction: Ring Index → temperature with full posterior uncertainty (runs Stan) |
208
+ | `get_posterior(data, model_name, temptype, ...)` | Run forward calibration Stan sampling |
209
+ | `save_posterior(ds)` / `load_posterior(name)` | Persist / load forward posterior as compressed NetCDF |
210
+ | `get_invT_posterior(...)` | Run inverse-T sampling and return full posterior xr.Dataset |
211
+ | `predict_temperature_from_RI(...)` | Run inverse-T and return `{p5, p50, p95, scaledRI, metadata}` |
212
+ | `generate_ensemble_auto(temperatures, posterior, ...)` | Sample draws from a posterior and compute calibration-curve percentiles |
213
+ | `summarize_sampler_diagnostics(fit)` | Compute divergences, R-hat, ESS, E-BFMI from a CmdStanMCMC fit |
214
+ | `plot_prior_distributions(posterior)` | Plot prior distributions from posterior metadata |
215
+
216
+ Full API reference: [https://paleolipidRR.github.io/TEXAS](https://paleolipidRR.github.io/TEXAS) *(coming soon)*
217
+
218
+ ---
219
+
220
+ ## Documentation
221
+
222
+ Full API reference and method details: [https://paleolipidRR.github.io/TEXAS](https://paleolipidRR.github.io/TEXAS) *(coming soon)*
223
+
224
+ ---
225
+
226
+ ## Citation
227
+
228
+ If you use TEXAS in your research, please cite:
229
+
230
+ > Rattanasriampaipong, R. et al. (in prep). *TEXAS: Bayesian GDGT–temperature calibration using Stan.* AGU Paleoceanography and Paleoclimatology.
231
+
232
+ A `CITATION.cff` and software DOI will be added upon submission.
233
+
234
+ ---
235
+
236
+ ## License
237
+
238
+ MIT © Ronnakrit Rattanasriampaipong
@@ -0,0 +1,181 @@
1
+ # TEXAS — Temperature Estimation via a Bayesian Approach with Stan
2
+
3
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
4
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/)
5
+
6
+ **TEXAS** (`texas-psm`) is a Python package for **Bayesian GDGT–temperature calibration**. It fits hierarchical generalized-logistic models to isoGDGT proxy data (TEX86 / Ring Index) using Stan, then reconstructs paleotemperatures from new sediment records with full posterior uncertainty.
7
+
8
+ ---
9
+
10
+ ## What it does
11
+
12
+ TEXAS implements a two-stage workflow:
13
+
14
+ | Stage | Description |
15
+ |---|---|
16
+ | **Forward calibration** | Fit a generalized logistic curve (Ring Index → temperature) to culture, mesocosm, and/or coretop data using a hierarchical Bayesian Stan model. Outputs a compressed posterior `.nc` file. |
17
+ | **Inverse reconstruction (invT)** | Predict paleotemperatures from new Ring Index observations by marginalizing over posterior parameter draws. Returns a full posterior temperature distribution per sample. |
18
+
19
+ Optional non-thermal corrections for GDGT-2/3 ratio and NO₃ concentration are supported.
20
+
21
+ ---
22
+
23
+ ## Getting started
24
+
25
+ ### Option A — No-code: Streamlit web app
26
+
27
+ Upload a CSV and get paleotemperature reconstructions in your browser — no Python or Stan installation required.
28
+
29
+ > **Streamlit deployment coming soon.**
30
+
31
+ The app accepts a CSV with Ring Index columns and returns downloadable posterior temperature estimates with uncertainty.
32
+
33
+ ---
34
+
35
+ ### Option B — Docker (recommended for reproducibility)
36
+
37
+ No Stan setup required — CmdStan and all dependencies are pre-installed.
38
+
39
+ ```bash
40
+ # Clone the repo
41
+ git clone https://github.com/PaleoLipidRR/TEXAS.git
42
+ cd TEXAS
43
+
44
+ # Build and start the container
45
+ docker compose up
46
+ ```
47
+
48
+ Then open JupyterLab at `http://localhost:8888` and run the notebooks in `notebooks/manuscripts/`.
49
+
50
+ > **Pre-built image on GHCR coming soon.** Until then, the image is built locally from `docker/Dockerfile`.
51
+
52
+ ---
53
+
54
+ ### Option C — pip install (Python users)
55
+
56
+ ```bash
57
+ pip install texas-psm
58
+ ```
59
+
60
+ **One-time CmdStan install** (required; sets a flag for the conda C++ compiler on Linux/macOS):
61
+
62
+ ```bash
63
+ TBB_CXX_TYPE=gcc python -c "import cmdstanpy; cmdstanpy.install_cmdstan(version='2.36.0')"
64
+ ```
65
+
66
+ TEXAS will search for CmdStan in `~/.cmdstan/`, `/opt/cmdstan/`, or the `CMDSTAN` environment variable.
67
+
68
+ ---
69
+
70
+ ### Option D — conda + pip from source (for development)
71
+
72
+ ```bash
73
+ git clone https://github.com/PaleoLipidRR/TEXAS.git
74
+ cd TEXAS
75
+
76
+ conda env create -f environment.yml
77
+ conda activate texas-env
78
+
79
+ pip install -e .
80
+ ```
81
+
82
+ Then install CmdStan as shown in Option C above.
83
+
84
+ ---
85
+
86
+ ## Example usage
87
+
88
+ ```python
89
+ import numpy as np
90
+ from TEXAS import predict_RI_from_T, predict_T_from_RI
91
+ from TEXAS.stan.sampler import get_posterior
92
+ from TEXAS.stan.io import save_posterior
93
+
94
+ # 1. Forward calibration — fit logistic curve to training data
95
+ posterior, diagnostics = get_posterior(
96
+ data,
97
+ model_name="gen_logi_fixed_hier_crtp_multiv",
98
+ temptype="SST",
99
+ )
100
+ save_posterior(posterior)
101
+
102
+ # 2. Forward prediction — evaluate the calibration curve at 20–30 °C
103
+ result = predict_RI_from_T(
104
+ temperatures=np.linspace(20, 30, 50),
105
+ posterior="gen_logi_fixed_hier_crtp_multiv_SST",
106
+ )
107
+ result["p50"] # median calibration curve
108
+
109
+ # 3. Inverse reconstruction — predict temperature from new Ring Index observations
110
+ result = predict_T_from_RI(
111
+ scaledRI=my_ri_array,
112
+ prior_mu_t=15.0, # prior mean temperature (°C)
113
+ prior_sigma_t=10.0, # prior uncertainty (°C)
114
+ fwd_posterior_name="gen_logi_fixed_hier_crtp_multiv_SST",
115
+ temptype="SST",
116
+ )
117
+ result["p50"] # median temperature reconstruction (°C)
118
+ result["p5"] # 5th percentile
119
+ result["p95"] # 95th percentile
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Repository layout
125
+
126
+ ```
127
+ src/TEXAS/
128
+ predict.py High-level API: predict_RI_from_T / predict_T_from_RI
129
+ stan/ Sampler, compiler, I/O, and invT orchestration
130
+ stan_models/ Stan model files (.stan)
131
+ data/ Input data builders, filters, and screening
132
+ ensemble/ Posterior ensemble generation and model detection
133
+ models/ Logistic curve functions and classical calibrations
134
+ plotting/ Prior/posterior distribution plots and range utilities
135
+ utils/ Path constants, system info
136
+ notebooks/
137
+ manuscripts/ Finalized analysis notebooks for the paper
138
+ streamlit_app/ Drag-and-drop web interface (Streamlit)
139
+ docker/ Dockerfile and compose configuration
140
+ docs/ MkDocs documentation source
141
+ ```
142
+
143
+ ---
144
+
145
+ ## API at a glance
146
+
147
+ | Function | Description |
148
+ |---|---|
149
+ | `predict_RI_from_T(temperatures, posterior, ...)` | Forward prediction: temperature → Ring Index (pure Python, wraps `generate_ensemble_auto`) |
150
+ | `predict_T_from_RI(scaledRI, prior_mu_t, prior_sigma_t, fwd_posterior_name, ...)` | Inverse reconstruction: Ring Index → temperature with full posterior uncertainty (runs Stan) |
151
+ | `get_posterior(data, model_name, temptype, ...)` | Run forward calibration Stan sampling |
152
+ | `save_posterior(ds)` / `load_posterior(name)` | Persist / load forward posterior as compressed NetCDF |
153
+ | `get_invT_posterior(...)` | Run inverse-T sampling and return full posterior xr.Dataset |
154
+ | `predict_temperature_from_RI(...)` | Run inverse-T and return `{p5, p50, p95, scaledRI, metadata}` |
155
+ | `generate_ensemble_auto(temperatures, posterior, ...)` | Sample draws from a posterior and compute calibration-curve percentiles |
156
+ | `summarize_sampler_diagnostics(fit)` | Compute divergences, R-hat, ESS, E-BFMI from a CmdStanMCMC fit |
157
+ | `plot_prior_distributions(posterior)` | Plot prior distributions from posterior metadata |
158
+
159
+ Full API reference: [https://paleolipidRR.github.io/TEXAS](https://paleolipidRR.github.io/TEXAS) *(coming soon)*
160
+
161
+ ---
162
+
163
+ ## Documentation
164
+
165
+ Full API reference and method details: [https://paleolipidRR.github.io/TEXAS](https://paleolipidRR.github.io/TEXAS) *(coming soon)*
166
+
167
+ ---
168
+
169
+ ## Citation
170
+
171
+ If you use TEXAS in your research, please cite:
172
+
173
+ > Rattanasriampaipong, R. et al. (in prep). *TEXAS: Bayesian GDGT–temperature calibration using Stan.* AGU Paleoceanography and Paleoclimatology.
174
+
175
+ A `CITATION.cff` and software DOI will be added upon submission.
176
+
177
+ ---
178
+
179
+ ## License
180
+
181
+ MIT © Ronnakrit Rattanasriampaipong
@@ -0,0 +1,87 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "texas-psm"
7
+ version = "0.1.0"
8
+ authors = [{ name = "Ronnakrit Rattanasriampaipong", email = "rattanasriampaipong.r@gmail.com" }]
9
+ description = "Bayesian GDGT–temperature utilities"
10
+ readme = "README.md"
11
+ requires-python = ">=3.8"
12
+ license = "MIT"
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "Operating System :: OS Independent",
16
+ ]
17
+
18
+ dependencies = [
19
+ "numpy>=1.18",
20
+ "xarray>=0.16",
21
+ "cmdstanpy>=1.0",
22
+ "typing-extensions>=3.7.4",
23
+ "scipy>=1.7",
24
+ "pandas>=1.3",
25
+ "baysparpy>=0.0.2",
26
+ "baysplinepy>=0.0.1",
27
+ "stanio>=0.4"
28
+ ]
29
+
30
+ [project.optional-dependencies]
31
+ plotting = [
32
+ "matplotlib>=3.5",
33
+ "proplot==0.9.7",
34
+ "cmocean",
35
+ "setuptools<81",
36
+ "plotly"
37
+ ]
38
+
39
+ dev = [
40
+ "ipykernel",
41
+ "pytest",
42
+ "mkdocs",
43
+ "jupyterlab",
44
+ "ipywidgets",
45
+ "tqdm",
46
+ "anywidget",
47
+ "ipylab",
48
+ "duckdb",
49
+ "pyarrow",
50
+ "sqlalchemy",
51
+ "pydantic"
52
+ ]
53
+
54
+ regrid = [
55
+ "geopandas",
56
+ "shapely",
57
+ "cartopy",
58
+ "pyproj<3.6",
59
+ "rtree",
60
+ "pyogrio",
61
+ "mapclassify",
62
+ "geopy",
63
+ "xesmf",
64
+ "esmpy",
65
+ "gsw>=3.3"
66
+ ]
67
+
68
+ all = [
69
+ "texas-psm[plotting]",
70
+ "texas-psm[dev]",
71
+ "texas-psm[regrid]"
72
+ ]
73
+ [tool.setuptools.packages.find]
74
+ where = ["src"]
75
+ include = ["TEXAS*"]
76
+
77
+ [tool.setuptools.package-data]
78
+ TEXAS = ["stan_models/*.stan"]
79
+
80
+ [project.urls]
81
+ "Homepage" = "https://github.com/PaleoLipidRR/TEXAS"
82
+ "Bug Tracker" = "https://github.com/PaleoLipidRR/TEXAS/issues"
83
+
84
+ [tool.conda-lock.dependencies]
85
+ pip = [
86
+ "pygwalker"
87
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,92 @@
1
+ # TEXAS/__init__.py
2
+
3
+ __version__ = "0.1.0"
4
+
5
+ # ─── Stan interface ──────────────────────────────────────────────────────
6
+ from .stan.compiler import StanCompiler
7
+ from .stan.sampler import (
8
+ StanSampler,
9
+ get_posterior,
10
+ sampler_invT_posterior,
11
+ )
12
+ from .stan.io import (
13
+ load_posterior,
14
+ save_posterior,
15
+ save_invT_posterior,
16
+ )
17
+ from .stan.invT import get_invT_posterior, predict_temperature_from_RI
18
+ from .predict import predict_RI_from_T, predict_T_from_RI
19
+
20
+ # ─── Data builder for inverse‐T models ──────────────────────────────────
21
+ from .data.builder import build_invT_inputData, InvTConfig
22
+
23
+ # ─── Pure-Python logistic helpers ───────────────────────────────────────
24
+ from .models.logistics import (
25
+ logistic,
26
+ logistic_fixed_upper,
27
+ inverse_logistic_fixed_upper,
28
+ generalized_logistic,
29
+ generalized_logistic_fixed_upper,
30
+ )
31
+ from .models.multivariate import (
32
+ generalized_logistic_fixed_upper_multivariate,
33
+ simple_logistic_fixed_upper_multivariate,
34
+ )
35
+
36
+ # ─── Ensemble generation ────────────────────────────────────────────────
37
+ from .ensemble.generator import generate_ensemble, generate_ensemble_auto
38
+ from .ensemble.detection import detect_model_and_params
39
+
40
+ # ─── Diagnostics utilities ─────────────────────────────────────────────
41
+ from .diagnostics import summarize_sampler_diagnostics, create_summary_table
42
+
43
+ # ─── Plotting / dataviz ─────────────────────────────────────────────────
44
+ from .plotting import (
45
+ compute_sample_range,
46
+ compute_density_based_range,
47
+ compute_suffix_specific_range,
48
+ compute_dataset_specific_range,
49
+ plot_prior_distributions,
50
+ )
51
+
52
+ __all__ = [
53
+ # version
54
+ "__version__",
55
+ # stan — calibration
56
+ "StanCompiler",
57
+ "StanSampler",
58
+ "get_posterior",
59
+ "load_posterior",
60
+ "save_posterior",
61
+ "save_invT_posterior",
62
+ # stan — inverse temperature
63
+ "get_invT_posterior",
64
+ "predict_temperature_from_RI",
65
+ # high-level prediction API
66
+ "predict_RI_from_T",
67
+ "predict_T_from_RI",
68
+ # data builder
69
+ "build_invT_inputData",
70
+ "InvTConfig",
71
+ # models — logistic curves
72
+ "logistic",
73
+ "logistic_fixed_upper",
74
+ "inverse_logistic_fixed_upper",
75
+ "generalized_logistic",
76
+ "generalized_logistic_fixed_upper",
77
+ "generalized_logistic_fixed_upper_multivariate",
78
+ "simple_logistic_fixed_upper_multivariate",
79
+ # ensemble
80
+ "generate_ensemble",
81
+ "generate_ensemble_auto",
82
+ "detect_model_and_params",
83
+ # diagnostics
84
+ "summarize_sampler_diagnostics",
85
+ "create_summary_table",
86
+ # plotting
87
+ "compute_sample_range",
88
+ "compute_density_based_range",
89
+ "compute_suffix_specific_range",
90
+ "compute_dataset_specific_range",
91
+ "plot_prior_distributions",
92
+ ]
@@ -0,0 +1,19 @@
1
+ # TEXAS/constants.py
2
+
3
+ # Optional predictors
4
+ OPTIONAL_PREDICTORS = ["gdgt23ratio", "no3"]
5
+
6
+ # Suffixes for logistic model parameter variants
7
+ DEFAULT_SUFFIXES = ["crtp", "culmesocore", "culmeso", "meso", "cul", "downcore"]
8
+
9
+ # Maps predictor data-variable name → Stan/posterior coefficient name
10
+ PREDICTOR_BETA_NAMES = {
11
+ "gdgt23ratio": "beta_G23",
12
+ "no3": "beta_NO3",
13
+ }
14
+
15
+ # Stan direct keys (if used across multiple places)
16
+ DIRECT_KEYS = ["scaledRI", "prior_mu_t", "prior_sigma_t",
17
+ "calibration_model_name", "N_cul", "N_meso", "N_crtp", "N",
18
+ "prior_mu_t", "prior_sigma_t", "M"
19
+ ]
@@ -0,0 +1,20 @@
1
+ # TEXAS/data/__init__.py
2
+
3
+ from .builder import (
4
+ build_invT_inputData,
5
+ InvTConfig
6
+ )
7
+ from .filter import (
8
+ filter_stan_compatible,
9
+ ensure_numpy,
10
+ )
11
+
12
+ from .screening import MahalanobisOutlierDetector
13
+
14
+ __all__ = [
15
+ "build_invT_inputData",
16
+ "InvTConfig",
17
+ "filter_stan_compatible",
18
+ "ensure_numpy",
19
+ 'MahalanobisOutlierDetector'
20
+ ]