syfop.util
- syfop.util.const_time_series(value, time_coords=None, time_coords_freq='h', time_coords_num=8760, time_coords_year=2020)[source]
Creates a constant time series as
xarray.DataArray. The time coordinates will be created from parameters if not given.- Parameters:
value (float) – constant value used for each time stamp
time_coords (pandas.DatetimeIndex) – time coordinates for the time series. If None, time_coords are generated using
time_coords_freq,time_coords_numandtime_coords_year.time_coords_freq (str) – used only if
time_coordsisNone, frequency of the time coordinatestime_coords_num (int) – used only if
time_coordsisNone, number of time stamps generatedtime_coords_year (int) – used only if
time_coordsisNone, year used for generating time stamps (first hour of this year will be used for the first time stamp)
- Return type:
- syfop.util.constraints_to_str(m)[source]
Lists all constraints with their names and with the variable names in a more or less readable form.
This function has been copy and pasted from linopy.io.constraints_to_file() (linopy version 0.3.8) and then modified. The original function writes to a file and simply numbers all constraints and variables, but does not use their real names. The original function is intended to be used to write a model to an lpfile, but this function is intended to be used for debugging and testing.
Use with caution: this function uses inter data structures of linopy and therefore might break with new versions of linopy.
- Parameters:
m (linopy.Model) – The model to be printed.
- Returns:
A string with the constraints.
- Return type:
- syfop.util.print_constraints(m)[source]
Print equations of model m in a more or less readable form.
Use with caution: see comment in constraints_to_str().
- Parameters:
m (linopy.Model) – The model to be printed.
- syfop.util.random_time_series(time_coords_freq='h', time_coords_num=8760, time_coords_year=2020)[source]
Create a random time series.
- Parameters:
time_coords_freq (str) – used only if
time_coordsisNone, frequency of the time coordinatestime_coords_num (int) – used only if
time_coordsisNone, number of time stamps generatedtime_coords_year (int) – used only if
time_coordsisNone, year used for generating time stamps (first hour of this year will be used for the first time stamp)
- Returns:
A random time series between 0 and 1 with given time coordinates.
- Return type:
- syfop.util.timeseries_variable(model, time_coords, name)[source]
Create a non-negative variable for a
linopy.model.Modelwith time coordinates.- Parameters:
model (linopy.Model) – The model to which the variable should be added.
time_coords (pandas.DatetimeIndex) – see
const_time_series()name (str) – Name of the variable.
- Returns:
The created variable.
- Return type: