Skip to content

Commit

Permalink
Updating all PythonModules to sync with PROJ_irox
Browse files Browse the repository at this point in the history
  • Loading branch information
raulf2012 committed May 18, 2020
1 parent 74bc475 commit 98a7aed
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 48 deletions.
7 changes: 6 additions & 1 deletion dft_job_automat/job_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,14 @@ def __load_dataframe__(self):
fle_name = self.root_dir + "/jobs_bin/job_dataframe.pickle"

with open(fle_name, "rb") as fle:


if sys.version_info.major > 2:
df = pickle.load(fle, encoding="latin1")
# print("IJDIFIDSj89yu892sdf")
# print("fle_name:", fle_name)

# NOTE Added encoding="latin1" for p36 support (180415 - RF)
df = pickle.load(fle, encoding="latin1")
else:
df = pickle.load(fle)

Expand Down
12 changes: 11 additions & 1 deletion dft_job_automat/job_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,18 @@ def __Job_list__(self):

print(job_i_dir)
if rev_dirs:

print("rev_dirs:", rev_dirs)

if self.parse_all_revisions is False:
rev_dirs = [rev_dirs[-1]]

last_rev_int = np.sort(
[int(i.split("_")[-1]) for i in rev_dirs])[-1]
rev_dirs = ["_" + str(last_rev_int), ]
# rev_dirs = [rev_dirs[-1]]

print("rev_dirs:", rev_dirs)
print("IOPSDFJOKIDSIJFIJDSF")

for rev_i in rev_dirs:
path_i = os.path.join(job_i_dir, rev_i)
Expand Down
1 change: 1 addition & 0 deletions oxr_reaction/oxr_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def df_calc_adsorption_e(
oxy_ref_e=oxy_ref,
hyd_ref_e=hyd_ref,
)
# print("ads_e_i:", ads_e_i)
ads_e_list.append(ads_e_i)

df["ads_e"] = np.array(ads_e_list)
Expand Down
97 changes: 89 additions & 8 deletions oxr_reaction/oxr_plotting_classes/oxr_plot_2d_volcano.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,20 @@ class Volcano_Plot_2D():
def __init__(self,
ORR_Free_E_Plot,
plot_range=None,
smart_format_dict=None,
marker_color_key="color2",
marker_border_color_key="color1",
marker_shape_key="symbol",

):
"""
"""
# | - __init__
self.ORR_Free_E_Plot = ORR_Free_E_Plot
self.smart_format_dict = smart_format_dict
self.marker_color_key = marker_color_key
self.marker_border_color_key = marker_border_color_key
self.marker_shape_key = marker_shape_key

