cosmicbiomass 0.1.1__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.
- cosmicbiomass-0.1.1/.gitignore +195 -0
- cosmicbiomass-0.1.1/.gitlab-ci.yml +84 -0
- cosmicbiomass-0.1.1/.python-version +1 -0
- cosmicbiomass-0.1.1/LICENSE +21 -0
- cosmicbiomass-0.1.1/PKG-INFO +319 -0
- cosmicbiomass-0.1.1/README.md +276 -0
- cosmicbiomass-0.1.1/cosmicbiomass_flowchart.py +217 -0
- cosmicbiomass-0.1.1/docs/CI_CD.md +92 -0
- cosmicbiomass-0.1.1/poetry.lock +3632 -0
- cosmicbiomass-0.1.1/pyproject.toml +178 -0
- cosmicbiomass-0.1.1/src/cosmicbiomass/__init__.py +90 -0
- cosmicbiomass-0.1.1/src/cosmicbiomass/config.py +70 -0
- cosmicbiomass-0.1.1/src/cosmicbiomass/core.py +595 -0
- cosmicbiomass-0.1.1/src/cosmicbiomass/processing/__init__.py +11 -0
- cosmicbiomass-0.1.1/src/cosmicbiomass/processing/footprint.py +160 -0
- cosmicbiomass-0.1.1/src/cosmicbiomass/processing/statistics.py +268 -0
- cosmicbiomass-0.1.1/src/cosmicbiomass/registry.py +83 -0
- cosmicbiomass-0.1.1/src/cosmicbiomass/sources/__init__.py +7 -0
- cosmicbiomass-0.1.1/src/cosmicbiomass/sources/base.py +49 -0
- cosmicbiomass-0.1.1/src/cosmicbiomass/sources/dlr.py +184 -0
- cosmicbiomass-0.1.1/src/cosmicbiomass/sources/vi.py +501 -0
- cosmicbiomass-0.1.1/tests/__init__.py +0 -0
- cosmicbiomass-0.1.1/tests/conftest.py +382 -0
- cosmicbiomass-0.1.1/tests/test_config.py +96 -0
- cosmicbiomass-0.1.1/tests/test_core.py +349 -0
- cosmicbiomass-0.1.1/tests/test_processing.py +730 -0
- cosmicbiomass-0.1.1/tests/test_registry.py +406 -0
- cosmicbiomass-0.1.1/tests/test_sources.py +567 -0
- cosmicbiomass-0.1.1/tests/test_temporal.py +75 -0
- cosmicbiomass-0.1.1/tests/test_utils.py +388 -0
- cosmicbiomass-0.1.1/uv.lock +3397 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
+
.pdm.toml
|
|
111
|
+
|
|
112
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
113
|
+
__pypackages__/
|
|
114
|
+
|
|
115
|
+
# Celery stuff
|
|
116
|
+
celerybeat-schedule
|
|
117
|
+
celerybeat.pid
|
|
118
|
+
|
|
119
|
+
# SageMath parsed files
|
|
120
|
+
*.sage.py
|
|
121
|
+
|
|
122
|
+
# Environments
|
|
123
|
+
.env
|
|
124
|
+
.venv
|
|
125
|
+
env/
|
|
126
|
+
venv/
|
|
127
|
+
ENV/
|
|
128
|
+
env.bak/
|
|
129
|
+
venv.bak/
|
|
130
|
+
|
|
131
|
+
# Spyder project settings
|
|
132
|
+
.spyderproject
|
|
133
|
+
.spyproject
|
|
134
|
+
|
|
135
|
+
# Rope project settings
|
|
136
|
+
.ropeproject
|
|
137
|
+
|
|
138
|
+
# mkdocs documentation
|
|
139
|
+
/site
|
|
140
|
+
|
|
141
|
+
# mypy
|
|
142
|
+
.mypy_cache/
|
|
143
|
+
.dmypy.json
|
|
144
|
+
dmypy.json
|
|
145
|
+
|
|
146
|
+
# Pyre type checker
|
|
147
|
+
.pyre/
|
|
148
|
+
|
|
149
|
+
# pytype static type analyzer
|
|
150
|
+
.pytype/
|
|
151
|
+
|
|
152
|
+
# Cython debug symbols
|
|
153
|
+
cython_debug/
|
|
154
|
+
|
|
155
|
+
# PyCharm
|
|
156
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
157
|
+
# be added to the global gitignore or merged into this project gitignore. For a PyCharm
|
|
158
|
+
# project, it is common to ignore the .idea/ directory.
|
|
159
|
+
.idea/
|
|
160
|
+
|
|
161
|
+
# VS Code
|
|
162
|
+
.vscode/
|
|
163
|
+
*.code-workspace
|
|
164
|
+
|
|
165
|
+
# OS specific files
|
|
166
|
+
.DS_Store
|
|
167
|
+
.DS_Store?
|
|
168
|
+
._*
|
|
169
|
+
.Spotlight-V100
|
|
170
|
+
.Trashes
|
|
171
|
+
ehthumbs.db
|
|
172
|
+
Thumbs.db
|
|
173
|
+
|
|
174
|
+
# Temporary files
|
|
175
|
+
*.tmp
|
|
176
|
+
*.temp
|
|
177
|
+
*.swp
|
|
178
|
+
*.swo
|
|
179
|
+
*~
|
|
180
|
+
|
|
181
|
+
# Project specific
|
|
182
|
+
# Debug and demo scripts can be kept for development
|
|
183
|
+
debug_footprint.py
|
|
184
|
+
plot_results.py
|
|
185
|
+
simple_demo.py
|
|
186
|
+
test_import.py
|
|
187
|
+
_cosmicbiomass/*
|
|
188
|
+
comprehensive_footprint_analysis.py
|
|
189
|
+
readme_scripts.py
|
|
190
|
+
|
|
191
|
+
# Generated plots (uncomment if you don't want to track generated plots)
|
|
192
|
+
*.png
|
|
193
|
+
*.jpg
|
|
194
|
+
*.pdf
|
|
195
|
+
*.html
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
stages:
|
|
2
|
+
- test
|
|
3
|
+
- build
|
|
4
|
+
- publish
|
|
5
|
+
|
|
6
|
+
variables:
|
|
7
|
+
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
|
8
|
+
UV_CACHE_DIR: "$CI_PROJECT_DIR/.uv-cache"
|
|
9
|
+
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
|
10
|
+
UV_PYTHON: "python3.12"
|
|
11
|
+
UV_PYTHON_PREFERENCE: "only-system"
|
|
12
|
+
UV_PYTHON_DOWNLOAD: "0"
|
|
13
|
+
|
|
14
|
+
default:
|
|
15
|
+
image: python:3.12-slim
|
|
16
|
+
tags:
|
|
17
|
+
- hifis-linux-small-amd64
|
|
18
|
+
- dind
|
|
19
|
+
- hifis
|
|
20
|
+
before_script:
|
|
21
|
+
- apt-get update && apt-get install -y --no-install-recommends libexpat1 && rm -rf /var/lib/apt/lists/*
|
|
22
|
+
- python -m pip install --upgrade pip uv
|
|
23
|
+
|
|
24
|
+
cache:
|
|
25
|
+
key: "uv-cache"
|
|
26
|
+
paths:
|
|
27
|
+
- .uv-cache/
|
|
28
|
+
- .cache/pip/
|
|
29
|
+
|
|
30
|
+
pytest:
|
|
31
|
+
stage: test
|
|
32
|
+
rules:
|
|
33
|
+
- if: '$CI_COMMIT_TAG'
|
|
34
|
+
when: never
|
|
35
|
+
- when: on_success
|
|
36
|
+
script:
|
|
37
|
+
- uv sync --group dev --frozen
|
|
38
|
+
- uv run ruff check .
|
|
39
|
+
- uv run pytest
|
|
40
|
+
|
|
41
|
+
build:
|
|
42
|
+
stage: build
|
|
43
|
+
script:
|
|
44
|
+
- |
|
|
45
|
+
if [ -n "$CI_COMMIT_TAG" ]; then
|
|
46
|
+
VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
|
|
47
|
+
TAG_VERSION=${CI_COMMIT_TAG#v}
|
|
48
|
+
if [ "$TAG_VERSION" != "$VERSION" ]; then
|
|
49
|
+
echo "Tag version ($TAG_VERSION) does not match pyproject.toml ($VERSION)."
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
fi
|
|
53
|
+
- uv build
|
|
54
|
+
- uv publish --dry-run dist/*.whl dist/*.tar.gz
|
|
55
|
+
artifacts:
|
|
56
|
+
paths:
|
|
57
|
+
- dist/
|
|
58
|
+
expire_in: 7 days
|
|
59
|
+
|
|
60
|
+
publish_testpypi:
|
|
61
|
+
stage: publish
|
|
62
|
+
needs:
|
|
63
|
+
- job: build
|
|
64
|
+
artifacts: true
|
|
65
|
+
dependencies:
|
|
66
|
+
- build
|
|
67
|
+
rules:
|
|
68
|
+
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+a\d+$/'
|
|
69
|
+
script:
|
|
70
|
+
- ls -la dist
|
|
71
|
+
- uv publish --publish-url https://test.pypi.org/legacy/ --token "$TESTPYPI_TOKEN" dist/*.whl dist/*.tar.gz
|
|
72
|
+
|
|
73
|
+
publish_pypi:
|
|
74
|
+
stage: publish
|
|
75
|
+
needs:
|
|
76
|
+
- job: build
|
|
77
|
+
artifacts: true
|
|
78
|
+
dependencies:
|
|
79
|
+
- build
|
|
80
|
+
rules:
|
|
81
|
+
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/'
|
|
82
|
+
script:
|
|
83
|
+
- ls -la dist
|
|
84
|
+
- uv publish --token "$PYPI_TOKEN" dist/*.whl dist/*.tar.gz
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13.2
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Louis Ferdinand Trinkle
|
|
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.
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cosmicbiomass
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Aboveground biomass extraction with footprint-weighted statistics.
|
|
5
|
+
Project-URL: Homepage, https://codebase.helmholtz.cloud/louis-ferdinand.trinkle/cosmicbiomass
|
|
6
|
+
Project-URL: Repository, https://codebase.helmholtz.cloud/louis-ferdinand.trinkle/cosmicbiomass
|
|
7
|
+
Project-URL: Issues, https://codebase.helmholtz.cloud/louis-ferdinand.trinkle/cosmicbiomass/issues
|
|
8
|
+
Author-email: LFT-W47 <louis.trinkle@gmail.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agbd,biomass,crns,geospatial,remote-sensing,stac
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: cubo<2025.0.0,>=2024.8.0
|
|
25
|
+
Requires-Dist: earthengine-api<2.0.0,>=1.1.4
|
|
26
|
+
Requires-Dist: geopandas<0.15.0,>=0.14.0
|
|
27
|
+
Requires-Dist: joblib<2.0.0,>=1.3.0
|
|
28
|
+
Requires-Dist: numpy<2.0.0,>=1.24.0
|
|
29
|
+
Requires-Dist: pandas<3.0.0,>=2.0.0
|
|
30
|
+
Requires-Dist: planetary-computer<2.0.0,>=1.0.0
|
|
31
|
+
Requires-Dist: pydantic<3.0.0,>=2.0.0
|
|
32
|
+
Requires-Dist: pystac-client<1.0.0,>=0.8.0
|
|
33
|
+
Requires-Dist: rasterio<2.0.0,>=1.3.0
|
|
34
|
+
Requires-Dist: rioxarray<0.20.0,>=0.19.0
|
|
35
|
+
Requires-Dist: scikit-learn<2.0.0,>=1.7.0
|
|
36
|
+
Requires-Dist: scipy<2.0.0,>=1.11.0
|
|
37
|
+
Requires-Dist: seaborn<0.14.0,>=0.13.2
|
|
38
|
+
Requires-Dist: setuptools>=80.9.0
|
|
39
|
+
Requires-Dist: shapely<3.0.0,>=2.0.0
|
|
40
|
+
Requires-Dist: stackstac<1.0.0,>=0.5.1
|
|
41
|
+
Requires-Dist: xee<1.0.0,>=0.0.13
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
|
|
44
|
+
# CosmicBiomass
|
|
45
|
+
|
|
46
|
+
A modern Python package for extracting and analyzing aboveground biomass density (AGBD) from satellite data sources with support for geospatial footprint weighting and statistical analysis.
|
|
47
|
+
|
|
48
|
+
## Features
|
|
49
|
+
|
|
50
|
+
- 🌍 **Geospatial biomass extraction** from DLR STAC data sources (2017-2023)
|
|
51
|
+
- 📊 **Footprint-weighted statistics** with circular, Gaussian, and CRNS weighting schemes
|
|
52
|
+
- 🔬 **CRNS weighting function** implementing Schrön et al. (2017) for cosmic ray neutron sensing
|
|
53
|
+
- 🎯 **High precision analysis** with uncertainty quantification and outlier detection
|
|
54
|
+
- 🏗️ **Modular architecture** with pluggable data sources and processing components
|
|
55
|
+
- ✅ **89% test coverage** with comprehensive unit and integration tests
|
|
56
|
+
- 🐍 **Modern Python 3.10+** with type hints, uv-managed environments, and `src/` layout
|
|
57
|
+
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
### Installation
|
|
61
|
+
|
|
62
|
+
#### Option 1: Install from GitHub (Recommended)
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Install directly from GitHub using pip
|
|
66
|
+
pip install git+https://codebase.helmholtz.cloud/louis-ferdinand.trinkle/cosmicbiomass.git
|
|
67
|
+
|
|
68
|
+
# Or install in development mode for contributions
|
|
69
|
+
pip install -e git+hhttps://codebase.helmholtz.cloud/louis-ferdinand.trinkle/cosmicbiomass.git#egg=cosmicbiomass
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### Option 2: Install with conda/mamba
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# First install dependencies via conda
|
|
76
|
+
conda install -c conda-forge numpy xarray matplotlib pyproj
|
|
77
|
+
|
|
78
|
+
# Then install cosmicbiomass from GitHub
|
|
79
|
+
pip install git+https://codebase.helmholtz.cloud/louis-ferdinand.trinkle/cosmicbiomass.git
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Option 3: Development Installation (uv)
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Clone the repository
|
|
86
|
+
git clone https://codebase.helmholtz.cloud/louis-ferdinand.trinkle/cosmicbiomass.git
|
|
87
|
+
cd cosmicbiomass
|
|
88
|
+
|
|
89
|
+
# Create a virtual environment
|
|
90
|
+
uv venv .venv
|
|
91
|
+
|
|
92
|
+
# Activate the environment
|
|
93
|
+
source .venv/bin/activate
|
|
94
|
+
|
|
95
|
+
# Install the package in development mode
|
|
96
|
+
uv pip install -e .
|
|
97
|
+
|
|
98
|
+
# Lock dependencies for reproducibility
|
|
99
|
+
uv lock
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Reproducible Workflow Example
|
|
104
|
+
|
|
105
|
+
Here's a complete example extracting biomass data at the TERENO Hohes Holz station:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
import cosmicbiomass
|
|
109
|
+
|
|
110
|
+
# TERENO Hohes Holz station coordinates
|
|
111
|
+
lat, lon = 52.09, 11.226 # degrees N, E
|
|
112
|
+
footprint_radius = 240 # meters
|
|
113
|
+
|
|
114
|
+
# Extract biomass data with 240m circular footprint
|
|
115
|
+
result = cosmicbiomass.get_average_biomass(
|
|
116
|
+
lat=lat,
|
|
117
|
+
lon=lon,
|
|
118
|
+
radius=footprint_radius,
|
|
119
|
+
source="dlr",
|
|
120
|
+
dataset="agbd_2018" # Available: 2017-2023
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
# Access results
|
|
124
|
+
biomass_mgha = result['summary']['mean_biomass_Mg_ha']
|
|
125
|
+
uncertainty_mgha = result['summary']['uncertainty_Mg_ha']
|
|
126
|
+
|
|
127
|
+
print(f"Mean AGBD: {biomass_mgha:.1f} ± {uncertainty_mgha:.1f} Mg/ha")
|
|
128
|
+
# Output: Mean AGBD: 202.6 ± 27.8 Mg/ha
|
|
129
|
+
|
|
130
|
+
# Access detailed information
|
|
131
|
+
print(f"Footprint coverage: {result['footprint']['effective_pixels']} pixels")
|
|
132
|
+
print(f"Data source: {result['data_info']['source']}")
|
|
133
|
+
print(f"Dataset: {result['data_info']['dataset']}")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Available Datasets
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
# List all available datasets
|
|
140
|
+
datasets = cosmicbiomass.list_available_datasets(source="dlr")
|
|
141
|
+
print("Available years:", list(datasets['datasets'].keys()))
|
|
142
|
+
# Output: ['agbd_2017', 'agbd_2018', 'agbd_2019', 'agbd_2020', 'agbd_2021', 'agbd_2022', 'agbd_2023']
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## API Reference
|
|
146
|
+
|
|
147
|
+
### Core Functions
|
|
148
|
+
|
|
149
|
+
#### `get_average_biomass(lat, lon, radius=500, source="dlr", dataset="agbd_2021", **kwargs)`
|
|
150
|
+
|
|
151
|
+
Extract footprint-weighted biomass statistics for a location.
|
|
152
|
+
|
|
153
|
+
**Parameters:**
|
|
154
|
+
|
|
155
|
+
- `lat`, `lon` (float): Center coordinates in WGS84 decimal degrees
|
|
156
|
+
- `radius` (float): Footprint radius in meters (default: 500)
|
|
157
|
+
- `source` (str): Data source name (default: "dlr")
|
|
158
|
+
- `dataset` (str): Dataset identifier like "agbd_2018" (default: "agbd_2021")
|
|
159
|
+
- `footprint_shape` (str): "circular", "gaussian", or "crns" (default: "crns")
|
|
160
|
+
- `include_uncertainty` (bool): Include uncertainty estimation (default: True)
|
|
161
|
+
- `outlier_method` (str): "iqr", "zscore", or None for outlier detection
|
|
162
|
+
|
|
163
|
+
**Returns:**
|
|
164
|
+
Dictionary with biomass statistics, location info, and metadata.
|
|
165
|
+
|
|
166
|
+
#### `list_available_datasets(source="dlr")`
|
|
167
|
+
|
|
168
|
+
Get information about available datasets for a data source.
|
|
169
|
+
|
|
170
|
+
#### `validate_coordinates(lat, lon)`
|
|
171
|
+
|
|
172
|
+
Validate latitude/longitude coordinates are within valid ranges.
|
|
173
|
+
|
|
174
|
+
## Directory Structure
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
cosmicbiomass/
|
|
178
|
+
├── README.md
|
|
179
|
+
├── pyproject.toml # Python project configuration
|
|
180
|
+
├── src/
|
|
181
|
+
│ └── cosmicbiomass/
|
|
182
|
+
│ ├── __init__.py # Public API
|
|
183
|
+
│ ├── core.py # Main analysis functions
|
|
184
|
+
│ ├── config.py # Configuration classes
|
|
185
|
+
│ ├── registry.py # Data source management
|
|
186
|
+
│ ├── processing/ # Statistical and footprint processing
|
|
187
|
+
│ └── sources/ # Data source implementations
|
|
188
|
+
└── tests/ # Comprehensive test suite (89% coverage)
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Dependency Lock
|
|
192
|
+
|
|
193
|
+
Use the lockfile for reproducible environments:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
uv lock
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Testing
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Run all tests
|
|
203
|
+
uv run pytest
|
|
204
|
+
|
|
205
|
+
# Run with coverage report
|
|
206
|
+
uv run pytest --cov=cosmicbiomass --cov-report=html
|
|
207
|
+
|
|
208
|
+
# Run specific test modules
|
|
209
|
+
uv run pytest tests/test_core.py -v
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Publishing to PyPI
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# Build wheel and sdist
|
|
216
|
+
uv build
|
|
217
|
+
|
|
218
|
+
# Publish to PyPI (requires credentials)
|
|
219
|
+
uv publish
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## CI/CD (GitLab)
|
|
223
|
+
|
|
224
|
+
See [docs/CI_CD.md](docs/CI_CD.md) for the GitLab pipeline, runner tags, and release tag formats.
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
## Advanced Usage
|
|
228
|
+
|
|
229
|
+
### Custom Footprint Analysis
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
# CRNS footprint (default) - Schrön et al. (2017) weighting
|
|
233
|
+
result = cosmicbiomass.get_average_biomass(
|
|
234
|
+
lat=52.09, lon=11.226,
|
|
235
|
+
radius=500,
|
|
236
|
+
footprint_shape="crns", # Cosmic ray neutron sensing weighting
|
|
237
|
+
dataset="agbd_2020"
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
# Gaussian footprint with outlier detection
|
|
241
|
+
result_gaussian = cosmicbiomass.get_average_biomass(
|
|
242
|
+
lat=52.09, lon=11.226,
|
|
243
|
+
radius=500,
|
|
244
|
+
footprint_shape="gaussian",
|
|
245
|
+
outlier_method="iqr",
|
|
246
|
+
dataset="agbd_2020"
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
# Access detailed footprint info
|
|
250
|
+
print(f"Effective pixels: {result['footprint']['effective_pixels']}")
|
|
251
|
+
print(f"Total weight: {result['footprint']['total_weight']:.1f}")
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Multi-year Analysis
|
|
255
|
+
|
|
256
|
+
```python
|
|
257
|
+
series = cosmicbiomass.get_average_biomass_timeseries(
|
|
258
|
+
lat=52.09,
|
|
259
|
+
lon=11.226,
|
|
260
|
+
radius=240,
|
|
261
|
+
dataset="agbd_{year}",
|
|
262
|
+
start_time="2017-01-01",
|
|
263
|
+
end_time="2023-12-31",
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
biomass_time_series = [
|
|
267
|
+
{
|
|
268
|
+
"year": entry["year"],
|
|
269
|
+
"biomass": entry["result"]["summary"]["mean_biomass_Mg_ha"],
|
|
270
|
+
"uncertainty": entry["result"]["summary"]["uncertainty_Mg_ha"],
|
|
271
|
+
}
|
|
272
|
+
for entry in series
|
|
273
|
+
]
|
|
274
|
+
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### VI-driven Seasonal Interpolation (pandas output)
|
|
278
|
+
|
|
279
|
+
Use vegetation indices (LAI/EVI/NDVI) to create a higher-frequency biomass series. The
|
|
280
|
+
frequency is inferred from your VI data or you can provide one (e.g., "1H", "1D").
|
|
281
|
+
|
|
282
|
+
```python
|
|
283
|
+
seasonal = cosmicbiomass.get_seasonal_biomass_timeseries(
|
|
284
|
+
lat=52.09,
|
|
285
|
+
lon=11.226,
|
|
286
|
+
radius=170,
|
|
287
|
+
dataset="agbd_{year}",
|
|
288
|
+
start_time="2017-01-01",
|
|
289
|
+
end_time="2023-12-31",
|
|
290
|
+
target_frequency="1D",
|
|
291
|
+
vi_source="auto", # fetch LAI via GEE, EVI/NDVI via Planetary Computer
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
print(seasonal.head())
|
|
295
|
+
```
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Data Sources
|
|
299
|
+
|
|
300
|
+
### DLR Global Aboveground Biomass Density
|
|
301
|
+
|
|
302
|
+
- **Coverage**: 2017-2023 annual products
|
|
303
|
+
- **Resolution**: 10m spatial resolution
|
|
304
|
+
- **Units**: Mg/ha (megagrams per hectare)
|
|
305
|
+
- **Uncertainty**: Available via data spread analysis
|
|
306
|
+
- **Access**: STAC catalog via `cubo` integration
|
|
307
|
+
|
|
308
|
+
## Contributing
|
|
309
|
+
|
|
310
|
+
- Follow PEP 8 and modern Python best practices
|
|
311
|
+
- Add tests for new features (maintain >85% coverage)
|
|
312
|
+
- Use f-strings, pathlib, and type hints
|
|
313
|
+
- Run `uv run pytest` before submitting changes
|
|
314
|
+
|
|
315
|
+
## License
|
|
316
|
+
|
|
317
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
318
|
+
|
|
319
|
+
Copyright (c) 2025 Louis Ferdinand Trinkle
|