MISO2 Output
Created on Thu Feb 17 17:27:56 2022
@author: bgrammer
- class model.output.MISO2_output.MISO2Output(mfa_system_control=None, run_options=None, region=None, mc_run=None, config_id=None)
Contains the output of a src model run.
- Parameters:
mfa_system_control (dict)
run_options (dict)
region (String) – Name of the region.
mc_run (int) – Number of Monte Carlo iteration. Optional.
- metadata
Metadata
- Type:
dict
- values
Pandas dataframes of shape ()
- Type:
dict
- data_constraints
- Type:
dict
- add_result(name, df, description='result')
Add a dataframe to the MISO2Output object.
- Parameters:
name (str) – Name of output
df (Pandas.DataFrame) – DataFrame of results
description (str) – Type of result, e.g. “result” or “mean”
- check_output_values()
Checks the dataframes in the values variable for negative and NaN values and gives a warning if any are found.
- equals_values(other_output, print_differences=False)
Compares equality of dataframe values between two miso outputs.
- Parameters:
other_output (MISO2Output) – Output to be compared.
print_differences (bool) – If true, non-equal parameters will be printed to console.
- Returns:
Returns true if all values are np.allclose for all parameters.
- Return type:
all_equal(bool)
- restore_from_parquets(metadata_filename, folder_path)
Restore a MISO2Output object from a JSON holding the metadata.
To use this function correctly, create an empty MISO2Output and use this function to load it with data. The validity of the JSON as metadata for an output file is checked via the existence of an “Output_type” key.
- Parameters:
metadata_filename (str) – Filename of the JSON to be loaded as metadata. Should include the file extension.
folder_path (str) – Path to the folder where JSON object is located.
- Raises:
FileNotFoundError – If the file does not exist.
ValueError – If the JSON exists, but is not valid MISO2Output metadata.
- save_to_file(filetype, output_path='model_output_data', filename=None)
Convenience wrapper for saving MISO2Output to disk.
Note that parquet will save to multiple files, grouped by array shape, xlsx will save to a one file per type of data (e.g. result or var) with dataframes as sheets, while pickle will save the entire object. There is no option to restore a miso output object from XLSX.
- Parameters:
output_path (str) – Path to save file to.
filetype (str) – Available options = “xlsx”, “parquet”, “pickle”.
filename (str) – Defaults to “MISO2_output_Nr_<Nr>.<extension>”. The correct extension will be added automatically.
- Raises:
AttributeError – If no legitimate filetype is provided.