Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GEO374
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
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Diego Gomes
GEO374
Commits
268d1a8c
Commit
268d1a8c
authored
2 years ago
by
Diego Gomes
Browse files
Options
Downloads
Patches
Plain Diff
Replace analysistool.py
parent
56498926
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
analysistool.py
+18
-9
18 additions, 9 deletions
analysistool.py
with
18 additions
and
9 deletions
analysistool.py
+
18
−
9
View file @
268d1a8c
...
...
@@ -2,6 +2,7 @@ import numpy as np
import
pandas
as
pd
import
seaborn
as
sns
import
matplotlib.pyplot
as
plt
from
matplotlib.ticker
import
MultipleLocator
from
datetime
import
datetime
class
AnalysisTool
:
...
...
@@ -18,9 +19,9 @@ class AnalysisTool:
def
boxplot
(
self
,
croptype
,
save
=
False
):
"""
Plot
relative
deltas of different cropsites for a give croptype
"""
"""
Plot
log
deltas of different cropsites for a give croptype
"""
colors
=
[
'
#134e6f
'
,
'
#ffa822
'
,
'
#ff6150
'
,
'
#1ac0c6
'
]
colors
=
[
'
#134e6f
'
,
'
#ffa822
'
,
'
#ff6150
'
,
'
#1ac0c6
'
,
'
#9e416b
'
]
data
=
pd
.
DataFrame
(
columns
=
[
'
Date
'
,
'
Month
'
,
'
Cropsite
'
,
'
Delta
'
])
...
...
@@ -31,7 +32,7 @@ class AnalysisTool:
if
croptype
in
self
.
data
[
cropsite
][
'
cropwise
'
].
keys
():
for
season
in
self
.
data
[
cropsite
][
'
cropwise
'
][
croptype
]:
dates
=
self
.
data
[
cropsite
][
'
cropwise
'
][
croptype
][
season
][
'
dates
'
]
deltas
=
self
.
data
[
cropsite
][
'
cropwise
'
][
croptype
][
season
][
'
deltas_
rel
'
][
'
MODIS
'
]
deltas
=
self
.
data
[
cropsite
][
'
cropwise
'
][
croptype
][
season
][
'
deltas_
log
'
][
'
MODIS
'
]
months
=
[]
cropsites
=
[]
...
...
@@ -43,24 +44,32 @@ class AnalysisTool:
months
.
append
(
date
.
strftime
(
'
%b
'
))
cropsites
.
append
(
cropsite
)
df
=
pd
.
DataFrame
(
list
(
zip
(
dates
,
months
,
cropsites
,
np
.
array
(
deltas
)
*
100
)
),
columns
=
[
'
Date
'
,
'
Month
'
,
'
Cropsite
'
,
'
Delta
'
])
df
=
pd
.
DataFrame
(
list
(
zip
(
dates
,
months
,
cropsites
,
deltas
)),
columns
=
[
'
Date
'
,
'
Month
'
,
'
Cropsite
'
,
'
Delta
'
])
data
=
pd
.
concat
([
data
,
df
])
months
=
[]
hold
=
[]
for
i
in
range
(
start_month
,
start_month
+
12
):
if
i
>
12
:
i
=
i
-
12
month
=
datetime
.
strptime
(
str
(
i
),
'
%m
'
).
strftime
(
'
%b
'
)
if
month
in
data
.
values
:
if
month
not
in
data
.
values
:
hold
.
append
(
month
)
else
:
months
+=
hold
hold
=
[]
months
.
append
(
month
)
plt
.
figure
(
figsize
=
(
1
0
,
2
0
))
plt
.
figure
(
figsize
=
(
2
0
,
1
0
))
axs
=
sns
.
boxplot
(
x
=
'
Month
'
,
y
=
'
Delta
'
,
hue
=
'
Cropsite
'
,
palette
=
colors
,
data
=
data
,
order
=
months
)
axs
.
set_title
(
croptype
)
axs
.
set_ylabel
(
'
Relative Difference in Latent Heat Flux [%]
'
)
axs
.
yaxis
.
set_major_locator
(
MultipleLocator
(
1
))
axs
.
set_ylabel
(
'
Sign-adjusted Natural Logarithm of Difference in Latent Heat Flux [sign(W m-2) * ln(|W m-2|)]
'
)
for
i
in
range
(
int
(
len
(
months
)
/
2
)):
axs
.
axvline
((
i
*
2
)
+
1
,
color
=
'
black
'
,
linestyle
=
'
-
'
,
linewidth
=
1120
/
len
(
months
),
alpha
=
0.05
)
try
:
axs
.
axvline
(
months
.
index
(
'
Jan
'
),
color
=
'
lightgrey
'
,
linestyle
=
'
--
'
)
axs
.
axvline
(
months
.
index
(
'
Jan
'
)
-
0.5
,
color
=
'
lightgrey
'
,
linestyle
=
'
--
'
)
except
ValueError
:
pass
axs
.
axhline
(
0
,
color
=
'
black
'
,
linestyle
=
'
-
'
)
...
...
@@ -74,7 +83,7 @@ class AnalysisTool:
def
scatterplot
(
self
,
croptype
,
cropsite
=
'
all
'
,
combine
=
True
,
save
=
False
):
"""
Plot latent heat values: MODIS vs FLUXNET
"""
colors
=
[
'
#134e6f
'
,
'
#ffa822
'
,
'
#ff6150
'
,
'
#1ac0c6
'
]
colors
=
[
'
#134e6f
'
,
'
#ffa822
'
,
'
#ff6150
'
,
'
#1ac0c6
'
,
'
#9e416b
'
]
fig
,
axs
=
plt
.
subplots
(
figsize
=
(
10
,
10
))
...
...
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