From 6d4d9de36795f4a7d46a4c196b526a96da106fb4 Mon Sep 17 00:00:00 2001 From: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:51:16 +0100 Subject: [PATCH 1/5] set MSYS_NO_PATHCONV through python script --- pynxtools/nexus/nexus.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pynxtools/nexus/nexus.py b/pynxtools/nexus/nexus.py index 7da178b72..5af0cbf58 100644 --- a/pynxtools/nexus/nexus.py +++ b/pynxtools/nexus/nexus.py @@ -776,6 +776,10 @@ def process_nexus_master_file(self, parser): ) def main(nexus_file, documentation, concept): """The main function to call when used as a script.""" + import platform + + if platform.system() == "Windows" and "Git" in os.environ["SHELL"]: + os.environ["MSYS_NO_PATHCONV"] = "1" logging_format = "%(levelname)s: %(message)s" stdout_handler = logging.StreamHandler(sys.stdout) stdout_handler.setLevel(logging.DEBUG) From 884742ee6b97c203eea0ab9aa3020fd70cc2f84f Mon Sep 17 00:00:00 2001 From: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> Date: Fri, 2 Feb 2024 10:22:25 +0100 Subject: [PATCH 2/5] remove env setting from code and just add to readme --- pynxtools/nexus/README.md | 11 ++++++++++- pynxtools/nexus/nexus.py | 4 ---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pynxtools/nexus/README.md b/pynxtools/nexus/README.md index e8357f75f..df04940dc 100644 --- a/pynxtools/nexus/README.md +++ b/pynxtools/nexus/README.md @@ -35,4 +35,13 @@ export 'NEXUS_DEF_PATH'= Following example dataset can be used to test `read_nexus` module `tests/data/nexus/201805_WSe2_arpes.nxs`. This is an angular-resolved photoelectron spectroscopy (ARPES) dataset and it is formatted according to -the [NXarpes application definition of NeXus](https://manual.nexusformat.org/classes/applications/NXarpes.html#nxarpes). \ No newline at end of file +the [NXarpes application definition of NeXus](https://manual.nexusformat.org/classes/applications/NXarpes.html#nxarpes). + + +A note to Windows users: if you run `read_nexus` from `git bash`, you need to set the environmental variable +`MSYS_NO_PATHCONV` to avoid the [path translation in Windows Git MSys](https://stackoverflow.com/questions/7250130/how-to-stop-mingw-and-msys-from-mangling-path-names-given-at-the-command-line#34386471). +The easiest way is to prefix the `read_nexus` call with `MSYS_NO_PATHCONV=1`: + +``` +MSYS_NO_PATHCONV=1 read_nexus -c /NXarpes/ENTRY/INSTRUMENT/analyser +``` \ No newline at end of file diff --git a/pynxtools/nexus/nexus.py b/pynxtools/nexus/nexus.py index 5af0cbf58..7da178b72 100644 --- a/pynxtools/nexus/nexus.py +++ b/pynxtools/nexus/nexus.py @@ -776,10 +776,6 @@ def process_nexus_master_file(self, parser): ) def main(nexus_file, documentation, concept): """The main function to call when used as a script.""" - import platform - - if platform.system() == "Windows" and "Git" in os.environ["SHELL"]: - os.environ["MSYS_NO_PATHCONV"] = "1" logging_format = "%(levelname)s: %(message)s" stdout_handler = logging.StreamHandler(sys.stdout) stdout_handler.setLevel(logging.DEBUG) From 133cd2c2676b02deba749488e0f603a0e3fe0254 Mon Sep 17 00:00:00 2001 From: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> Date: Fri, 2 Feb 2024 10:31:54 +0100 Subject: [PATCH 3/5] update read_nexus readme --- pynxtools/nexus/README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pynxtools/nexus/README.md b/pynxtools/nexus/README.md index df04940dc..2700b62b6 100644 --- a/pynxtools/nexus/README.md +++ b/pynxtools/nexus/README.md @@ -1,3 +1,6 @@ +# Debugger and + + This utility outputs a debug log for a given NeXus file by annotating the data and metadata entries with the schema definitions from the respective NeXus base classes and application definitions to which the file refers to. @@ -23,6 +26,11 @@ read_nexus [Options] ``` +The following example dataset can be used to test the `read_nexus` module: `tests/data/nexus/201805_WSe2_arpes.nxs`. +This is an angular-resolved photoelectron spectroscopy (ARPES) dataset and it is formatted according to +the [NXarpes application definition of NeXus](https://manual.nexusformat.org/classes/applications/NXarpes.html#nxarpes). + +## Using a different set of NeXus definitions _The environmental variable called "NEXUS_DEF_PATH" can be set to a directory, which contains the NeXus definitions as XML files. If this environmental variable is not defined, the module will use the definitions in its bundle._ @@ -33,12 +41,8 @@ An environmental variable can be set as follows: export 'NEXUS_DEF_PATH'= ``` -Following example dataset can be used to test `read_nexus` module `tests/data/nexus/201805_WSe2_arpes.nxs`. -This is an angular-resolved photoelectron spectroscopy (ARPES) dataset and it is formatted according to -the [NXarpes application definition of NeXus](https://manual.nexusformat.org/classes/applications/NXarpes.html#nxarpes). - - -A note to Windows users: if you run `read_nexus` from `git bash`, you need to set the environmental variable +## A note to Windows users +If you run `read_nexus` from `git bash`, you need to set the environmental variable `MSYS_NO_PATHCONV` to avoid the [path translation in Windows Git MSys](https://stackoverflow.com/questions/7250130/how-to-stop-mingw-and-msys-from-mangling-path-names-given-at-the-command-line#34386471). The easiest way is to prefix the `read_nexus` call with `MSYS_NO_PATHCONV=1`: From 30430e75b4a1503f441fd59764b6f63190018fea Mon Sep 17 00:00:00 2001 From: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> Date: Fri, 2 Feb 2024 10:33:39 +0100 Subject: [PATCH 4/5] typo fix in readme --- pynxtools/nexus/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pynxtools/nexus/README.md b/pynxtools/nexus/README.md index 2700b62b6..aad387630 100644 --- a/pynxtools/nexus/README.md +++ b/pynxtools/nexus/README.md @@ -1,5 +1,4 @@ -# Debugger and - +# NeXus file reader and debugger This utility outputs a debug log for a given NeXus file by annotating the data and metadata entries with the schema definitions from the respective NeXus base classes From 7d27c38c7681934a1c6be5c0af716ceadfb10404 Mon Sep 17 00:00:00 2001 From: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:31:39 +0100 Subject: [PATCH 5/5] use --help output in read_nexus readme --- pynxtools/nexus/README.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/pynxtools/nexus/README.md b/pynxtools/nexus/README.md index aad387630..ac6a889d1 100644 --- a/pynxtools/nexus/README.md +++ b/pynxtools/nexus/README.md @@ -4,25 +4,25 @@ This utility outputs a debug log for a given NeXus file by annotating the data a metadata entries with the schema definitions from the respective NeXus base classes and application definitions to which the file refers to. -``` -Options: - -f, --nexus-file : Name of nexus output file (.nxs) to enquiry. - -d, --documentation : Definition path in nexus output (.nxs) file. Returns debug - log relavent with that definition path. - Example: /entry/data/delays - -c, --concept : Concept path from application definition file (.nxdl,xml). Finds out - all the available concept definition (IS-A realation) for rendered - concept path. - Example: /NXarpes/ENTRY/INSTRUMENT/analyser - --help : To get the documentaion above - NOTE: Only one option from (-d and -c) is acceptable. - -In console: - -read_nexus [Options] - +```console +user@box:~$ read_nexus --help +Usage: read_nexus [OPTIONS] + The main function to call when used as a script. +Options: + -f, --nexus-file TEXT NeXus file with extension .nxs to learn NeXus + different concept documentation and concept. + -d, --documentation TEXT Definition path in nexus output (.nxs) file. + Returns debuglog relavent with that definition + path. Example: /entry/data/delays + -c, --concept TEXT Concept path from application definition file + (.nxdl,xml). Finds outall the available concept + definition (IS-A realation) for renderedconcept + path. Example: /NXarpes/ENTRY/INSTRUMENT/analyser + --help Show this message and exit. + +NOTE: Only one option from (-d and -c) is acceptable. ``` The following example dataset can be used to test the `read_nexus` module: `tests/data/nexus/201805_WSe2_arpes.nxs`.