ODYM Functions

Created on Thu Mar 2 17:33:00 2017

@author: spauliuk

odym.ODYM_Functions.DetermineElementComposition_All_Oth(me)

Given an array of flows of materials (rows) broken down into chem. elements (columns), where the first element is “all” and the last element is “other”, the function determines the share of each element in the material, and fills nonexistent rows with a 1 for all and other, resp.

odym.ODYM_Functions.EvalItemSelectString(ItemSelectStr, IndexLength)

Extract index item selection lists from ODYM datafile information

odym.ODYM_Functions.ExcelExportAdd_tAB(Sheet, Data, rowoffset, coloffset, IName, UName, RName, FName, REName, ALabels, BLabels)

This function exports a 3D array with aspects time, A, and B to a given excel sheet. Same as xlsxExportAdd_tAB but this function is for xls files with xlrd. The t dimension is exported in one row, the A and B dimensions as several rows. Each row starts with IName (indicator), UName (unit), RName (region), FName (figure where data are used), REName (Resource efficiency scenario), and then come the values for the dimensions A and B and from coloffset onwards, the time dimension. Function is meant to be used multiple times, so a rowoffset is given, incremented, and returned for the next run.

odym.ODYM_Functions.GroupingDict2Array(GroupingDict, ElementList)

Tbd.

odym.ODYM_Functions.ListStringToListNumbers(ListStr)

Extracts numbers from a string that looks like a list commant in python, and returns them as proper list Examples: ListStringToListNumbers(‘[1,2,3]’) yields [1,2,3]

odym.ODYM_Functions.MI_Tuple(value, Is)

Define function for obtaining multiindex tuple from index value value: flattened index position, Is: Number of values for each index dimension Example: MI_Tuple(10, [3,4,2,6]) returns [0,0,1,4] MI_Tuple is the inverse of Tuple_MI.

odym.ODYM_Functions.ModelIndexPositions_FromData(Positions, RowPos, ColPos)

This function is needed to read data files into ODYM. It takes the positions of a given data point in the parameter file and checks where in the model index structure this data points belongs, if it is needed at all.

odym.ODYM_Functions.ParseClassificationFile_Main(Classsheet, Mylog)

Parse the ODYM classification file, format version

odym.ODYM_Functions.ParseConfigFile(Model_Configsheet, ScriptConfig, Mylog)

Standard routine to parse the ODYM model config file.

odym.ODYM_Functions.ParseModelControl(Model_Configsheet, ScriptConfig)

Parse the RECC and ODYM model control parameters from the ODYM config sheet.

odym.ODYM_Functions.ReadParameter(ParPath, ThisPar, ThisParIx, IndexMatch, ThisParLayerSel, MasterClassification, IndexTable, IndexTable_ClassificationNames, ScriptConfig, Mylog)

This function reads a model parameter from the corresponding parameter file

odym.ODYM_Functions.ReadParameterV2(ParPath, ThisPar, ThisParIx, IndexMatch, ThisParLayerSel, MasterClassification, IndexTable, IndexTable_ClassificationNames, ScriptConfig, Mylog, ParseUncertainty)

This function reads a model parameter from the corresponding parameter file

odym.ODYM_Functions.ReadParameterXLSX(ParPath, ThisPar, ThisParIx, IndexMatch, ThisParLayerSel, MasterClassification, IndexTable, IndexTable_ClassificationNames, ScriptConfig, Mylog, ParseUncertainty, Uncert_sheetname=None)

This function reads a model parameter from the corresponding parameter file and used openpyxl

odym.ODYM_Functions.TableWithFlowsToShares(Table, axis)

Given a 2D-table with flow values that sum up to a total, either along the columns (= across rows, axis =0) or along the rows (=across the columns, axis =1). The function then converts the flows into shares (between 0 and 1), that each element has in the column sum (axis =0) or the row sum (axis =1). Only makes sense if all table entries have the same sign, that is not checked by the function.

odym.ODYM_Functions.Tuple_MI(Tuple, IdxLength)

Function to return the absolution position of a multiindex when the index tuple and the index hierarchy and size are given. Example: Tuple_MI([2,7,3],[100,10,5]) = 138 Tuple_MI is the inverse of MI_Tuple.

odym.ODYM_Functions.convert_log(file, file_format='html')

Converts the log file to a given file format

Parameters:
  • file – The filename and path

  • file_format – The desired format

odym.ODYM_Functions.function_logger(log_filename, log_pathname, file_level=10, console_level=30)

This is the logging routine of the model. It returns alogger that can be used by other functions to write to the log(file).

Parameters:
  • file_level – Verbosity level for the logger’s output file. This can be log.WARNING (default), log.INFO, log.DEBUG

  • log_filename – The filename for the logfile.

  • log_pathname – The pathname for the logfile.

  • console_level – Verbosity level for the logger’s output file.

out :param logfile_type: Type of file to write. Markdown syntax is the default.

TODO: If other outputs types are desired, they can be converted via pandoc.

Returns:

A logger that can be used by other files to write to the log(file)

odym.ODYM_Functions.xlsxExportAdd_tAB(Sheet, Data, rowoffset, coloffset, IName, UName, RName, FName, REName, ALabels, BLabels)

This function exports a 3D array with aspects time, A, and B to a given excel sheet. Same as ExcelExportAdd_tAB but this function is for xlsx files with openpyxl. The t dimension is exported in one row, the A and B dimensions as several rows. Each row starts with IName (indicator), UName (unit), RName (region), FName (figure where data are used), REName (Resource efficiency scenario), and then come the values for the dimensions A and B and from coloffset onwards, the time dimension. Function is meant to be used multiple times, so a rowoffset is given, incremented, and returned for the next run.