Postprocessor API¶
-
calvin.postprocessor.aggregate_regions(fp)¶ Read the results CSV files and aggregate results by region (optional).
Parameters: fp – (string) directory where output files are written. Returns: nothing, but overwrites the results files with new columns added for regional aggregations.
-
calvin.postprocessor.dict_get(D, k1, k2, default=0.0)¶ Custom retrieval from nested dictionary. Get D[k1][k2] if it exists, otherwise default.
-
calvin.postprocessor.dict_insert(D, k1, k2, v, collision_rule=None)¶ Custom insertion into nested dictionary. Assign D[k1][k2] = v if those keys do not exist yet. If the keys do exist, follow instructions for collision_rule
-
calvin.postprocessor.postprocess(df, model, resultdir=None, annual=False)¶ Postprocess model results into timeseries CSV files.
Parameters: - df – (dataframe) network links data
- model – (CALVIN object) model object, post-optimization
- resultdir – (string) directory to place CSV file results
- annual – (boolean) whether to run annual optimization or not
Returns EOP_storage: (dict) end-of-period storage, only when running annual optimization. Otherwise returns nothing, but writes files.
-
calvin.postprocessor.save_dict_as_csv(data, filename, mode='w')¶ Given nested dict data, write to CSV file where rows are timesteps and columns are links/nodes as appropriate.
Parameters: - data – (dict) Nested dictionary of results data
- filename – (string) Output CSV filename
- mode – (string) file writing mode, ‘w’ for write, ‘a’ for append in particular the annual optimization uses ‘a’ to append results each year.
Returns: nothing, but writes the output CSV file.