Skip to content

Commit

Permalink
refactor: move extract_data arg parser to parser module
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Hagg committed Dec 15, 2020
1 parent 7c0d675 commit c8c5350
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 68 deletions.
2 changes: 1 addition & 1 deletion pyreisejl/utility/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def launch_scenario(


if __name__ == "__main__":
args = parser.parse_args()
args = parser.parse_call_args()

# Get scenario info if using PowerSimData
if args.scenario_id:
Expand Down
68 changes: 2 additions & 66 deletions pyreisejl/utility/extract_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import argparse
import glob
import os
import re
Expand All @@ -9,7 +8,7 @@
from scipy.io import loadmat, savemat
from tqdm import tqdm

from pyreisejl.utility import const
from pyreisejl.utility import const, parser
from pyreisejl.utility.helpers import (
WrongNumberOfArguments,
get_scenario,
Expand Down Expand Up @@ -364,70 +363,7 @@ def extract_scenario(


if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Extract data from the results of the REISE.jl simulation."
)

# Arguments needed to run REISE.jl
parser.add_argument(
"-s",
"--start-date",
help="The start date as provided to run the simulation. Supported formats are"
" 'YYYY-MM-DD'. 'YYYY-MM-DD HH'. 'YYYY-MM-DD HH:MM', or 'YYYY-MM-DD HH:MM:SS'.",
)
parser.add_argument(
"-e",
"--end-date",
help="The end date as provided to run the simulation. Supported formats are"
" 'YYYY-MM-DD'. 'YYYY-MM-DD HH'. 'YYYY-MM-DD HH:MM', or 'YYYY-MM-DD HH:MM:SS'.",
)
parser.add_argument(
"-x",
"--execute-dir",
help="The directory where the REISE.jl results are stored.",
)
parser.add_argument(
"-o",
"--output-dir",
nargs="?",
default=None,
help="The directory to store the results. This is optional and defaults "
"to the execute directory.",
)
parser.add_argument(
"-m",
"--matlab-dir",
nargs="?",
default=None,
help="The directory to store the modified case.mat used by the engine. "
"This is optional and defaults to the execute directory.",
)
parser.add_argument(
"-f",
"--frequency",
nargs="?",
default="H",
help="The frequency of data points in the original profile csvs as a "
"Pandas frequency string. "
"This is optional and defaults to an hour.",
)
parser.add_argument(
"-k",
"--keep-matlab",
action="store_true",
help="If this flag is used, the result.mat files found in the "
"execute directory will be kept instead of deleted.",
)

# For backwards compatability with PowerSimData
parser.add_argument(
"scenario_id",
nargs="?",
default=None,
help="Scenario ID only if using PowerSimData.",
)

args = parser.parse_args()
args = parser.parse_extract_args()

# Get scenario info if using PowerSimData
if args.scenario_id:
Expand Down
68 changes: 67 additions & 1 deletion pyreisejl/utility/parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse


def parse_args():
def parse_call_args():
parser = argparse.ArgumentParser(description="Run REISE.jl simulation.")

# Arguments needed to run REISE.jl
Expand Down Expand Up @@ -82,3 +82,69 @@ def parse_args():
help="Scenario ID only if using PowerSimData. ",
)
return parser.parse_args()


def parse_extract_args():
parser = argparse.ArgumentParser(
description="Extract data from the results of the REISE.jl simulation."
)

# Arguments needed to run REISE.jl
parser.add_argument(
"-s",
"--start-date",
help="The start date as provided to run the simulation. Supported formats are"
" 'YYYY-MM-DD', 'YYYY-MM-DD HH', 'YYYY-MM-DD HH:MM', or 'YYYY-MM-DD HH:MM:SS'.",
)
parser.add_argument(
"-e",
"--end-date",
help="The end date as provided to run the simulation. Supported formats are"
" 'YYYY-MM-DD', 'YYYY-MM-DD HH', 'YYYY-MM-DD HH:MM', or 'YYYY-MM-DD HH:MM:SS'.",
)
parser.add_argument(
"-x",
"--execute-dir",
help="The directory where the REISE.jl results are stored.",
)
parser.add_argument(
"-o",
"--output-dir",
nargs="?",
default=None,
help="The directory to store the results. This is optional and defaults "
"to the execute directory.",
)
parser.add_argument(
"-m",
"--matlab-dir",
nargs="?",
default=None,
help="The directory to store the modified case.mat used by the engine. "
"This is optional and defaults to the execute directory.",
)
parser.add_argument(
"-f",
"--frequency",
nargs="?",
default="H",
help="The frequency of data points in the original profile csvs as a "
"Pandas frequency string. "
"This is optional and defaults to an hour.",
)
parser.add_argument(
"-k",
"--keep-matlab",
action="store_true",
help="If this flag is used, the result.mat files found in the "
"execute directory will be kept instead of deleted.",
)

# For backwards compatability with PowerSimData
parser.add_argument(
"scenario_id",
nargs="?",
default=None,
help="Scenario ID only if using PowerSimData.",
)
return parser.parse_args()

0 comments on commit c8c5350

Please sign in to comment.