Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #77 from qitianshi/resolve-issue
Browse files Browse the repository at this point in the history
Resolve issue #75
  • Loading branch information
qitianshi authored Jan 8, 2022
2 parents 1d66c4a + 2390643 commit 8668801
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
29 changes: 25 additions & 4 deletions analysis/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,18 @@ def __parse_cli_input() -> tuple:
help="magnetization components to plot and analyze, any of: x y z, defaults to all"
)

comm_spatialline.add_argument(
"--show",
action="store_true",
help="whether to show the plot in a new window"
)

comm_spatialline.add_argument(
"--save",
action="store_true",
help="whether to save the plot"
)

spatialline_axis_grp = comm_spatialline.add_mutually_exclusive_group(required=True)

spatialline_axis_grp.add_argument(
Expand Down Expand Up @@ -266,14 +278,14 @@ def __parse_cli_input() -> tuple:
__validate_date(args.date, argobj_spatialline_dates)
__validate_arg_list(args.components, argobj_spatialline_components, ("x", "y", "z"))

comm_args = [args.date, args.quantity, args.components]
comm_args = [args.date, args.quantity, args.components, args.show, args.save]

if args.x_val is not None:
comm_args.extend(("x", args.x_val))
elif args.y_val is not None:
comm_args.extend(("y", args.y_val))

return (Commands.SPATIALLINE, (comm_args,), (args.cli_test,))
return (Commands.SPATIALLINE, list(comm_args), (args.cli_test,))

if args.command == "preparse":

Expand Down Expand Up @@ -531,7 +543,14 @@ def __plot_spatial_line():
x_index=AXIS_VAL if AXIS == 'x' else None,
y_index=AXIS_VAL if AXIS == 'y' else None,
component=component,
filename=QUANTITY
filename=QUANTITY,
save_to = anl.paths.plots.spatial_line(
filename=QUANTITY,
component=component,
index=('y' if AXIS == 'x' else 'x'),
date=date
) if SAVE else None,
show_plot=SHOW,
)

#endregion
Expand All @@ -557,7 +576,7 @@ def __create_json():
elif COMMAND is Commands.SPATIAL:
date_arg, COMPONENTS = COMM_ARGS #pylint: disable=W0632
elif COMMAND is Commands.SPATIALLINE:
date_arg, QUANTITY, COMPONENTS, AXIS, AXIS_VAL = COMM_ARGS #pylint: disable=W0632
date_arg, QUANTITY, COMPONENTS, SHOW, SAVE, AXIS, AXIS_VAL = COMM_ARGS #pylint: disable=W0632
elif COMMAND is Commands.PREPARSE:
date_arg, RESULT_TYPE = COMM_ARGS #pylint: disable=W0632

Expand Down Expand Up @@ -631,6 +650,8 @@ def __create_json():
f"date: {DATE.__repr__()}",
f"quantity: {QUANTITY.__repr__()}",
f"components: {COMPONENTS.__repr__()}",
f"show: {SHOW.__repr__()}",
f"save: {SAVE.__repr__()}",
f"axis: {AXIS.__repr__()}",
f"axis_val: {AXIS_VAL.__repr__()}",
sep='\n ',
Expand Down
5 changes: 4 additions & 1 deletion analysis/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ def plot_spatial_line(
y_index: int = None,
component: str = "z",
filename: str = None,
save_to: str = None,
show_plot: bool = False,
slices: int = None
):
"""Plots the graphs of spatial data against the x or y index of the cells.
Expand Down Expand Up @@ -264,7 +266,8 @@ def plot_spatial_line(
xlabel,
ylabel,
xstep=0.2e-06,
save_to=paths.plots.spatial_line(filename, component, line_index, date)
save_to=save_to,
show_plot=show_plot
)


Expand Down

0 comments on commit 8668801

Please sign in to comment.