cost_eco_model_linker.handlers.spreadsheet_interface¶
Functions¶
Retrieve industry classification codes found in the given worksheet. |
|
|
Identifies and retrieves table in a given worksheet identified by its first header. |
|
Identifies and retrieves cost table based on initial header "Amount". |
|
Attempts to identify the matching row. If none found, adds a new row. |
|
Single-pass update of industry costs in EIA template. Accumulates into existing |
|
Fill OPEX industry costs and labour, summing all relevant costs for each industry code. |
|
Fill CAPEX industry costs, summing all relevant costs for each industry code. |
|
Create an EIA template for the LM cost model. |
|
Fill an LM EIA template with cost data from the |
|
Fill EIA template with cost data for a single workbook and intervention type. |
Module Contents¶
- cost_eco_model_linker.handlers.spreadsheet_interface.get_industry_codes(ws: win32com.client.CDispatch)¶
Retrieve industry classification codes found in the given worksheet.
- Parameters:
ws (win32com.client.CDispatch) – Excel WorkSheet object
- Return type:
List of industry classification codes
- cost_eco_model_linker.handlers.spreadsheet_interface.find_table(ws: win32com.client.CDispatch, first_header: str) pandas.DataFrame¶
Identifies and retrieves table in a given worksheet identified by its first header. Selects contiguous data regions.
Note: Drops NA rows.
- Parameters:
ws (w32client.CDispatch) – Excel worksheet
first_header (str) – Header of first column
- cost_eco_model_linker.handlers.spreadsheet_interface.find_cost_table(ws: win32com.client.CDispatch) pandas.DataFrame¶
Identifies and retrieves cost table based on initial header “Amount”. Selects contiguous data regions.
Note: Drops NA rows.
- Parameters:
ws (w32client.CDispatch) – Excel worksheet
- cost_eco_model_linker.handlers.spreadsheet_interface.create_eia_template(wb)¶
- cost_eco_model_linker.handlers.spreadsheet_interface.find_or_fill_row(eia_template, it, year, intervention, port, expense_type)¶
Attempts to identify the matching row. If none found, adds a new row. Returns the row ID (of the existing row, or the new row).
- cost_eco_model_linker.handlers.spreadsheet_interface.fill_industry_costs(eia_template, next_idx, cost_df, ind_codes, unique_ind_codes)¶
Single-pass update of industry costs in EIA template. Accumulates into existing values.
- cost_eco_model_linker.handlers.spreadsheet_interface.fill_opex(it, _, year, intervention, port, eia_template, wb)¶
Fill OPEX industry costs and labour, summing all relevant costs for each industry code.
Rows whose Type is ‘passive labour’ or ‘active labour’ are accumulated into the ‘labour’ column regardless of their industry classification code. All other rows are accumulated into their respective industry code columns.
- cost_eco_model_linker.handlers.spreadsheet_interface.fill_capex(it, _, year, intervention, port, eia_template, wb)¶
Fill CAPEX industry costs, summing all relevant costs for each industry code.
- cost_eco_model_linker.handlers.spreadsheet_interface.create_lm_eia_template(wb) pandas.DataFrame¶
Create an EIA template for the LM cost model.
The LM workbook has a single
"Expenses"sheet (no CAPEX/OPEX split). Industry classification codes are read from that sheet and used as columns, with a trailing"labour"column for labour costs.
- cost_eco_model_linker.handlers.spreadsheet_interface.fill_lm_EIA_info(wb, intervention: str, it: int, iv_start_year: int, year: int, port: str, eia_template: pandas.DataFrame) pandas.DataFrame¶
Fill an LM EIA template with cost data from the
"Expenses"sheet.All costs are treated as a single expense type (
"Expenses"). Rows whose"Type"is"Labour"accumulate into the"labour"column; all other rows accumulate into their industry code column using the"Total cost"column.- Parameters:
wb – Open LM cost model workbook.
intervention (str) – Intervention type code, e.g.
"LM".it (int) – ReefMod Engine Iteration ID.
iv_start_year (int) – Year interventions begin.
year (int) – Simulation year.
port (str) – Port / location label.
eia_template (pd.DataFrame) – Template to fill (as created by
create_lm_eia_template).
- cost_eco_model_linker.handlers.spreadsheet_interface.fill_EIA_info(wb, intervention: str, it: int, iv_start_year: int, year: int, port: str, eia_template: pandas.DataFrame)¶
Fill EIA template with cost data for a single workbook and intervention type.
- Parameters:
wb – Cost model workbook (production or deployment).
intervention (str) – Intervention type code, e.g.
"CA-P"(production) or"CA-D"(deployment).it (int) – ReefMod Engine Iteration ID.
iv_start_year (int) – Year interventions begin.
year (int) – Simulation year.
port (str) – Port where deployments launched from.
eia_template (pd.DataFrame) – Template to fill.