if plot_range is None:
self.plot_range = {
Expand Down Expand Up @@ -167,9 +176,54 @@ def __create_data_point_traces__(self):
"""
"""
# | - __create_data_point_traces__


# | - Default Smart Format Dict
smart_format_dict = self.smart_format_dict

if smart_format_dict is None:
print("No smart format given!")
smart_format_dict = [
[{"bulk_system": "IrO3"}, {self.marker_color_key: "green"}],
[{"bulk_system": "IrO2"}, {self.marker_color_key: "yellow"}],

[{"coverage_type": "o_covered"}, {"symbol": "s"}],
[{"coverage_type": "h_covered"}, {"symbol": "^"}],

[{"facet": "110"}, {"color1": "red"}],
[{"facet": "211"}, {"color1": "green"}],
[{"facet": "100"}, {"color1": "black"}],
]
# __|


data_list = []
for sys_i in self.ORR_Free_E_Plot.series_list:
trace_i = self.__create_scatter_trace_i__(sys_i)
for series_i in self.ORR_Free_E_Plot.series_list:


smart_format_i = self.ORR_Free_E_Plot.__create_smart_format_dict__(
series_i.properties,
smart_format_dict,
)

name_i = series_i.series_name

if series_i.color is not None:
smart_format_i[self.marker_color_key] = series_i.color


format_i = smart_format_i

if series_i.format_dict:
format_i = series_i.format_dict


print("format_i:", format_i)

trace_i = self.__create_scatter_trace_i__(
series_i,
smart_format_i=format_i,
)
data_list.append(trace_i)

return(data_list)
Expand All @@ -182,6 +236,7 @@ def __create_scatter_trace_i__(self,
"""
"""
# | - __create_trace_i__
print("sys_i:", sys_i)
trace_i = go.Scatter(
x=[sys_i.energy_states_dict["o"] - sys_i.energy_states_dict["oh"]],
y=[sys_i.energy_states_dict["oh"]],
Expand All @@ -193,15 +248,41 @@ def __create_scatter_trace_i__(self,
# <br>
hoverinfo="name",

# marker=dict(
# size=20,
# # symbol=sys_i.format_dict["symbol_i"],
# symbol=sys_i.format_dict.get("symbol_i", "circle"),
# color=sys_i.format_dict.get("color_2", "blue"),
# line=dict(
# width=2,
# smart_format_i
# color=sys_i.format_dict.get("color_1", "black"),
# ),
# ),

marker=dict(
size=20,
symbol=sys_i.format_dict["symbol_i"],
color=sys_i.format_dict["color_2"],
size=smart_format_i.get("marker_size", 9),
color=smart_format_i.get(self.marker_color_key, "red"),
symbol=smart_format_i.get(
self.marker_shape_key, "circle"),
line=dict(
width=2,
color=sys_i.format_dict["color_1"],
width=smart_format_i.get("marker_border_width", 1.),
color=smart_format_i.get(
self.marker_border_color_key, "black"),
),
),

# marker=dict(
# size=20,
# # symbol=sys_i.format_dict["symbol_i"],
# symbol=sys_i.format_dict.get("symbol_i", "circle"),
# color=sys_i.format_dict.get("color_2", "blue"),
# line=dict(
# width=2,
# color=sys_i.format_dict.get("color_1", "black"),
# ),
# ),

)

return(trace_i)
Expand All @@ -223,7 +304,7 @@ def ooh_oh_scaling(self, doh):
"""ooh_oh_scaling equation."""
# | - ooh_oh_scaling
#like ambars
#dooh=0.5*doh + 3.0 #O
#dooh=0.5*doh + 3.0 #O
#normal one
# dooh = doh + 3.2

Expand Down
21 changes: 13 additions & 8 deletions oxr_reaction/oxr_plotting_classes/oxr_plot_scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ def __create_trace_i__(self,
# color=smart_format_i[marker_border_color_key],
color=smart_format_i.get(
self.marker_border_color_key, "black"),
width=1.,
# width=1.,

width=smart_format_i.get("marker_border_width", 1.),
)
)
)
Expand Down Expand Up @@ -381,10 +383,11 @@ def fit_scaling_lines(self,
# | - Equation Annotations
if dependent_species == "ooh":
eqn_str_i = ("" +
"ΔG<sub>OOH</sub>=" +
"ΔG<sub>OOH</sub> = " +
str(round(slope_i, num_round)) +
" ΔG<sub>OH</sub>+" +
" ΔG<sub>OH</sub> + " +
str(round(intercept_i, num_round)) +
" (eV)" +
""
)

Expand All @@ -394,17 +397,19 @@ def fit_scaling_lines(self,
eqn_str_i = ("" +
"ΔG<sub>O</sub> = " +
str(round(slope_i, num_round)) +
" ΔG<sub>OH</sub>+" +
" ΔG<sub>OH</sub> + " +
str(round(intercept_i, num_round)) +
" (eV)" +
""
)

elif dependent_species == "oh":
eqn_str_i = ("" +
"ΔG<sub>OH</sub> = " +
str(round(slope_i, num_round)) +
" ΔG<sub>OH</sub>+" +
" ΔG<sub>OH</sub> + " +
str(round(intercept_i, num_round)) +
" (eV)" +
""
)

Expand Down Expand Up @@ -481,21 +486,21 @@ def add_ideal_lines(self):
name="*OOH vs *OH Scaling",
color="black",
width=1,
dash="dash",
dash="dot",
)

self.add_line({"slope": 2, "intercept": 0.},
name="*O vs *OH Scaling",
color="black",
width=1,
dash="dash",
dash="dot",
)

self.add_line({"slope": 1, "intercept": 0.},
name="*OH vs *OH Scaling",
color="black",
width=1,
dash="dash",
dash="dot",
)
# __|

Expand Down
2 changes: 1 addition & 1 deletion oxr_reaction/oxr_plotting_classes/oxr_plot_volcano.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def __create_trace_i__(self,

legendgroup=group,

hoverinfo="text",
# hoverinfo="text",

# hoverinfo=None,
# hoverinfosrc=None,
Expand Down
3 changes: 3 additions & 0 deletions oxr_reaction/oxr_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ def __init__(
self.hover_text_col = hover_text_col
self.plot_mode = plot_mode
self.smart_format = smart_format

self.format_dict = format_dict
if format_dict is None:
self.format_dict = dict()

# self.overpotential_type = overpotential_type
self.rxn_type = rxn_type
Expand Down
60 changes: 49 additions & 11 deletions plotting/my_plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,42 @@ def add_duplicate_axes(
):
"""
Note: range must be set for this to work
Example usage:
from plotting.my_plotly import add_duplicate_axes
shared_axis_data = {
"tickcolor": "black",
"ticklen": 3,
}
shared_xaxis_data = {
"dtick": 50,
**shared_axis_data,
}
shared_yaxis_data = {
"dtick": 1,
**shared_axis_data,
}
shared_meth_props = dict(
tmp_define_both_axis_types=True,
)
add_duplicate_axes(
fig, axis_type='x',
axis_data=shared_xaxis_data,
axis_num_list=[1, ],
**shared_meth_props)
add_duplicate_axes(
fig, axis_type='y',
axis_data=shared_yaxis_data,
axis_num_list=[1, ],
**shared_meth_props)
"""
# | - add_duplicate_axes

Expand Down Expand Up @@ -309,6 +345,12 @@ def my_plotly_plot(
)
# __|

if write_svg:
try:
fig.write_image(prepath + ".svg")
except:
print("Couldn't write svg")

# | - Write pdf and svg (if ORCA is installed and working)
# Getting the hostname of computer
import socket
Expand All @@ -333,11 +375,6 @@ def my_plotly_plot(
fig.write_image(prepath + ".pdf")
except:
print("Couldn't write pdf")
if write_svg:
try:
fig.write_image(prepath + ".svg")
except:
print("Couldn't write svg")
if write_png:
try:
fig.write_image(prepath + ".png", scale=png_scale)
Expand Down Expand Up @@ -393,11 +430,6 @@ def reapply_colors(data):
# __|


def plot_layout(
# xax_labels =
):
"""



Expand All @@ -408,6 +440,13 @@ def plot_layout(


# | - OLD | add_duplicate_axes

# def plot_layout(
# # xax_labels =
# ):
# """


# def add_duplicate_axes(
# fig,
# axis_type="x", # 'x' or 'y'
Expand Down Expand Up @@ -461,4 +500,3 @@ def plot_layout(
# }).to_plotly_json())
# # __|
# __|

Loading

0 comments on commit 98a7aed

Please sign in to comment.