output_data

This module contains functions to save solving results of models.

prepshot.output_data.create_data_array(data, dims, unit, model, extractor=None)[源代码]

Create a xarray DataArray with specified data, dimensions, coordinates and units.

参数
  • data (dict) -- The data to be included in the DataArray.

  • dims (list) -- The list of dimentions of the data.

  • unit (str) -- The unit of the data.

  • model (object) -- The model object.

  • extractor (callable, optional) -- Function that turns a tupledict entry into a scalar. Defaults to model.get_value (primal values for a variable tupledict). Pass model.get_constraint_dual to extract shadow prices from a constraint tupledict.

返回

A DataArray with the specified data, dimensions, coordinates and units.

返回类型

xr.DataArray

prepshot.output_data.extract_results_hydro(model)[源代码]

Extracts results for hydro models.

参数

model (object) -- Model solved already.

返回

A Dataset containing DataArrays for each attribute of the model.

返回类型

xr.Dataset

prepshot.output_data.extract_results_non_hydro(model)[源代码]

Extracts results for non-hydro models.

参数

model (object) -- Model object sloved already.

返回

A Dataset containing DataArrays for each attribute of the model.

返回类型

xr.Dataset

prepshot.output_data.save_result(model)[源代码]

Extracts results from the provided model.

参数

model (object) -- The model object to extract results from and save.

返回类型

None

prepshot.output_data.save_to_excel(ds, output_filename)[源代码]

Save the results to an Excel file.

参数
  • ds (xr.Dataset) -- Dataset containing the results.

  • output_filename (str) -- The name of the output file.

返回类型

None

prepshot.output_data.update_output_filename(output_filename, args)[源代码]

Update the output filename based on the arguments.

参数
  • output_filename (str) -- The name of the output file.

  • args (argparse.Namespace) -- Arguments parsed by argparse.

返回

The updated output filename.

返回类型

str