8000 Hall enum parsing by domna · Pull Request #63 · FAIRmat-NFDI/pynxtools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Hall enum parsing #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
python -m pip install -r dev-requirements.txt
- name: pycodestyle
run: |
python -m pycodestyle --ignore=E501,E701,E731 nexusutils tests --exclude=nexusutils/definitions
python -m pycodestyle --ignore=E501,E701,E731,W503 nexusutils tests --exclude=nexusutils/definitions
- name: pylint
run: |
python -m pylint nexusutils tests
Expand Down
56 changes: 27 additions & 29 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
{
"editor.rulers": [90],
"editor.renderWhitespace": "all",
"editor.tabSize": 4,
"[javascript]": {
"editor.tabSize": 2
},
"files.trimTrailingWhitespace": true,
"python.linting.pycodestylePath": "pycodestyle",
"python.linting.pycodestyleEnabled": true,
"python.linting.pycodestyleArgs": ["--ignore=E501,E701,E731"],
"python.linting.mypyEnabled": true,
"python.linting.mypyArgs": [
"--ignore-missing-imports",
"--follow-imports=silent",
"--no-strict-optional",
"--show-error-codes"
],
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.linting.pylintArgs": [
"--load-plugins=nomad.metainfo.pylint_plugin",
"nexusutils",
"tests"
],
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
"editor.rulers": [90],
"editor.renderWhitespace": "all",
"editor.tabSize": 4,
"[javascript]": {
"editor.tabSize": 2
},
"files.trimTrailingWhitespace": true,
"python.linting.pycodestylePath": "pycodestyle",
"python.linting.pycodestyleEnabled": true,
"python.linting.pycodestyleArgs": ["--ignore=E501,E701,E731,W503"],
"python.linting.mypyEnabled": true,
"python.linting.mypyArgs": [
"--ignore-missing-imports",
"--follow-imports=silent",
"--no-strict-optional",
"--show-error-codes"
],
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.linting.pylintArgs": [
"--load-plugins=nomad.metainfo.pylint_plugin",
"nexusutils",
"tests"
],
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
112 changes: 112 additions & 0 deletions nexusutils/dataconverter/readers/hall/enum_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"Measurement State Machine": {
"System Model": {
"0": "75XX-LVWR(-HS)",
"1": "75XX-LVWR-SWT(-HS), 77XX-LVWR",
"2": "75XX-HVWR(-HS), 77XX-HVWR",
"3": "76XX",
"4": "95XX-LVWR(-HS)",
"5": "95XX-LVWR-SWT(-HS), 97XX-LVWR",
"6": "95XX-HVWR(-HS), 97XX-HVWR",
"7": "77XXA",
"8": "97XXA"
},
"Wiring": {
"0": "van der Pauw",
"1": "Hall Bar"
},
"ElectroMeter": {
"0": "Keithley 6512",
"1": "Keithley 6514"
},
"VoltMeter": {
"0": "Keithley 2000",
"1": "Keithley 2182",
"2": "Keithley 182"
},
"CurrentMeter": {
"0": "Keithley 6485",
"1": "Keithley 485/6/7"
},
"Current Source": {
"0": "Keithley 220",
"1": "Keithley 6220"
},
"AC Hall type": {
"0": "AC Current only",
"1": "AC Field and Current"
}
},
"Keithley 7001": {
"Resting State": {
"0": "Closed",
"1": "Open"
}
},
"Keithley 6485": {
"Reading Rate": {
"0": "Slow",
"1": "Medium",
"2": "Fast"
},
"Digital Filter Type": {
"0": "Repeat",
"1": "Moving"
}
},
"Field Controller": {
"Gaussmeter": {
"0": "LS450",
"1": "LS475",
"2": "LS736"
},
"Power Supply": {
"0": "642,643, or 662 (Max. 70 Amp)",
"1": "665 (Max. 100 Amp)",
"2": "648 or 668 (Max. 135 Amp)",
"3": "647 (Max. 72 Amp Must be controlled via EXT input terminal)"
},
"LS450 Display Unit": {
"0": "Gauss",
"1": "Tesla"
}
},
"Temperature Controller": {
"Sample Sensor Type": {
"0": "Silicon diode",
"1": "GaAlAs diode",
"2": "Platinum 100/200",
"3": "Platinum 100/500",
"4": "Platinum 1000",
"5": "Rhodium Iron",
"6": "Carbon-glass",
"7": "Cernox",
"8": "RuOx",
"9": "Germanium",
"10": "Thermocouple"
}
},
"Temperature Domain": {
"Direction": {
"0": "Both",
"1": "Ascending",
"2": "Descending"
},
"Heater Range": {
"0": "Heater off",
"1": "4.9 mW",
"2": "49 mW",
"3": "490 mW",
"4": "4.9 W",
"5": "49.0W"
},
"Sample Space Evacuation Valve During Rampe": {
"0": "Open",
"1": "Closed"
},
"Sample Space Evacuation Valve After Ramp": {
"0": "Open",
"1": "Closed"
}
}
}
32 changes: 31 additions & 1 deletion nexusutils/dataconverter/readers/hall/reader.py
EDBE
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
# limitations under the License.
#
"""Lake Shore Hall file reader implementation for the DataConverter."""
from pathlib import Path
import re
from typing import Any, List, TextIO, Dict, Optional
import logging
import numpy as np
import pandas as pd

Expand Down Expand Up @@ -47,6 +49,13 @@
# Keys that indicate the start of measurement block
MEASUREMENT_KEYS = ["Contact Sets"]

reader_dir = Path(__file__).parent
config_file = reader_dir.joinpath("enum_map.json")
ENUM_FIELDS = parse_json(str(config_file))

logger = logging.getLogger(__name__)
logger.setLevel(logging.WARN)


def split_add_key(fobj: Optional[TextIO], dic: dict, prefix: str, expr: str) -> None:
"""Splits a key value pair and adds it to the dictionary.
Expand All @@ -62,13 +71,34 @@ def split_add_key(fobj: Optional[TextIO], dic: dict, prefix: str, expr: str) ->
key, *val = re.split(r"\s*[:|=]\s*", expr)
jval = "".join(val).strip()

def parse_enum() -> bool:
sprefix = prefix.strip("/")
w_trailing_num = re.search(r"(.*) \d+$", sprefix)
if w_trailing_num:
sprefix = w_trailing_num.group(1)

if (
sprefix in ENUM_FIELDS
and key in ENUM_FIELDS[sprefix]
and helpers.is_integer(jval)
):
if jval not in ENUM_FIELDS[sprefix][key]:
logger.warning("Option `%s` not in `%s, %s`", jval, sprefix, key)
dic[f"{prefix}/{key}"] = ENUM_FIELDS[sprefix][key].get(jval, "UNKNOWN")
return True

return False

def parse_field():
if helpers.is_value_with_unit(jval):
value, unit = helpers.split_value_with_unit(jval)
dic[f"{prefix}/{key}"] = value
dic[f"{prefix}/{key}/@units"] = helpers.clean(unit)
return

if parse_enum():
return

if helpers.is_integer(jval):
dic[f"{prefix}/{key}"] = int(jval)
return
Expand Down Expand Up @@ -161,7 +191,7 @@ def parse(line: str, current_section: str, current_measurement: str):
return parse_measurement(line, current_section, current_measurement)

if line.strip():
print(f"Warning: line `{line.strip()}` ignored")
logger.warning("Line `%s` ignored", line.strip())

return current_section, current_measurement

Expand Down
0