mirror of
https://github.com/ANL-CEEESA/LLEPE.git
synced 2025-12-06 01:48:53 -06:00
changed REEPS name to LLEPE, modified opt_dict to deal with more general xml properties,
This commit is contained in:
2
llepe/__init__.py
Normal file
2
llepe/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from .llepe import LLEPE
|
||||
from .utils import get_xml_value, set_size
|
||||
1401
llepe/llepe.py
Normal file
1401
llepe/llepe.py
Normal file
File diff suppressed because it is too large
Load Diff
49
llepe/utils.py
Normal file
49
llepe/utils.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import xml.etree.ElementTree as ET
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
def set_size(w, h, ax=None):
|
||||
""" w, h: width, height in inches """
|
||||
if not ax:
|
||||
ax = plt.gca()
|
||||
left = ax.figure.subplotpars.left
|
||||
right = ax.figure.subplotpars.right
|
||||
top = ax.figure.subplotpars.top
|
||||
bottom = ax.figure.subplotpars.bottom
|
||||
fig_width = float(w) / (right - left)
|
||||
fig_height = float(h) / (top - bottom)
|
||||
ax.figure.set_size_inches(fig_width, fig_height)
|
||||
|
||||
|
||||
def get_xml_value(info_dict, xml_filename):
|
||||
tree = ET.parse(xml_filename)
|
||||
root = tree.getroot()
|
||||
d = info_dict
|
||||
value = None
|
||||
if (d['upper_attrib_name'] is not None
|
||||
and d['lower_attrib_name'] is not None):
|
||||
for child1 in root.iter(d['upper_element_name']):
|
||||
if (child1.attrib[d['upper_attrib_name']]
|
||||
== d['upper_attrib_value']):
|
||||
for child2 in child1.iter(d['lower_element_name']):
|
||||
if (child1.attrib[d['lower_attrib_name']]
|
||||
== d['lower_attrib_value']):
|
||||
value = child2.text
|
||||
|
||||
elif d['upper_attrib_name'] is None and d['lower_attrib_name'] is not None:
|
||||
for child1 in root.iter(d['upper_element_name']):
|
||||
for child2 in child1.iter(d['lower_element_name']):
|
||||
if (child1.attrib[d['lower_attrib_name']]
|
||||
== d['lower_attrib_value']):
|
||||
value = child2.text
|
||||
elif d['upper_attrib_name'] is not None and d['lower_attrib_name'] is None:
|
||||
for child1 in root.iter(d['upper_element_name']):
|
||||
if (child1.attrib[d['upper_attrib_name']]
|
||||
== d['upper_attrib_value']):
|
||||
for child2 in child1.iter(d['lower_element_name']):
|
||||
value = child2.text
|
||||
else:
|
||||
for child1 in root.iter(d['upper_element_name']):
|
||||
for child2 in child1.iter(d['lower_element_name']):
|
||||
value = child2.text
|
||||
return value
|
||||
Reference in New Issue
Block a user