Skip to content

Commit

Permalink
Adding fixing ci.
Browse files Browse the repository at this point in the history
  • Loading branch information
RubelMozumder committed Nov 27, 2023
1 parent b09250e commit f3b6134
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 14 deletions.
6 changes: 3 additions & 3 deletions pynxtools/dataconverter/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,9 @@ def transform_to_intended_dt(str_value: Any) -> Optional[Any]:
except ValueError:
pass

if isinstance(str_value, np.ndarray):
elif isinstance(str_value, np.ndarray):
return str_value
if isinstance(str_value, str):
elif isinstance(str_value, str):
try:
transformed = int(str_value)
except ValueError:
Expand All @@ -695,7 +695,7 @@ def transform_to_intended_dt(str_value: Any) -> Optional[Any]:
except ValueError:
if '[' in str_value and ']' in str_value:
transformed = json.loads(str_value)
if transformed:
if transformed is not None:
return transformed
for sym in symbol_list_for_data_seperation:
if sym in str_value:
Expand Down
3 changes: 1 addition & 2 deletions pynxtools/dataconverter/readers/sts/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ def get_appropriate_parser(self, eln_dict: Dict) -> Callable:

# pylint: disable=invalid-name, too-few-public-methods
class STMReader(BaseReader):
""" Reader for XPS.
"""
"""Reader for STM/STS."""

supported_nxdls = ["NXsts"]

Expand Down
13 changes: 11 additions & 2 deletions pynxtools/dataconverter/readers/xrd/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,22 @@
from pynxtools.dataconverter.readers.utils import flatten_and_replace, FlattenSettings
from pynxtools.dataconverter.readers.base.reader import BaseReader

CONVERT_DICT: Dict[str, str] = {}
CONVERT_DICT: Dict[str, str] = {
'unit': '@units',
'Instrument': 'INSTRUMENT[instrument]',
'Source': 'SOURCE[source]',
'Detector': 'DETECTOR[detector]',
'Collection': 'COLLECTION[collection]',
'Sample': 'SAMPLE[sample]',
'version': '@version',
'User': 'USER[user]',
}


# Global var to collect the root from get_template_from_nxdl_name()
# and use it in the the the varidate_data_dict()
ROOT: ET.Element = None
REPLACE_NESTED: Dict[str, str] = {}
REPLACE_NESTED: Dict[str, Any] = {}
XRD_FILE_EXTENSIONS = [".xrdml", "xrdml", ".udf", ".raw", ".xye"]


Expand Down
7 changes: 4 additions & 3 deletions pynxtools/dataconverter/readers/xrd/xrd_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ def fill_template_from_config_data(config_dict: dict, template: Template,
if not isinstance(val, dict) and isinstance(val, str):
template[nx_key] = val

fill_template_from_config_data(config_dict, template,
xrd_dict, file_term)

def two_theta_plot():
two_theta_gr = "/ENTRY[entry]/2theta_plot"
template[two_theta_gr + "/" + "@axes"] = ["two_theta"]
Expand All @@ -128,6 +125,8 @@ def q_plot():
template[q_plot_gr + "/" + "@q_vec_indicies"] = 0
template[q_plot_gr + "/" + "@axes"] = ["q_vec"]

template[q_plot_gr + "/" + "@signal"] = "intensity"

def handle_special_fields():
"""Some fields need special treatment."""

Expand Down Expand Up @@ -155,6 +154,8 @@ def handle_special_fields():
template[key] = count_time[0] if (isinstance(count_time, np.ndarray)
and count_time.shape == (1,)) else count_time

fill_template_from_config_data(config_dict, template,
xrd_dict, file_term)
two_theta_plot()
q_plot()
handle_special_fields()
Expand Down
9 changes: 5 additions & 4 deletions pynxtools/dataconverter/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ class Writer:

def __init__(self, data: dict = None,
nxdl_path: str = None,
output_path: str = None, write_in_memory: bool = False):
output_path: str = None,
write_in_memory: bool = False):
"""Constructs the necessary objects required by the Writer class."""
self.data = data
self.nxdl_path = nxdl_path
Expand Down Expand Up @@ -248,7 +249,7 @@ def ensure_and_get_parent_node(self, path: str, undocumented_paths) -> h5py.Grou
return grp
return self.output_nexus[parent_path_hdf5]

def _process_data_into_hdf5(self):
def _put_data_into_hdf5(self):
"""Store data in hdf5 in in-memory file or file."""

hdf5_links_for_later = []
Expand Down Expand Up @@ -321,7 +322,7 @@ def write(self):
if self.write_in_memory:
raise ValueError("To write in memory and get the file obhect please use "
"the method get_in_memory_obj()")
self._process_data_into_hdf5()
self._put_data_into_hdf5()
finally:
self.output_nexus.close()

Expand All @@ -332,7 +333,7 @@ def get_in_memory_obj(self):
"""
try:
if self.write_in_memory:
self._process_data_into_hdf5()
self._put_data_into_hdf5()
else:
raise ValueError("The write_in_memory variable is False Writer"
"class initialization.")
Expand Down
106 changes: 106 additions & 0 deletions tests/data/dataconverter/readers/xrd/ACZCTS_5-60_181.xrdml

Large diffs are not rendered by default.

0 comments on commit f3b6134

Please sign in to comment.