Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mvs_report from json_with_results #814

Open
wants to merge 24 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
93fab41
check KPI dict in B0_data_input_json.py
TheOneAndra Mar 2, 2021
45074de
update constants_json_strings import
TheOneAndra Mar 2, 2021
41562f8
correct wrong indentation
TheOneAndra Mar 2, 2021
db8de85
Upload sensitivity code example
TheOneAndra Jun 23, 2021
726cb0c
Improve docstrings of `A0.process_user_arguments`
smartie2076 Jul 6, 2021
5dc6224
Add script `M_res_DOA_var.py` for sensitivity analysis
smartie2076 Jul 6, 2021
a6b5e67
Add files `sensitivity_experiment_parameters_groups.csv` and `sensit…
smartie2076 Jul 6, 2021
84bdd69
Update json example so that it can be used in senstivity analysis
smartie2076 Jul 6, 2021
aabbc7b
Update `utils.analysis.single_param_variation_analysis` to enable sen…
smartie2076 Jul 6, 2021
84db483
Revert "Extend `utils.analysis` by senstitivity function of `pvcompar…
smartie2076 Jul 6, 2021
a677afd
Update `utils.analysis`: Add feature for senstitivity analysis from p…
smartie2076 Jul 6, 2021
9bfc740
Integrate senstivity analysis in MVS terminal call
smartie2076 Jul 6, 2021
491c69c
Remove excess code for pvcompare
smartie2076 Jul 6, 2021
80be8f9
Adapt pvcompare code to MVS
smartie2076 Jul 6, 2021
d0e619d
Formatting with Black
smartie2076 Jul 6, 2021
6825e39
Deactivate for now to enable script to run independently from MVS
smartie2076 Jul 6, 2021
6a445ae
Working senstivity analysis (standalone)
smartie2076 Jul 7, 2021
15ecdd2
execute func
smartie2076 Jul 7, 2021
6184f67
Also print CAP and TOTAL FLOW
smartie2076 Jul 8, 2021
21de38b
Decrease repetitive list definitions, add CAP fuel cell
smartie2076 Jul 14, 2021
6f34b96
Beautify graphs
smartie2076 Jul 14, 2021
12d34c2
Beautify graph
smartie2076 Jul 14, 2021
7007a33
Improve labels
smartie2076 Jul 14, 2021
86c85dd
Add li-ion storage to senstivity results
smartie2076 Jul 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 58 additions & 10 deletions src/multi_vector_simulator/A0_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
PACKAGE_DATA_PATH,
DEFAULT_INPUT_PATH,
DEFAULT_OUTPUT_PATH,
RUN_SENSITIVITY,
JSON_FNAME,
CSV_FNAME,
JSON_EXT,
Expand Down Expand Up @@ -215,6 +216,14 @@ def mvs_arg_parser():

parser.add_argument("--version", action="version", version=version_num)

parser.add_argument(
"-s",
dest=RUN_SENSITIVITY,
nargs="?",
type=str,
help="path to the output folder for the simulation's results",
default=True,
)
return parser


Expand Down Expand Up @@ -394,36 +403,71 @@ def process_user_arguments(
save_png=None,
lp_file_output=False,
welcome_text=None,
sensitivity=None,
):
"""
Process user command from terminal inputs. If inputs provided as arguments of the function,
they will overwrite the command line arguments.

:param path_input_folder:
Parameters
----------

path_input_folder: str
Describes path to inputs folder (command line "-i")
:param input_type:

input_type: str
Describes type of input to expect (command line "-ext")
:param path_output_folder:

path_output_folder: str
Describes path to folder to be used for terminal output (command line "-o")
Must not exist before
:param overwrite:

overwrite: str
(Optional) Can force tool to replace existing output folder (command line "-f")
:param pdf_report:

pdf_report: str
(Optional) Can generate an automatic pdf report of the simulation's results (Command line "-pdf")
:param save_png:

save_png: str
(Optional) Can generate png figures with the simulation's results (Command line "-png")
:param display_output:

display_output: str
(Optional) Determines which messages are used for terminal output (command line "-log")
Allowed values are
"debug": All logging messages,
"info": All informative messages and warnings (default),
"warning": All warnings,
"error": Only errors,
:param lp_file_output:

lp_file_output: str
Save linear equation system generated as lp file
:param welcome_text:

welcome_text: str
Text to be displayed
:return: a dict with these arguments as keys (except welcome_text which is replaced by label)

Returns
-------

user_input: dict
Dictionary with these arguments as keys (except welcome_text which is replaced by label)

Notes
-----

Tested with:
- A0.test_input_folder_is_copied_in_output_within_folder_named_input()
- A0.test_input_folder_not_existing_raise_filenotfound_error()
- A0.test_if_json_opt_and_no_json_file_in_input_folder_raise_filenotfound_error()
- A0.test_if_csv_opt_and_csv_elements_folder_not_in_input_folder_raise_filenotfound_error()
- A0.test_if_csv_opt_path_input_file_set_to_path_input_folder_mvs_csv_config_dot_json()
- A0.test_if_log_opt_display_output_is_set_with_correct_value()
- A0.test_if_path_output_folder_exists_raise_fileexists_error()
- A0.test_if_f_opt_preexisting_path_output_folder_should_be_replaced()
- A0.test_if_path_output_folder_recursive_create_full_path()
- A0.test_if_pdf_opt_the_key_path_pdf_report_exists_in_user_inputs()
- A0.test_if_no_pdf_opt_the_key_path_pdf_report_does_not_exist_in_user_inputs()
- A0.test_if_png_pdf_not_active()
- A0.test_if_both_pdf_and_png_opt_raises_no_error()
"""

logging.debug("Get user inputs from console")
Expand Down Expand Up @@ -506,6 +550,10 @@ def process_user_arguments(
else:
screen_level = logging.INFO

#if sensitivity is None:
# sensitivity = args.get(RUN_SENSITIVITY, DEFAULT_MAIN_KWARGS[RUN_SENSITIVITY])


# Define logging settings and path for saving log
logger.define_logging(
logpath=path_output_folder,
Expand Down
13 changes: 13 additions & 0 deletions src/multi_vector_simulator/B0_data_input_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
VALUE,
DATA,
TIMESERIES,
KPI,
KPI_COST_MATRIX,
KPI_SCALAR_MATRIX,
LABEL,
)

from multi_vector_simulator.utils.constants import (
Expand Down Expand Up @@ -336,4 +340,13 @@ def load_json(
dict_values, flag_missing=flag_missing_values, set_default=set_default_values
)

if KPI in dict_values:
for kpi in (KPI_COST_MATRIX, KPI_SCALAR_MATRIX):

if not isinstance(dict_values[KPI][kpi], pd.DataFrame):
dict_values[KPI][kpi] = pd.DataFrame.from_records(dict_values[KPI][kpi])

if LABEL not in dict_values[KPI][kpi].columns:
dict_values[KPI][kpi][LABEL] = dict_values[KPI][kpi].index

return dict_values
Loading