ladybug.analysisperiod module

Ladybug analysis period class.

class ladybug.analysisperiod.AnalysisPeriod(st_month=1, st_day=1, st_hour=0, end_month=12, end_day=31, end_hour=23, timestep=1, is_leap_year=False)[source]

Bases: object

An analysis period between two dates of the year and between certain hours.

Parameters:
  • st_month – An integer between 1-12 for starting month (default = 1)

  • st_day – An integer between 1-31 for starting day (default = 1). Note that some months are shorter than 31 days.

  • st_hour – An integer between 0-23 for starting hour (default = 0)

  • end_month – An integer between 1-12 for ending month (default = 12)

  • end_day – An integer between 1-31 for ending day (default = 31) Note that some months are shorter than 31 days.

  • end_hour – An integer between 0-23 for ending hour (default = 23)

  • timestep – An integer for the number of timesteps per hour. (Default: 1). Choose from: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60

  • is_leap_year – A boolean to indicate whether the AnalysisPeriod represents a leap year. (Default: False)

Properties:
  • st_month

  • st_day

  • end_hour

  • end_month

  • end_day

  • end_hour

  • timestep

  • is_leap_year

  • st_time

  • end_time

  • datetimes

  • moys

  • hoys

  • hoys_int

  • doys_int

  • months_int

  • months_per_hour

  • minute_intervals

  • is_annual

  • is_overnight

  • is_reversed

ToString()[source]

Overwrite .NET representation.

duplicate()[source]

Return a copy of the analysis period.

classmethod from_dict(data)[source]

Create an analysis period from a dictionary.

Parameters:

data – A python dictionary in the following format

{
"st_month": 1  # An integer between 1-12 for starting month (default = 1)
"st_day": 1  # An integer between 1-31 for starting day (default = 1).
           # Note that some months are shorter than 31 days.
"st_hour": 0  # An integer between 0-23 for starting hour (default = 0)
"end_month": 12  # An integer between 1-12 for ending month (default = 12)
"end_day": 31  # An integer between 1-31 for ending day (default = 31)
             #Note that some months are shorter than 31 days.
"end_hour": 23  # An integer between 0-23 for ending hour (default = 23)
"timestep": 1 # An integer number from 1, 2, 3, 4, 5, 6, 10, 12, 15,
              #20, 30, 60
}
classmethod from_start_end_datetime(start_datetime, end_datetime, timestep)[source]

Create and AnalysisPeriod from start and end date objects.

Parameters:
  • start_datetime – A Ladybug DateTime object for the start of the period.

  • end_datetime – A Ladybug DateTime object for the end of the period.

  • timestep – An integer for the number of timesteps per hour. (Default: 1). Choose from: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60

classmethod from_string(analysis_period_string)[source]

Create an Analysis Period object from an analysis period string.

Format is: %s/%s to %s/%s between %s and %s @%s

is_possible_hour(hour)[source]

Check if a float hour is a possible hour for this analysis period.

is_time_included(time)[source]

Check if time is included in analysis period.

Note that time filtering in Ladybug Tools is slightly different than “normal” filtering since start hour and end hour will be applied for every day. For instance 2/20 9am to 2/22 5pm means hour between 9-17 during 20, 21 and 22 of Feb.

Parameters:

time – A DateTime to be tested

Returns:

A boolean. True if time is included in analysis period

to_dict()[source]

Convert the analysis period to a dictionary.

MONTHNAMES = {1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr', 5: 'May', 6: 'Jun', 7: 'Jul', 8: 'Aug', 9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec'}
NUMOFDAYSEACHMONTH = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
NUMOFDAYSEACHMONTHLEAP = (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
VALIDTIMESTEPS = {1: 60, 2: 30, 3: 20, 4: 15, 5: 12, 6: 10, 10: 6, 12: 5, 15: 4, 20: 3, 30: 2, 60: 1}
property datetimes

A sorted list of hourly datetimes in this analysis period.

property doys_int

A sorted list of days of the year in this analysis period as integers.

property end_day

End day.

property end_hour

End hour.

property end_month

End month.

property end_time

End datetime.

property hoys

A sorted list of hours of year in this analysis period.

property hoys_int

A sorted list of hours of year in this analysis period as integers.

property is_annual

Check if an analysis period is annual.

property is_leap_year

A boolean to indicate if analysis period is for a leap year.

property is_overnight

Return True if the analysis period is overnight.

If an analysis period is overnight each segments of hours will be in two different days (e.g. from 9pm to 2am).

property is_reversed

Return True if the analysis period is reversed.

A reversed analysis period defines a period that starting month is after ending month (e.g DEC to JUN).

property minute_intervals

The number of minutes between each of the timesteps of the analysis period.

property months_int

A sorted list of months of the year in this analysis period as integers.

property months_per_hour

A list of tuples representing months per hour in this analysis period.

property moys

A sorted list of hourly minutes of year in this analysis period as integers.

property st_day

Start day.

property st_hour

Start hour.

property st_month

Start month.

property st_time

Start datetime.

property timestep

Timestep.