Skip to content

Commit

Permalink
Merge pull request #25 from JannisHoch/dev
Browse files Browse the repository at this point in the history
major additions
  • Loading branch information
JannisHoch authored Jul 8, 2020
2 parents c35568a + b43260e commit a4275fa
Show file tree
Hide file tree
Showing 24 changed files with 1,199 additions and 1,780 deletions.
File renamed without changes.
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"python.pythonPath": "C:\\Users\\hoch0001\\AppData\\Local\\Continuum\\anaconda3\\envs\\conflict_model\\python.exe",
"restructuredtext.confPath": "${workspaceFolder}\\docs"
}
2 changes: 1 addition & 1 deletion conflict_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

__author__ = """Jannis M. Hoch"""
__email__ = '[email protected]'
__version__ = '0.0.1'
__version__ = '0.0.2b3'
6 changes: 3 additions & 3 deletions conflict_model/get_var_from_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import matplotlib.pyplot as plt
import os, sys

def nc_with_integer_timestamp(extent_gdf, config, var_name, sim_year, stat_func='mean'):
def nc_with_float_timestamp(extent_gdf, config, var_name, sim_year, stat_func='mean'):
"""This function extracts a statistical value from a netCDF-file (specified in the config-file) for each polygon specified in extent_gdf for a given year.
By default, the mean value of all cells within a polygon is computed.
The resulting list does not contain additional meta-information about the files or polygons and is mostly intended for data-driven approaches such as machine learning.
Expand Down Expand Up @@ -35,7 +35,7 @@ def nc_with_integer_timestamp(extent_gdf, config, var_name, sim_year, stat_func=
list: list containing statistical value per polygon, i.e. with same length as extent_gdf
"""
# get path to netCDF-file.
nc_fo = os.path.join(config.get('general', 'input_dir'),
nc_fo = os.path.join(os.path.abspath(config.get('general', 'input_dir')),
config.get('env_vars', var_name))

print('calculating mean {0} per aggregation unit from file {1} for year {2}'.format(var_name, nc_fo, sim_year))
Expand Down Expand Up @@ -66,7 +66,7 @@ def nc_with_integer_timestamp(extent_gdf, config, var_name, sim_year, stat_func=

return list_out

def nc_with_continous_regular_timestamp(extent_gdf, config, var_name, sim_year, stat_func='mean'):
def nc_with_continous_datetime_timestamp(extent_gdf, config, var_name, sim_year, stat_func='mean'):
"""This function extracts a statistical value from a netCDF-file (specified in the config-file) for each polygon specified in extent_gdf for a given year.
By default, the mean value of all cells within a polygon is computed.
The resulting list does not contain additional meta-information about the files or polygons and is mostly intended for data-driven approaches such as machine learning.
Expand Down
17 changes: 0 additions & 17 deletions conflict_model/machine_learning.py

This file was deleted.

6 changes: 3 additions & 3 deletions conflict_model/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def clip_to_extent(gdf, config):
geodataframe: geodataframe containing country polygons of selected continent
"""

shp_fo = os.path.join(config.get('general', 'input_dir'),
shp_fo = os.path.join(os.path.abspath(config.get('general', 'input_dir')),
config.get('extent', 'shp'))

print('reading extent and spatial aggregation level from file {}'.format(shp_fo))
Expand All @@ -97,10 +97,10 @@ def climate_zoning(gdf, config):
geodataframe: geodataframe containing filtered entries
"""

Koeppen_Geiger_fo = os.path.join(config.get('general', 'input_dir'),
Koeppen_Geiger_fo = os.path.join(os.path.abspath(config.get('general', 'input_dir')),
config.get('climate', 'shp'))

code2class_fo = os.path.join(config.get('general', 'input_dir'),
code2class_fo = os.path.join(os.path.abspath(config.get('general', 'input_dir')),
config.get('climate', 'code2class'))

look_up_classes = config.get('climate', 'zones').rsplit(',')
Expand Down
2 changes: 1 addition & 1 deletion conflict_model/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get_geodataframe(config, longitude='longitude', latitude='latitude', crs='EP
"""

# construct path to file with conflict data
conflict_fo = os.path.join(config.get('general', 'input_dir'),
conflict_fo = os.path.join(os.path.abspath(config.get('general', 'input_dir')),
config.get('conflict', 'conflict_file'))

# read file to pandas dataframe
Expand Down
Loading

0 comments on commit a4275fa

Please sign in to comment.