Skip to content

Commit 4b01c9f

Browse files
author
José Gómez-Dans
committed
Merge branch 'master' of github.com:jgomezdans/prosail
2 parents d876ff5 + bdb89fc commit 4b01c9f

6 files changed

+266
-139
lines changed

README.md

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<img src="http://www.nceo.ac.uk/images/NCEO_logo_lrg.jpg" scale=50% alt="NCEO logo" align="right" />
2+
<img src="http://www.esa.int/esalogo/images/logotype/img_colorlogo_darkblue.gif" scale=20% alt="ESA logo" align="left" />
3+
4+
<br/>
5+
<br/>
6+
<br/>
7+
8+
---
9+
10+
# PROSAIL Python Bindings
11+
12+
#### J Gomez-Dans (NCEO & UCL) ``[email protected]``
13+
14+
15+
## Description
16+
17+
This repository contains the Python bindings to the PROSPECT and SAIL leaf and
18+
canopy reflectance models. The code is written in FORTRAN. The original fortran
19+
code was downloaded from [Jussieu](http://teledetection.ipgp.jussieu.fr/prosail/).
20+
I only added a function to simplify writing the wrappers, and you should go to
21+
that page to get newer versions of the code. A recent review of the use of both
22+
models is availabe in [this paper](http://webdocs.dow.wur.nl/internet/grs/Workshops/Environmental_Applications_Imaging_Spectroscopy/12_Jacquemoud_Prospect/IEEE_Jacquemoud_PROSPECT.pdf)_.
23+
24+
25+
## Installing the bindings
26+
27+
The installation of the bindings is quite straightforward: unpack the distribution
28+
and run the following command
29+
30+
python setup.py install
31+
32+
You can usually install it to your user's directory (if you haven't got superuser
33+
privileges) by
34+
35+
python setup.py install --user
36+
37+
#### **Note**
38+
39+
40+
You will need a working FORTRAN compiler. I have only tested this with GCC on Linux, but it should work on other systems. You can also pass optimisation flags to the compiler:
41+
42+
python setup.py config_fc --fcompiler=gnu95 --arch=-march=native --opt=-O3 install --user
43+
44+
## Using the bindings
45+
46+
The bindings offer several functions, which will be described in detail below:.
47+
48+
* ``run_prospect``: This function runs the PROSPECT 5B model in Feret et al 2008. The input parameters are the usual ``(n,cab,car,cbrown,cw,cm)`` (e.g. leaf layers, leaf Chlorophyll concentration, leaf Carotenoid concentration, leaf senescent fraction, Equivalent leaf water, leaf dry matter). It returns a spectrum between 400 and 2500 nm.
49+
* ``run_sail``: The SAILh model, which in this case requires leaf reflectance and transmittance to be fed to the model (e.g. you have already measured these spectra in the field). The rest of the parameters are ``(refl,trans,lai,lidfa,lidfb,rsoil,psoil,hspot,tts,tto,psi,typelidf)``. Additionally, there are two optional parameters, ``soil_spectrum1``, ``soil_spectrum2``, which allow you to set the soil spectra (otherwise, some default spectra get used). Output is a spectrum in the 400-2500 nm range.
50+
* ``run_prosail``: PROSPECT_5B and SAILh coupled together, with input parameters given by ``(n,cab,car,cbrown,cw,cm,lai,lidfa,lidfb,rsoil,psoil,hspot,tts,tto,psi,typelidf)``. Output is a spectrum in the 400-2500 nm range.
51+
52+
53+
## The parameters
54+
55+
The parameters used by the models and their units are introduced below:
56+
57+
| Parameter | Description of parameter | Units |Typical min | Typical max |
58+
|-------------|---------------------------------|--------------|------------|-------------|
59+
| N | Leaf structure parameter | N/A | 0.8 | 2.5 |
60+
| cab | Chlorophyll a+b concentration | ug/cm2 | 0 | 80 |
61+
| caw | Equivalent water thickiness | cm | 0 | 200 |
62+
| car | Carotenoid concentration | ug/cm2 | 0 | 20 |
63+
| cbrown | Brown pigment | NA | 0 | 1 |
64+
| cm | Dry matter content | g/cm2 | 0 | 200 |
65+
| lai | Leaf Area Index | N/A | 0 | 10 |
66+
| lidfa | Leaf angle distribution | N/A | - | - |
67+
| lidfb | Leaf angle distribution | N/A | - | - |
68+
| psoil | Dry/Wet soil factor | N/A | 0 | 1 |
69+
| rsoil | Soil brigthness factor | N/A | - | - |
70+
| hspot | Hotspot parameter | N/A | - | - |
71+
| tts | Solar zenith angle | deg | 0 | 90 |
72+
| tto | Observer zenith angle | deg | 0 | 90 |
73+
| phi | Relative azimuth angle | deg | 0 | 360 |
74+
| typelidf | Leaf angle distribution type | Integer | - | - |
75+
76+
### Specifying the leaf angle distribution
77+
78+
The parameter ``typelidf`` regulates the leaf angle distribution family being used. The following options are understood:
79+
80+
* ``typelidf = 1``: use the two parameter LAD parameterisation, where ``a`` and ``b`` control the average leaf slope and the distribution bimodality, respectively. Typical distributions
81+
are given by the following parameter choices:
82+
83+
| LIDF type | ``LIDFa`` | ``LIDFb`` |
84+
|--------------|-----------|------------------|
85+
| Planophile | 1 | 0 |
86+
| Erectophile| -1 | 0 |
87+
| Plagiophile| 0 | -1 |
88+
| Extremophile| 0 | 1 |
89+
| Spherical | -0.35 | -0.15 |
90+
| Uniform | 0 | 0 |
91+
92+
* ``typelidf = 2`` Ellipsoidal distribution, where ``LIDFa`` parameter stands for mean leaf angle (0 degrees is planophile, 90 degrees is erectophile). ``LIDFb`` parameter is ignored.
93+
94+
### The soil model
95+
96+
The soil model is a fairly simple linear mixture model, where two spectra are mixed and then a brightness term added:
97+
98+
rho_soil = rsoil*(psoil*soil_spectrum1+(1-psoil)*soil_spectrum2)
99+
100+
101+
The idea is that one of the spectra is a dry soil and the other a wet soil, so soil moisture is then contorlled by ``psoil``. ``rsoil`` is just a brightness scaling term.
102+
103+

README.rst

-119
This file was deleted.

prosail/__init__.py

+137-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,141 @@
11
import numpy as np
2-
from prosail_fortran import run_sail, run_prosail, prospect_5b
2+
from prosail_fortran import run_sail as sail, run_prosail as prosail
3+
from prosail_fortran import prospect_5b
4+
from prosail_fortran import mod_dataspec_p5b as spectral_libs
5+
6+
def run_prosail (n,cab,car,cbrown,cw,cm,lai,lidfa,lidfb,rsoil,psoil,hspot,
7+
tts,tto,psi,typelidf,
8+
soil_spectrum1=None,soil_spectrum2=None ):
9+
"""Run the PROSPECT_5B and SAILh radiative transfer models. The soil
10+
model is a linear mixture model, where two spectra are combined together as
11+
12+
rho_soil = rsoil*(psoil*soil_spectrum1+(1-psoil)*soil_spectrum2)
13+
By default, ``soil_spectrum1`` is a dry soil, and ``soil_spectrum2`` is a
14+
wet soil, so in that case, ``psoil`` is a surface soil moisture parameter.
15+
``rsoil`` is a soil brightness term. You can provide one or the two
16+
soil spectra if you want. The soil spectra must be defined
17+
between 400 and 2500 nm with 1nm spacing.
18+
19+
Parameters
20+
----------
21+
n: float
22+
Leaf layers
23+
cab: float
24+
leaf chlorophyll concentration
25+
car: float
26+
leaf carotenoid concentration
27+
cbrown: float
28+
senescent pigment
29+
cw: float
30+
equivalent leaf water
31+
cm: float
32+
leaf dry matter
33+
lai: float
34+
leaf area index
35+
lidfa: float
36+
a parameter for leaf angle distribution. If ``typliedf``=2, average
37+
leaf inclination angle.
38+
lidfb: float
39+
b parameter for leaf angle distribution. If ``typelidf``=2, ignored
40+
rsoil: float
41+
Soil scalar
42+
psoil: float
43+
Soil scalar
44+
tts: float
45+
Solar zenith angle
46+
tto: float
47+
Sensor zenith angle
48+
psi: float
49+
Relative sensor-solar azimuth angle ( saa - vaa )
50+
soil_spectrum1: 2101-element array
51+
First component of the soil spectrum
52+
soil_spectrum2: 2101-element array
53+
Second component of the soil spectrum
54+
55+
Returns
56+
--------
57+
Directional surface reflectance between 400 and 2500 nm
58+
59+
60+
"""
61+
62+
if soil_spectrum1 is not None:
63+
assert ( len(soil_spectrum1) == 2101 )
64+
else:
65+
soil_spectrum1 = spectral_libs.rsoil1
66+
67+
if soil_spectrum2 is not None:
68+
assert ( len(soil_spectrum1) == 2101 )
69+
else:
70+
soil_spectrum2 = spectral_libs.rsoil1
71+
72+
rho = prosail (n,cab,car,cbrown,cw,cm,lai,lidfa,lidfb,rsoil,psoil,hspot,
73+
tts,tto,psi,typelidf, soil_spectrum1, soil_spectrum2 )
74+
return rho
75+
76+
def run_sail (refl,trans,lai,lidfa,lidfb,rsoil,psoil,hspot,tts,tto,psi,typelidf,
77+
soil_spectrum1=None,soil_spectrum2=None ):
78+
"""Run the SAILh radiative transfer model. The soil model is a linear
79+
mixture model, where two spectra are combined together as
80+
81+
rho_soil = rsoil*(psoil*soil_spectrum1+(1-psoil)*soil_spectrum2)
82+
83+
By default, ``soil_spectrum1`` is a dry soil, and ``soil_spectrum2`` is a
84+
wet soil, so in that case, ``psoil`` is a surface soil moisture parameter.
85+
``rsoil`` is a soil brightness term. You can provide one or the two
86+
soil spectra if you want. The soil spectra, and leaf spectra must be defined
87+
between 400 and 2500 nm with 1nm spacing.
88+
89+
Parameters
90+
----------
91+
refl: 2101-element array
92+
Leaf reflectance
93+
trans: 2101-element array
94+
leaf transmittance
95+
lai: float
96+
leaf area index
97+
lidfa: float
98+
a parameter for leaf angle distribution. If ``typliedf``=2, average
99+
leaf inclination angle.
100+
lidfb: float
101+
b parameter for leaf angle distribution. If ``typelidf``=2, ignored
102+
rsoil: float
103+
Soil scalar
104+
psoil: float
105+
Soil scalar
106+
tts: float
107+
Solar zenith angle
108+
tto: float
109+
Sensor zenith angle
110+
psi: float
111+
Relative sensor-solar azimuth angle ( saa - vaa )
112+
soil_spectrum1: 2101-element array
113+
First component of the soil spectrum
114+
soil_spectrum2: 2101-element array
115+
Second component of the soil spectrum
116+
117+
Returns
118+
--------
119+
Directional surface reflectance between 400 and 2500 nm
120+
121+
122+
"""
123+
124+
125+
if soil_spectrum1 is not None:
126+
assert ( len(soil_spectrum1) == 2101 )
127+
else:
128+
soil_spectrum1 = spectral_libs.rsoil1
129+
130+
if soil_spectrum2 is not None:
131+
assert ( len(soil_spectrum1) == 2101 )
132+
else:
133+
soil_spectrum2 = spectral_libs.rsoil1
134+
135+
rho = sail (refl,trans,lai,lidfa,lidfb,rsoil,psoil,hspot,tts,tto,psi,typelidf,
136+
soil_spectrum1, soil_spectrum2 )
137+
return rho
138+
3139

4140

5141
def trans_prosail ( N, cab, car, cbrown, cw, cm, lai, lidfa, lidfb, rsoil, psoil, \

prosail/dataSpec_P5B.f90

+1-1
Original file line numberDiff line numberDiff line change
@@ -2268,4 +2268,4 @@ MODULE MOD_dataSpec_P5B
22682268
4.960E-02,4.960E-02,4.960E-02,4.960E-02,4.959E-02,4.959E-02,4.944E-02,4.930E-02,4.915E-02,4.900E-02,&
22692269
4.885E-02/
22702270

2271-
END
2271+
END

0 commit comments

Comments
 (0)