Commit 896e782d authored by Roelofsen, Hans's avatar Roelofsen, Hans
Browse files

tabel met alle mnp soorten

parent b998a02a
This diff is collapsed.
......@@ -89,7 +89,7 @@ for row in dk.itertuples():
mean_freq = sel.Frequentie.mean()
mean_trouw = sel.Trouw.mean()
dk_ww = hlp.draagkracht_ww(frequentie=mean_freq, trouw=mean_trouw)
dk_ww = hlp.draagkracht_ww(frequentie=mean_freq, trouw=mean_trouw, th=0.01)
print('{0} X {1}: n={2} freq={3} trouw={4} dk={5}'
.format(row.Scientific_name, row.Land_type_code, sel.shape[0], mean_freq, mean_trouw, dk_ww))
......@@ -98,16 +98,25 @@ for row in dk.itertuples():
dk.loc[row.Index, 'Land_type_quality'] = dk_ww
'''Write draagkracht file per species'''
# TODO: minimale draagkracht is 0.01
fails = []
for species_code in list(set(dk.Species_code)):
local_name = code2localname[species_code].replace(' ', '_')
sel = dk.loc[(dk.Species_code == species_code) & (dk.Land_type_quality.notna() & dk.Land_type_quality >= 0.01),
sel = dk.loc[(dk.Species_code == species_code) & (dk.Land_type_quality.notna()),
['Species_code', 'Land_type_code', 'Land_type_quality']].round({'Land_type_quality': 3})
if not sel.empty:
index=False, header=True, sep=',')
index=False, header=True, sep=',')
print('To file: {}'.format(local_name))
sel = pd.Series({'Species_code': species_code, 'Local_name': local_name,
'Scientific_name': code2scientificname[species_code], 'msg': 'failed'})
print('Fail: {}'.format(local_name))
if len(fails) > 0:
fails_df = pd.concat(fails, axis=1)
index=True, header=True, sep='\t')
'''5. Reporting
......@@ -54,7 +54,7 @@ for i, species in enumerate(species, start=1):
sp = hlp.Species(species)
ndff = hlp.query_ndff(gdf=ndff_all, species=sp, max_area=10000) # NDFF shapefile for selected species.
except (AssertionError, ImportError) as e:
hlp.write2file(df=pd.Series({sp.naam_ned: e}), out_name='error_{}'.format(species), out_dir=args.out_dir)
hlp.write2file(df=pd.Series({species: e}), out_name='error_{}'.format(species), out_dir=args.out_dir)
out_name = '03_MNP_versie7_par_density_factors_{0}'.format(sp.naam_ned)
......@@ -131,12 +131,17 @@ for i, species in enumerate(species, start=1):
draagkracht = areas.loc[:, '{}_ndffpxls'.format(beheertype)].divide(areas.loc[:, beheertype]).max().round(3)
if draagkracht >=
dks[beheertype] = {'Species_code': sp.mnp_species_code, 'Land_type_code': beheertype,
'Land_type_quality': draagkracht}
'Land_type_quality': draagkracht}
except KeyError:
out = pd.DataFrame.from_dict(dks, orient='index')
hlp.write2file(df=out, out_name=out_name, out_dir=args.out_dir)
if not out.empty:
print(' {0} matched to {1} beheertypen'.format(sp.naam_ned, out.shape[0]))
hlp.write2file(df=out, out_name=out_name, out_dir=args.out_dir)
print(' zero dk for {}'.format(sp.naam_ned))
......@@ -450,6 +450,7 @@ def ndff_sources():
'dagvlinder': r'W:\PROJECTS\MNP2020\c_fases\f7_draagkracht\a_source_data\vlinders_ndff_shapefiles\ndff_vlinders_merged_okt2020.shp',
'test': r'c:\apps\temp_geodata\ndff\ndff_vogel_sample.shp'}
class Species:
Class holding all info related to a species
......@@ -594,15 +595,19 @@ def fix_bt(code_in, as_mnp=False):
return '{0}{1}.{2}'.format(pre, head, tail)
def draagkracht_ww(frequentie, trouw):
def draagkracht_ww(frequentie, trouw, th):
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
:param th: minumum draagkracht value
:return: draagkracht soort X - beheertype Y combinatie, gemaximaliseerd tot 1.
dk = np.min([np.multiply(np.divide(np.max([frequentie, trouw]), 100), 5), 1])
return dk
if dk >= th:
return dk
return np.nan
def valid_dir(x):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment