Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snap_biovar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Earth Informatics
snap_biovar
Commits
5e3fb9e7
Commit
5e3fb9e7
authored
1 year ago
by
Wit, Allard de
Browse files
Options
Downloads
Patches
Plain Diff
version of snap_biovar that takes zenith/azimuth angles from grompy 1.3 dataframe
parent
f9f2c958
Branches
main
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
snap_biovar/__init__.py
+9
-10
9 additions, 10 deletions
snap_biovar/__init__.py
snap_biovar/fapar.py
+2
-2
2 additions, 2 deletions
snap_biovar/fapar.py
snap_biovar/fcover.py
+2
-2
2 additions, 2 deletions
snap_biovar/fcover.py
snap_biovar/lai.py
+2
-2
2 additions, 2 deletions
snap_biovar/lai.py
with
15 additions
and
16 deletions
snap_biovar/__init__.py
+
9
−
10
View file @
5e3fb9e7
...
...
@@ -15,18 +15,17 @@ from .fapar import compute_fapar
from
.lai
import
compute_lai
from
.fcover
import
compute_fcover
__version__
=
"
1.0.
0
"
__version__
=
"
1.0.
2
"
def
compute_biovar
(
df_s2
,
longitude
,
latitude
,
timezone
=
"
Europe/Amsterdam
"
,
view_zenith_mean
=
None
,
view_azimuth_mean
=
None
):
def
compute_biovar
(
df_s2
,
longitude
,
latitude
,
timezone
=
"
Europe/Amsterdam
"
):
"""
:param df_s2: The dataframe with Sentinel2 timeseries data
:param longitude: The site longitude
:param latitude: The site latitude
:param timezone: The timezone
:param
view
_zenith
_mean
: the view zenith angle
:param
view
_azimuth
_mean
: the view azimuth angle
:param
sensor
_zenith: the view zenith angle
:param
sensor
_azimuth: the view azimuth angle
:return: the same dataframe with several columns added:
- lai: the calculated leaf area index
- fapar: the calculated fraction of absorbed PAR
...
...
@@ -51,16 +50,16 @@ def compute_biovar(df_s2, longitude, latitude, timezone="Europe/Amsterdam",
loc
=
LocationInfo
(
""
,
""
,
timezone
,
latitude
,
longitude
)
S2_bands
=
[
"
B02
"
,
"
B03
"
,
"
B04
"
,
"
B05
"
,
"
B06
"
,
"
B07
"
,
"
B08
"
,
"
B11
"
,
"
B12
"
,
"
B8A
"
,
"
NDVI
"
]
# Scale to reflectance values
df_s2
.
i
loc
[:,
1
:
-
1
]
/=
10000
df_s2
.
loc
[:,
S2_bands
]
/=
10000
# We assume a local overpass time of 10:30 in the morning (adding 10.5 hours)
tmp
=
pd
.
to_datetime
(
df_s2
.
day
)
+
pd
.
Timedelta
(
10.5
,
unit
=
"
h
"
)
df_s2
[
"
day_tz
"
]
=
tmp
.
dt
.
tz_localize
(
timezone
)
df_s2
[
"
solar_azimuth
"
]
=
df_s2
.
day_tz
.
apply
(
Location
(
loc
).
solar_azimuth
)
df_s2
[
"
solar_zenith
"
]
=
df_s2
.
day_tz
.
apply
(
Location
(
loc
).
solar_zenith
)
df_s2
[
"
fapar
"
]
=
compute_fapar
(
df_s2
,
view_zenith_mean
,
view_azimuth_mean
)
df_s2
[
"
lai
"
]
=
compute_lai
(
df_s2
,
view_zenith_mean
,
view_azimuth_mean
)
df_s2
[
"
fcover
"
]
=
compute_fcover
(
df_s2
,
view_zenith_mean
,
view_azimuth_mean
)
df_s2
[
"
fapar
"
]
=
compute_fapar
(
df_s2
)
df_s2
[
"
lai
"
]
=
compute_lai
(
df_s2
)
df_s2
[
"
fcover
"
]
=
compute_fcover
(
df_s2
)
return
df_s2
\ No newline at end of file
This diff is collapsed.
Click to expand it.
snap_biovar/fapar.py
+
2
−
2
View file @
5e3fb9e7
...
...
@@ -14,9 +14,9 @@ def compute_fapar(input):
b8a_norm
=
normalize
(
input
.
B8A
,
0.026690138082061
,
0.782011770669178
)
b11_norm
=
normalize
(
input
.
B11
,
0.016388074192258
,
0.493761397883092
)
b12_norm
=
normalize
(
input
.
B12
,
0
,
0.493025984460231
)
viewZen_norm
=
normalize
(
np
.
cos
(
input
.
view
_zenith
_mean
*
degToRad
),
0.918595400582046
,
1
)
viewZen_norm
=
normalize
(
np
.
cos
(
input
.
sensor
_zenith
*
degToRad
),
0.918595400582046
,
1
)
sunZen_norm
=
normalize
(
np
.
cos
(
input
.
solar_zenith
*
degToRad
),
0.342022871159208
,
0.936206429175402
)
relAzim_norm
=
np
.
cos
((
input
.
solar_azimuth
-
input
.
view
_azimuth
_mean
)
*
degToRad
)
relAzim_norm
=
np
.
cos
((
input
.
solar_azimuth
-
input
.
sensor
_azimuth
)
*
degToRad
)
inp
=
(
b03_norm
,
b04_norm
,
b05_norm
,
b06_norm
,
b07_norm
,
b8a_norm
,
b11_norm
,
b12_norm
,
viewZen_norm
,
sunZen_norm
,
relAzim_norm
)
...
...
This diff is collapsed.
Click to expand it.
snap_biovar/fcover.py
+
2
−
2
View file @
5e3fb9e7
...
...
@@ -14,9 +14,9 @@ def compute_fcover(input):
b8a_norm
=
normalize
(
input
.
B8A
,
0.026690138082061
,
0.782011770669178
)
b11_norm
=
normalize
(
input
.
B11
,
0.016388074192258
,
0.493761397883092
)
b12_norm
=
normalize
(
input
.
B12
,
0
,
0.493025984460231
)
viewZen_norm
=
normalize
(
np
.
cos
(
input
.
view
_zenith
_mean
*
degToRad
),
0.918595400582046
,
1
)
viewZen_norm
=
normalize
(
np
.
cos
(
input
.
sensor
_zenith
*
degToRad
),
0.918595400582046
,
1
)
sunZen_norm
=
normalize
(
np
.
cos
(
input
.
solar_zenith
*
degToRad
),
0.342022871159208
,
0.936206429175402
)
relAzim_norm
=
np
.
cos
((
input
.
solar_azimuth
-
input
.
view
_azimuth
_mean
)
*
degToRad
)
relAzim_norm
=
np
.
cos
((
input
.
solar_azimuth
-
input
.
sensor
_azimuth
)
*
degToRad
)
inp
=
(
b03_norm
,
b04_norm
,
b05_norm
,
b06_norm
,
b07_norm
,
b8a_norm
,
b11_norm
,
b12_norm
,
viewZen_norm
,
sunZen_norm
,
relAzim_norm
)
...
...
This diff is collapsed.
Click to expand it.
snap_biovar/lai.py
+
2
−
2
View file @
5e3fb9e7
...
...
@@ -14,9 +14,9 @@ def compute_lai(input):
b8a_norm
=
normalize
(
input
.
B8A
,
0.026690138082061
,
0.782011770669178
)
b11_norm
=
normalize
(
input
.
B11
,
0.016388074192258
,
0.493761397883092
)
b12_norm
=
normalize
(
input
.
B12
,
0
,
0.493025984460231
)
viewZen_norm
=
normalize
(
np
.
cos
(
input
.
view
_zenith
_mean
*
degToRad
),
0.918595400582046
,
1
)
viewZen_norm
=
normalize
(
np
.
cos
(
input
.
sensor
_zenith
*
degToRad
),
0.918595400582046
,
1
)
sunZen_norm
=
normalize
(
np
.
cos
(
input
.
solar_zenith
*
degToRad
),
0.342022871159208
,
0.936206429175402
)
relAzim_norm
=
np
.
cos
((
input
.
solar_azimuth
-
input
.
view
_azimuth
_mean
)
*
degToRad
)
relAzim_norm
=
np
.
cos
((
input
.
solar_azimuth
-
input
.
sensor
_azimuth
)
*
degToRad
)
inp
=
(
b03_norm
,
b04_norm
,
b05_norm
,
b06_norm
,
b07_norm
,
b8a_norm
,
b11_norm
,
b12_norm
,
viewZen_norm
,
sunZen_norm
,
relAzim_norm
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment