Skip to content

Commit

Permalink
Merge pull request #24 from bobleesj/fix-figure
Browse files Browse the repository at this point in the history
Customize extra frame lines in ternary diagram based on tags
  • Loading branch information
bobleesj authored Oct 20, 2024
2 parents 6b30494 + 0a151e8 commit c8bcc9a
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 103 deletions.
36 changes: 0 additions & 36 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

19 changes: 0 additions & 19 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

21 changes: 0 additions & 21 deletions .github/ISSUE_TEMPLATE/pull_request_template.md

This file was deleted.

10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,14 @@ For Types 2, 3, and 4:

![ternary](https://github.com/bobleesj/cif-bond-analyzer/assets/14892262/7496f433-c218-49ac-8372-cb75a369e409)

To customize the legend position in the ternary diagram, you may modify the
values of `X_SHIFT = 0.0` and `Y_SHIFT = 0.0` in `core/configs/ternary.py`.
**Customize legend position:**

To adjust the legend position in the ternary diagram, modify the values of `X_SHIFT = 0.0` and `Y_SHIFT = 0.0` in `core/configs/ternary.py`.

**Customize extra lines:**

To add extra lines to the ternary diagram based on tags, edit `TAGS_IN_FIRST_EXTRA_LINE = ["lt", "ht", "hp", "hp1", "hp2", "hp3"]` and `TAGS_IN_SECOND_EXTRA_LINE = ["lt", "ht", "hp", "hp1", "hp2", "hp3"]` in `core/configs/ternary.py`.


For Type 1:

Expand Down
3 changes: 3 additions & 0 deletions core/configs/ternary.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
class TernaryConfig(Enum):
X_SHIFT = 0.0
Y_SHIFT = 0.0
TAGS_IN_FIRST_EXTRA_LINE = ["lt", "ht", "hp", "hp1", "hp2", "hp3"]
TAGS_IN_SECOND_EXTRA_LINE = ["trig", "ht_trig"]
TAGS_IN_THIRD_EXTRA_LINE = [""]
9 changes: 6 additions & 3 deletions core/site/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ def get_site_pair_data_ordered_by_mendeleev(cif_ensemble: CifEnsemble):
start_time = time.perf_counter()

prompt_progress_current(i, cif.file_name, cif.supercell_atom_count, file_count)

mixing_info = cif.mixing_info_per_label_pair_sorted_by_mendeleev
shortest_distances = cif.shortest_site_pair_distance
try:
mixing_info = cif.mixing_info_per_label_pair_sorted_by_mendeleev
shortest_distances = cif.shortest_site_pair_distance
except Exception as e:
print(f"Error occured processing {cif.file_name}: {e}")
continue

# Alphabetically sort the label pair and find min distance per unique pair
unique_label_pair_distances = {}
Expand Down
36 changes: 18 additions & 18 deletions core/system/ternary.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from core.system.figure_util import (
shift_points_xy,
)
from core.configs.ternary import TernaryConfig


def get_point_in_triangle(vertices, R_norm_index, M_norm_index):
Expand Down Expand Up @@ -350,6 +351,11 @@ def draw_extra_frame(pair, p1_x, p1_y, p2_x, p2_y):
zorder=2,
lw=extra_edge_line_width,
)

# Get the tags for the first and second extra lines from configs/ternary.py
TAGS_IN_FIRST_EXTRA_LINE = TernaryConfig.TAGS_IN_FIRST_EXTRA_LINE.value
TAGS_IN_SECOND_EXTRA_LINE = TernaryConfig.TAGS_IN_SECOND_EXTRA_LINE.value
TAGS_IN_THIRD_EXTRA_LINE = TernaryConfig.TAGS_IN_THIRD_EXTRA_LINE.value

if A_label == R and B_label == M:
# ErCo
Expand All @@ -358,50 +364,44 @@ def draw_extra_frame(pair, p1_x, p1_y, p2_x, p2_y):
A_norm_index,
B_norm_index,
)
if tag == "hex" or tag == "rt":
if tag == "hex" or tag == "rt" or is_formula_with_tag_in_main_line:
center_pt = center_pt
elif tag == "lt":
elif tag in TAGS_IN_FIRST_EXTRA_LINE:
center_pt = shift_points_xy(center_pt, 0.0, -0.1)
draw_extra_frame("RM", 0.0, -0.1, 0.0, -0.1)
elif tag == "ht":
elif tag in TAGS_IN_SECOND_EXTRA_LINE:
center_pt = shift_points_xy(center_pt, 0.0, -0.2)
draw_extra_frame("RM", 0.0, -0.2, 0.0, -0.2)
elif is_formula_with_tag_in_main_line:
center_pt = center_pt
elif tag is not None:
elif tag in TAGS_IN_THIRD_EXTRA_LINE or tag is not None:
center_pt = shift_points_xy(center_pt, 0.0, -0.3)
draw_extra_frame("RM", 0.0, -0.3, 0.0, -0.3)

# CoIn2
if A_label == M and B_label == X:
center_pt = get_point_in_triangle(vertices, 0, (1 - B_norm_index))
if tag == "hex" or tag == "rt":
if tag == "hex" or tag == "rt" or is_formula_with_tag_in_main_line:
center_pt = center_pt
elif tag == "lt":
elif tag in TAGS_IN_FIRST_EXTRA_LINE:
center_pt = shift_points_xy(center_pt, 0.1, 0.0)
draw_extra_frame("MX", 0.1, 0.0, 0.1, 0.0)
elif tag == "ht":
elif tag in TAGS_IN_SECOND_EXTRA_LINE:
center_pt = shift_points_xy(center_pt, 0.2, 0.0)
draw_extra_frame("MX", 0.2, 0.0, 0.2, 0.0)
elif is_formula_with_tag_in_main_line:
center_pt = center_pt
elif tag is not None:
elif tag in TAGS_IN_THIRD_EXTRA_LINE or tag is not None:
center_pt = shift_points_xy(center_pt, 0.3, 0.0)
draw_extra_frame("MX", 0.3, 0.0, 0.3, 0.0)
# ErIn
if A_label == R and B_label == X:
center_pt = get_point_in_triangle(vertices, A_norm_index, 0.0)
if tag == "hex" or tag == "rt":
if tag == "hex" or tag == "rt" or is_formula_with_tag_in_main_line:
center_pt = center_pt
elif tag == "lt":
elif tag in TAGS_IN_FIRST_EXTRA_LINE:
center_pt = shift_points_xy(center_pt, -0.1, 0.0)
draw_extra_frame("RX", -0.1, 0.0, -0.1, 0.0)
elif tag == "ht":
elif tag in TAGS_IN_SECOND_EXTRA_LINE:
center_pt = shift_points_xy(center_pt, -0.2, 0.0)
draw_extra_frame("RX", -0.2, 0.0, -0.2, 0.0)
elif is_formula_with_tag_in_main_line:
center_pt = center_pt
elif tag is not None:
elif tag in TAGS_IN_THIRD_EXTRA_LINE or tag is not None:
center_pt = shift_points_xy(center_pt, -0.3, 0.0)
draw_extra_frame("RX", -0.3, 0.0, -0.3, 0.0)

Expand Down
4 changes: 0 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
python main.py
Author: Sangjoon Bob Lee
Last update: June 23, 2024
Release date: Mar 10, 2024
"""

import os
Expand Down

0 comments on commit c8bcc9a

Please sign in to comment.