Metadata-Version: 2.4
Name: resprpy
Version: 0.1.1
Summary: Python port of the respR R package: import, process, analyse and calculate rates from respirometry data
Author: resprpy contributors
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/haexiao/resprpy
Project-URL: Source, https://github.com/haexiao/resprpy
Project-URL: Documentation, https://github.com/haexiao/resprpy/blob/master/docs/respR_resprpy_guide.en.html
Project-URL: Original, https://github.com/januarharianto/respR
Keywords: respirometry,oxygen,metabolic-rate,respR,aquatic,mo2,pcrit
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.22
Requires-Dist: scipy>=1.8
Provides-Extra: plot
Requires-Dist: matplotlib>=3.5; extra == "plot"
Provides-Extra: test
Requires-Dist: pytest>=7; extra == "test"
Requires-Dist: openpyxl>=3.1; extra == "test"
Dynamic: license-file

# resprpy

**resprpy** is a complete Python port of the **respR 2.3.4** R package
(Harianto & Carey, *Methods in Ecology and Evolution* 2019,
doi:10.1111/2041-210X.13162) for processing and analysis of respirometry
(oxygen uptake / metabolic rate) data.

The goal is **numeric parity with R**: every exported function is verified
against outputs generated by R 4.5.3 (pytest parity tests, all 57 passing).

> 🇨🇳 中文版说明见 [README.zh-CN.md](README.zh-CN.md) ·
> Full usage guide (EN): [docs/respR_resprpy_guide.en.html](docs/respR_resprpy_guide.en.html) ·
> 使用手册（中文）: [docs/respR_resprpy_guide.zh.html](docs/respR_resprpy_guide.zh.html)

## Installation

```bash
pip install -e .            # or: pip install -e ".[plot,test]"
```

Dependencies: numpy, scipy (optional: matplotlib, pytest, openpyxl).

## Feature parity (all 27 respR exports)

| respR (R) | resprpy (Python) | Status |
|---|---|---|
| `calc_rate` | `calc_rate` | ✅ ≤1e-13 |
| `calc_rate.int` | `calc_rate_int` | ✅ ≤1e-6 |
| `calc_rate.bg` | `calc_rate_bg` | ✅ ≤1e-6 |
| `calc_rate.ft` | `calc_rate_ft` | ✅ ≤1e-5 |
| `auto_rate` | `auto_rate` | ✅ bw.SJ/density bit-exact |
| `auto_rate.int` | `auto_rate_int` | ✅ ≤1e-5 |
| `adjust_rate` | `adjust_rate` | ✅ 6 methods |
| `adjust_rate.ft` | `adjust_rate_ft` | ✅ ≤1e-6 |
| `select_rate` | `select_rate` | ✅ all 34 methods |
| `select_rate.ft` | `select_rate_ft` | ✅ ≤1e-5 |
| `convert_DO` | `convert_DO` | ✅ ≤1e-12 |
| `convert_MR` | `convert_MR` | ✅ ≤1e-12 |
| `convert_rate` | `convert_rate` | ✅ ≤1e-12 |
| `convert_rate.ft` | `convert_rate_ft` | ✅ ≤1e-8 |
| `convert_val` | `convert_val` | ✅ ≤1e-12 |
| `format_time` | `format_time` | ✅ exact |
| `inspect` | `inspect` | ✅ checks/locs match |
| `inspect.ft` | `inspect_ft` | ✅ |
| `oxy_crit` | `oxy_crit` | ✅ bsr + segmented |
| `import_file` | `import_file` | ✅ NeoFox exact (14 parsers) |
| `sim_data` | `sim_data` | ✅ structure |
| `subsample` | `subsample` | ✅ |
| `subset_data` | `subset_data` | ✅ |
| `select` | `select` | ✅ |
| `%>%` | — (Python chaining) | ➖ n/a |
| `test_lin` | `test_lin` | 🟡 structure matches |
| `unit_args` | `unit_args` | ✅ |
| S3 `plot()` | `plot_inspect` `plot_calc_rate` `plot_auto_rate` `plot_oxy_crit` | ✅ matplotlib |

## Highlights

- **Segmented (Muggeo 2003) breakpoint analysis** ported from the
  `segmented` 2.2-1 package *including* R's MT19937 RNG (bit-exact
  `set.seed` sequences, bootstrap-restart search) — crit values match R
  exactly (e.g. 7.719111…).
- **`select_rate`** — all 34 methods verified against R, including error
  behaviour (methods R rejects raise the same errors).
- **`convert_*`** — physical anchors exact (sw_dens=1024.64077347883,
  molvol=24.03038425, mg/L→%Air=108.4419).
- **No C/C++ runtime**: the rolling regression, kernel density,
  marelac physics and segmented algorithm used by respR's dependencies are
  all inlined into pure numpy/scipy — PyInstaller-friendly.

## Tests

```bash
python -m pytest tests/ -v        # 57 tests, all green
```

Reference CSVs under `tests/reference/` were generated by R 4.5.3
(`reference/gen_refs_*.R`); pytest compares element-wise with graded
tolerances (coeffs 1e-8, rsq 1e-12, time 1e-9, density 1e-3).

## Package structure (vs respR)

See the structure comparison section in the usage guides.

## Citation

resprpy is a Python port of the R package **respR**. If you use resprpy in
publications or derived software, please cite the original respR work:

> Harianto, J., Carey, N., &amp; Byrne, M. (2019). respR — An R package for the
> manipulation and analysis of respirometry data. *Methods in Ecology and
> Evolution*, 10(6), 912–920. doi:10.1111/2041-210X.13162

- respR source: <https://github.com/januarharianto/respR>
- respR documentation: <https://januarharianto.github.io/respR/>
- CRAN: <https://cran.r-project.org/package=respR>

Machine-readable citation metadata: [CITATION.cff](CITATION.cff).

## License

GPL-3 (same as respR). This is a clean-room style port of respR's
algorithms and its dependencies' algorithms; distributing it requires
GPL-3 compliance.
