Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Roelofsen, Hans
MNP utilities
Commits
41a59c92
Commit
41a59c92
authored
Sep 02, 2020
by
Roelofsen, Hans
Browse files
implemented formule WW for DK plant
parent
fd8f3fae
Changes
2
Hide whitespace changes
Inline
Side-by-side
sample/dk_plant.py
View file @
41a59c92
...
...
@@ -10,18 +10,18 @@ Relation between species presence and vegetation types is sourced from DVN data,
Hans Roelofsen, 23 June 2020
"""
import
itertools
import
pandas
as
pd
from
sample.mnp
import
helpers
as
hlp
# from mnp import helpers as hlp
"""Source data"""
src_mnp_sp_tax
=
r
'
C:\apps\temp_geodata\MNP_DK
\07_MNP_versie4_par_population_factors.csv'
src_mnp_sp_nms
=
r
'
c
:\
apps\temp_geodata\MNP_DK
\09_MNP_versie4_Group_Species_valid model_468.csv'
src_mnp_dk
=
r
'
C:\apps\temp_geodata\MNP_DK
\03_MNP_versie6_par_density_factors_BT2019_v2.csv'
src_asso_x_bts
=
r
'
C
:\
apps\temp_geodata\MNP_DK
\vertaling_IPO_ASSO_2009.txt'
src_asso_x_sps
=
r
'
C
:\
apps\temp_geodata\MNP_DK
\q_syntaxa_soorten_frequentie_trouwsoorten.txt'
src_mnp_sp_tax
=
r
'
W:\PROJECTS\qmar\MNP-SNL-ParameterSet\Parameters_v06_2019_12_09
\07_MNP_versie4_par_population_factors.csv'
src_mnp_sp_nms
=
r
'
w
:\
PROJECTS\qmar\MNP-SNL-ParameterSet\Parameters_v06_2019_12_09
\09_MNP_versie4_Group_Species_valid model_468.csv'
src_mnp_dk
=
r
'
w:\PROJECTS\qmar\MNP-SNL-ParameterSet\Parameters_v06_2019_12_09
\03_MNP_versie6_par_density_factors_BT2019_v2.csv'
src_asso_x_bts
=
r
'
c
:\
Users\roelo008\OneDrive - WageningenUR\a_projects\MNP\draakgracht\plant\src_data
\vertaling_IPO_ASSO_2009.txt'
src_asso_x_sps
=
r
'
c
:\
Users\roelo008\OneDrive - WageningenUR\a_projects\MNP\draakgracht\plant\src_data
\q_syntaxa_soorten_frequentie_trouwsoorten.txt'
mnp_sp_tax
=
pd
.
read_csv
(
src_mnp_sp_tax
,
sep
=
','
)
mnp_sp_nms
=
pd
.
read_csv
(
src_mnp_sp_nms
,
sep
=
','
)
...
...
@@ -55,24 +55,32 @@ dk = pd.DataFrame(data=[(a, b) for (a, b) in itertools.product(mnp.loc[mnp.Taxon
dk
.
loc
[:,
'sp_code'
]
=
dk
.
sp_name
.
map
(
name2code
)
'''Summarize Frequentie for each BT <> Species combination'''
qualitis
=
[]
mnp_ref
=
[]
frequenties
=
[]
trouws
=
[]
mnp_draagkracht
=
[]
for
row
in
dk
.
itertuples
():
# landtype_quality = gemiddelde frequentie van de soort in de associaties behorende bij het gevraagde BT
sel
=
asso_x_sps
.
loc
[(
asso_x_sps
.
Soortnaam
==
row
.
sp_name
)
&
(
asso_x_sps
.
syntaxon_gen
.
isin
(
bt2asso
[
row
.
BT
])),
:]
mean_freq
=
sel
.
Frequentie
.
mean
()
qualitis
.
append
(
mean_freq
)
mean_trouw
=
sel
.
Trouw
.
mean
()
mean_mnp_dk
=
mnp_dk
.
loc
[(
mnp_dk
.
Species_code
==
row
.
sp_code
)
&
(
mnp_dk
.
BT
==
row
.
BT
),
'Land_type_quality'
].
mean
()
frequenties
.
append
(
mean_freq
)
trouws
.
append
(
mean_trouw
)
mnp_draagkracht
.
append
(
mean_mnp_dk
)
# dit kan vast simpeler met groupby of zo, fuck it
if
sel
.
shape
[
0
]
>
0
:
print
(
'Found {0} records for species {1} and BT {2}, with mean '
'Frequentie: {3}'
.
format
(
sel
.
shape
[
0
],
row
.
sp_name
,
row
.
BT
,
mean_freq
))
mnp_ref
.
append
(
mnp_dk
.
loc
[(
mnp_dk
.
Species_code
==
row
.
sp_code
)
&
(
mnp_dk
.
BT
==
row
.
BT
),
'Land_type_quality'
].
mean
())
'Frequentie: {3}
and mean Trouw: {4}
'
.
format
(
sel
.
shape
[
0
],
row
.
sp_name
,
row
.
BT
,
mean_freq
,
mean_trouw
))
dk
.
loc
[:,
'land_type_q'
]
=
qualitis
dk
.
loc
[:,
'mnp_land_type_q'
]
=
mnp_ref
dk
.
loc
[
dk
.
land_type_q
.
notna
(),
:].
to_clipboard
(
sep
=
';'
,
index
=
False
)
dk
.
loc
[:,
'mean_frequentie'
]
=
frequenties
dk
.
loc
[:,
'mean_trouw'
]
=
trouws
dk
.
loc
[:,
'mnp_land_type_q'
]
=
mnp_draagkracht
dk
.
loc
[:,
'dk_ww'
]
=
dk
.
apply
(
lambda
row
:
hlp
.
draagkracht_ww
(
row
.
mean_frequentie
,
row
.
mean_trouw
),
axis
=
1
)
dk
.
loc
[
dk
.
mnp_land_type_q
.
notna
(),
:].
to_clipboard
(
sep
=
';'
,
index
=
False
)
'''5. Reporting'''
...
...
sample/mnp/helpers.py
View file @
41a59c92
...
...
@@ -198,4 +198,16 @@ def fix_bt(code_in):
return
'{0}{1}.{2}'
.
format
(
pre
,
head
,
tail
)
def
draagkracht_ww
(
frequentie
,
trouw
):
"""
Draagkracht formule volgens Wieger Wamelink. Zie MS Teams discussie 16-07-2020 MNP2020/Fase 7 Objectivering Draagk..
:param frequentie: gemiddelde frequentie van soort X binnen beheertype Y
:param trouw: gemiddelde trouw van soort X binnen beheertype Y
:return: draagkracht soort X - beheertype Y combinatie
"""
dk
=
np
.
multiply
(
np
.
divide
(
np
.
max
([
frequentie
,
trouw
]),
100
),
5
)
return
dk
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment