optiontools¶
This module implements classes that help to manage global HydPy options.
Module optiontools
implements the following members:
TIn
Type variable.
TOption
Type variable.
TOrig
Type variable.
TOut
Type variable.
Options
Singleton class for global options placed in modulepub
.
-
class
hydpy.core.optiontools.
Options
[source]¶ Bases:
object
Singleton class for global options placed in module
pub
.Note that Most options are simple True/False or 0/1 flags.
You can change all options in two ways. By using the with statement, you make sure that the change is undone after leaving the corresponding code block (even if an error occurs):
>>> from hydpy import pub >>> pub.options.printprogress = 0 >>> pub.options.printprogress 0 >>> with pub.options.printprogress(True): ... print(pub.options.printprogress) 1 >>> pub.options.printprogress 0
Alternatively, you can change all options via simple assignments:
>>> pub.options.printprogress = True >>> pub.options.printprogress 1
But then you might have to keep in mind to undo the change later:
>>> pub.options.printprogress 1 >>> pub.options.printprogress = False >>> pub.options.printprogress 0
When using the with statement, you can assign
None
, which does not change the original setting and resets it after leaving the with block:>>> with pub.options.printprogress(None): ... print(pub.options.printprogress) ... pub.options.printprogress = True ... print(pub.options.printprogress) 0 1 >>> pub.options.printprogress 0
The delete attribute restores the respective default setting:
>>> del pub.options.printprogress >>> pub.options.printprogress 1
-
autocompile
= 1¶ A True/False flag for enabling/disabling the automatic conversion of pure Python models to computationally more efficient Cython models whenever a existing Cython model may be outdated.
-
checkseries
= 1¶ True/False flag for raising an error when trying to load an input time series not spanning the whole initialisation period or containing
nan
values.
-
dirverbose
= 0¶ A True/False flag for letting the autocompletion textbox include all members of an object or only the most relevant ones. So far, this option affects the behaviour of a few implemented classes only.
-
ellipsis
= -999¶ Ellipsis points are used to shorten the string representations of iterable HydPy objects containing many entries. Set a value to define the maximum number of entries before and behind ellipsis points. Set it to zero to avoid any ellipsis points. Set it to -999 to rely on the default values of the respective iterable objects.
-
flattennetcdf
= 0¶ A True/False flag relevant when working with NetCDF files that decides whether to handle multidimensional time series as a larger number of 1-dimensional time series (True) or to keep the original shape (False) (see the documentation on module
netcdftools
for further information).
-
forcecompiling
= 0¶ A True/False flag for enabling that each cythonizable model is cythonized when imported.
-
isolatenetcdf
= 0¶ A True/False flag relevant when working with NetCDF files that decides whether to handle only the time series of a single sequence type (True) or the time series of multiple sequence types (False) in individual NetCDF files (see the documentation on module
netcdftools
for further information).
-
parameterstep
= Period("1d")¶ The actual parameter time step size. Change it by passing a
Period
object or any validPeriod
constructor argument. The default parameter step is one day.>>> from hydpy import pub >>> pub.options.parameterstep Period("1d")
-
printprogress
= 1¶ A True/False flag for printing information about the progress of some processes to the standard output.
-
printincolor
= 1¶ A True/False flag for printing progress information in colour eventually.
-
reprcomments
= 0¶ A True/False flag for including comments into string representations. So far, this option affects the behaviour of a few implemented classes, only.
-
reprdigits
= -1¶ Required precision of string representations of floating point numbers, defined as the minimum number of digits to be reproduced by the string representation (see function
repr_
).
-
simulationstep
= Period()¶ The actual simulation time step size. Change it by passing a
Period
object or any validPeriod
constructor argument. HydPy does not define a default simulation step (indicated by an emptyPeriod
object).Note that you cannot manually define the
simulationstep
whenever it is already available via attributestepsize
of the globalTimegrids
object in modulepub
(pub.timegrids):>>> from hydpy import pub >>> pub.options.simulationstep Period()
>>> pub.options.simulationstep = "1h" >>> pub.options.simulationstep Period("1h")
>>> pub.timegrids = "2000-01-01", "2001-01-01", "1d" >>> pub.options.simulationstep Period("1d")
>>> pub.options.simulationstep = "1s" >>> pub.options.simulationstep Period("1d")
>>> del pub.timegrids >>> pub.options.simulationstep Period("1s")
>>> del pub.options.simulationstep >>> pub.options.simulationstep Period()
-
skipdoctests
= 0¶ A True/False flag for skipping the automatic execution of documentation tests.
-
timeaxisnetcdf
= 1¶ An integer value relevant when working with NetCDF files that determines the axis of the time variable (see the documentation on module
netcdftools
for further information).
-
trimvariables
= 1¶ A True/False flag for enabling/disabling function
trim()
. Set it toFalse
only for good reasons.
-
usecython
= 1¶ TA True/False flag for applying cythonized models if possible, which are much faster than pure Python models.
-
usedefaultvalues
= 0¶ A True/False flag for initialising parameters with standard values.
-
utclongitude
= 15¶ Longitude of the centre of the local time zone (see option
utcoffset
). Defaults to 15, which corresponds to the central meridian of UTC+01:00.
-
utcoffset
= 60¶ Offset of your local time from UTC in minutes (see option
utclongitude
. Defaults to 60, which corresponds to UTC+01:00.
-
warnmissingcontrolfile
= 0¶ A True/False flag for only raising a warning instead of an exception when a necessary control file is missing.
-
warnmissingobsfile
= 1¶ A True/False flag for raising a warning when a requested observation sequence demanded by a node instance is missing.
-
warnmissingsimfile
= 1¶ A True/False flag for raising a warning when a requested simulation sequence demanded by a node instance is missing.
-
warnsimulationstep
= 1¶ A True/False flag for raising a warning when function
simulationstep()
called for the first time directly by the user.
-