postreise.analyze package

Subpackages

Submodules

postreise.analyze.demand module

postreise.analyze.demand.get_demand_time_series(scenario, area, area_type=None)[source]

Get time series demand in certain area of a scenario

Parameters:
  • scenario (powersimdata.scenario.scenario.Scenario) – scenario instance

  • area (str) – one of loadzone, state, state abbreviation, interconnect, ‘all’

  • area_type (str) – one of ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’

Returns:

(pandas.Series) – time series of total demand, index: time stamps, column: demand values

postreise.analyze.demand.get_net_demand_time_series(scenario, area, area_type=None)[source]

Get time series net demand in certain area of a scenario

Parameters:
  • scenario (powersimdata.scenario.scenario.Scenario) – scenario instance

  • area (str) – one of loadzone, state, state abbreviation, interconnect, ‘all’

  • area_type (str) – one of ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’

Returns:

(pandas.Series) – time series of total demand, index: time stamps, column: net demand values

postreise.analyze.time module

postreise.analyze.time.change_time_zone(ts, tz)[source]

Convert hourly time series to new time zone. UTC is assumed if no time zone is assigned to the input time series.

Parameters:
  • ts (pandas.DataFrame/pands.Series) – time series.

  • tz (str) – new time zone.

Returns:

(pandas.DataFrame/pandas.Series) – time series with new time zone.

Raises:
  • TypeError – if tz is not a str.

  • ValueError – if tz is invalid or the time series has already been resampled.

postreise.analyze.time.is_24_hour_format(time)[source]

Check if the input string is in 24-hour format

Parameters:

time (str) – input string

Returns:

(bool) – the input string is in 24-hour format or not

postreise.analyze.time.is_dst(ts)[source]

Flag Daylight Saving Time (DST) in a time series.

Parameters:

ts (pandas.DataFrame/pands.Series) – time series.

Returns:

(bool) – True if time zone observes DST.

postreise.analyze.time.resample_time_series(ts, freq, agg='sum')[source]

Resample a time series.

Parameters:
  • ts (pandas.DataFrame/pandas.Series) – time series to resample.

  • freq (str) – frequency. Either ‘D’ (day), ‘W’ (week), ‘M’ (month).

  • agg (str) – aggregation method. Either ‘sum’ or ‘mean’.

Returns:

(pandas.DataFrame/pandas.Series) – the resampled time series.

Raises:

ValueError – if freq is not one of ‘D’, ‘W’, ‘M’ or agg is not one of ‘sum’ or ‘mean’ or ts is time zone aware with DST.

Note

When resampling:

  • the left side of the bin interval is closed.

  • the left bin edge is used to label the interval.

  • intervals start at midnight when freq is ‘D’.

  • intervals start on Sunday when freq is ‘W’.

  • incomplete days, weeks and months are clipped when agg is ‘sum’.

  • incomplete days, weeks and months are calculated using available data samples when agg is ‘mean’.

postreise.analyze.time.slice_time_series(ts, start, end, between_time=None, dayofweek=None)[source]

Slice a time series.

Parameters:
  • ts (pandas.DataFrame/pandas.Series) – time series to slice.

  • start (pandas.Timestamp/numpy.datetime64/datetime.datetime) – start date.

  • end (pandas.Timestamp/numpy.datetime64/datetime.datetime) – end date.

  • between_time (list) – specify the start hour and end hour of each day inclusively, default to None, which includes every hour of a day. Note that if the end hour is set before the start hour, the complementary hours of a day are picked.

  • dayofweek (set) – specify the interest days of week, which is a subset of integers in [0, 6] with 0 being Monday and 6 being Sunday, default to None, which includes every day of a week.

Returns:

(pandas.DataFrame/pandas.Series) – the sliced time series.

Raises:
  • TypeError – if between_time is provided but not a list and/or if not all elements of between_time are strings and/or if dayofweek is provided but not a set.

  • ValueError – if between_time is provided but does not have exactly two elements and/or if not all elements of between_time are in 24 hour format and/or if dayofweek is provided but not a subset of integers in [0, 6].

Module contents