pubtools

This module provides features for handling public (global) project data.

Module pubtools implements the following members:


class hydpy.core.pubtools.TimegridsProperty[source]

Bases: hydpy.core.pubtools._PubProperty[Union[hydpy.core.timetools.Timegrids, Tuple[Union[Date, datetime.datetime, str], Union[Date, datetime.datetime, str], Union[Period, datetime.timedelta, str]]], hydpy.core.timetools.Timegrids]

DefaultProperty specialised for Timegrids objects.

For convenience, property TimegridsProperty can create a Timegrids object from a combination of a first and a last date (of type str or Date) and a step size (of type str or Period):

>>> from hydpy import pub, Timegrid, Timegrids
>>> pub.timegrids = "2000-01-01", "2010-01-01", "1d"

The given date and period information applies for the init, the sim, and the eval_ attribute, as well:

>>> pub.timegrids.init
Timegrid("2000-01-01 00:00:00",
         "2010-01-01 00:00:00",
         "1d")
>>> pub.timegrids.sim
Timegrid("2000-01-01 00:00:00",
         "2010-01-01 00:00:00",
         "1d")
>>> pub.timegrids.eval_
Timegrid("2000-01-01 00:00:00",
         "2010-01-01 00:00:00",
         "1d")

Alternatively, you can assign a ready Timegrids object directly:

>>> pub.timegrids = Timegrids(Timegrid("2000-01-01", "2010-01-01", "1d"),
...                           Timegrid("2000-01-01", "2001-01-01", "1d"))
>>> pub.timegrids
Timegrids(init=Timegrid("2000-01-01 00:00:00",
                        "2010-01-01 00:00:00",
                        "1d"),
          sim=Timegrid("2000-01-01 00:00:00",
                       "2001-01-01 00:00:00",
                       "1d"),
          eval_=Timegrid("2000-01-01 00:00:00",
                         "2001-01-01 00:00:00",
                         "1d"))
call_fset(obj: Any, value: Union[hydpy.core.timetools.Timegrids, Tuple[Union[Date, datetime.datetime, str], Union[Date, datetime.datetime, str], Union[Period, datetime.timedelta, str]]])None[source]

Try to convert the given input value(s).

fget: hydpy.core.propertytools.FGet[OutputType]
fset: hydpy.core.propertytools.FSet[InputType]
fdel: hydpy.core.propertytools.FDel
objtype: Type[Any]
module: Optional[module]
name: str
class hydpy.core.pubtools.Pub(name: str, doc: Optional[str] = None)[source]

Bases: module

Base class/module of module pub.

After initialisation pub takes over Pub as its new base class. The reason for this complicated trick is that it makes the attribute handling of pub easier for users.

You can import pub like other modules:

>>> from hydpy import pub

However, if you try to access unprepared attributes, Pub returns the following error message:

>>> pub.timegrids
Traceback (most recent call last):
...
hydpy.core.exceptiontools.AttributeNotReady: Attribute timegrids of module `pub` is not defined at the moment.

After setting an attribute value successfully, it is accessible (we select the timegrids attribute here, as its setter supplies a little magic to make defining new Timegrids objects more convenient:

>>> pub.timegrids = None
Traceback (most recent call last):
...
ValueError: While trying to define a new `Timegrids` object based on the arguments `None`, the following error occurred: Initialising a `Timegrids` object either requires one, two, or three `Timegrid` objects or two dates objects (of type `Date`, `datetime`, or `str`) and one period object (of type `Period`, `timedelta`, or `str`), but objects of the types `None, None, and None` are given.
>>> pub.timegrids = "2000-01-01", "2001-01-01", "1d"
>>> pub.timegrids
Timegrids("2000-01-01 00:00:00",
          "2001-01-01 00:00:00",
          "1d")

After deleting, the attribute is not accessible anymore:

>>> del pub.timegrids
>>> pub.timegrids
Traceback (most recent call last):
...
hydpy.core.exceptiontools.AttributeNotReady: Attribute timegrids of module `pub` is not defined at the moment.
config: configutils.Config
projectname
indexer
networkmanager
controlmanager
conditionmanager
sequencemanager
timegrids

DefaultProperty specialised for Timegrids objects.

For convenience, property TimegridsProperty can create a Timegrids object from a combination of a first and a last date (of type str or Date) and a step size (of type str or Period):

>>> from hydpy import pub, Timegrid, Timegrids
>>> pub.timegrids = "2000-01-01", "2010-01-01", "1d"

The given date and period information applies for the init, the sim, and the eval_ attribute, as well:

>>> pub.timegrids.init
Timegrid("2000-01-01 00:00:00",
         "2010-01-01 00:00:00",
         "1d")
>>> pub.timegrids.sim
Timegrid("2000-01-01 00:00:00",
         "2010-01-01 00:00:00",
         "1d")
>>> pub.timegrids.eval_
Timegrid("2000-01-01 00:00:00",
         "2010-01-01 00:00:00",
         "1d")

Alternatively, you can assign a ready Timegrids object directly:

>>> pub.timegrids = Timegrids(Timegrid("2000-01-01", "2010-01-01", "1d"),
...                           Timegrid("2000-01-01", "2001-01-01", "1d"))
>>> pub.timegrids
Timegrids(init=Timegrid("2000-01-01 00:00:00",
                        "2010-01-01 00:00:00",
                        "1d"),
          sim=Timegrid("2000-01-01 00:00:00",
                       "2001-01-01 00:00:00",
                       "1d"),
          eval_=Timegrid("2000-01-01 00:00:00",
                         "2001-01-01 00:00:00",
                         "1d"))
selections
options: hydpy.core.optiontools.Options
scriptfunctions: Dict[str, hydpy.core.typingtools.ScriptFunction]