oemof.solph.helpers

Private helper functions.

oemof.solph._helpers.check_node_object_for_missing_attribute(obj, attribute)[source]

Raises a predefined warning if object does not have attribute.

Parameters:
  • obj (python object)

  • attribute ((string) name of the attribute to test for)

oemof.solph._helpers.create_time_index(year: int = None, interval: float = 1, number: int = None, start: date = None)[source]

Create a datetime index for one year.

Notes

To create 8760 hourly intervals for a non leap year a datetime index with 8761 time points need to be created. So the number of time steps is always the number of intervals plus one.

Parameters:
  • year (int, datetime) – The year of the index. Used to automatically set start and number for the specific year.

  • interval (float) – The time interval in hours e.g. 0.5 for 30min or 2 for a two hour interval (default: 1).

  • number (int) – The number of time intervals. By default number is calculated to create an index of one year. For a shorter or longer period the number of intervals can be set by the user.

  • start (datetime.datetime or datetime.date) – Optional start time. If start is not set, 00:00 of the first day of the given year is the start time.

Examples

>>> len(create_time_index(2014))
8761
>>> len(create_time_index(2012))  # leap year
8785
>>> len(create_time_index(2014, interval=0.5))
17521
>>> len(create_time_index(2014, interval=0.5, number=10))
11
>>> len(create_time_index(2014, number=10))
11
>>> str(create_time_index(2014, interval=0.5, number=10)[-1])
'2014-01-01 05:00:00'
>>> str(create_time_index(2014, interval=2, number=10)[-1])
'2014-01-01 20:00:00'
oemof.solph._helpers.warn_if_missing_attribute(obj, attribute)[source]

Raises warning if attribute is missing for given object