# vegspec
A compilation of spectral vegetation indices and transformations in Python
The goal of the vegspec package is to encapsulate computations of 1) more than 145 published spectral vegetation indices and 2) several published pretreatment transformations for vegetative spectral reflectance data.
Scientific background material for the methods implemented in the vegspec package is given [here](http://github.com/kthorp/vegspec/tree/main/docs/document.pdf).
## Source Code
The spectral methodologies are contained in one Python module (i.e., [vegspec.py](http://github.com/kthorp/vegspec/tree/main/src/vegspec/vegspec.py)). The module defines a class (i.e., `VegSpec`) to encapsulate all the computations for one vegetative reflectance spectrum. To analyze sets of multiple spectral measurements, users can develop a list of unique `VegSpec` instances for each measurement. At minimum, each `VegSpec` instance requires inputting two 1-dimensional lists that specify the spectral reflecance factors and associated wavelengths.
The source code is available [here](http://github.com/kthorp/vegspec/tree/main/src/vegspec/vegspec.py).
## Install
`pip install vegspec`
## Quickstart
### Import the package
`import vegspec as vs`
### Instantiate a VegSpec class
`spectrum = vs.VegSpec(wl,rf)`
where required inputs are defined as follows:
* wl : list, Wavelengths (nm) corresponding to the data in rf
* rf : list, Reflectance factors (0 to 1) for a single spectral scan
Other optional arguments for the `VegSpec` constructor are as follows:
* fs1 : int, optional, Filter size for Savitsky-Golay first derivatives, (default = 7)
* po1 : int, optional, Polynomial order for Savitsky-Golay first derivatives, (default = 2)
* fs2 : int, optional, Filter size for Savitsky-Golay second derivatives, (default = 15)
* po2 : int, optional, Polynomial order for Savitsky-Golay second derivatives, (default = 2)
* wlblu : float, optional, Primary wavelength of visible blue light (nm), (default = 480.)
* wlgrn : float, optional, Primary wavelength of visible green light (nm), (default = 550.)
* wlred : float, optional, Primary wavelength of visible red light (nm), (default = 670.)
* wlnir : float, optional, Primary wavelength of near-infrared light (nm), (default = 800.)
* solslp : float, optional, Slope of the soil line, (default = 1.166)
* solicpt : float, optional, Intercept of the soil line, (default = 0.042)
* getlirf : boolean, optional, If True, compute log inverse reflectance, (default = True)
* getcrrf : boolean, optional, If True, compute continuum removed spectra, (default = True)
The `VegSpec` class constructor will automatically compute all spectral vegetation indices and spectral data pretreatment transformations unless optional arguments (i.e., `getlirf` and `getcrrf`) are changed to `False`. If increased computational efficiency is needed, consider changing `getcrrf` to `False`.
### Access the results
```
for key in spectrum.indices.keys():
print(key+',{:f}'.format(spectrum.indices[key]))
```
`print(spectrum.rfd1)`
The VegSpec class stores the computational results in the following attribute variables:
* rfd1 : numpy.ndarray, A 1D array of the Savitsky-Golay first derivative of rf
* rfd2 : numpy.ndarray, A 1D array of the Savitsky-Golay second derivative of rf
* lirf : numpy.ndarray, A 1D array of the logarithm of inverse rf (log10(1/rf))
* lirfd1 : numpy.ndarray, A 1D array of the Savitsky-Golay first derivative of lirf
* lirfd2 : numpy.ndarry, A 1D array of the Savitsky-Golay second derivative of lirf
* crrf : numpy.ndarray, A 1D array of the continuum removal of rf
* indices : dict, A dictionary of 145+ published spectral vegetation indices
For further information on the keys of the `indices` attribute, see the documentation [here](http://github.com/kthorp/vegspec/tree/main/docs/document.pdf).
## Test suite and further examples
A test suite and further example scripts for using the vegspec package are [here](https://github.com/kthorp/vegspec/tree/main/tests).
[test0](https://github.com/kthorp/vegspec/tree/main/tests/test0) - Demonstrates the computation of spectral transformations for one example spectrum, collected from a cotton leaf at Maricopa, Arizona.
[test1](https://github.com/kthorp/vegspec/tree/main/tests/test1) - Demonstrates computation of spectral vegetation indices for cotton leaf spectra collected at Maricopa, Arizona in 2021 and 2022 and correlates the indices with leaf chlorophyll.
[test2](https://github.com/kthorp/vegspec/tree/main/tests/test2) - Demonstrates computation of spectral vegetation indices for cotton leaf spectra collected at Maricopa, Arizona in 2019 and 2020 and correlates the indices with leaf chlorophyll and leaf nitrogen.
[test3](https://github.com/kthorp/vegspec/tree/main/tests/test3) - Demonstrates computation of spectral vegetation indices for wheat canopy spectra collected at Maricopa, Arizona in 2011 and 2012 and correlates the indices with leaf area index, canopy weight, and plant nitrogen.
[test4](https://github.com/kthorp/vegspec/tree/main/tests/test4) - Demonstrates computation of spectral vegetation indices for cotton canopy spectra collected at Maricopa, Arizona in 2010, 2011, and 2012 and correlates the indices with leaf chlorophyll, leaf water thickness, specific leaf weight, and leaf area index.
[test5](https://github.com/kthorp/vegspec/tree/main/tests/test5) - Demonstrates computation of spectral vegetation indices for lesquerella canopy spectra collected at Maricopa, Arizona in 2008 and 2009 and correlates the indices with canopy weight, flower count, silique count, and silique dry weight.
[test6](https://github.com/kthorp/vegspec/tree/main/tests/test6) - Demonstrates computation of spectral vegetation indices for maize canopy spectra collected at Ames, Iowa in 2004 and correlates the indices with plant stand density.
[test7](https://github.com/kthorp/vegspec/tree/main/tests/test7) - Demonstrates computation of spectral vegetation indices for soybean canopy spectra collected at Urbana, Illinois in 2001 and correlates the indices with vegetation and weed cover.
## Further information
The vegspec package is further described in the following article:
Thorp, K. R., 2024. vegspec: A compilation of spectral vegetation indices and transformations in Python. SoftwareX. In review.
Also, the vegspec package was used to conduct the following research:
Thorp, K. R., Thompson, A. L., Herritt, M. T., 2024. Phenotyping cotton leaf chlorophyll via proximal hyperspectral reflectance sensing, spectral vegetation indices, and machine learning. Frontiers in Plant Science. In prep.
Raw data
{
"_id": null,
"home_page": "http://github.com/kthorp/vegspec",
"name": "vegspec",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Dr. Kelly R. Thorp",
"author_email": "kelly.thorp@usda.gov",
"download_url": "https://files.pythonhosted.org/packages/9f/43/db7b04e7db75d4530e66a13151328b0b946118c5c247da6b1e086678734d/vegspec-1.0.4.tar.gz",
"platform": null,
"description": "# vegspec\nA compilation of spectral vegetation indices and transformations in Python\n\nThe goal of the vegspec package is to encapsulate computations of 1) more than 145 published spectral vegetation indices and 2) several published pretreatment transformations for vegetative spectral reflectance data.\n\nScientific background material for the methods implemented in the vegspec package is given [here](http://github.com/kthorp/vegspec/tree/main/docs/document.pdf).\n\n## Source Code\nThe spectral methodologies are contained in one Python module (i.e., [vegspec.py](http://github.com/kthorp/vegspec/tree/main/src/vegspec/vegspec.py)). The module defines a class (i.e., `VegSpec`) to encapsulate all the computations for one vegetative reflectance spectrum. To analyze sets of multiple spectral measurements, users can develop a list of unique `VegSpec` instances for each measurement. At minimum, each `VegSpec` instance requires inputting two 1-dimensional lists that specify the spectral reflecance factors and associated wavelengths.\n\nThe source code is available [here](http://github.com/kthorp/vegspec/tree/main/src/vegspec/vegspec.py).\n\n## Install\n`pip install vegspec`\n\n## Quickstart\n\n### Import the package\n`import vegspec as vs`\n\n### Instantiate a VegSpec class\n`spectrum = vs.VegSpec(wl,rf)`\n\nwhere required inputs are defined as follows:\n\n* wl : list, Wavelengths (nm) corresponding to the data in rf\n* rf : list, Reflectance factors (0 to 1) for a single spectral scan\n\nOther optional arguments for the `VegSpec` constructor are as follows:\n\n* fs1 : int, optional, Filter size for Savitsky-Golay first derivatives, (default = 7)\n* po1 : int, optional, Polynomial order for Savitsky-Golay first derivatives, (default = 2)\n* fs2 : int, optional, Filter size for Savitsky-Golay second derivatives, (default = 15)\n* po2 : int, optional, Polynomial order for Savitsky-Golay second derivatives, (default = 2)\n* wlblu : float, optional, Primary wavelength of visible blue light (nm), (default = 480.)\n* wlgrn : float, optional, Primary wavelength of visible green light (nm), (default = 550.)\n* wlred : float, optional, Primary wavelength of visible red light (nm), (default = 670.)\n* wlnir : float, optional, Primary wavelength of near-infrared light (nm), (default = 800.)\n* solslp : float, optional, Slope of the soil line, (default = 1.166)\n* solicpt : float, optional, Intercept of the soil line, (default = 0.042)\n* getlirf : boolean, optional, If True, compute log inverse reflectance, (default = True)\n* getcrrf : boolean, optional, If True, compute continuum removed spectra, (default = True)\n\nThe `VegSpec` class constructor will automatically compute all spectral vegetation indices and spectral data pretreatment transformations unless optional arguments (i.e., `getlirf` and `getcrrf`) are changed to `False`. If increased computational efficiency is needed, consider changing `getcrrf` to `False`.\n\n### Access the results\n```\nfor key in spectrum.indices.keys():\n print(key+',{:f}'.format(spectrum.indices[key]))\n```\n\n`print(spectrum.rfd1)`\n\nThe VegSpec class stores the computational results in the following attribute variables:\n* rfd1 : numpy.ndarray, A 1D array of the Savitsky-Golay first derivative of rf\n* rfd2 : numpy.ndarray, A 1D array of the Savitsky-Golay second derivative of rf\n* lirf : numpy.ndarray, A 1D array of the logarithm of inverse rf (log10(1/rf))\n* lirfd1 : numpy.ndarray, A 1D array of the Savitsky-Golay first derivative of lirf\n* lirfd2 : numpy.ndarry, A 1D array of the Savitsky-Golay second derivative of lirf\n* crrf : numpy.ndarray, A 1D array of the continuum removal of rf\n* indices : dict, A dictionary of 145+ published spectral vegetation indices\n\nFor further information on the keys of the `indices` attribute, see the documentation [here](http://github.com/kthorp/vegspec/tree/main/docs/document.pdf).\n\n## Test suite and further examples\nA test suite and further example scripts for using the vegspec package are [here](https://github.com/kthorp/vegspec/tree/main/tests).\n\n[test0](https://github.com/kthorp/vegspec/tree/main/tests/test0) - Demonstrates the computation of spectral transformations for one example spectrum, collected from a cotton leaf at Maricopa, Arizona.\n\n[test1](https://github.com/kthorp/vegspec/tree/main/tests/test1) - Demonstrates computation of spectral vegetation indices for cotton leaf spectra collected at Maricopa, Arizona in 2021 and 2022 and correlates the indices with leaf chlorophyll.\n\n[test2](https://github.com/kthorp/vegspec/tree/main/tests/test2) - Demonstrates computation of spectral vegetation indices for cotton leaf spectra collected at Maricopa, Arizona in 2019 and 2020 and correlates the indices with leaf chlorophyll and leaf nitrogen.\n\n[test3](https://github.com/kthorp/vegspec/tree/main/tests/test3) - Demonstrates computation of spectral vegetation indices for wheat canopy spectra collected at Maricopa, Arizona in 2011 and 2012 and correlates the indices with leaf area index, canopy weight, and plant nitrogen.\n\n[test4](https://github.com/kthorp/vegspec/tree/main/tests/test4) - Demonstrates computation of spectral vegetation indices for cotton canopy spectra collected at Maricopa, Arizona in 2010, 2011, and 2012 and correlates the indices with leaf chlorophyll, leaf water thickness, specific leaf weight, and leaf area index.\n\n[test5](https://github.com/kthorp/vegspec/tree/main/tests/test5) - Demonstrates computation of spectral vegetation indices for lesquerella canopy spectra collected at Maricopa, Arizona in 2008 and 2009 and correlates the indices with canopy weight, flower count, silique count, and silique dry weight.\n\n[test6](https://github.com/kthorp/vegspec/tree/main/tests/test6) - Demonstrates computation of spectral vegetation indices for maize canopy spectra collected at Ames, Iowa in 2004 and correlates the indices with plant stand density.\n\n[test7](https://github.com/kthorp/vegspec/tree/main/tests/test7) - Demonstrates computation of spectral vegetation indices for soybean canopy spectra collected at Urbana, Illinois in 2001 and correlates the indices with vegetation and weed cover.\n\n## Further information\nThe vegspec package is further described in the following article:\n\nThorp, K. R., 2024. vegspec: A compilation of spectral vegetation indices and transformations in Python. SoftwareX. In review.\n\n\nAlso, the vegspec package was used to conduct the following research:\n\nThorp, K. R., Thompson, A. L., Herritt, M. T., 2024. Phenotyping cotton leaf chlorophyll via proximal hyperspectral reflectance sensing, spectral vegetation indices, and machine learning. Frontiers in Plant Science. In prep.\n",
"bugtrack_url": null,
"license": "Public Domain",
"summary": "A compilation of vegetative spectral indices and transformations in Python",
"version": "1.0.4",
"project_urls": {
"Bug Tracker": "http://github.com/kthorp/vegspec/issues",
"Homepage": "http://github.com/kthorp/vegspec",
"Source": "http://github.com/kthorp/vegspec"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "77e116e37fe9cac1826b1cd17fc5566aacc77abbbbf03887e380e6d82fc303a6",
"md5": "d661fcc8d7c0a35d992fffc5d1cb4951",
"sha256": "7d770090aa5dd63d1d95c11b88bcb5ba4ce53c1334b53481851439cc93fed5aa"
},
"downloads": -1,
"filename": "vegspec-1.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d661fcc8d7c0a35d992fffc5d1cb4951",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 15199,
"upload_time": "2024-09-05T18:37:54",
"upload_time_iso_8601": "2024-09-05T18:37:54.637721Z",
"url": "https://files.pythonhosted.org/packages/77/e1/16e37fe9cac1826b1cd17fc5566aacc77abbbbf03887e380e6d82fc303a6/vegspec-1.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9f43db7b04e7db75d4530e66a13151328b0b946118c5c247da6b1e086678734d",
"md5": "2d2f2e402228b8270bb2c17fd76f35dd",
"sha256": "132c1b9f52b44077a9135ca75904feff15339dbfecbe4f20c48c53b05e4cdf8d"
},
"downloads": -1,
"filename": "vegspec-1.0.4.tar.gz",
"has_sig": false,
"md5_digest": "2d2f2e402228b8270bb2c17fd76f35dd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 16727,
"upload_time": "2024-09-05T18:37:56",
"upload_time_iso_8601": "2024-09-05T18:37:56.216442Z",
"url": "https://files.pythonhosted.org/packages/9f/43/db7b04e7db75d4530e66a13151328b0b946118c5c247da6b1e086678734d/vegspec-1.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-05 18:37:56",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kthorp",
"github_project": "vegspec",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "vegspec"
}