Skip to main content

An auto-calibration tool for environmental models based on heuristic algorithms and uncertainty estimation theory.

Project description

PyCUP

This is an open-source package designed for (environmental) model calibration and uncertainty analysis. The current version is the very first version, we welcome all comments, suggestions, and improvements.

v 0.1.6 Update

PyCUP now supports a basic integration with PEST++ calibration project for a more convenient model-agnostic calibration process. The pycup.integrate.PESTconvertor can generate an objective function, which can read/write the parameter file, run the commandline, read the simulation results with the PEST++ instruction files. The function can be used by PyCUP algorithms so that users can do the calibration without writting the objective function and IO functions by themselves. As the PyCUP algorithms have mechanisms differ from which used by PEST++, some settings in PEST++ control file will be ignored. More details can be found in the example in documentations in the repository.

What does it have

(1) For model calibration/optimization

  1. Single-objective heuristic algorithms including PSO, GWO, MFO, SOA, SCA, SSA, TSA, and WOA.
  2. Multi-objective heuristic algorithms including MOPSO, MODE, and NSGA-II.
  3. Elite opposition strategy modified heuristic algorithms -- with better optimum search abilities.
  4. Statistic based-method LHS-GLUE.
  5. Three kinds of algorithm border check mechanisms including Absorb, Random, and Rebound, designed for different problems.

(2) For sensitivity & uncertainty analysis

  1. Likelihood uncertainty estimation used in the GLUE framework for the parameter uncertainty analysis/prediction uncertainty estimation.
  2. The frequency based-uncertainty estimation method for the prediction uncertainty estimation.
  3. The multi-linear regression method for the all-at-a-time parameter sensitivity based on statmodels.

(3) Other convenient features

  1. Multi-processing calibration.
  2. Recording and resuming during the calibration task.
  3. Several result plotting functions.
  4. A special simulation result object for multi-station & multi-event results (of environmental models) in pycup.ResLib.

(4) Package/Tools integration

  1. PyCUP can be linked to spotpy database for post-processing, a pycup objective function can also be generated from the spotpy objective function using the module named pycup.integrate.
  2. The required objective function for pycup calibration can be easily generated using a PEST++ optimization project with/without a tsproc.exe. The PESTconvertor object in pycup.integrate provides several APIs for reading PEST++ files such as .pst, .ins, and .tpl.

How to install

​ The project has been uploaded onto the PyPI https://pypi.org/project/pycup/ . Or install the .whl file in the dist folder.

pip install pycup

How to use

​ Here is a simple example. For more details, please see the documentation.

import pycup as cp
import numpy as np

def uni_fun1(X):
	# X for example np.array([1,2,3,...,30])
    fitness = np.sum(np.power(X,2)) + 1 # example: 1.2
    result = fitness.reshape(1,-1) # example ([1.2,])

    return fitness,result

lb = -100 * np.ones(30)
ub = 100 * np.ones(30)
cp.SSA.run(pop = 1000, dim = 30, lb = lb, ub = ub, MaxIter = 30, fun = uni_fun1)

Example SWMM (Storm Water Management Model) calibration projects

IMPORTANT: PLEASE OPEN YOUR PYCHARM OR COMMAND LINE WITH THE ADMINISTRATOR RIGHTS BEFORE EXECUTING THE EXAMPLE PROJECT

Location: https://github.com/QianyangWang/PyCUP

  1. The example in folder 'Example01-GLUE' contains an SWMM calibration project using single-processing GLUE. Install the dependencies (for example: pip install swmm-api==0.2.0.18.3, pip install pyswmm). Execute the 'Calibrate.py' to calibrate the model. Then, execute the 'PostProcessing.py' for uncertainty analysis.
  2. The example in folder 'Example02-multiprocessing' contains an SWMM calibration project using multi-processing EOGWO.
  3. The example in folder 'Example03-multiobjective' contains an SWMM multi-objective calibration project using EOMOPSO.
  4. The example in folder 'Example04-validation&prediction' shows how to use our (Ensemble)Validator/(Ensemble)Predictor objects for the validation and prediction of the model using the calibrated parameter (set).
  5. The example in folder 'Example05-multi-station&event' shows how to use the pycup.Reslib.SimulationResult object for the storage of multi-station & multi-event simulation results, as well as the further analysis using them.

Example PEST++ conversion project (with a Xinanjiang hydrologic model)

  1. The example in folder 'Example06-PESTintegration' contains a PEST++ Xinanjiang model calibration project and the python script to run a PyCUP calibration based on it.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycup-0.1.6.1.tar.gz (863.4 kB view details)

Uploaded Source

Built Distribution

pycup-0.1.6.1-py3-none-any.whl (885.3 kB view details)

Uploaded Python 3

File details

Details for the file pycup-0.1.6.1.tar.gz.

File metadata

  • Download URL: pycup-0.1.6.1.tar.gz
  • Upload date:
  • Size: 863.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.3

File hashes

Hashes for pycup-0.1.6.1.tar.gz
Algorithm Hash digest
SHA256 284f4dd8f4569b14abd487e7a55120d84369b824691840bf142187b91d2cae54
MD5 b081b6f82b96928feed11771cded2eb4
BLAKE2b-256 922de28a713edaa8a9f5d42aac3eba5e16e0d190a2ec83601bf23562c6797b04

See more details on using hashes here.

File details

Details for the file pycup-0.1.6.1-py3-none-any.whl.

File metadata

  • Download URL: pycup-0.1.6.1-py3-none-any.whl
  • Upload date:
  • Size: 885.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.3

File hashes

Hashes for pycup-0.1.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 26c3c3a1da3403d5c4bc9174212d4316f8b958f7976b5df5b4f11d54d5b38066
MD5 2011edc01a5d705c110c3cc5ce71c041
BLAKE2b-256 1a9e92446d726562b88427f8365ac13a3c48e9363576500638f05e12b88fdea2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page