From 0ace551d0df1aa11a96c8c016dde176850f69b9a Mon Sep 17 00:00:00 2001 From: thouska Date: Fri, 6 Dec 2019 13:15:25 +0100 Subject: [PATCH 01/35] Fix some typos in docs --- docs/Tutorial/7-Advanced_hints.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/Tutorial/7-Advanced_hints.md b/docs/Tutorial/7-Advanced_hints.md index 5c9f2c0d..da74b6c3 100644 --- a/docs/Tutorial/7-Advanced_hints.md +++ b/docs/Tutorial/7-Advanced_hints.md @@ -48,7 +48,7 @@ IMPLEMENTATION OF TWO COMPLEMENTING VARIANCE-BASED ALGORITHMS, 2012] (https://ww $$N = (1+4M^2(1+(k-2)d))k$$ -with N = needed parameter iterations, M= inference factor (SPOTPY default M=4) and d= frequenzy step (SPOTPY default d=2) and k as the number of parameters of your model. +with N = needed parameter iterations, M= inference factor (SPOTPY default M=4) and d= frequency step (SPOTPY default d=2) and k as the number of parameters of your model. You can start the simulation with @@ -99,9 +99,9 @@ Just note that this works not for 'MLE', 'MCMC', 'SCE-UA', 'SA', 'DE-MCz' and 'R ## Sampling from a given parameter list -SPOTPY enables you to sample directly from a given parameter list. This can be useful if you want to check specific parameter combinations or if you want to resample +SPOTPY enables you to sample directly from a given parameter list. This can be useful if you want to check specific parameter combinations or if you want to re-sample calibrated parameter set, in order to test different model setups or to save further model outputs. To use this functionality you just have to rewrite your paramters function -in your spotpy setup. We will show you a example how to test parameters of the rosenbrock tutorial. Just give the values you want to test as a list into the spotpy.parameter.List function: +in your spotpy setup. We will show you a example how to test parameters of the Rosenbrock tutorial. Just give the values you want to test as a list into the spotpy.parameter.List function: def __init__(self): self.params = [spotpy.parameter.List('x',[1,2,3,4,6,7,8,9,0]), #Give possible x values as a List @@ -128,13 +128,13 @@ After that you will be able to sample the parameter combinations with the normal sampler=spotpy.algorithms.mc(spot_setup(),dbname='Iterator_example', dbformat='csv') #Parameter lists can be sampled with MC sampler.sample(10) #Choose equaly (or less) repetitions as you have parameters in your List -This will also run with MPI parallelzation. +This will also run with MPI parallelization. ## Create a own database -SPOTPY enables you to save results of the sampling in a own database. Users may request different sorts of databases like SQL, hdf5 files, tab separated txt files, xls timeseries. +SPOTPY enables you to save results of the sampling in a own database. Users may request different sorts of databases like SQL, hdf5 files, tab separated txt files, xls time-series. SPOTPY does not provide all these databases yet, BUT any sort of database can be connected to SPOTPY. Therefore one just has to write his one interface. We provide a simple example how this can be done: -We use the above created example and add a selfmade txt database into a new save function: +We use the above created example and add a self-made txt database into a new save function: class spot_setup(object): slow = 1000 @@ -172,10 +172,10 @@ out the keywords 'dbname' and 'dbformat' when you initialize the algorithm: spot_setup=spot_setup() 'Leave out dbformat and dbname and spotpy will return results in spot_setup.save function' sampler=spotpy.algorithms.mc(spot_setup) - sampler.sample(10) #Choose equaly or less repetitions as you have parameters in your List + sampler.sample(10) #Choose equally or less repetitions as you have parameters in your List spot_setup.database.close() # Close the created txt file -Apart from that, some users might be interested not to save there simulation results and only the objective functions and the paramter values, +Apart from that, some users might be interested not to save there simulation results and only the objective functions and the parameter values, e.g. to save memory space. This is supported during the initialization of the algorithm, by setting save_sim to False (default=True): sampler = spotpy.algorithms.mc(spotpy_setup() dbname='no_simulations', dbformat='csv', save_sim=False) From e61db20b797fe3c4200a7ed8f44ff7f667735474 Mon Sep 17 00:00:00 2001 From: thouska Date: Mon, 3 Feb 2020 10:44:46 +0100 Subject: [PATCH 02/35] Fix order in calc like function --- spotpy/algorithms/fast.py | 1 + spotpy/analyser.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/spotpy/algorithms/fast.py b/spotpy/algorithms/fast.py index b23967e9..9556e2ec 100644 --- a/spotpy/algorithms/fast.py +++ b/spotpy/algorithms/fast.py @@ -107,6 +107,7 @@ def matrix(self, bounds, N, M=4): # Discretization of the frequency space, s s = (2 * math.pi / N) * np.arange(N) + #s = math.pi / 2.0 * (2 * np.arange(1,N+1) - N-1) / N # Transformation to get points in the X space X = np.empty([N * D, D]) diff --git a/spotpy/analyser.py b/spotpy/analyser.py index 29df384f..e026de95 100644 --- a/spotpy/analyser.py +++ b/spotpy/analyser.py @@ -232,7 +232,7 @@ def calc_like(results,evaluation,objectivefunction): likes=[] sim=get_modelruns(results) for s in sim: - likes.append(objectivefunction(list(s),evaluation)) + likes.append(objectivefunction(evaluation,list(s))) return likes def compare_different_objectivefunctions(like1,like2): From 8338372a9336a74a91b962ad165b1d18e92c10fb Mon Sep 17 00:00:00 2001 From: thouska Date: Tue, 31 Mar 2020 11:21:33 +0200 Subject: [PATCH 03/35] Upload readthedocs configuration --- .gitignore | 2 +- mkdocs.yml | 34 ++++++++++++++++++++++++++++++++++ readthedocs.yml | 15 +++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 mkdocs.yml create mode 100644 readthedocs.yml diff --git a/.gitignore b/.gitignore index ee4e359b..e396c9ab 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,7 @@ __pycache__/ *.png *.csv site/* -mkdocs.yml +#mkdocs.yml # Distribution / packaging .Python diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 00000000..5bb6fb66 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,34 @@ +site_name: SPOTPY Documentation +site_url: http://fb09-pasig.umwelt.uni-giessen.de/spotpy/ +site_description: The documentation of the Statistical Parameter Optimization Framework +site_author: Tobias Houska + +repo_url: https://github.com/thouska/spotpy/ +edit_url: "" + +theme: + name: readthedocs + +#markdown_extensions: [mathjax] + + +nav: + - Home: index.md + - Getting Started: getting_started.md + - Tutorial: + - 1-Introduction: Tutorial\1-Introduction.md + - 2-Rosenbrock: Tutorial\2-Rosenbrock.md + - 3-Griewank: Tutorial\3-Griewank.md + - 4-Ackley: Tutorial\4-Ackley.md + - 5-Hydrological_model: Tutorial\5-Hydrological_model.md + - 6-Working with DREAM and Hymod: Tutorial\6-Working with DREAM and Hymod.md + - 7-Advanced_hints: Tutorial\7-Advanced_hints.md + - 8-Algorithm_guide: Tutorial\8-Algorithm_guide.md + + - License: license.md + + +copyright: Copyright © 2015, Tobias Houska. + + + diff --git a/readthedocs.yml b/readthedocs.yml new file mode 100644 index 00000000..a0c39652 --- /dev/null +++ b/readthedocs.yml @@ -0,0 +1,15 @@ +# .readthedocs.yml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + + +# Build documentation with MkDocs +mkdocs: + configuration: mkdocs.yml + +# Optionally build your docs in additional formats such as PDF and ePub +formats: all + From 1df931f749006a7eabd5096c44cf89f208b46bca Mon Sep 17 00:00:00 2001 From: thouska Date: Tue, 31 Mar 2020 11:44:15 +0200 Subject: [PATCH 04/35] Moved Getting Started.md --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index 5bb6fb66..2889c0ee 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -14,8 +14,8 @@ theme: nav: - Home: index.md - - Getting Started: getting_started.md - Tutorial: + - Getting Started: getting_started.md - 1-Introduction: Tutorial\1-Introduction.md - 2-Rosenbrock: Tutorial\2-Rosenbrock.md - 3-Griewank: Tutorial\3-Griewank.md From 51e7616c388ec19e4870d320b03fe91cfce613c2 Mon Sep 17 00:00:00 2001 From: thouska Date: Tue, 31 Mar 2020 12:10:06 +0200 Subject: [PATCH 05/35] Restructured docs --- docs/{Tutorial/4-Ackley.md => Ackley.md} | 0 .../7-Advanced_hints.md => Advanced_hints.md} | 0 ...8-Algorithm_guide.md => Algorithm_guide.md} | 0 docs/{Tutorial/3-Griewank.md => Griewank.md} | 0 ...ological_model.md => Hydrological_model.md} | 0 .../1-Introduction.md => Introduction.md} | 2 +- .../2-Rosenbrock.md => Rosenbrock.md} | 6 ++++-- ...ymod.md => Working with DREAM and Hymod.md} | 0 mkdocs.yml | 18 +++++++++--------- 9 files changed, 14 insertions(+), 12 deletions(-) rename docs/{Tutorial/4-Ackley.md => Ackley.md} (100%) rename docs/{Tutorial/7-Advanced_hints.md => Advanced_hints.md} (100%) rename docs/{Tutorial/8-Algorithm_guide.md => Algorithm_guide.md} (100%) rename docs/{Tutorial/3-Griewank.md => Griewank.md} (100%) rename docs/{Tutorial/5-Hydrological_model.md => Hydrological_model.md} (100%) rename docs/{Tutorial/1-Introduction.md => Introduction.md} (72%) rename docs/{Tutorial/2-Rosenbrock.md => Rosenbrock.md} (98%) rename docs/{Tutorial/6-Working with DREAM and Hymod.md => Working with DREAM and Hymod.md} (100%) diff --git a/docs/Tutorial/4-Ackley.md b/docs/Ackley.md similarity index 100% rename from docs/Tutorial/4-Ackley.md rename to docs/Ackley.md diff --git a/docs/Tutorial/7-Advanced_hints.md b/docs/Advanced_hints.md similarity index 100% rename from docs/Tutorial/7-Advanced_hints.md rename to docs/Advanced_hints.md diff --git a/docs/Tutorial/8-Algorithm_guide.md b/docs/Algorithm_guide.md similarity index 100% rename from docs/Tutorial/8-Algorithm_guide.md rename to docs/Algorithm_guide.md diff --git a/docs/Tutorial/3-Griewank.md b/docs/Griewank.md similarity index 100% rename from docs/Tutorial/3-Griewank.md rename to docs/Griewank.md diff --git a/docs/Tutorial/5-Hydrological_model.md b/docs/Hydrological_model.md similarity index 100% rename from docs/Tutorial/5-Hydrological_model.md rename to docs/Hydrological_model.md diff --git a/docs/Tutorial/1-Introduction.md b/docs/Introduction.md similarity index 72% rename from docs/Tutorial/1-Introduction.md rename to docs/Introduction.md index f68b1290..f55e433e 100644 --- a/docs/Tutorial/1-Introduction.md +++ b/docs/Introduction.md @@ -4,6 +4,6 @@ Before you start to use SPOTPY you should be familiar with Python. Otherwise I r Basic knowledge about NumPy is also needed. You can get this [here](http://www.engr.ucsb.edu/~shell/che210d/numpy.pdf "NumPY tutorial"). -Last but not least you will need to have knowledge about [Bayesian techniques](https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/tree/master/ "Bayesian techniques"). +Last but not least you might want to have some knowledge about [Bayesian techniques](https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/tree/master/ "Bayesian techniques"). You will find all the needed code to reproduce the following examples in the `PYTHONPATH/Lib/site-packages/spotpy/examples` folder. diff --git a/docs/Tutorial/2-Rosenbrock.md b/docs/Rosenbrock.md similarity index 98% rename from docs/Tutorial/2-Rosenbrock.md rename to docs/Rosenbrock.md index 6a42e25a..9a802266 100644 --- a/docs/Tutorial/2-Rosenbrock.md +++ b/docs/Rosenbrock.md @@ -13,7 +13,7 @@ where we defined control variables as *-10 < x < 10* and *-10 < y < 10*, with * *Figure 1: Response surface of the two dimensional Rosenbrock function. Check out `/examples/3dplot.py`to produce such plots.* -We want to find the global minimum of this function. To do so, one could test every possible parameter setting for *x* and *y* OR one can use SPOTPYPY. +We want to find the global minimum of this function. To do so, one could test every possible parameter setting for *x* and *y* OR one can use SPOTPY. ## Creating the setup file @@ -34,10 +34,12 @@ We start to have a look at the parameters *x* and *y*: We assume to have no prior knowledge about the parameters *x* and *y*, which is why we select a uniform prior distribution from them using NumPy. Numpy offers a wide range of distributions such as uniform, normal and chi-squared. As a minimum (`low`) of the distribution we select *-10* and as maximum (`high`) *10*. The next information which is needed is the name of each parameter (`x` and `y`). + The `stepsize` is biggest possible jump, which a algorithm can make to the next sampling point (used in MCMC, MLE and SA). It is used as the standard derivation within a normal distribution around the last sampled point. The `optguess` value is the initial parameter setting. It will be your first sample in the results and should be selected to a good as possible setting, because it influences how the algorithms evolove from this position. + Further settings can be made by minbound and maxbound, which set the boundaries for the algorithms to sample parameter combination inside the prior given range. If they are not given, bound are determined by sampling 1,000 times from the prior distribution and selecting the minimum and maximum of the sampled values as bounds. @@ -55,7 +57,7 @@ In this case, we know, that *f(x=1,y=1) = 0*. Accordingly, our evaluation functi observations=[0] return observations -Finally, we have to create a function to evaluate our samples. To do so, we select a objective function out of the SPOTPYPY objective function package. +Finally, we have to create a function to evaluate our samples. To do so, we select a objective function out of the SPOTPY objective function package. In this case we select the Root Mean Squared Error, giving the simulations and the evaluations. As we want to minimize our function, we select a negative objective function at this point. diff --git a/docs/Tutorial/6-Working with DREAM and Hymod.md b/docs/Working with DREAM and Hymod.md similarity index 100% rename from docs/Tutorial/6-Working with DREAM and Hymod.md rename to docs/Working with DREAM and Hymod.md diff --git a/mkdocs.yml b/mkdocs.yml index 2889c0ee..4d818d6d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -15,15 +15,15 @@ theme: nav: - Home: index.md - Tutorial: - - Getting Started: getting_started.md - - 1-Introduction: Tutorial\1-Introduction.md - - 2-Rosenbrock: Tutorial\2-Rosenbrock.md - - 3-Griewank: Tutorial\3-Griewank.md - - 4-Ackley: Tutorial\4-Ackley.md - - 5-Hydrological_model: Tutorial\5-Hydrological_model.md - - 6-Working with DREAM and Hymod: Tutorial\6-Working with DREAM and Hymod.md - - 7-Advanced_hints: Tutorial\7-Advanced_hints.md - - 8-Algorithm_guide: Tutorial\8-Algorithm_guide.md + - 1-Introduction: Introduction.md + - 2-Getting Started: getting_started.md + - 3-Rosenbrock: Rosenbrock.md + - 4-Griewank: Griewank.md + - 5-Ackley: Ackley.md + - 6-Hydrological_model: Hydrological_model.md + - 7-Working with DREAM and Hymod: Working with DREAM and Hymod.md + - 8-Advanced_hints: Advanced_hints.md + - 9-Algorithm_guide: Algorithm_guide.md - License: license.md From 8361b67c982d1238a08308232c6c238c74a439a7 Mon Sep 17 00:00:00 2001 From: thouska Date: Tue, 31 Mar 2020 12:14:01 +0200 Subject: [PATCH 06/35] Removed numbers from chapters --- mkdocs.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index 4d818d6d..44b31de5 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -15,15 +15,15 @@ theme: nav: - Home: index.md - Tutorial: - - 1-Introduction: Introduction.md - - 2-Getting Started: getting_started.md - - 3-Rosenbrock: Rosenbrock.md - - 4-Griewank: Griewank.md - - 5-Ackley: Ackley.md - - 6-Hydrological_model: Hydrological_model.md - - 7-Working with DREAM and Hymod: Working with DREAM and Hymod.md - - 8-Advanced_hints: Advanced_hints.md - - 9-Algorithm_guide: Algorithm_guide.md + - Introduction: Introduction.md + - Getting Started: getting_started.md + - Rosenbrock: Rosenbrock.md + - Griewank: Griewank.md + - Ackley: Ackley.md + - Hydrological_model: Hydrological_model.md + - Working with DREAM and Hymod: Working with DREAM and Hymod.md + - Advanced_hints: Advanced_hints.md + - Algorithm_guide: Algorithm_guide.md - License: license.md From a1ea95ebef35924f91e3202ebab68c17a01d5d7f Mon Sep 17 00:00:00 2001 From: thouska Date: Wed, 1 Apr 2020 13:24:04 +0200 Subject: [PATCH 07/35] Updated links to documentation --- README.md | 4 ++-- README.rst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fb57658c..f660c360 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ Or, after downloading the [source code](https://pypi.python.org/pypi/spotpy "sou Support ================= -* Documentation: http://www.uni-giessen.de/cms/faculties/f09/institutes/ilr/hydro/download/spotpy +* Documentation: https://spotpy.readthedocs.io/en/latest/ * Feel free to contact the authors of this tool for any support questions. @@ -160,7 +160,7 @@ Support Getting started ================= -Have a look at https://github.com/thouska/spotpy/tree/master/spotpy/examples and http://fb09-pasig.umwelt.uni-giessen.de/spotpy/Tutorial/2-Rosenbrock/ +Have a look at https://github.com/thouska/spotpy/tree/master/spotpy/examples and https://spotpy.readthedocs.io/en/latest/getting_started/ Contributing diff --git a/README.rst b/README.rst index d0273919..cfe820de 100644 --- a/README.rst +++ b/README.rst @@ -130,7 +130,7 @@ We want to make this task as easy as possible. Some features you can use with th Documentation ------------- -Documentation is available at ``__ +Documentation is available at ``__ Install @@ -178,4 +178,4 @@ Patches/enhancements/new algorithms and any other contributions to this package Getting started --------------- -Have a look at https://github.com/thouska/spotpy/tree/master/spotpy/examples and http://fb09-pasig.umwelt.uni-giessen.de/spotpy/Tutorial/2-Rosenbrock/ +Have a look at https://github.com/thouska/spotpy/tree/master/spotpy/examples and https://spotpy.readthedocs.io/en/latest/getting_started/ From f57c01978b329301e3b8965a0dc700f8908dfc79 Mon Sep 17 00:00:00 2001 From: thouska Date: Wed, 1 Apr 2020 14:49:59 +0200 Subject: [PATCH 08/35] Update version number and references to documentation --- .travis.yml | 2 +- setup.py | 6 +++--- spotpy/__init__.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index f1ad83c4..66c1ed73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,8 @@ language: python python: #- "2.7" #- "3.5" - - "3.6" - "3.7" + - "3.8" # this ubuntu distribution has sure the libopenmpi-dev packages available dist: bionic diff --git a/setup.py b/setup.py index 34f231a4..91078876 100644 --- a/setup.py +++ b/setup.py @@ -5,16 +5,15 @@ setup( name = 'spotpy', - version = '1.5.8', + version = '1.5.9', description = 'A Statistical Parameter Optimization Tool', long_description=open(os.path.join(os.path.dirname(__file__), "README.rst")).read(), author = 'Tobias Houska, Philipp Kraft, Alejandro Chamorro-Chavez and Lutz Breuer', author_email = 'tobias.houska@umwelt.uni-giessen.de', - url = 'http://www.uni-giessen.de/cms/faculties/f09/institutes/ilr/hydro/download/spotpy', + url = 'https://spotpy.readthedocs.io/en/latest/', license = 'MIT', packages=find_packages(exclude=["tests*", "docs*"]), - include_package_data = True, use_2to3 = True, keywords = 'Monte Carlo, MCMC, MLE, SCE-UA, Simulated Annealing, DE-MCz, DREAM, ROPE, Artifical Bee Colony, DDS, PA-DDS, Uncertainty, Calibration, Model, Signatures', classifiers = [ @@ -28,5 +27,6 @@ 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Topic :: Software Development :: Libraries :: Python Modules'], ) diff --git a/spotpy/__init__.py b/spotpy/__init__.py index eed88abe..ba916d3c 100644 --- a/spotpy/__init__.py +++ b/spotpy/__init__.py @@ -22,7 +22,7 @@ - sqlite3 (optional) (https://pypi.python.org/pypi/sqlite3/) :help: For specific questions, try to use the documentation website at: - http://fb09-pasig.umwelt.uni-giessen.de/spotpy/ + https://spotpy.readthedocs.io/en/latest/ For general things about parameter optimization techniques have a look at: https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/tree/master/ @@ -39,4 +39,4 @@ from . import describe # Contains some helper functions to describe samplers and set-ups from .hydrology import signatures # Quantifies goodness of fit between simulation and evaluation data with hydrological signatures -__version__ = '1.5.8' \ No newline at end of file +__version__ = '1.5.9' \ No newline at end of file From 513b1308cce9211950531c531775b6614813571e Mon Sep 17 00:00:00 2001 From: thouska Date: Wed, 1 Apr 2020 14:51:46 +0200 Subject: [PATCH 09/35] Add Mainfest.in for PEP527 --- .gitignore | 1 - MANIFEST.in | 9 +++++++++ spotpy/examples/hymod_exe/Param.in | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 MANIFEST.in create mode 100644 spotpy/examples/hymod_exe/Param.in diff --git a/.gitignore b/.gitignore index e396c9ab..a96f533f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ __pycache__/ #other files *.out -*.in *.png *.csv site/* diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..e5706096 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,9 @@ +include README.md +include MANIFEST.in +include setup.py +include setup.cfg +recursive-include spotpy/examples/cmf_data * +recursive-include spotpy/examples/hymod_exe * +recursive-include spotpy/examples/hymod_unix * +recursive-include spotpy/examples/hymod_python * +include LICENSE \ No newline at end of file diff --git a/spotpy/examples/hymod_exe/Param.in b/spotpy/examples/hymod_exe/Param.in new file mode 100644 index 00000000..1c4f755a --- /dev/null +++ b/spotpy/examples/hymod_exe/Param.in @@ -0,0 +1 @@ +306.82853 1.20622 0.63259 0.05897 0.60575 \ No newline at end of file From 719776d4a8c391d24900a42e8989e9833063b6e0 Mon Sep 17 00:00:00 2001 From: thouska Date: Wed, 1 Apr 2020 14:59:15 +0200 Subject: [PATCH 10/35] Include Documentation badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f660c360..1c325503 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ A Statistical Parameter Optimization Tool for Python [![Build Status][travis-image]][travis-link] [![License][license-image]][license-link] [![Coverage Status](https://coveralls.io/repos/github/thouska/spotpy/badge.svg?branch=master)](https://coveralls.io/github/thouska/spotpy?branch=master) +[![Documentation Status](https://readthedocs.org/projects/spotpy/badge/?version=latest)](https://readthedocs.org/projects/spotpy/badge/?version=latest) [pypi-v-image]: https://img.shields.io/pypi/v/spotpy.png [pypi-v-link]: https://pypi.python.org/pypi/spotpy From 4b4eec4f3544dd710e5c823de9c351b077ce0d04 Mon Sep 17 00:00:00 2001 From: thouska Date: Wed, 1 Apr 2020 15:13:47 +0200 Subject: [PATCH 11/35] Reomve Python 3.8 from Travis test becasue of strange time out error --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 66c1ed73..2144899a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ python: #- "2.7" #- "3.5" - "3.7" - - "3.8" +# - "3.8" #Errors on Travis, build times out because no output was received... # this ubuntu distribution has sure the libopenmpi-dev packages available dist: bionic From 23f4fce2f1410a47c969858e1f89a956e7bac04a Mon Sep 17 00:00:00 2001 From: thouska Date: Tue, 28 Apr 2020 09:15:01 +0200 Subject: [PATCH 12/35] Update documentation --- docs/Hydrological_model.md | 26 +++++++++++++------------ spotpy/__init__.py | 1 + spotpy/examples/tutorial_sceua_hymod.py | 4 ++-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/docs/Hydrological_model.md b/docs/Hydrological_model.md index 07769e02..ea8aef55 100644 --- a/docs/Hydrological_model.md +++ b/docs/Hydrological_model.md @@ -142,7 +142,8 @@ Keep in mind, that the \__init\__ function is only called once during the sampli The more you can separate from you model into the \__init\__ function, the faster you sampling will be. class spotpy_setup(object): - def __init__(self): + def __init__(self, used_algorithm = 'default'): + self._used_algorithm = _used_algorithm datastart = datetime(1998,6,1) dataend = datetime(2000,1,1) analysestart = datetime(1999,1,1) @@ -171,21 +172,22 @@ To define the VanGenuchten parameter boundaries we use a normal distribution. return self.cmfmodel.observations def objectivefunction(self,simulation,evaluation): - objectivefunction= -spotpy.objectivefunctions.rmse(evaluation,simulation) - return objectivefunction + if self._used_algorithm == 'sceua': # The SCE-UA algorithm minimizes the objectivefunction + like = spotpy.objectivefunctions.rmse(evaluation,simulation) + else: # All other implemented algorithm maximize the objectivefunction + objectivefunction= -spotpy.objectivefunctions.rmse(evaluation,simulation) + return objectivefunction ## Sampling - spotpy_setup=spotpy_setup() - - sampler = spotpy.algorithms.mc(spotpy_setup,dbname='MC_CMF',dbformat='csv') - sampler = spotpy.algorithms.mle(spotpy_setup,dbname='MLE_CMF',dbformat='csv') - sampler = spotpy.algorithms.lhs(spotpy_setup,dbname='LHS_CMF',dbformat='csv') - sampler = spotpy.algorithms.sceua(spotpy_setup,dbname='SCEUA_CMF',dbformat='csv') - sampler = spotpy.algorithms.demcz(spotpy_setup,dbname='DE-MCz_CMF',dbformat='csv') - sampler = spotpy.algorithms.sa(spotpy_setup,dbname='SA_CMF',dbformat='csv') - sampler = spotpy.algorithms.rope(spotpy_setup,dbname='ROPE_CMF',dbformat='csv') + sampler = spotpy.algorithms.mc(spotpy_setup(),dbname='MC_CMF',dbformat='csv') + sampler = spotpy.algorithms.mle(spotpy_setup(),dbname='MLE_CMF',dbformat='csv') + sampler = spotpy.algorithms.lhs(spotpy_setup(),dbname='LHS_CMF',dbformat='csv') + sampler = spotpy.algorithms.sceua(spotpy_setup(used_algorithm='sceua'),dbname='SCEUA_CMF',dbformat='csv') + sampler = spotpy.algorithms.demcz(spotpy_setup(),dbname='DE-MCz_CMF',dbformat='csv') + sampler = spotpy.algorithms.sa(spotpy_setup(),dbname='SA_CMF',dbformat='csv') + sampler = spotpy.algorithms.rope(spotpy_setup(),dbname='ROPE_CMF',dbformat='csv') algorithms=['MC','LHS','MLE','MCMC','SCE-UA','SA','DE-MCz','ROPE'] results=[] diff --git a/spotpy/__init__.py b/spotpy/__init__.py index ba916d3c..a51c3d61 100644 --- a/spotpy/__init__.py +++ b/spotpy/__init__.py @@ -20,6 +20,7 @@ - mpi4py (optional) (http://mpi4py.scipy.org/) - pathos (optional) (https://pypi.python.org/pypi/pathos/) - sqlite3 (optional) (https://pypi.python.org/pypi/sqlite3/) + - numba (optional) (https://pypi.python.org/pypi/numba/) :help: For specific questions, try to use the documentation website at: https://spotpy.readthedocs.io/en/latest/ diff --git a/spotpy/examples/tutorial_sceua_hymod.py b/spotpy/examples/tutorial_sceua_hymod.py index efedb3bc..6acea594 100644 --- a/spotpy/examples/tutorial_sceua_hymod.py +++ b/spotpy/examples/tutorial_sceua_hymod.py @@ -11,7 +11,7 @@ import numpy as np import spotpy from spotpy.examples.spot_setup_hymod_python import spot_setup -import pylab as plt +import matplotlib.pyplot as plt if __name__ == "__main__": @@ -24,7 +24,7 @@ spot_setup=spot_setup(_used_algorithm='sceua') #Select number of maximum allowed repetitions - rep=5000 + rep=500 filename = 'SCEUA_hymod' # Create the SCE-UA sampler of spotpy, alt_objfun is set to None to force SPOTPY # to jump into the def objectivefunction in the spot_setup class (default is From c203994dcf9f75a06d1cd0cbabbd13c93c66fde2 Mon Sep 17 00:00:00 2001 From: thouska Date: Tue, 28 Apr 2020 09:19:37 +0200 Subject: [PATCH 13/35] Add tab --- docs/Hydrological_model.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/Hydrological_model.md b/docs/Hydrological_model.md index ea8aef55..fe25527f 100644 --- a/docs/Hydrological_model.md +++ b/docs/Hydrological_model.md @@ -172,11 +172,11 @@ To define the VanGenuchten parameter boundaries we use a normal distribution. return self.cmfmodel.observations def objectivefunction(self,simulation,evaluation): - if self._used_algorithm == 'sceua': # The SCE-UA algorithm minimizes the objectivefunction - like = spotpy.objectivefunctions.rmse(evaluation,simulation) - else: # All other implemented algorithm maximize the objectivefunction - objectivefunction= -spotpy.objectivefunctions.rmse(evaluation,simulation) - return objectivefunction + if self._used_algorithm == 'sceua': # The SCE-UA algorithm minimizes the objectivefunction + like = spotpy.objectivefunctions.rmse(evaluation,simulation) + else: # All other implemented algorithm maximize the objectivefunction + objectivefunction= -spotpy.objectivefunctions.rmse(evaluation,simulation) + return objectivefunction ## Sampling From cf73991d0bfbde83e466b30474f2a594389b549e Mon Sep 17 00:00:00 2001 From: thouska Date: Tue, 26 May 2020 09:26:36 +0200 Subject: [PATCH 14/35] Fix according to #245 in generalized likelihood function --- spotpy/likelihoods.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spotpy/likelihoods.py b/spotpy/likelihoods.py index e8e55537..dfc37a57 100644 --- a/spotpy/likelihoods.py +++ b/spotpy/likelihoods.py @@ -527,7 +527,7 @@ def generalizedLikelihoodFunction(data, comparedata, measerror=None, params=None # where Y_{ht} should be the simulated model data and mu_t = exp(mu_h * Y_{ht}). # So, mu_h is "a bias parameter to be inferred from the model." (cite, page 3, formula (3)) - mu_t = np.mean(muh * comparedata) + mu_t = np.exp(muh * comparedata) E = comparedata * mu_t From bcd48a8527465ba5644123294cd327558345f5e7 Mon Sep 17 00:00:00 2001 From: thouska Date: Tue, 26 May 2020 09:27:18 +0200 Subject: [PATCH 15/35] Update version number --- setup.py | 2 +- spotpy/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 91078876..8b786c28 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name = 'spotpy', - version = '1.5.9', + version = '1.5.10', description = 'A Statistical Parameter Optimization Tool', long_description=open(os.path.join(os.path.dirname(__file__), "README.rst")).read(), diff --git a/spotpy/__init__.py b/spotpy/__init__.py index a51c3d61..89b1022b 100644 --- a/spotpy/__init__.py +++ b/spotpy/__init__.py @@ -40,4 +40,4 @@ from . import describe # Contains some helper functions to describe samplers and set-ups from .hydrology import signatures # Quantifies goodness of fit between simulation and evaluation data with hydrological signatures -__version__ = '1.5.9' \ No newline at end of file +__version__ = '1.5.10' \ No newline at end of file From ed7c28dedf69e238efff186a94bcacc4292aed38 Mon Sep 17 00:00:00 2001 From: lu-kas <> Date: Mon, 22 Jun 2020 09:39:31 +0200 Subject: [PATCH 16/35] SCEUA: added maximal number of loops to be exectued during a sampling call --- spotpy/algorithms/sceua.py | 61 ++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/spotpy/algorithms/sceua.py b/spotpy/algorithms/sceua.py index bdcc5f9a..e212ab22 100644 --- a/spotpy/algorithms/sceua.py +++ b/spotpy/algorithms/sceua.py @@ -5,10 +5,10 @@ :author: Tobias Houska and Stijn Van Hoey ''' -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals + + + + from . import _algorithm import numpy as np @@ -63,6 +63,8 @@ def __init__(self, *args, **kwargs): kwargs['optimization_direction'] = 'minimize' kwargs['algorithm_name'] = 'Shuffled Complex Evolution (SCE-UA) algorithm' super(sceua, self).__init__(*args, **kwargs) + + print("LUKAS version anchor") def simulate(self, id_params_tuple): @@ -128,7 +130,7 @@ def simulate(self, id_params_tuple): # Replace the complex back into the population; return igs, likes, pars, sims, cx, cf, k1, k2, discarded_runs - def sample(self, repetitions, ngs=20, kstop=100, pcento=0.0000001, peps=0.0000001): + def sample(self, repetitions, ngs=20, kstop=100, pcento=0.0000001, peps=0.0000001, max_loop_inc=None): """ Samples from parameter distributions using SCE-UA (Duan, 2004), converted to python by Van Hoey (2011), restructured and parallelized by Houska et al (2015). @@ -146,6 +148,8 @@ def sample(self, repetitions, ngs=20, kstop=100, pcento=0.0000001, peps=0.000000 the percentage change allowed in the past kstop loops below which convergence is assumed to be achieved. peps: float Value of the normalized geometric range of the parameters in the population below which convergence is deemed achieved. + max_loop_inc: int + Number of loops executed at max in this function call """ self.set_repetiton(repetitions) # Initialize SCE parameters: @@ -163,6 +167,9 @@ def sample(self, repetitions, ngs=20, kstop=100, pcento=0.0000001, peps=0.000000 bound = self.bu - self.bl # np.array self.stochastic_parameters = bound != 0 proceed = True + + # burnin_only, needed to indictat if only the burnin phase should be run + burnin_only = False if self.breakpoint == 'read' or self.breakpoint == 'readandwrite': data_frombreak = self.read_breakdata(self.dbname) icall = data_frombreak[0] @@ -177,7 +184,7 @@ def sample(self, repetitions, ngs=20, kstop=100, pcento=0.0000001, peps=0.000000 icall = 0 xf = np.zeros(npt) - print ('Starting burn-in sampling...') + print('Starting burn-in sampling...') # Burn in param_generator = ((rep, x[rep]) for rep in range(int(npt))) @@ -194,6 +201,17 @@ def sample(self, repetitions, ngs=20, kstop=100, pcento=0.0000001, peps=0.000000 idx = np.argsort(xf) xf = np.sort(xf) x = x[idx, :] + + print('Burn-in sampling completed...') + + # write brakpoint if only a single generation shall be computed and + # the main loop will not be executed + if (self.breakpoint == 'write' or self.breakpoint == 'readandwrite') \ + and max_loop_inc == 1: + work = (self.status.rep, (x, xf), gnrng) + self.write_breakdata(self.dbname, work) + burnin_only = True + else: raise ValueError("Don't know the breakpoint keyword {}".format(self.breakpoint)) @@ -221,16 +239,23 @@ def sample(self, repetitions, ngs=20, kstop=100, pcento=0.0000001, peps=0.000000 print( 'THE POPULATION HAS CONVERGED TO A PRESPECIFIED SMALL PARAMETER SPACE') - print ('Burn-in sampling completed...') + + # Begin evolution loops: nloop = 0 criter = [] criter_change_pcent = 1e+5 - - self.repeat.setphase('ComplexEvo') - print ('Starting Complex Evolution...') proceed = True + + # if only burnin, stop the following while loop to be started + if burnin_only: + proceed = False + print('ONLY THE BURNIN PHASE WAS COMPUTED') + else: + self.repeat.setphase('ComplexEvo') + print('Starting Complex Evolution...') + while icall < repetitions and gnrng > peps and criter_change_pcent > pcento and proceed == True: nloop += 1 print ('ComplexEvo loop #%d in progress...' % nloop) @@ -260,10 +285,10 @@ def sample(self, repetitions, ngs=20, kstop=100, pcento=0.0000001, peps=0.000000 self.discarded_runs+=1 print('Skipping saving') - if self.breakpoint == 'write' or self.breakpoint == 'readandwrite'\ - and self.status.rep >= self.backup_every_rep: - work = (self.status.rep, (x, xf), gnrng) - self.write_breakdata(self.dbname, work) + if self.breakpoint == 'write' or self.breakpoint == 'readandwrite'\ + and self.status.rep >= self.backup_every_rep: + work = (self.status.rep, (x, xf), gnrng) + self.write_breakdata(self.dbname, work) # End of Loop on Complex Evolution; @@ -315,7 +340,13 @@ def sample(self, repetitions, ngs=20, kstop=100, pcento=0.0000001, peps=0.000000 'CONVERGENCY HAS ACHIEVED BASED ON OBJECTIVE FUNCTION CRITERIA!!!') elif self.status.stop: proceed = False - break + break + + # stop, if max number of loop iteration was reached + elif max_loop_inc and nloop >= max_loop_inc: + proceed = False + print('THE MAXIMAL NUMBER OF LOOPS PER EXECUTION WAS REACHED') + break # End of the Outer Loops print('SEARCH WAS STOPPED AT TRIAL NUMBER: %d' % self.status.rep) From e89fbb7c5f220dbaae04f7bfde403878ef96affd Mon Sep 17 00:00:00 2001 From: lu-kas <> Date: Mon, 22 Jun 2020 11:00:00 +0200 Subject: [PATCH 17/35] moved write breakpoint --- spotpy/algorithms/sceua.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/spotpy/algorithms/sceua.py b/spotpy/algorithms/sceua.py index e212ab22..601fc594 100644 --- a/spotpy/algorithms/sceua.py +++ b/spotpy/algorithms/sceua.py @@ -170,6 +170,7 @@ def sample(self, repetitions, ngs=20, kstop=100, pcento=0.0000001, peps=0.000000 # burnin_only, needed to indictat if only the burnin phase should be run burnin_only = False + if self.breakpoint == 'read' or self.breakpoint == 'readandwrite': data_frombreak = self.read_breakdata(self.dbname) icall = data_frombreak[0] @@ -202,16 +203,11 @@ def sample(self, repetitions, ngs=20, kstop=100, pcento=0.0000001, peps=0.000000 xf = np.sort(xf) x = x[idx, :] - print('Burn-in sampling completed...') - - # write brakpoint if only a single generation shall be computed and - # the main loop will not be executed - if (self.breakpoint == 'write' or self.breakpoint == 'readandwrite') \ - and max_loop_inc == 1: - work = (self.status.rep, (x, xf), gnrng) - self.write_breakdata(self.dbname, work) + if max_loop_inc == 1: burnin_only = True + print('Burn-in sampling completed...') + else: raise ValueError("Don't know the breakpoint keyword {}".format(self.breakpoint)) @@ -249,9 +245,15 @@ def sample(self, repetitions, ngs=20, kstop=100, pcento=0.0000001, peps=0.000000 proceed = True # if only burnin, stop the following while loop to be started + # write brakpoint if only a single generation shall be computed and + # the main loop will not be executed if burnin_only: + if self.breakpoint == 'write' or self.breakpoint == 'readandwrite': + work = (self.status.rep, (x, xf), gnrng) + self.write_breakdata(self.dbname, work) proceed = False print('ONLY THE BURNIN PHASE WAS COMPUTED') + else: self.repeat.setphase('ComplexEvo') print('Starting Complex Evolution...') From ffb17474f7bacf23e589316096dbaee76a326fc1 Mon Sep 17 00:00:00 2001 From: thouska Date: Fri, 14 Aug 2020 16:58:19 +0200 Subject: [PATCH 18/35] Fix figure plotting and printing in Tutorials --- spotpy/algorithms/_algorithm.py | 2 +- spotpy/algorithms/padds.py | 1 + spotpy/analyser.py | 4 +- spotpy/examples/MyOwnDatabase.txt | 1 + spotpy/examples/hymod_exe/Param.in | 2 +- spotpy/examples/spot_setup_hymod_python.py | 38 ++--- spotpy/examples/spot_setup_rosenbrock.py | 24 ++-- .../tutorial_Parameterlist_iterator.py | 6 +- spotpy/examples/tutorial_dds_hymod.py | 136 ++++++------------ spotpy/examples/tutorial_dream_hymod.py | 4 +- spotpy/examples/tutorial_fast_hymod.py | 3 +- spotpy/examples/tutorial_likelihood.py | 2 +- spotpy/examples/tutorial_own_database.py | 2 +- spotpy/examples/tutorial_padds.py | 3 - spotpy/examples/tutorial_padds_hymod.py | 2 +- spotpy/examples/tutorial_rosenbrock.py | 69 ++++----- spotpy/examples/tutorial_sceua_hymod.py | 2 +- 17 files changed, 129 insertions(+), 172 deletions(-) create mode 100644 spotpy/examples/MyOwnDatabase.txt diff --git a/spotpy/algorithms/_algorithm.py b/spotpy/algorithms/_algorithm.py index 2fe61884..b41705c7 100644 --- a/spotpy/algorithms/_algorithm.py +++ b/spotpy/algorithms/_algorithm.py @@ -45,7 +45,7 @@ def __init__(self, repetitions, algorithm_name, optimization_direction, parnames print('The objective function will be minimized') if optimization_direction == 'maximize': self.compare = self.maximizer - print('The objective function will be minimized') + print('The objective function will be maximized') if optimization_direction == 'grid': self.compare = self.grid diff --git a/spotpy/algorithms/padds.py b/spotpy/algorithms/padds.py index a53c364a..2d9e7fdf 100644 --- a/spotpy/algorithms/padds.py +++ b/spotpy/algorithms/padds.py @@ -182,6 +182,7 @@ def sample(self, repetitions, trials=1, initial_objs=np.array([]), initial_param # Spotpy will not need this values. debug_results = [] print('Starting the PADDS algotrithm with ' + str(repetitions) + ' repetitions...') + print('WARNING: THE PADDS algorithm as implemented in SPOTPY is in an beta stage and not ready for production use!') self.set_repetiton(repetitions) self.number_of_parameters = len(self.best_value.parameters) # number_of_parameters is the amount of parameters diff --git a/spotpy/analyser.py b/spotpy/analyser.py index e026de95..7767d8ee 100644 --- a/spotpy/analyser.py +++ b/spotpy/analyser.py @@ -280,7 +280,7 @@ def get_posterior(results,percentage=10, maximize=True): return results[index] def plot_parameter_uncertainty(posterior_results,evaluation, fig_name='Posterior_parameter_uncertainty.png'): - import pylab as plt + import matplotlib.pyplot as plt simulation_fields = get_simulation_fields(posterior_results) fig= plt.figure(figsize=(16,9)) @@ -781,7 +781,7 @@ def plot_bestmodelrun(results,evaluation,fig_name ='Best_model_run.png'): Returns: figure. Plot of the simulation with the maximum objectivefunction value in the result array as a blue line and dots for the evaluation data. """ - import pylab as plt + import matplotlib.pyplot as plt fig= plt.figure(figsize=(16,9)) for i in range(len(evaluation)): if evaluation[i] == -9999: diff --git a/spotpy/examples/MyOwnDatabase.txt b/spotpy/examples/MyOwnDatabase.txt new file mode 100644 index 00000000..5eaa3fd3 --- /dev/null +++ b/spotpy/examples/MyOwnDatabase.txt @@ -0,0 +1 @@ +obj_functions parameters simulations diff --git a/spotpy/examples/hymod_exe/Param.in b/spotpy/examples/hymod_exe/Param.in index 1c4f755a..de97657f 100644 --- a/spotpy/examples/hymod_exe/Param.in +++ b/spotpy/examples/hymod_exe/Param.in @@ -1 +1 @@ -306.82853 1.20622 0.63259 0.05897 0.60575 \ No newline at end of file +401.08218 0.23071 0.43731 0.06884 0.16352 \ No newline at end of file diff --git a/spotpy/examples/spot_setup_hymod_python.py b/spotpy/examples/spot_setup_hymod_python.py index 67db19d6..7fdefa2f 100644 --- a/spotpy/examples/spot_setup_hymod_python.py +++ b/spotpy/examples/spot_setup_hymod_python.py @@ -12,31 +12,35 @@ from __future__ import print_function from __future__ import unicode_literals -import spotpy +from spotpy.parameter import Uniform +from spotpy.objectivefunctions import rmse from spotpy.examples.hymod_python.hymod import hymod import os class spot_setup(object): - cmax = spotpy.parameter.Uniform(low=1.0 , high=500, optguess=412.33) - bexp = spotpy.parameter.Uniform(low=0.1 , high=2.0, optguess=0.1725) - alpha = spotpy.parameter.Uniform(low=0.1 , high=0.99, optguess=0.8127) - Ks = spotpy.parameter.Uniform(low=0.001 , high=0.10, optguess=0.0404) - Kq = spotpy.parameter.Uniform(low=0.1 , high=0.99, optguess=0.5592) + cmax = Uniform(low=1.0 , high=500, optguess=412.33) + bexp = Uniform(low=0.1 , high=2.0, optguess=0.1725) + alpha = Uniform(low=0.1 , high=0.99, optguess=0.8127) + Ks = Uniform(low=0.001 , high=0.10, optguess=0.0404) + Kq = Uniform(low=0.1 , high=0.99, optguess=0.5592) #fake1 =spotpy.parameter.Uniform(low=0.1 , high=10, optguess=0.5592) #fake2 =spotpy.parameter.Uniform(low=0.1 , high=10, optguess=0.5592) - def __init__(self, _used_algorithm = 'default'): - self._used_algorithm = _used_algorithm + def __init__(self, obj_func=None): + #Just a way to keep this example flexible and applicable to various examples + self.obj_func = obj_func #Transform [mm/day] into [l s-1], where 1.783 is the catchment area self.Factor = 1.783 * 1000 * 1000 / (60 * 60 * 24) #Load Observation data from file self.PET,self.Precip = [], [] self.date,self.trueObs = [], [] + #Find Path to Hymod on users system self.owd = os.path.dirname(os.path.realpath(__file__)) self.hymod_path = self.owd+os.sep+'hymod_python' climatefile = open(self.hymod_path+os.sep+'hymod_input.csv', 'r') headerline = climatefile.readline()[:-1] + #Read model forcing in working storage (this is done only ones) if ';' in headerline: self.delimiter = ';' else: @@ -48,27 +52,27 @@ def __init__(self, _used_algorithm = 'default'): self.Precip.append(float(values[1])) self.PET.append(float(values[2])) self.trueObs.append(float(values[3])) - climatefile.close() - def simulation(self,x): + #Here the model is actualy startet with one paramter combination data = hymod(self.Precip, self.PET, x[0], x[1], x[2], x[3], x[4]) sim=[] for val in data: sim.append(val*self.Factor) + #The first year of simulation data is ignored (warm-up) return sim[366:] def evaluation(self): return self.trueObs[366:] def objectivefunction(self,simulation,evaluation, params=None): - if self._used_algorithm == 'sceua': - like = spotpy.objectivefunctions.rmse(evaluation,simulation) - elif self._used_algorithm == 'dream': - like = spotpy.objectivefunctions.log_p(evaluation,simulation) - elif self._used_algorithm == 'default': - like = spotpy.objectivefunctions.nashsutcliffe(evaluation,simulation) + #SPOTPY expects to get one or multiple values back, + #that define the performence of the model run + if not self.obj_func: + # This is used if not overwritten by user + like = rmse(evaluation,simulation) else: - like = spotpy.likelihoods.gaussianLikelihoodMeasErrorOut(evaluation,simulation) + #Way to ensure on flexible spot setup class + like = self.obj_func(evaluation,simulation) return like \ No newline at end of file diff --git a/spotpy/examples/spot_setup_rosenbrock.py b/spotpy/examples/spot_setup_rosenbrock.py index edc17969..d811cd7f 100644 --- a/spotpy/examples/spot_setup_rosenbrock.py +++ b/spotpy/examples/spot_setup_rosenbrock.py @@ -9,10 +9,10 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals -import numpy as np +import numpy as np from spotpy.parameter import Uniform -from spotpy.objectivefunctions import rmse, log_p +from spotpy.objectivefunctions import rmse class spot_setup(object): """ @@ -23,8 +23,10 @@ class spot_setup(object): x = Uniform(-10, 10, 1.5, 3.0, -10, 10, doc='x value of Rosenbrock function') y = Uniform(-10, 10, 1.5, 3.0, -10, 10, doc='y value of Rosenbrock function') z = Uniform(-10, 10, 1.5, 3.0, -10, 10, doc='z value of Rosenbrock function') - def __init__(self,used_algorithm='default'): - self.used_algorithm =used_algorithm + + def __init__(self,obj_func=None): + self.obj_func = obj_func + def simulation(self, vector): x=np.array(vector) simulations= [sum(100.0 * (x[1:] - x[:-1] ** 2.0) ** 2.0 + (1 - x[:-1]) ** 2.0)] @@ -35,10 +37,12 @@ def evaluation(self): return observations def objectivefunction(self, simulation, evaluation): - if self.used_algorithm == 'sceua' or self.used_algorithm == 'abc' or self.used_algorithm == 'fscabc': - objectivefunction = rmse(evaluation=evaluation, simulation=simulation) - elif self.used_algorithm == 'dream' or self.used_algorithm == 'demcz' or self.used_algorithm == 'mcmc': - objectivefunction = log_p(evaluation=evaluation, simulation=simulation) + #SPOTPY expects to get one or multiple values back, + #that define the performence of the model run + if not self.obj_func: + # This is used if not overwritten by user + like = rmse(evaluation,simulation) else: - objectivefunction = - rmse(evaluation=evaluation, simulation=simulation) - return objectivefunction \ No newline at end of file + #Way to ensure on flexible spot setup class + like = self.obj_func(evaluation,simulation) + return like \ No newline at end of file diff --git a/spotpy/examples/tutorial_Parameterlist_iterator.py b/spotpy/examples/tutorial_Parameterlist_iterator.py index 63736c08..724bed36 100644 --- a/spotpy/examples/tutorial_Parameterlist_iterator.py +++ b/spotpy/examples/tutorial_Parameterlist_iterator.py @@ -15,11 +15,13 @@ class spot_setup(object): - slow = 1000 + def __init__(self): + self.slow = 1000 self.params = [spotpy.parameter.List('x',[1,2,3,4,5,6,7,8,9,0]), #Give possible x values as a List spotpy.parameter.List('y',[0,1,2,5,6,7,8,9,0,1]) #Give possible y values as a List - ] + + ] def parameters(self): return spotpy.parameter.generate(self.params) diff --git a/spotpy/examples/tutorial_dds_hymod.py b/spotpy/examples/tutorial_dds_hymod.py index 67c26715..f94a061c 100644 --- a/spotpy/examples/tutorial_dds_hymod.py +++ b/spotpy/examples/tutorial_dds_hymod.py @@ -17,7 +17,7 @@ import spotpy from spotpy.examples.spot_setup_hymod_python import spot_setup -import pylab as plt +import matplotlib.pyplot as plt if __name__ == "__main__": @@ -27,7 +27,7 @@ # Initialize the Hymod example # In this case, we tell the setup which algorithm we want to use, so # we can use this exmaple for different algorithms - spot_setup=spot_setup() + spot_setup=spot_setup(users_objective_function=spotpy.objectivefunctions.nashsutcliffe) #Select number of maximum allowed repetitions rep=1000 @@ -35,117 +35,65 @@ # Create the SCE-UA sampler of spotpy, alt_objfun is set to None to force SPOTPY # to jump into the def objectivefunction in the spot_setup class (default is # spotpy.objectivefunctions.rmse) - sampler=spotpy.algorithms.dds(spot_setup, dbname='DDS_hymod', dbformat='csv', alt_objfun=None) + sampler=spotpy.algorithms.dds(spot_setup, dbname='DDS_hymod', dbformat='csv') #Start the sampler, one can specify ngs, kstop, peps and pcento id desired sampler.sample(rep) results = sampler.getdata() - print(results) + fig= plt.figure(1,figsize=(9,5)) plt.plot(results['like1']) plt.show() - plt.ylabel('RMSE') + plt.ylabel('Objective function') plt.xlabel('Iteration') fig.savefig('hymod_objectivefunction.png',dpi=300) # Example plot to show the parameter distribution ###### + def plot_parameter_trace(ax, results, parameter): + ax.plot(results['par'+parameter.name],'.') + ax.set_ylabel(parameter.name) + ax.set_ylim(parameter.minbound, parameter.maxbound) + + def plot_parameter_histogram(ax, results, parameter): + #chooses the last 20% of the sample + ax.hist(results['par'+parameter.name][int(len(results)*0.9):], + bins =np.linspace(parameter.minbound,parameter.maxbound,20)) + ax.set_ylabel('Density') + ax.set_xlim(parameter.minbound, parameter.maxbound) + fig= plt.figure(2,figsize=(9,9)) - normed_value = 1 - - plt.subplot(5,2,1) - x = results['parcmax'] - for i in range(int(max(results['chain'])-1)): - index=np.where(results['chain']==i+1) #Ignores burn-in chain - plt.plot(x[index],'.') - plt.ylabel('cmax') - plt.ylim(spot_setup.cmax.minbound, spot_setup.cmax.maxbound) - - - plt.subplot(5,2,2) - x = x[int(len(results)*0.9):] #choose the last 10% of the sample - hist, bins = np.histogram(x, bins=20, density=True) - widths = np.diff(bins) - hist *= normed_value - plt.bar(bins[:-1], hist, widths) - plt.ylabel('cmax') - plt.xlim(spot_setup.cmax.minbound, spot_setup.cmax.maxbound) - - - plt.subplot(5,2,3) - x = results['parbexp'] - for i in range(int(max(results['chain'])-1)): - index=np.where(results['chain']==i+1) - plt.plot(x[index],'.') - plt.ylabel('bexp') - plt.ylim(spot_setup.bexp.minbound, spot_setup.bexp.maxbound) - plt.subplot(5,2,4) - x = x[int(len(results)*0.9):] - hist, bins = np.histogram(x, bins=20, density=True) - widths = np.diff(bins) - hist *= normed_value - plt.bar(bins[:-1], hist, widths) - plt.ylabel('bexp') - plt.xlim(spot_setup.bexp.minbound, spot_setup.bexp.maxbound) + ax1 = plt.subplot(5,2,1) + plot_parameter_trace(ax1, results, spot_setup.cmax) + ax2 = plt.subplot(5,2,2) + plot_parameter_histogram(ax2,results, spot_setup.cmax) + ax3 = plt.subplot(5,2,3) + plot_parameter_trace(ax3, results, spot_setup.bexp) - plt.subplot(5,2,5) - x = results['paralpha'] - for i in range(int(max(results['chain'])-1)): - index=np.where(results['chain']==i+1) - plt.plot(x[index],'.') - plt.ylabel('alpha') - plt.ylim(spot_setup.alpha.minbound, spot_setup.alpha.maxbound) - - - plt.subplot(5,2,6) - x = x[int(len(results)*0.9):] - hist, bins = np.histogram(x, bins=20, density=True) - widths = np.diff(bins) - hist *= normed_value - plt.bar(bins[:-1], hist, widths) - plt.ylabel('alpha') - plt.xlim(spot_setup.alpha.minbound, spot_setup.alpha.maxbound) - - - plt.subplot(5,2,7) - x = results['parKs'] - for i in range(int(max(results['chain'])-1)): - index=np.where(results['chain']==i+1) - plt.plot(x[index],'.') - plt.ylabel('Ks') - plt.ylim(spot_setup.Ks.minbound, spot_setup.Ks.maxbound) - - - plt.subplot(5,2,8) - x = x[int(len(results)*0.9):] + ax4 = plt.subplot(5,2,4) + plot_parameter_histogram(ax4, results, spot_setup.bexp) + + ax5 = plt.subplot(5,2,5) + plot_parameter_trace(ax5, results, spot_setup.alpha) + + ax6 = plt.subplot(5,2,6) + plot_parameter_histogram(ax6, results, spot_setup.alpha) - hist, bins = np.histogram(x, bins=20, density=True) - widths = np.diff(bins) - hist *= normed_value - plt.bar(bins[:-1], hist, widths) - plt.ylabel('Ks') - plt.xlim(spot_setup.Ks.minbound, spot_setup.Ks.maxbound) + ax7 = plt.subplot(5,2,7) + plot_parameter_trace(ax7, results, spot_setup.Ks) + ax8 = plt.subplot(5,2,8) + plot_parameter_histogram(ax8, results, spot_setup.Ks) + + ax9 = plt.subplot(5,2,9) + plot_parameter_trace(ax9, results, spot_setup.Kq) + ax9.set_xlabel('Iterations') - plt.subplot(5,2,9) - x = results['parKq'] - for i in range(int(max(results['chain'])-1)): - index=np.where(results['chain']==i+1) - plt.plot(x[index],'.') - plt.ylabel('Kq') - plt.ylim(spot_setup.Kq.minbound, spot_setup.Kq.maxbound) - plt.xlabel('Iterations') + ax10 = plt.subplot(5,2,10) + plot_parameter_histogram(ax10, results, spot_setup.Kq) + ax10.set_xlabel('Parameter range') - plt.subplot(5,2,10) - x = x[int(len(results)*0.9):] - hist, bins = np.histogram(x, bins=20, density=True) - widths = np.diff(bins) - hist *= normed_value - plt.bar(bins[:-1], hist, widths) - plt.ylabel('Kq') - plt.xlabel('Parameter range') - plt.xlim(spot_setup.Kq.minbound, spot_setup.Kq.maxbound) plt.show() fig.savefig('hymod_parameters.png',dpi=300) \ No newline at end of file diff --git a/spotpy/examples/tutorial_dream_hymod.py b/spotpy/examples/tutorial_dream_hymod.py index 9513e645..543ac514 100644 --- a/spotpy/examples/tutorial_dream_hymod.py +++ b/spotpy/examples/tutorial_dream_hymod.py @@ -12,14 +12,14 @@ import spotpy #from spotpy.examples.spot_setup_hymod_exe import spot_setup from spotpy.examples.spot_setup_hymod_python import spot_setup -import pylab as plt +import matplotlib.pyplot as plt if __name__ == "__main__": parallel ='seq' # Initialize the Hymod example (will only work on Windows systems) #spot_setup=spot_setup(parallel=parallel) - spot_setup=spot_setup(_used_algorithm='dream') + spot_setup=spot_setup(obj_func = spotpy.likelihoods.gaussianLikelihoodMeasErrorOut) # Create the Dream sampler of spotpy, al_objfun is set to None to force SPOTPY # to jump into the def objectivefunction in the spot_setup class (default is diff --git a/spotpy/examples/tutorial_fast_hymod.py b/spotpy/examples/tutorial_fast_hymod.py index b6761e86..4ea0f05e 100644 --- a/spotpy/examples/tutorial_fast_hymod.py +++ b/spotpy/examples/tutorial_fast_hymod.py @@ -14,8 +14,7 @@ import sys sys.path.append(".") import spotpy -from spotpy.examples.spot_setup_hymod_exe import spot_setup -#from spotpy.examples.spot_setup_hymod_python import spot_setup +from spotpy.examples.spot_setup_hymod_python import spot_setup if __name__ == "__main__": diff --git a/spotpy/examples/tutorial_likelihood.py b/spotpy/examples/tutorial_likelihood.py index 06e3de14..a0b9c4c3 100644 --- a/spotpy/examples/tutorial_likelihood.py +++ b/spotpy/examples/tutorial_likelihood.py @@ -350,7 +350,7 @@ def objectivefunction(self, simulation=simulation, evaluation=evaluation, params sampler = spotpy.algorithms.lhs(spot_setup, dbname='RosenMC', dbformat='csv', alt_objfun=None) sampler.sample(rep) results.append(sampler.getdata()) -import pprint + import pickle pickle.dump(results, open('mle_LimitsOfAcceptability_v2.p', 'wb')) diff --git a/spotpy/examples/tutorial_own_database.py b/spotpy/examples/tutorial_own_database.py index b75e0fcd..2fc4f5e9 100644 --- a/spotpy/examples/tutorial_own_database.py +++ b/spotpy/examples/tutorial_own_database.py @@ -54,5 +54,5 @@ def save(self, objectivefunctions, parameter, simulations, *args, **kwargs): # Leave out dbformat and dbname and spotpy will return results in spot_setup.save function sampler = spotpy.algorithms.mc(spot_setup) -sampler.sample(10) # Choose equal or less repetitions as you have parameters in your List +sampler.sample(9) # Choose equal or less repetitions as you have parameters in your List spot_setup.database.close() # Close the created txt file diff --git a/spotpy/examples/tutorial_padds.py b/spotpy/examples/tutorial_padds.py index 7ebd5f3a..3dd54cdc 100644 --- a/spotpy/examples/tutorial_padds.py +++ b/spotpy/examples/tutorial_padds.py @@ -54,9 +54,6 @@ def __init__(self): self.params.append(spotpy.parameter.Uniform(str(i+1), 0, 1, 0, 0, 0, 1,doc="param no " + str(i+1))) def parameters(self): - - a = spotpy.parameter.generate(self.params) - return spotpy.parameter.generate(self.params) def simulation(self, vector): diff --git a/spotpy/examples/tutorial_padds_hymod.py b/spotpy/examples/tutorial_padds_hymod.py index b8493734..7a9c695c 100644 --- a/spotpy/examples/tutorial_padds_hymod.py +++ b/spotpy/examples/tutorial_padds_hymod.py @@ -17,7 +17,7 @@ import spotpy from spotpy.examples.spot_setup_hymod_python_pareto import spot_setup -import pylab as plt +import matplotlib.pyplot as plt if __name__ == "__main__": diff --git a/spotpy/examples/tutorial_rosenbrock.py b/spotpy/examples/tutorial_rosenbrock.py index 4f91c205..d4c8c36d 100644 --- a/spotpy/examples/tutorial_rosenbrock.py +++ b/spotpy/examples/tutorial_rosenbrock.py @@ -26,86 +26,87 @@ #Create samplers for every algorithm: results=[] -spot_setup=spot_setup() rep=1000 timeout=10 #Given in Seconds parallel = "seq" dbformat = "csv" -sampler=spotpy.algorithms.mc(spot_setup,parallel=parallel, dbname='RosenMC', dbformat=dbformat, sim_timeout=timeout) -print(describe(sampler)) -sampler.sample(rep) -results.append(sampler.getdata()) - +# Bayesian algorithms should be run with a likelihood function +bayesian_likelihood_func = spotpy.likelihoods.gaussianLikelihoodMeasErrorOut -sampler=spotpy.algorithms.lhs(spot_setup,parallel=parallel, dbname='RosenLHS', dbformat=dbformat, sim_timeout=timeout) +sampler = spotpy.algorithms.mc(spot_setup(), + parallel=parallel, dbname='RosenMC', dbformat=dbformat, sim_timeout=timeout) print(describe(sampler)) sampler.sample(rep) results.append(sampler.getdata()) -sampler=spotpy.algorithms.mle(spot_setup, parallel=parallel, dbname='RosenMLE', dbformat=dbformat, sim_timeout=timeout) -print(describe(sampler)) +sampler = spotpy.algorithms.lhs(spot_setup(), + parallel=parallel, dbname='RosenLHS', dbformat=dbformat, sim_timeout=timeout) sampler.sample(rep) results.append(sampler.getdata()) -# -sampler=spotpy.algorithms.mcmc(spot_setup, parallel=parallel, dbname='RosenMCMC', dbformat=dbformat, sim_timeout=timeout) -print(describe(sampler)) + + +sampler=spotpy.algorithms.mle(spot_setup(obj_func=bayesian_likelihood_func), + parallel=parallel, dbname='RosenMLE', dbformat=dbformat, sim_timeout=timeout) sampler.sample(rep) results.append(sampler.getdata()) -sampler=spotpy.algorithms.sceua(spot_setup, parallel=parallel, dbname='RosenSCEUA', dbformat=dbformat, sim_timeout=timeout) -print(describe(sampler)) + +sampler=spotpy.algorithms.sceua(spot_setup(), + parallel=parallel, dbname='RosenSCEUA', dbformat=dbformat, sim_timeout=timeout) sampler.sample(rep,ngs=4) results.append(sampler.getdata()) -sampler=spotpy.algorithms.sa(spot_setup, parallel=parallel, dbname='RosenSA', dbformat=dbformat, sim_timeout=timeout) -print(describe(sampler)) + +sampler=spotpy.algorithms.sa(spot_setup(obj_func=bayesian_likelihood_func), + parallel=parallel, dbname='RosenSA', dbformat=dbformat, sim_timeout=timeout) sampler.sample(rep) results.append(sampler.getdata()) -sampler=spotpy.algorithms.demcz(spot_setup,parallel=parallel, dbname='RosenDEMCz', dbformat=dbformat, sim_timeout=timeout) -print(describe(sampler)) -sampler.sample(rep,nChains=4) -results.append(sampler.getdata()) -sampler=spotpy.algorithms.rope(spot_setup, parallel=parallel, dbname='RosenROPE', dbformat=dbformat,sim_timeout=timeout) -print(describe(sampler)) +sampler=spotpy.algorithms.rope(spot_setup(), + parallel=parallel, dbname='RosenROPE', dbformat=dbformat,sim_timeout=timeout) sampler.sample(rep) results.append(sampler.getdata()) -sampler=spotpy.algorithms.abc(spot_setup, parallel=parallel, dbname='RosenABC', dbformat=dbformat,sim_timeout=timeout) -print(describe(sampler)) +sampler=spotpy.algorithms.abc(spot_setup(), + parallel=parallel, dbname='RosenABC', dbformat=dbformat,sim_timeout=timeout) sampler.sample(rep) results.append(sampler.getdata()) -sampler=spotpy.algorithms.fscabc(spot_setup, parallel=parallel, dbname='RosenFSABC', dbformat=dbformat, sim_timeout=timeout) -print(describe(sampler)) +sampler=spotpy.algorithms.fscabc(spot_setup(), + parallel=parallel, dbname='RosenFSABC', dbformat=dbformat, sim_timeout=timeout) sampler.sample(rep) results.append(sampler.getdata()) -sampler=spotpy.algorithms.demcz(spot_setup, parallel=parallel, dbname='RosenDEMCZ', dbformat=dbformat, sim_timeout=timeout) -print(describe(sampler)) +sampler=spotpy.algorithms.mcmc(spot_setup(obj_func=bayesian_likelihood_func), + parallel=parallel, dbname='RosenMCMC', dbformat=dbformat, sim_timeout=timeout) sampler.sample(rep) results.append(sampler.getdata()) -sampler=spotpy.algorithms.dream(spot_setup, parallel=parallel, dbname='RosenDREAM', dbformat=dbformat, sim_timeout=timeout) -print(describe(sampler)) -sampler.sample(rep) +sampler=spotpy.algorithms.demcz(spot_setup(obj_func = bayesian_likelihood_func), + parallel=parallel, dbname='RosenDEMCz', dbformat=dbformat, sim_timeout=timeout) +sampler.sample(rep,nChains=4) +results.append(sampler.getdata()) + +sampler=spotpy.algorithms.dream(spot_setup(obj_func = bayesian_likelihood_func), + parallel=parallel, dbname='RosenDREAM', dbformat=dbformat, sim_timeout=timeout) +sampler.sample(rep,nChains=4) results.append(sampler.getdata()) print(results[0].dtype) # Check for Travis: Get the last sampled parameter for x -evaluation = spot_setup.evaluation() +evaluation = spot_setup().evaluation() # Example how to plot the data -algorithms = ['mc','lhs','mle','mcmc','sceua','sa','demcz','rope','abc','fscabc', 'demcz', 'dream'] -spotpy.analyser.plot_parametertrace_algorithms(results, algorithms, spot_setup) +algorithms = ['mc','lhs','mle','sceua','sa','rope','abc','fscabc', 'mcmc', 'demcz', 'dream'] +spotpy.analyser.plot_parametertrace_algorithms(results, algorithms, spot_setup()) diff --git a/spotpy/examples/tutorial_sceua_hymod.py b/spotpy/examples/tutorial_sceua_hymod.py index 6acea594..25c7129c 100644 --- a/spotpy/examples/tutorial_sceua_hymod.py +++ b/spotpy/examples/tutorial_sceua_hymod.py @@ -21,7 +21,7 @@ # Initialize the Hymod example # In this case, we tell the setup which algorithm we want to use, so # we can use this exmaple for different algorithms - spot_setup=spot_setup(_used_algorithm='sceua') + spot_setup=spot_setup(users_objective_function=spotpy.objectivefunctions.rmse) #Select number of maximum allowed repetitions rep=500 From 3dab42943821934b1f02d35e9fee53d962b803f2 Mon Sep 17 00:00:00 2001 From: thouska Date: Sat, 15 Aug 2020 14:35:22 +0200 Subject: [PATCH 19/35] Unify use of spot_setup hymod example --- docs/Hydrological_model.md | 22 +++++++++++++------ spotpy/examples/gui_hymod.py | 3 ++- spotpy/examples/spot_setup_hymod_python.py | 2 +- .../spot_setup_hymod_python_pareto.py | 3 +-- spotpy/examples/tutorial_dream_hymod.py | 6 ++--- tests/test_algorithms.py | 14 +++++++----- tests/test_analyser.py | 4 ++-- 7 files changed, 32 insertions(+), 22 deletions(-) diff --git a/docs/Hydrological_model.md b/docs/Hydrological_model.md index fe25527f..09cf2bd4 100644 --- a/docs/Hydrological_model.md +++ b/docs/Hydrological_model.md @@ -142,8 +142,9 @@ Keep in mind, that the \__init\__ function is only called once during the sampli The more you can separate from you model into the \__init\__ function, the faster you sampling will be. class spotpy_setup(object): - def __init__(self, used_algorithm = 'default'): - self._used_algorithm = _used_algorithm + def __init__(self, obj_func=None): + #Just a way to keep this example flexible and applicable to various examples + self.obj_func = obj_func datastart = datetime(1998,6,1) dataend = datetime(2000,1,1) analysestart = datetime(1999,1,1) @@ -172,11 +173,18 @@ To define the VanGenuchten parameter boundaries we use a normal distribution. return self.cmfmodel.observations def objectivefunction(self,simulation,evaluation): - if self._used_algorithm == 'sceua': # The SCE-UA algorithm minimizes the objectivefunction - like = spotpy.objectivefunctions.rmse(evaluation,simulation) - else: # All other implemented algorithm maximize the objectivefunction - objectivefunction= -spotpy.objectivefunctions.rmse(evaluation,simulation) - return objectivefunction + #SPOTPY expects to get one or multiple values back, + #that define the performence of the model run + if not self.obj_func: + # This is used if not overwritten by user + # RMSE (root mean squared error) works good for the SCE-UA algorithm, + # as it minimizes the objective function. + # All other implemented algorithm maximize the objectivefunction + model_performance = spotpy.objectivefunctions.rmse(evaluation,simulation) + else: + #Way to ensure flexible spot setup class + model_performance = self.obj_func(evaluation,simulation) + return model_performance ## Sampling diff --git a/spotpy/examples/gui_hymod.py b/spotpy/examples/gui_hymod.py index a1d8ffd7..d0f7f9b3 100644 --- a/spotpy/examples/gui_hymod.py +++ b/spotpy/examples/gui_hymod.py @@ -10,9 +10,10 @@ import spotpy from spotpy.gui.mpl import GUI from spotpy.examples.spot_setup_hymod_python import spot_setup +from spotpy.objectivefunctions import rmse if __name__ == '__main__': - setup_class=spot_setup(_used_algorithm='sceua') + setup_class=spot_setup(rmse) #Select number of maximum allowed repetitions rep=10000 diff --git a/spotpy/examples/spot_setup_hymod_python.py b/spotpy/examples/spot_setup_hymod_python.py index 7fdefa2f..876f1f41 100644 --- a/spotpy/examples/spot_setup_hymod_python.py +++ b/spotpy/examples/spot_setup_hymod_python.py @@ -73,6 +73,6 @@ def objectivefunction(self,simulation,evaluation, params=None): # This is used if not overwritten by user like = rmse(evaluation,simulation) else: - #Way to ensure on flexible spot setup class + #Way to ensure flexible spot setup class like = self.obj_func(evaluation,simulation) return like \ No newline at end of file diff --git a/spotpy/examples/spot_setup_hymod_python_pareto.py b/spotpy/examples/spot_setup_hymod_python_pareto.py index cc15b13c..ceb2fffa 100644 --- a/spotpy/examples/spot_setup_hymod_python_pareto.py +++ b/spotpy/examples/spot_setup_hymod_python_pareto.py @@ -24,8 +24,7 @@ class spot_setup(object): Ks = spotpy.parameter.Uniform(low=0.0 , high=0.10, optguess=0.0404) Kq = spotpy.parameter.Uniform(low=0.1 , high=0.99, optguess=0.5592) - def __init__(self, _used_algorithm = 'default'): - self._used_algorithm = _used_algorithm + def __init__(self): #Transform [mm/day] into [l s-1], where 1.783 is the catchment area self.Factor = 1.783 * 1000 * 1000 / (60 * 60 * 24) #Load Observation data from file diff --git a/spotpy/examples/tutorial_dream_hymod.py b/spotpy/examples/tutorial_dream_hymod.py index 543ac514..c7cc3d9a 100644 --- a/spotpy/examples/tutorial_dream_hymod.py +++ b/spotpy/examples/tutorial_dream_hymod.py @@ -13,20 +13,20 @@ #from spotpy.examples.spot_setup_hymod_exe import spot_setup from spotpy.examples.spot_setup_hymod_python import spot_setup import matplotlib.pyplot as plt - +from spotpy.likelihoods import gaussianLikelihoodMeasErrorOut as GausianLike if __name__ == "__main__": parallel ='seq' # Initialize the Hymod example (will only work on Windows systems) #spot_setup=spot_setup(parallel=parallel) - spot_setup=spot_setup(obj_func = spotpy.likelihoods.gaussianLikelihoodMeasErrorOut) + spot_setup=spot_setup(GausianLike) # Create the Dream sampler of spotpy, al_objfun is set to None to force SPOTPY # to jump into the def objectivefunction in the spot_setup class (default is # spotpy.objectivefunctions.log_p) #Select number of maximum repetitions - rep=10000 + rep=5000 # Select five chains and set the Gelman-Rubin convergence limit nChains = 4 diff --git a/tests/test_algorithms.py b/tests/test_algorithms.py index 63578543..f6bfce4b 100644 --- a/tests/test_algorithms.py +++ b/tests/test_algorithms.py @@ -17,6 +17,8 @@ from spotpy.examples.tutorial_padds import padds_spot_setup from spotpy.describe import describe import os +from spotpy.likelihoods import gaussianLikelihoodMeasErrorOut as GausianLike + #https://docs.python.org/3/library/unittest.html @@ -50,37 +52,37 @@ def test_mle(self): self.assertEqual(len(results), self.rep) def test_mcmc(self): - sampler=spotpy.algorithms.mcmc(spot_setup(used_algorithm='mcmc'),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) + sampler=spotpy.algorithms.mcmc(spot_setup(GausianLike),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) sampler.sample(self.rep) results = sampler.getdata() self.assertEqual(len(results), self.rep) def test_demcz(self): - sampler=spotpy.algorithms.demcz(spot_setup(used_algorithm='demcz'),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) + sampler=spotpy.algorithms.demcz(spot_setup(GausianLike),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) sampler.sample(self.rep, convergenceCriteria=0) results = sampler.getdata() self.assertEqual(len(results), self.rep) def test_dream(self): - sampler=spotpy.algorithms.dream(spot_setup(used_algorithm='dream'),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) + sampler=spotpy.algorithms.dream(spot_setup(GausianLike),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) sampler.sample(self.rep, convergence_limit=0.9, runs_after_convergence=500) results = sampler.getdata() self.assertEqual(len(results), self.rep) def test_sceua(self): - sampler=spotpy.algorithms.sceua(spot_setup(used_algorithm='sceua'),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) + sampler=spotpy.algorithms.sceua(spot_setup(),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) sampler.sample(self.rep) results = sampler.getdata() self.assertLessEqual(len(results), self.rep) #Sceua save per definition not all sampled runs def test_abc(self): - sampler=spotpy.algorithms.abc(spot_setup(used_algorithm='abc'),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) + sampler=spotpy.algorithms.abc(spot_setup(),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) sampler.sample(self.rep) results = sampler.getdata() self.assertEqual(len(results), self.rep) def test_fscabc(self): - sampler=spotpy.algorithms.fscabc(spot_setup(used_algorithm='fscabc'),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) + sampler=spotpy.algorithms.fscabc(spot_setup(),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) sampler.sample(self.rep) results = sampler.getdata() self.assertEqual(len(results), self.rep) diff --git a/tests/test_analyser.py b/tests/test_analyser.py index 3379427d..ba35f13f 100644 --- a/tests/test_analyser.py +++ b/tests/test_analyser.py @@ -23,7 +23,7 @@ from spotpy.examples.spot_setup_rosenbrock import spot_setup as rosenbrock_setup from spotpy.examples.spot_setup_griewank import spot_setup as griewank_setup from spotpy.examples.spot_setup_hymod_python import spot_setup as hymod_setup - +from spotpy.likelihoods import gaussianLikelihoodMeasErrorOut as GausianLike class TestAnalyser(unittest.TestCase): @classmethod @@ -51,7 +51,7 @@ def setUpClass(self): sampler.sample(self.rep) self.sens_results = sampler.getdata() #Hymod resuts are empty with Python <3.6 - sampler = spotpy.algorithms.dream(hymod_setup(_used_algorithm='dream'), + sampler = spotpy.algorithms.dream(hymod_setup(GausianLike), sim_timeout=self.timeout) self.r_hat = sampler.sample(self.rep) self.hymod_results = sampler.getdata() From b5bcce0e70585c929f7d600afd972a9a1f0e81a8 Mon Sep 17 00:00:00 2001 From: Jinadelee <58844036+Jinadelee@users.noreply.github.com> Date: Tue, 1 Sep 2020 15:22:58 +1000 Subject: [PATCH 20/35] Update padds.py This will ensure new_value within the predefined min and max bounds --- spotpy/algorithms/padds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spotpy/algorithms/padds.py b/spotpy/algorithms/padds.py index 2d9e7fdf..90105f33 100644 --- a/spotpy/algorithms/padds.py +++ b/spotpy/algorithms/padds.py @@ -307,7 +307,7 @@ def calculate_next_s_test(self, previous_x_curr, rep, rep_limit, r): if dvn_count == 0: # no DVs selected at random, so select ONE dec_var = np.int(np.ceil(amount_params * self.np_random.rand())) - new_value = self.dds_generator.neigh_value_mixed(previous_x_curr, r, dec_var - 1, self.min_bound[j],self.max_bound[j]) + new_value = self.dds_generator.neigh_value_mixed(previous_x_curr, r, dec_var - 1, self.min_bound[dec_var - 1],self.max_bound[dec_var - 1]) new_x_curr[dec_var - 1] = new_value # change relevant decision variable value in s_test From 9676bfc06d0929a5c5828c0ccac630d4a487936d Mon Sep 17 00:00:00 2001 From: lu-kas <> Date: Fri, 4 Sep 2020 10:39:54 +0200 Subject: [PATCH 21/35] cleanup for PR --- spotpy/algorithms/sceua.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/spotpy/algorithms/sceua.py b/spotpy/algorithms/sceua.py index 601fc594..7d901f6b 100644 --- a/spotpy/algorithms/sceua.py +++ b/spotpy/algorithms/sceua.py @@ -5,10 +5,10 @@ :author: Tobias Houska and Stijn Van Hoey ''' - - - - +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals from . import _algorithm import numpy as np @@ -64,8 +64,6 @@ def __init__(self, *args, **kwargs): kwargs['algorithm_name'] = 'Shuffled Complex Evolution (SCE-UA) algorithm' super(sceua, self).__init__(*args, **kwargs) - print("LUKAS version anchor") - def simulate(self, id_params_tuple): """This overwrites the simple wrapper function of _algorithms.py @@ -253,7 +251,7 @@ def sample(self, repetitions, ngs=20, kstop=100, pcento=0.0000001, peps=0.000000 self.write_breakdata(self.dbname, work) proceed = False print('ONLY THE BURNIN PHASE WAS COMPUTED') - + else: self.repeat.setphase('ComplexEvo') print('Starting Complex Evolution...') @@ -446,4 +444,4 @@ def _sampleinputmatrix(self, nrows, npars): x = np.zeros((nrows, npars)) for i in range(nrows): x[i, :] = self.parameter()['random'] - return x \ No newline at end of file + return x From 4418bc215a60af2af4e09b12d40bec009797b4e4 Mon Sep 17 00:00:00 2001 From: lu-kas <> Date: Fri, 4 Sep 2020 10:41:48 +0200 Subject: [PATCH 22/35] removed whitespaces --- spotpy/algorithms/sceua.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spotpy/algorithms/sceua.py b/spotpy/algorithms/sceua.py index 7d901f6b..86679eb1 100644 --- a/spotpy/algorithms/sceua.py +++ b/spotpy/algorithms/sceua.py @@ -5,9 +5,9 @@ :author: Tobias Houska and Stijn Van Hoey ''' -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function from __future__ import unicode_literals from . import _algorithm import numpy as np @@ -64,7 +64,6 @@ def __init__(self, *args, **kwargs): kwargs['algorithm_name'] = 'Shuffled Complex Evolution (SCE-UA) algorithm' super(sceua, self).__init__(*args, **kwargs) - def simulate(self, id_params_tuple): """This overwrites the simple wrapper function of _algorithms.py and makes a two phase mpi parallelization possbile: From bc7a24ad13ca43472790433d7a03525b0008dc3f Mon Sep 17 00:00:00 2001 From: thouska Date: Fri, 4 Sep 2020 14:09:01 +0200 Subject: [PATCH 23/35] Updated version number Slight performance improvement for sceua example --- setup.py | 2 +- spotpy/__init__.py | 2 +- spotpy/examples/tutorial_sceua_hymod.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 8b786c28..728f6be6 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name = 'spotpy', - version = '1.5.10', + version = '1.5.11', description = 'A Statistical Parameter Optimization Tool', long_description=open(os.path.join(os.path.dirname(__file__), "README.rst")).read(), diff --git a/spotpy/__init__.py b/spotpy/__init__.py index 89b1022b..322f1456 100644 --- a/spotpy/__init__.py +++ b/spotpy/__init__.py @@ -40,4 +40,4 @@ from . import describe # Contains some helper functions to describe samplers and set-ups from .hydrology import signatures # Quantifies goodness of fit between simulation and evaluation data with hydrological signatures -__version__ = '1.5.10' \ No newline at end of file +__version__ = '1.5.11' \ No newline at end of file diff --git a/spotpy/examples/tutorial_sceua_hymod.py b/spotpy/examples/tutorial_sceua_hymod.py index 25c7129c..3fd3626f 100644 --- a/spotpy/examples/tutorial_sceua_hymod.py +++ b/spotpy/examples/tutorial_sceua_hymod.py @@ -21,10 +21,10 @@ # Initialize the Hymod example # In this case, we tell the setup which algorithm we want to use, so # we can use this exmaple for different algorithms - spot_setup=spot_setup(users_objective_function=spotpy.objectivefunctions.rmse) + spot_setup=spot_setup(spotpy.objectivefunctions.rmse) #Select number of maximum allowed repetitions - rep=500 + rep=1000 filename = 'SCEUA_hymod' # Create the SCE-UA sampler of spotpy, alt_objfun is set to None to force SPOTPY # to jump into the def objectivefunction in the spot_setup class (default is @@ -32,7 +32,7 @@ sampler=spotpy.algorithms.sceua(spot_setup, dbname='SCEUA_hymod', dbformat='csv') #Start the sampler, one can specify ngs, kstop, peps and pcento id desired - sampler.sample(rep)#,ngs=10, kstop=50, peps=0.1, pcento=0.1) + sampler.sample(rep, ngs=7, kstop=3, peps=0.1, pcento=0.1) # Load the results gained with the sceua sampler, stored in SCEUA_hymod.csv results = spotpy.analyser.load_csv_results('SCEUA_hymod') From f1bc4fd7b4b48dea239892a2f07462bdce81e7c1 Mon Sep 17 00:00:00 2001 From: thouska Date: Mon, 7 Sep 2020 13:05:09 +0200 Subject: [PATCH 24/35] Test upload on testpypi --- .travis.yml | 17 ++++++++++++++--- setup.py | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2144899a..66560d89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,8 +31,19 @@ install: script: - - py.test tests/test_* --cov spotpy --cov-report term-missing -v + - py.test tests/test_* --cov spotpy --cov-report term-missing -v # - mpirun -c 4 python spotpy/examples/tutorial_parallel_computing_hymod.py 100 - pip uninstall spotpy -y -after_success: - - coveralls + +jobs: + include: + - stage: Coveralls + name: Report Coveralls + after_success: python3 -m coveralls + + # Test Deploy source distribution + - stage: deploy + name: PyPi Test Deploy + script: python3 setup.py sdist --formats=gztar bdist_wheel + after_success: + - python3 -m twine upload --verbose --skip-existing --repository-url https://test.pypi.org/legacy/ dist/* \ No newline at end of file diff --git a/setup.py b/setup.py index 728f6be6..b2fe2a8b 100644 --- a/setup.py +++ b/setup.py @@ -13,6 +13,8 @@ author_email = 'tobias.houska@umwelt.uni-giessen.de', url = 'https://spotpy.readthedocs.io/en/latest/', license = 'MIT', + install_requires=[ + 'scipy', 'numpy', 'random', 'time', 'math', 'copy', 'threading', 'logging'], packages=find_packages(exclude=["tests*", "docs*"]), use_2to3 = True, keywords = 'Monte Carlo, MCMC, MLE, SCE-UA, Simulated Annealing, DE-MCz, DREAM, ROPE, Artifical Bee Colony, DDS, PA-DDS, Uncertainty, Calibration, Model, Signatures', From 2ddcc72854ac79fc98d200511c9a90e0df314880 Mon Sep 17 00:00:00 2001 From: thouska Date: Mon, 7 Sep 2020 13:15:18 +0200 Subject: [PATCH 25/35] Removed unecessarry module from pre-install --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b2fe2a8b..a751b762 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ url = 'https://spotpy.readthedocs.io/en/latest/', license = 'MIT', install_requires=[ - 'scipy', 'numpy', 'random', 'time', 'math', 'copy', 'threading', 'logging'], + 'scipy', 'numpy', 'random', 'time', 'math', 'copy', 'logging'], packages=find_packages(exclude=["tests*", "docs*"]), use_2to3 = True, keywords = 'Monte Carlo, MCMC, MLE, SCE-UA, Simulated Annealing, DE-MCz, DREAM, ROPE, Artifical Bee Colony, DDS, PA-DDS, Uncertainty, Calibration, Model, Signatures', From a02e532e7657d82484231d3058b927d7e2546e55 Mon Sep 17 00:00:00 2001 From: thouska Date: Mon, 7 Sep 2020 13:21:41 +0200 Subject: [PATCH 26/35] Further cleanding of pre-install requirements --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a751b762..1c3a7b17 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ url = 'https://spotpy.readthedocs.io/en/latest/', license = 'MIT', install_requires=[ - 'scipy', 'numpy', 'random', 'time', 'math', 'copy', 'logging'], + 'scipy', 'numpy', 'logging'], packages=find_packages(exclude=["tests*", "docs*"]), use_2to3 = True, keywords = 'Monte Carlo, MCMC, MLE, SCE-UA, Simulated Annealing, DE-MCz, DREAM, ROPE, Artifical Bee Colony, DDS, PA-DDS, Uncertainty, Calibration, Model, Signatures', From be6d393cf8d02e034cb96bea2ca1d4eee5bb7f22 Mon Sep 17 00:00:00 2001 From: Christian Krause Date: Mon, 7 Sep 2020 14:16:29 +0200 Subject: [PATCH 27/35] avoids spawning of timeout thread if no timeout set fixes #253 --- spotpy/algorithms/_algorithm.py | 49 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/spotpy/algorithms/_algorithm.py b/spotpy/algorithms/_algorithm.py index b41705c7..1a2fc94c 100644 --- a/spotpy/algorithms/_algorithm.py +++ b/spotpy/algorithms/_algorithm.py @@ -432,26 +432,31 @@ def simulate(self, id_params_tuple): self.all_params[self.non_constant_positions] = params #TODO: List parameters are not updated if not accepted for the algorithm, we may have to warn/error if list is given all_params = self.all_params - # we need a layer to fetch returned data from a threaded process into a queue. - def model_layer(q,all_params): - # Call self.model with a namedtuple instead of another sequence - q.put(self.setup.simulation(self.partype(*all_params))) - - # starting a queue, where in python2.7 this is a multiprocessing class and can cause errors because of - # incompability which the main thread. Therefore only for older Python version a workaround follows - que = Queue() - sim_thread = threading.Thread(target=model_layer, args=(que, all_params)) - sim_thread.daemon = True - sim_thread.start() - - - # If self.sim_timeout is not None the self.model will break after self.sim_timeout seconds otherwise is runs as - # long it needs to run - sim_thread.join(self.sim_timeout) - - # If no result from the thread is given, i.e. the thread was killed from the watcher the default result is - # '[nan]' and will not be saved. Otherwise get the result from the thread - model_result = None - if not que.empty(): - model_result = que.get() + if self.sim_timeout: + # we need a layer to fetch returned data from a threaded process into a queue. + def model_layer(q,all_params): + # Call self.model with a namedtuple instead of another sequence + q.put(self.setup.simulation(self.partype(*all_params))) + + # starting a queue, where in python2.7 this is a multiprocessing class and can cause errors because of + # incompability which the main thread. Therefore only for older Python version a workaround follows + que = Queue() + + sim_thread = threading.Thread(target=model_layer, args=(que, all_params)) + sim_thread.daemon = True + sim_thread.start() + + # If self.sim_timeout is not None the self.model will break after self.sim_timeout seconds otherwise is runs as + # long it needs to run + sim_thread.join(self.sim_timeout) + + # If no result from the thread is given, i.e. the thread was killed from the watcher the default result is + # '[nan]' and will not be saved. Otherwise get the result from the thread + model_result = None + if not que.empty(): + model_result = que.get() + + else: + model_result = self.setup.simulation(self.partype(*all_params)) + return id, params, model_result From e76384bdcfdd1ccb7e58f4fbf89772fa2f45b1b2 Mon Sep 17 00:00:00 2001 From: thouska Date: Mon, 7 Sep 2020 14:40:04 +0200 Subject: [PATCH 28/35] Enable taged deployment with travis --- .travis.yml | 24 ++++++++++++++++++------ setup.py | 5 +++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 66560d89..aa79a230 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,9 @@ python: - "3.7" # - "3.8" #Errors on Travis, build times out because no output was received... +# Uses cache to build faster +cache: pip + # this ubuntu distribution has sure the libopenmpi-dev packages available dist: bionic @@ -41,9 +44,18 @@ jobs: name: Report Coveralls after_success: python3 -m coveralls - # Test Deploy source distribution - - stage: deploy - name: PyPi Test Deploy - script: python3 setup.py sdist --formats=gztar bdist_wheel - after_success: - - python3 -m twine upload --verbose --skip-existing --repository-url https://test.pypi.org/legacy/ dist/* \ No newline at end of file +# Publish spotpy on PyPi if taged +deploy: + # If you need to deploy files Travis has built, use the next line + skip_cleanup: true + provider: pypi + distributions: sdist bdist_wheel gztar + on: + # In this case I want to deploy only when a tag is present... + tags: true + # ... and when tag is on master and respects the form "v0.0.0" + branch: + - master + - /v?(\d+\.)?(\d+\.)?(\*|\d+)$/ + user: thouska + password : ${deploying} \ No newline at end of file diff --git a/setup.py b/setup.py index 1c3a7b17..ef554167 100644 --- a/setup.py +++ b/setup.py @@ -3,10 +3,15 @@ from setuptools import setup, find_packages import os +# Type of python distribution +[bdist_wheel] +universal=0 + setup( name = 'spotpy', version = '1.5.11', description = 'A Statistical Parameter Optimization Tool', + description-file = README.rst long_description=open(os.path.join(os.path.dirname(__file__), "README.rst")).read(), author = 'Tobias Houska, Philipp Kraft, Alejandro Chamorro-Chavez and Lutz Breuer', From c644da407f3a90f63c24f82d511db9c63da7bef9 Mon Sep 17 00:00:00 2001 From: thouska Date: Mon, 7 Sep 2020 14:45:19 +0200 Subject: [PATCH 29/35] Fix string --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ef554167..731312fa 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ name = 'spotpy', version = '1.5.11', description = 'A Statistical Parameter Optimization Tool', - description-file = README.rst + description-file = 'README.rst', long_description=open(os.path.join(os.path.dirname(__file__), "README.rst")).read(), author = 'Tobias Houska, Philipp Kraft, Alejandro Chamorro-Chavez and Lutz Breuer', From 260c3ca66c5df3bbfb4c2001008b17602f76dfad Mon Sep 17 00:00:00 2001 From: thouska Date: Mon, 7 Sep 2020 14:48:32 +0200 Subject: [PATCH 30/35] Skipping description-file --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 731312fa..0396ad68 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,6 @@ name = 'spotpy', version = '1.5.11', description = 'A Statistical Parameter Optimization Tool', - description-file = 'README.rst', long_description=open(os.path.join(os.path.dirname(__file__), "README.rst")).read(), author = 'Tobias Houska, Philipp Kraft, Alejandro Chamorro-Chavez and Lutz Breuer', From acf63adc560a693145856bc800f1d4afb79a2dcd Mon Sep 17 00:00:00 2001 From: thouska Date: Mon, 7 Sep 2020 14:51:45 +0200 Subject: [PATCH 31/35] Remove specified pypi build --- setup.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/setup.py b/setup.py index 0396ad68..1c3a7b17 100644 --- a/setup.py +++ b/setup.py @@ -3,10 +3,6 @@ from setuptools import setup, find_packages import os -# Type of python distribution -[bdist_wheel] -universal=0 - setup( name = 'spotpy', version = '1.5.11', From 719a32ed7382470d9f4622505d8cfdc65e82f534 Mon Sep 17 00:00:00 2001 From: thouska Date: Mon, 7 Sep 2020 15:51:27 +0200 Subject: [PATCH 32/35] Try to fix #256 --- .travis.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index aa79a230..6a2d50e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: python python: #- "2.7" - #- "3.5" - "3.7" # - "3.8" #Errors on Travis, build times out because no output was received... @@ -46,10 +45,8 @@ jobs: # Publish spotpy on PyPi if taged deploy: - # If you need to deploy files Travis has built, use the next line - skip_cleanup: true provider: pypi - distributions: sdist bdist_wheel gztar + distributions: "sdist bdist_wheel gztar" on: # In this case I want to deploy only when a tag is present... tags: true @@ -58,4 +55,5 @@ deploy: - master - /v?(\d+\.)?(\d+\.)?(\*|\d+)$/ user: thouska - password : ${deploying} \ No newline at end of file + password : ${deploying} + skip_existing: true \ No newline at end of file From 294c89894bc0c51c5b7dd35a442c16b4a2c3d265 Mon Sep 17 00:00:00 2001 From: thouska Date: Mon, 7 Sep 2020 15:59:36 +0200 Subject: [PATCH 33/35] Upate version number --- setup.py | 2 +- spotpy/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 1c3a7b17..6f5235f2 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name = 'spotpy', - version = '1.5.11', + version = '1.5.12', description = 'A Statistical Parameter Optimization Tool', long_description=open(os.path.join(os.path.dirname(__file__), "README.rst")).read(), diff --git a/spotpy/__init__.py b/spotpy/__init__.py index 322f1456..8cddb744 100644 --- a/spotpy/__init__.py +++ b/spotpy/__init__.py @@ -40,4 +40,4 @@ from . import describe # Contains some helper functions to describe samplers and set-ups from .hydrology import signatures # Quantifies goodness of fit between simulation and evaluation data with hydrological signatures -__version__ = '1.5.11' \ No newline at end of file +__version__ = '1.5.12' \ No newline at end of file From 8b0e9fed43ece0d520397e65e2488a5a65453171 Mon Sep 17 00:00:00 2001 From: thouska Date: Mon, 7 Sep 2020 16:17:13 +0200 Subject: [PATCH 34/35] Remove gztar from pypi upload --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a2d50e6..bdb3ccb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,7 +46,7 @@ jobs: # Publish spotpy on PyPi if taged deploy: provider: pypi - distributions: "sdist bdist_wheel gztar" + distributions: "sdist bdist_wheel" on: # In this case I want to deploy only when a tag is present... tags: true @@ -55,5 +55,4 @@ deploy: - master - /v?(\d+\.)?(\d+\.)?(\*|\d+)$/ user: thouska - password : ${deploying} - skip_existing: true \ No newline at end of file + password : ${deploying} \ No newline at end of file From 309e8d9624bddf9a667faabe13a0f4cbff4a49b5 Mon Sep 17 00:00:00 2001 From: thouska Date: Tue, 8 Sep 2020 11:30:21 +0200 Subject: [PATCH 35/35] Reomve logging from preinstall and update version number --- setup.py | 4 ++-- spotpy/__init__.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 6f5235f2..b2af788d 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name = 'spotpy', - version = '1.5.12', + version = '1.5.13', description = 'A Statistical Parameter Optimization Tool', long_description=open(os.path.join(os.path.dirname(__file__), "README.rst")).read(), @@ -14,7 +14,7 @@ url = 'https://spotpy.readthedocs.io/en/latest/', license = 'MIT', install_requires=[ - 'scipy', 'numpy', 'logging'], + 'scipy', 'numpy'], packages=find_packages(exclude=["tests*", "docs*"]), use_2to3 = True, keywords = 'Monte Carlo, MCMC, MLE, SCE-UA, Simulated Annealing, DE-MCz, DREAM, ROPE, Artifical Bee Colony, DDS, PA-DDS, Uncertainty, Calibration, Model, Signatures', diff --git a/spotpy/__init__.py b/spotpy/__init__.py index 8cddb744..26d052b9 100644 --- a/spotpy/__init__.py +++ b/spotpy/__init__.py @@ -40,4 +40,4 @@ from . import describe # Contains some helper functions to describe samplers and set-ups from .hydrology import signatures # Quantifies goodness of fit between simulation and evaluation data with hydrological signatures -__version__ = '1.5.12' \ No newline at end of file +__version__ = '1.5.13' \ No newline at end of file