Package: pyeee
A Python library for parameter screening of computational models using
the extension of Morris’ method of Elementary Effects called Efficient
or Sequential Elementary Effects by Cuntz, Mai et al. (Water Res
Research, 2015).About pyeeepyeeeis a Python library for performing parameter screening of
computational models. It uses the extension of Morris’ method of
Elementary Effects of so-called Efficient or Sequential Elementary
Effects published byCuntz, Maiet al.(2015) Computationally inexpensive identification
of noninformative model parameters by sequential screening,Water Resources Research51, 6417-6441, doi:10.1002/2015WR016907.pyeeecan be used with Python functions but also with external
programs, using for example the librarypartialwrap. Function
evaluation can be distributed with Python’smultiprocessingmodule
or via the Message Passing Interface (MPI).DocumentationThe complete documentation forpyeeeis available at Github Pages:https://mcuntz.github.io/pyeee/Quick usage guideSimple Python functionConsider the Ishigami-Homma function:y = sin(x_0) + a *sin(x_1)^2+ b * x_2^4 * sin(x_0).Takinga = b = 1gives:importnumpyasnpdefishigami1(x):returnnp.sin(x[0])+np.sin(x[1])**2+x[2]**4*np.sin(x[0])The three paramtersx_0,x_1,x_2follow
uniform distributions between-piand+pi.Morris’ Elementary Effects can then be calculated using, for example,
the Python librarypyjams, giving the Elementary Effects (mu*):frompyjamsimporteenpars=3# lower boundarieslb=np.ones(npars)*(-np.pi)# upper boundariesub=np.ones(npars)*np.pi# Elementary Effectsnp.random.seed(seed=1023)# for reproducibility of examplesout=ee(ishigami1,lb,ub,10)# mu*print("{:.1f}{:.1f}{:.1f}".format(*out[:,0]))# gives: 173.1 0.6 61.7Sequential Elementary Effects distinguish between informative and
uninformative parameters using several times Morris’ Elementary
Effects, returning a logical ndarray with True for the informative
parameters and False for the uninformative parameters:frompyeeeimporteee# screennp.random.seed(seed=1023)# for reproducibility of examplesout=eee(ishigami1,lb,ub,ntfirst=10)print(out)[TrueFalseTrue]Python function with extra parametersThe function forpyeeemust be of the formfunc(x). Use
Python’spartialfrom thefunctoolsmodule to pass other
function parameters. For example pass the parametersaandbto the Ishigami-Homma function.importnumpyasnpfrompyeeeimporteeefromfunctoolsimportpartialdefishigami(x,a,b):returnnp.sin(x[0])+a*np.sin(x[1])**2+b*x[2]**4*np.sin(x[0])defcall_ishigami(func,a,b,x):returnfunc(x,a,b)# Partialise function with fixed parametersa=0.5b=2.0func=partial(call_ishigami,ishigami,a,b)npars=3# lower boundarieslb=np.ones(npars)*(-np.pi)# upper boundariesub=np.ones(npars)*np.pi# Elementary Effectsnp.random.seed(seed=1023)# for reproducibility of examplesout=eee(func,lb,ub,ntfirst=10)Figuratively speaking,partialpassesaandbto the
functioncall_ishigamialready during definition so thateeecan then simply call it asfunc(x), wherexis passed tocall_ishigamithen as well.Function wrappersWe recommend to use our packagepartialwrapfor external
executables, which allows easy use of external programs and also their
parallel execution. See theuserguidefor details. A trivial
example is the use ofpartialwrapfor the above function wrapping:frompartialwrapimportfunction_wrapperargs=[a,b]kwargs={}func=partial(func_wrapper,ishigami,args,kwargs)# screenout=eee(func,lb,ub,ntfirst=10)InstallationThe easiest way to install is viapip:pipinstallpyeeeRequirementsNumPySciPyschwimmbadpyjamsLicensepyeeeis distributed under the MIT License. See theLICENSEfile for details.Copyright (c) 2019-2024 Matthias Cuntz, Juliane MaiThe project structure is based on atemplateprovided bySebastian Müller.