sobig 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.
@@ -0,0 +1,20 @@
1
+ name: publish
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build-and-publish:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ id-token: write
12
+
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.x"
18
+ - run: python -m pip install --upgrade build
19
+ - run: python -m build
20
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,21 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: ${{ matrix.python-version }}
19
+ - run: python -m pip install --upgrade pip
20
+ - run: pip install -e ".[dev]"
21
+ - run: pytest
sobig-0.1.0/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ TODO.md
2
+ *.png
3
+ *.tif
4
+ *.csv
5
+ *.odp
6
+ *.pptx
7
+ *.pdf
8
+ scratch/*
9
+ __pycache__/
10
+ *.py[cod]
11
+ *.so
12
+ .Python
13
+ .venv/
14
+ venv/
15
+ env/
16
+ build/
17
+ dist/
18
+ *.egg-info/
19
+ .pytest_cache/
20
+ .ruff_cache/
21
+ .coverage
22
+ htmlcov/
23
+ .DS_Store
24
+ .ipynb_checkpoints/
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ All changes to the project will be documented here.
4
+
5
+ ## [0.1.0] - Unreleased
6
+
7
+ - Initial package release. Plan to upgrade to 1.0.0 when methods paper is ready for release.
sobig-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026, Drew Ellison Terasaki Hart, Geonomics Development Team
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.
sobig-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,86 @@
1
+ Metadata-Version: 2.5
2
+ Name: sobig
3
+ Version: 0.1.0
4
+ Summary: Simulation of observations of biodiversity across gradients.
5
+ Project-URL: Homepage, https://github.com/erthward/sobig
6
+ Project-URL: Repository, https://github.com/erthward/sobig
7
+ Project-URL: Issues, https://github.com/erthward/sobig/issues
8
+ Author-email: Drew Terasaki Hart <drew.terasaki.hart@gmail.com>
9
+ License: MIT License
10
+
11
+ Copyright (c) 2026, Drew Ellison Terasaki Hart, Geonomics Development Team
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+ License-File: LICENSE
31
+ Requires-Python: >=3.10
32
+ Requires-Dist: dms-variants
33
+ Requires-Dist: matplotlib
34
+ Requires-Dist: nlmpy
35
+ Requires-Dist: numba
36
+ Requires-Dist: numpy
37
+ Requires-Dist: pandas
38
+ Requires-Dist: rasterio
39
+ Requires-Dist: rioxarray
40
+ Requires-Dist: scikit-learn
41
+ Requires-Dist: scipy
42
+ Requires-Dist: xarray
43
+ Provides-Extra: dev
44
+ Requires-Dist: build>=1.2; extra == 'dev'
45
+ Requires-Dist: pytest>=8; extra == 'dev'
46
+ Requires-Dist: ruff>=0.6; extra == 'dev'
47
+ Requires-Dist: twine>=5; extra == 'dev'
48
+ Description-Content-Type: text/markdown
49
+
50
+ # SOBiG!
51
+
52
+ ##**S**imulation of **O**bservations of **Bi**odiversity across **G**radients
53
+
54
+ A Python package for 'reverse-engineering' generalised dissimilarity modelling (GDM)
55
+ to simulate communities distributed across variable landscapes,
56
+ and then using a 'virtual ecologist' to simulate various observation processes on those communities.
57
+
58
+ ## Overview
59
+
60
+ This package is designed for methods development in community ecology and biodiversity
61
+ modelling. It 'reverse-engineers' generalised dissimilarity modelling (GDM), allowing
62
+ the user to define environmental landscapes, monotonic environmental
63
+ turnover functions (e.g. I-splines) that relate ecological community turnover to those landscapes' variables, the size of the regional species pool (i.e., gamma diversity), and the set of sampling locations. Then it simulates communities at all sampling locations and
64
+ uses a 'virtual ecologist' approach to simulate various observation processes on those communities
65
+ (ranging from full-communtiy censuses, to abudance-absence, presence-absence, or presence-only (i.e., 'opportunistic') records.
66
+
67
+ Workflows can be built from the following steps:
68
+
69
+ 1. Define a landscape and environmental turnover functions.
70
+ 2. Simulate the latent communities.
71
+ 3. Simulate one or more observation/survey processes.
72
+ 4. Fit/visualize GDM or other biodiversity models to the simulated data.
73
+ 5. Modify environmental layers to represent environmental change.
74
+ 6. Re-simulate communities and observations.
75
+
76
+ See the documentation for the full API and examples.
77
+
78
+ ## Installation
79
+
80
+ ```bash
81
+ pip install sobig
82
+ ```
83
+
84
+ ## License
85
+
86
+ See `LICENSE`.
sobig-0.1.0/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # SOBiG!
2
+
3
+ ##**S**imulation of **O**bservations of **Bi**odiversity across **G**radients
4
+
5
+ A Python package for 'reverse-engineering' generalised dissimilarity modelling (GDM)
6
+ to simulate communities distributed across variable landscapes,
7
+ and then using a 'virtual ecologist' to simulate various observation processes on those communities.
8
+
9
+ ## Overview
10
+
11
+ This package is designed for methods development in community ecology and biodiversity
12
+ modelling. It 'reverse-engineers' generalised dissimilarity modelling (GDM), allowing
13
+ the user to define environmental landscapes, monotonic environmental
14
+ turnover functions (e.g. I-splines) that relate ecological community turnover to those landscapes' variables, the size of the regional species pool (i.e., gamma diversity), and the set of sampling locations. Then it simulates communities at all sampling locations and
15
+ uses a 'virtual ecologist' approach to simulate various observation processes on those communities
16
+ (ranging from full-communtiy censuses, to abudance-absence, presence-absence, or presence-only (i.e., 'opportunistic') records.
17
+
18
+ Workflows can be built from the following steps:
19
+
20
+ 1. Define a landscape and environmental turnover functions.
21
+ 2. Simulate the latent communities.
22
+ 3. Simulate one or more observation/survey processes.
23
+ 4. Fit/visualize GDM or other biodiversity models to the simulated data.
24
+ 5. Modify environmental layers to represent environmental change.
25
+ 6. Re-simulate communities and observations.
26
+
27
+ See the documentation for the full API and examples.
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ pip install sobig
33
+ ```
34
+
35
+ ## License
36
+
37
+ See `LICENSE`.
@@ -0,0 +1,26 @@
1
+ # Assumptions and limitations
2
+
3
+ The initial simulator makes several deliberate simplifying assumptions.
4
+
5
+ ## Biogeographic assumptions
6
+
7
+ - Species have an idealized climatic niche represented by a multivariate niche
8
+ center and niche width.
9
+ - Species' niche centers are realized stochastically within the environmental
10
+ space represented by the supplied landscape.
11
+ - Areas within a species' climatic niche are assumed to be reachable.
12
+ - There is currently no explicit dispersal limitation or movement model.
13
+ - There are no biotic interactions or competitive effects.
14
+ - There is no explicit truncation of the climatic niche into a realized niche.
15
+ - Spatial autocorrelation in occurrence patterns arises indirectly through
16
+ spatial structure in the environmental layers rather than through neighboring
17
+ occurrence states.
18
+
19
+ ## Observation assumptions
20
+
21
+ Observation processes can be specified separately from the latent community,
22
+ allowing multiple linked or nested datasets to be generated from the same
23
+ underlying community.
24
+
25
+ Document the precise detection, abundance, and reporting models here as the API
26
+ is finalized.
@@ -0,0 +1,19 @@
1
+ # SOBiG documentation
2
+
3
+ Documentation is under construction.
4
+
5
+ ## Planned sections
6
+
7
+ - Installation
8
+ - Quick-start example
9
+ - Landscape and environmental layers
10
+ - I-spline / turnover functions
11
+ - Species niche generation
12
+ - Latent community simulation
13
+ - Observation-process simulation
14
+ - Geographic, species-specific detection and reporting bias
15
+ - Environmental change and re-simulation
16
+ - Reproducing GDM relationships
17
+ - API reference
18
+ - Reproducibility and random seeds
19
+ - Assumptions and limitations
@@ -0,0 +1,50 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "sobig"
7
+ version = "0.1.0"
8
+ description = "Simulation of observations of biodiversity across gradients."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { file = "LICENSE" }
12
+ authors = [
13
+ { name = "Drew Terasaki Hart", email = "drew.terasaki.hart@gmail.com" }
14
+ ]
15
+ dependencies = [
16
+ "numpy",
17
+ "pandas",
18
+ "numba",
19
+ "nlmpy",
20
+ "scikit-learn",
21
+ "dms-variants",
22
+ "scipy",
23
+ "matplotlib",
24
+ "rasterio",
25
+ "xarray",
26
+ "rioxarray",
27
+ ]
28
+
29
+ [project.optional-dependencies]
30
+ dev = [
31
+ "pytest>=8",
32
+ "ruff>=0.6",
33
+ "build>=1.2",
34
+ "twine>=5",
35
+ ]
36
+
37
+ [project.urls]
38
+ Homepage = "https://github.com/erthward/sobig"
39
+ Repository = "https://github.com/erthward/sobig"
40
+ Issues = "https://github.com/erthward/sobig/issues"
41
+
42
+ [tool.hatch.build.targets.wheel]
43
+ packages = ["src/sobig"]
44
+
45
+ [tool.pytest.ini_options]
46
+ testpaths = ["tests"]
47
+
48
+ [tool.ruff]
49
+ line-length = 100
50
+ target-version = "py310"
@@ -0,0 +1,7 @@
1
+ """Simulation of observations of biodiversity across gradients."""
2
+
3
+ __version__ = "0.1.0"
4
+
5
+ from .sobig import fEnv, Species, Sim, run_demo
6
+
7
+ # Public API exports will go here as the package stabilizes.
@@ -0,0 +1,42 @@
1
+ library(gdm)
2
+ library(terra)
3
+
4
+ # get file paths
5
+ args <- commandArgs(trailingOnly = TRUE)
6
+ site_survey_filename = args[1]
7
+ env_rast_filename = args[2]
8
+ abundance = as.logical(args[3])
9
+ fits_filename = args[4]
10
+ pca_rast_filename = args[5]
11
+
12
+ # read site-survey table
13
+ site_survey = read.csv(site_survey_filename)
14
+
15
+ # read environmental raster data
16
+ env_rast = terra::rast(env_rast_filename)
17
+
18
+ # format data for analysis
19
+ site_pair = gdm::formatsitepair(bioData=site_survey,
20
+ bioFormat=1,
21
+ abundance=abundance,
22
+ siteColumn='site',
23
+ XColumn='x',
24
+ YColumn='y',
25
+ predData=env_rast)
26
+
27
+ # fit GDM
28
+ mod = gdm::gdm(site_pair, geo=F)
29
+ print(summary(mod))
30
+
31
+ # save fitted functions
32
+ fits = as.data.frame(isplineExtract(mod))
33
+ write.csv(fits, fits_filename)
34
+
35
+ # save first <=3 PCs of GDM-transformed env space
36
+ env_rast_trans <- gdm::gdm.transform(model=mod, data=env_rast)
37
+ pca_samp <- terra::prcomp(env_rast_trans, maxcell = 5e5)
38
+ n_pcs = min(3, dim(env_rast)[3])
39
+ pca_rast <- terra::predict(env_rast_trans, pca_samp, index=1:n_pcs)
40
+ pca_rast <- terra::stretch(pca_rast)
41
+ terra::writeRaster(pca_rast, pca_rast_filename, overwrite=T)
42
+ cat("\nGDM OUTPUTS SAVED TO DISK.\n")