Skip to content

Commit

Permalink
update interactive plots and cli to work for coop/cobi
Browse files Browse the repository at this point in the history
  • Loading branch information
naik-aakash committed Aug 17, 2023
1 parent b2d58f5 commit f2bde28
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
70 changes: 69 additions & 1 deletion lobsterpy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from lobsterpy.cohp.analyze import Analysis
from lobsterpy.cohp.describe import Description
from lobsterpy.plotting import PlainCohpPlotter, get_style_list, InteractiveCohpPlotter
from lobsterpy.plotting import PlainCohpPlotter, get_style_list


def main() -> None:
Expand Down Expand Up @@ -227,6 +227,34 @@ def get_parser() -> argparse.ArgumentParser:
help="This option will force the automatc analysis to consider"
" all bonds, not only cation-anion bonds (default) ",
)
auto_group.add_argument(
"--arecobis",
"--are-cobis",
action="store_true",
default=False,
help="This option will start automatc bonding analysis of" " COBIs",
)
auto_group.add_argument(
"--arecoops",
"--are-coops",
action="store_true",
default=False,
help="This option will start automatc bonding analysis of" " COOPs",
)
auto_group.add_argument(
"--noisecutoff",
type=float,
default=None,
help="Sets the lower limit of icohps or icoops or icobis considered",
)

auto_group.add_argument(
"--cutofficohp",
type=float,
default=0.1,
help="Only bonds that are stronger than cutoff_icoxx *strongest ICOHP "
" (ICOBI or ICOOP) will be considered",
)

subparsers = parser.add_subparsers(
dest="action",
Expand Down Expand Up @@ -393,6 +421,42 @@ def run(args):
"not found in the current directory"
)

if args.arecoops:
default_files_coops = {
"icohplist": "ICOOPLIST.lobster",
"cohpcar": "COOPCAR.lobster",
}
for arg_name, file_name in default_files_coops.items():
setattr(args, arg_name, Path(file_name))
file_path = getattr(args, arg_name)
if not file_path.exists():
gz_file_path = file_path.with_name(file_path.name + ".gz")
if gz_file_path.exists():
setattr(args, arg_name, gz_file_path)
else:
raise ValueError(
"Files required for automatic analysis of COOPs (ICOOPLIST.lobster and"
"COOPCAR.lobster) not found in the directory"
)

if args.arecobis:
default_files_cobis = {
"icohplist": "ICOBILIST.lobster",
"cohpcar": "COBICAR.lobster",
}
for arg_name, file_name in default_files_cobis.items():
setattr(args, arg_name, Path(file_name))
file_path = getattr(args, arg_name)
if not file_path.exists():
gz_file_path = file_path.with_name(file_path.name + ".gz")
if gz_file_path.exists():
setattr(args, arg_name, gz_file_path)
else:
raise ValueError(
"Files required for automatic analysis of COOPs (ICOBILIST.lobster and"
"COBICAR.lobster) not found in the directory"
)

if args.action in ["automaticplot", "autoplot", "auto-plot"]:
args.action = "automatic-plot"

Expand All @@ -418,6 +482,10 @@ def run(args):
path_to_cohpcar=args.cohpcar,
path_to_icohplist=args.icohplist,
whichbonds=whichbonds,
are_coops=args.arecoops,
are_cobis=args.arecobis,
noise_cutoff=args.noisecutoff,
cutoff_icohp=args.cutofficohp,
)

describe = Description(analysis_object=analyse)
Expand Down
5 changes: 4 additions & 1 deletion lobsterpy/cohp/describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,10 @@ def plot_interactive_cohps(
if label is not None:
cba_cohp_plot_data[label_str + label] = cohp

ip = InteractiveCohpPlotter()
ip = InteractiveCohpPlotter(
are_coops=self.analysis_object.are_coops,
are_cobis=self.analysis_object.are_cobis,
)
if label_resolved:
ip.add_all_relevant_cohps(
analyse=self.analysis_object, label_resolved=label_resolved
Expand Down

0 comments on commit f2bde28

Please sign in to comment.