new_modeling_toolkit.core.temporal package
Submodules
new_modeling_toolkit.core.temporal.new_temporal module
new_modeling_toolkit.core.temporal.timeseries module
- class BooleanTimeseries
Bases:
Timeseries
- Fields:
DST ()
data ()
data_dir ()
freq_ ()
name ()
timezone ()
type ()
weather_year ()
- class FractionalTimeseries
Bases:
Timeseries
- Fields:
DST ()
data ()
data_dir ()
freq_ ()
name ()
timezone ()
type ()
weather_year ()
- class NoDateTimeseries
Bases:
CustomModel
- Fields:
- field data: Series [Required]
- field type: TimeseriesType | None = None
- class NumericTimeseries
Bases:
Timeseries
- Fields:
DST ()
data ()
data_dir ()
freq_ ()
name ()
timezone ()
type ()
weather_year ()
- class Timeseries
Bases:
CustomModel
- Fields:
- field data: Series [Required]
- field type: TimeseriesType | None = None
- add_leap_day(year, interval)
- Parameters:
interval โ Interval of timeseries in minutes. Ex: 60
Only valid when original timeseries do not contain leap day.
- classmethod from_annual_series(name: str, data: Series, **kwargs)
Try to convert a pd.Series with year (e.g., 2020) indices into a Timeseries (with DateTimeIndex).
- classmethod from_csv(name: str, filepath: str | Path, **kwargs)
Lightweight wrapper around pandas.read_csv() method
- classmethod from_dir(directory, filetype='csv') Dict[str, Timeseries]
Reads all files in specified directory to Timeseries objects and returns dictionary of Timeseries objects
- Parameters:
directory (str or pathlib.Path object) โ directory containing files to be read to timeseries objects
filetype (str) โ either โcsvโ or โjsonโ; specifies type of file being read to Timeseries objects
- Returns:
dictionary containing Timeseries objects with Timeseries names as keys
- Return type:
ts_dict (dict)
- model_post_init(__context: Any) None
This function is meant to behave like a BaseModel method to initialise private attributes.
It takes context as an argument since thatโs what pydantic-core passes when calling it.
- Parameters:
self โ The BaseModel instance.
__context โ The context.
- remove_leap_day(year, interval)
- Parameters:
interval โ Interval of timeseries in minutes. Ex: 60
Only valid when original timeseries do contain leap day.
- repeat_ts(repeat_year_dict)
Replicate the timeseries for certain times.
- Parameters:
repeat_year_dict โ a dictionary between weather/load year and data year.
e.g. โ one year of raw DR data};
profiles (for Hydro) โ one year of raw DR data};
year (the dictionary can be {extended load) โ one year of raw DR data};
e.g. โ shuffled hydro year}
profiles โ shuffled hydro year}
year โ shuffled hydro year}
- static resample_down(df, frequency, method)
Resample timeseries by reducing the timestamps.
- Parameters:
frequency โ New frequency of timestamps. Ex: โHโ for hourly
method โ Method for combining data into less frequent timestamps. - โsumโ to add all existing values that fall into new timestamp range - โmeanโ to average all existing values that fall into new timestamp range - โfirstโ to take the first existing value within the new timestamp range
- resample_month_hour_to_hourly(correct_index: DatetimeIndex)
- resample_month_or_season_hour_to_hourly(correct_index: DatetimeIndex)
This is a method called by resample_ts_attributes in the Component Class which resamples monthly, month-hour, or season-hour data to the correct frequency and start and end date for a specific attribute.
- resample_season_hour_to_hourly(correct_index: DatetimeIndex)
- resample_simple_extend_years(weather_years: tuple[int, int])
Copies a year of data for the range of weather years. For leap years, wraps the first day of the year around for last day of leap year
- Parameters:
weather_years โ tuple of beginning and end of weather year range
Returns:
- static resample_up(df, method)
Resample timeseries by increasing the timestamps.
- Parameters:
frequency โ New freqency of timestamps. Ex: โHโ for hourly
method โ Method for upsampling data into more frequent timestamps. - โinterpolateโ to interpolate between existing values - โffillโ to forward fill value until next timestamp - โbfillโ to back fill value until previous timestamp
- serialize_pd_series()
This is needed for loading system from json. Without this, the default is to shrink timeseries with repeated values to a single timestamp, which does not translate correctly when resampling the timeseries attributes again because depending on the `up_methodโ it might try
to interpolate for example instead of forward fill
- slice_by_timepoint(temporal_settings, model_year, period, hour)
Given model_year, period, and hour, find the correct value for this time series at those times. The ts_type determines the behavior of the tp slicing. For renewable profiles, we use only the period and hour to slice the correct value. For load components, we find the correct load through load profiles that are scaled to a future year, which is not incorporated into this function right now. For all others, we directly query the corresponding datetime.
- Parameters:
system โ System object that contains the power system component and linkages
model_year โ The year we are trying to model. Doesnโt make an impact for renewable profiles
period โ The index of the representative period weโre looking for
hour โ The hour within the representative period
Returns: Value of the current TS at the queried (model year, period, hour)
- property data_dict
Accessing data as a dictionary is faster than using .iloc/.loc.
Should only use this once, because this will only crease the _as_dict hidden field once. For this to be more robust, need a way to update _as_dict every time data field gets updated
- property days_in_year: Series
Returns the number of days in each year of a timeseries