el1xr_opt.Modules.oM_OutputData#
- el1xr_opt.Modules.oM_OutputData.save_to_csv(df, path, filename, index=False)[source]#
Save a DataFrame to CSV file.
- Parameters:
df (pd.DataFrame) – DataFrame to save
path (str) – Directory path
filename (str) – Filename including extension
index (bool) – Whether to include index in CSV
- el1xr_opt.Modules.oM_OutputData.create_line_chart(df, x_col, y_col, color_col=None, title='', x_title='', y_title='', width=800, height=400, date_format='%a, %b %d, %H:%M', strokeDash=None)[source]#
Create a reusable Altair line chart.
- Parameters:
df (pd.DataFrame) – Data to plot
x_col (str) – Column name for x-axis
y_col (str) – Column name for y-axis
color_col (str, optional) – Column name for color encoding
title (str) – Chart title
x_title (str) – X-axis title
y_title (str) – Y-axis title
width (int) – Chart width
height (int) – Chart height
date_format (str) – Format string for date axis
strokeDash (list, optional) – Dash pattern for line [5, 5]
- Returns:
Altair chart object
- Return type:
alt.Chart
- el1xr_opt.Modules.oM_OutputData.create_bar_chart(df, x_col, y_col, color_col, title='', x_title='', y_title='', width=800, height=400, date_format='%a, %b %d, %H:%M')[source]#
Create a reusable Altair bar chart.
- Parameters:
df (pd.DataFrame) – Data to plot
x_col (str) – Column name for x-axis
y_col (str) – Column name for y-axis (use ‘sum(…)’ for aggregation)
color_col (str) – Column name for color encoding
title (str) – Chart title
x_title (str) – X-axis title
y_title (str) – Y-axis title
width (int) – Chart width
height (int) – Chart height
date_format (str) – Format string for date axis
- Returns:
Altair chart object
- Return type:
alt.Chart
- el1xr_opt.Modules.oM_OutputData.create_duration_curve(df, value_col, date_col, title, y_label, path, filename)[source]#
Create and save a duration curve plot.
- Parameters:
df (pd.DataFrame) – Input dataframe
value_col (str) – Column name containing values to plot
date_col (str) – Column name containing dates
title (str) – Chart title
y_label (str) – Y-axis label
path (str) – Directory path to save chart
filename (str) – Output filename
- Returns:
DataFrame sorted by value (descending) with counter column
- Return type:
pd.DataFrame
- el1xr_opt.Modules.oM_OutputData.save_chart(chart, path, filename, embed_options=None)[source]#
Save an Altair chart to HTML file.
- Parameters:
chart – Altair chart object
path (str) – Directory path
filename (str) – Filename including extension
embed_options (dict, optional) – Options for embedding the chart. Defaults to {‘renderer’: ‘svg’}.
- el1xr_opt.Modules.oM_OutputData.create_and_save_duration_curve(series_data, index_tuples, value_col_name, Date, hour_of_year, path, csv_filename, html_filename, title, y_label)[source]#
Create and save a duration curve with both CSV and HTML outputs.
- Parameters:
series_data (list) – List of values
index_tuples – Index tuples (e.g., from model.psn)
value_col_name (str) – Name for the value column
Date – Starting date
hour_of_year (str) – Hour of year reference
path (str) – Output directory
csv_filename (str) – CSV filename
html_filename (str) – HTML filename
title (str) – Chart title
y_label (str) – Y-axis label
- Returns:
Processed dataframe with counter
- Return type:
pd.DataFrame
- el1xr_opt.Modules.oM_OutputData.saving_rawdata(DirName, CaseName, SolverName, model, optmodel, indlog)[source]#
Save raw optimization model data to CSV files.
This function iterates through all active variables, parameters, and constraints in the optimization model and saves their data to separate CSV files.
Variables are saved with their values, lower bounds, and upper bounds.
Parameters are saved with their values.
Constraints are saved with their dual values.
- Parameters:
DirName (str) – The directory where the result files will be saved.
CaseName (str) – The name of the case, used for subdirectory and file naming.
SolverName (str) – The name of the solver used.
model – The optimization model object.
optmodel – The concrete optimization model instance.
indlog – Logging indicator.
- Returns:
The original optimization model object.
- Return type:
model
- el1xr_opt.Modules.oM_OutputData.saving_results(DirName, CaseName, Date, model, optmodel, indlog)[source]#
Save processed optimization results to CSV files and generate plots.
This function processes the results from the optimization model to generate a series of CSV files and Altair plots for analysis. It covers:
Total costs (hourly and general)
Electricity balance (generation, consumption, flows)
Net and original electricity demand
State of energy for storage systems
Fixed availability of assets
A summary of all key output metrics
It also generates Sankey diagrams and duration curves for various metrics.
- Parameters:
DirName (str) – The directory where the result files will be saved.
CaseName (str) – The name of the case, used for subdirectory and file naming.
Date (str or datetime) – The starting date for the results, used to calculate time-series data.
model – The optimization model object.
optmodel – The concrete optimization model instance.
- Returns:
The original optimization model object.
- Return type:
model