MIT License

项目介绍

earth-chris/xleaf 是一个托管在 GitHub 上的开源项目,主要使用 Fortran 编写,采用 MIT License 许可证,目前获得 16 个 Star、2 次 Fork。

仓库全名
earth-chris/xleaf
开源许可证
MIT License
Star 数
16
Fork 数
2

README 摘要

xleaf Leaf and canopy radiative transfer modeling tools built on PROSPECT-D and SAIL. Introduction 🌳 xleaf is a python package for running leaf and canopy simulation models using PROSAIL. It provides python bindings to the PROSPECT-D & 4SAIL Fortran code. 🌿 It includes sensible defaults that make it easy to get up and running quickly, and clear code documentation in the form of docstrings and type hints. 📚 All…

完整内容见 GitHub 原始 README 或本页 。

常见问题

xleaf 用什么语言开发?

主要使用 Fortran 编写,采用 MIT License 许可证,目前有 16 个 Star。

xleaf 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 xleaf 的源码?

可以直接克隆仓库:git clone https://github.com/earth-chris/xleaf.git,默认分支为 main;安装与运行步骤见仓库 README。

xleaf 最近还在维护吗?

仓库最近一次更新为 8月4日,当前没有未关闭的 Issue;Star 数为 16,可作为社区活跃度的参考。

关于

Leaf and canopy radiative transfer modeling tools built on PROSPECT-D and SAIL

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
21
价值分
10
活跃状态
活跃

README

xleaf

Canopy reflectance simulated in rainbows.

Leaf and canopy radiative transfer modeling tools built on PROSPECT-D and SAIL.

GitHub GitHub last commit PyPI version DOI


Introduction

🌳 xleaf is a python package for running leaf and canopy simulation models using PROSAIL. It provides python bindings to the PROSPECT-D & 4SAIL Fortran code.

🌿 It includes sensible defaults that make it easy to get up and running quickly, and clear code documentation in the form of docstrings and type hints.

📚 All credit for the fundamental modeling code and for the underlying science belongs to the original researchers. xleaf is mostly a wrapper. Please cite their most recent research:

@article{feret2017prospect,
  title={PROSPECT-D: Towards modeling leaf optical properties through a complete lifecycle},
  author={Feret, J-B and Gitelson, AA and Noble, SD and Jacquemoud, S},
  journal={Remote Sensing of Environment},
  volume={193},
  pages={204--215},
  year={2017},
  publisher={Elsevier}
}

🧙 Shout out to my man JB.

If you used xleaf in your research and want to credit it, please cite:

@software{anderson_xleaf_2026,
  author       = {Anderson, Christopher B.},
  title        = {xleaf: Leaf and canopy radiative transfer modeling tools for PROSPECT-D and SAIL},
  month        = aug,
  year         = 2026,
  version      = {1.2.2},
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.21786969},
  url          = {https://github.com/earth-chris/xleaf}
}

Install

Install from PyPI:

pip install xleaf

Development

This project uses pixi to manage dependencies and builds. To set up a development environment:

pixi install

This installs all dependencies including the Fortran compiler (gfortran), meson, and numpy. To run tests:

pixi run test

Leaf and canopy simulations

import xleaf
import matplotlib.pyplot as plt

# run with off-the-shelf defaults
leaf = xleaf.simulate_leaf()

# or specify detailed parameters
canopy = xleaf.simulate_canopy(
    chl = 40, # ug/cm2
    car = 8, # ug/cm2
    antho = 0.5, # ug/cm2
    ewt = 0.01, # cm
    lma = 0.009, # g/cm2
    N = 1.5, # unitless
    lai = 3.0, # m2/m2
    lidf = 30, # degrees
    soil_dryness = 0.75, # %
    solar_zenith = 35, # degrees
    solar_azimuth = 120, # degrees
    view_zenith = 0, # degrees
    view_azimuth = 60, # degrees
    hot_spot = 0.01, # unitless
)

# and plot them together
plt.plot(xleaf.wavelengths, leaf, label='leaf')
plt.plot(xleaf.wavelengths, canopy, label='canopy')
plt.legend()

📄 The definitions and expected range of values for each parameter are described in the xleaf docstrings.


Chaining leaf and canopy models

🔗 simulate_canopy runs PROSPECT and 4SAIL together. If you’d rather run the canopy model on a leaf spectrum you already have — a measured spectrum, or one from a different leaf model — use simulate_sail. It takes leaf reflectance and transmittance directly, so you can pair it with simulate_leaf(transmittance=True):

import xleaf
import matplotlib.pyplot as plt

# simulate a leaf, returning both reflectance and transmittance
reflectance, transmittance = xleaf.simulate_leaf(
    chl = 40, # ug/cm2
    car = 8, # ug/cm2
    antho = 0.5, # ug/cm2
    ewt = 0.01, # cm
    lma = 0.009, # g/cm2
    N = 1.5, # unitless
    transmittance = True,
)

# then run the canopy model on that leaf spectrum
canopy = xleaf.simulate_sail(
    reflectance,
    transmittance,
    lai = 3.0, # m2/m2
    lidf = 30, # degrees
    soil_dryness = 0.75, # %
    solar_zenith = 35, # degrees
    solar_azimuth = 120, # degrees
    view_zenith = 0, # degrees
    view_azimuth = 60, # degrees
    hot_spot = 0.01, # unitless
)

plt.plot(xleaf.wavelengths, reflectance, label='leaf')
plt.plot(xleaf.wavelengths, canopy, label='canopy')
plt.legend()

This enables canopy simulations from field-measured reflectance and transmittence.


Random forests

📊 xleaf provides classes for generating random parameters within the global range of expected values. These classes have a .sample() method for generating an appropriate random value based on a literature review.

import xleaf
import matplotlib.pyplot as plt

# generate 5 random leaf spectra from global defaults
for idx in range(5):
    chl = xleaf.ChlorophyllSampler.sample()
    car = xleaf.CarotenoidSampler.sample()
    antho = xleaf.AnthocyaninSampler.sample()
    ewt = xleaf.EWTSampler.sample()
    lma = xleaf.LMASampler.sample()
    N = xleaf.NSampler.sample()
    leaf = xleaf.simulate_leaf(chl, car, antho, ewt, lma, N)
    plt.plot(xleaf.wavelengths, leaf, label=f"leaf {idx+1}")

plt.legend()

🧪 Or experiment by setting the range of values yourself:

import xleaf
import matplotlib.pyplot as plt

MyLAISampler = xleaf.UniformSampler(min=2, max=6)
MyVZASampler = xleaf.NormalSampler(mean=0, stdv=3, min=-10, max=10)

# generate 5 random canopy spectra just varying LAI/VZA
for idx in range(5):
    lai = MyLAISampler.sample()
    vza = MyVZASampler.sample()
    canopy = xleaf.simulate_canopy(lai=lai, view_zenith=vza)
    plt.plot(xleaf.wavelengths, canopy, label=f"lai: {lai:0.2f}, vza: {vza:0.2f}")

plt.legend()

⚡ These parameters don’t always vary independently. Try to exercise caution when constructing parameter estimates to ensure biological realism.


Developed by

Christopher Anderson[^1]

Twitter Follow GitHub Stars

[^1]: Planet Labs PBC, San Francisco

评论

暂无评论