From 90a2f9adc54a0fc2c6882f6a9d014b0543c3da69 Mon Sep 17 00:00:00 2001 From: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:54:07 +0200 Subject: [PATCH 1/6] move all READMEs to docs, overhaul doc structure --- .github/workflows/build_docs.yml | 1 + README.md | 53 +++++------ docs/index.md | 32 +++++-- docs/learn/dataconverter-and-readers.md | 75 ++++++++++++++++ docs/learn/multi-format-reader.md | 6 +- docs/learn/nexus-rules.md | 2 - docs/learn/nexus-verification.md | 45 ++++++++++ docs/reference/built-in-readers.md | 88 +++++++++++++++++++ docs/reference/cli-api.md | 81 +++++++++-------- docs/reference/plugins.md | 10 +-- .../tutorial/troubleshooting.md | 6 +- mkdocs.yaml | 16 ++-- src/pynxtools/dataconverter/README.md | 57 +++--------- src/pynxtools/dataconverter/readers/README.md | 47 +--------- .../dataconverter/readers/base/README.md | 5 +- .../dataconverter/readers/json_map/README.md | 62 +------------ .../dataconverter/readers/json_yml/README.md | 3 + .../dataconverter/readers/multi/README.md | 9 ++ 18 files changed, 353 insertions(+), 245 deletions(-) create mode 100644 docs/learn/dataconverter-and-readers.md create mode 100644 docs/learn/nexus-verification.md create mode 100644 docs/reference/built-in-readers.md rename TROUBLESHOOTING.md => docs/tutorial/troubleshooting.md (82%) create mode 100644 src/pynxtools/dataconverter/readers/multi/README.md diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index f26824c20..697418b98 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -4,6 +4,7 @@ on: push: branches: - master # Triggers deployment on push to the main branch + - 405-move-readme-content-to-documentation env: UV_SYSTEM_PYTHON: true diff --git a/README.md b/README.md index 60def5dcb..c51afb850 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,15 @@ `pynxtools` is a tool designed for making your experimental data FAIR. It allows to develop ontologies and to create ontological instances based on the [NeXus format](https://www.nexusformat.org/). +# Scope + +`pynxtools` (previously called `nexusutils`) is intended as a parser for combining various instrument output formats and electronic lab notebook (ELN) formats to an hdf5 file according to NeXus application definitions. + +Additionally, the software can be used as a plugin in the research data management system NOMAD for +making experimental data searchable and publishable. +NOMAD is developed by the FAIRMAT consortium, as a part of the German National Research Data Infrastructure +(NFDI). + # Installation It is recommended to use python 3.10 with a dedicated virtual environment for this package. @@ -28,26 +37,13 @@ You can also install the latest _development_ version with pip install git+https://github.com/FAIRmat-NFDI/pynxtools.git ``` -# Scope - -`pynxtools` (previously called `nexusutils`) is intended as a parser for combining various instrument output formats and electronic lab notebook (ELN) formats to an hdf5 file according to NeXus application definitions. - -Additionally, the software can be used as a plugin in the research data management system NOMAD for -making experimental data searchable and publishable. -NOMAD is developed by the FAIRMAT consortium, as a part of the German National Research Data Infrastructure -(NFDI). - -The software tools are located inside [`pynxtools`](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/src/pynxtools) and they are -shipped with unit tests located in [`tests`](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/tests). -Some examples with real datasets are provided in [`examples`](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/examples). -It guides you through the process of converting instrument raw -data into the NeXus standard and visualising the files content. +# Documentation +Documentation can be found [here](https://fairmat-nfdi.github.io/pynxtools/). -# Command line tools +# Repository structure -- [**dataconverter**](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/dataconverter/README.md): Creates compliant instances of NeXus/HDF5 files to [NeXus schemas](https://nexusformat.org). -- [**read_nexus**](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/nexus/README.md): Outputs a debug log for a given NeXus file. -- [**generate_eln**](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/eln_mapper/README.md): Outputs ELN files that can be used to add metadata to the dataconverter routine. +The software tools are located inside [`src/pynxtools`](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/src/pynxtools) and they are shipped with unit tests located in [`tests`](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/tests). +Some examples with real datasets are provided in [`examples`](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/examples). They guide you through the process of converting instrument raw data into the NeXus standard and visualising the files' content. # NOMAD integration @@ -56,8 +52,9 @@ NOMAD will recognize pynxtools as a plugin automatically and offer automatic par and a schema for NeXus application definitions. pynxtools is already included in the NOMAD main deployment and NOMAD NeXus distribution images. -# Documentation -Documentation for the different tools can be found [here](https://fairmat-nfdi.github.io/pynxtools/). +### Does this software require NOMAD or NOMAD OASIS ? + +No. The data files produced here can be uploaded to NOMAD. Therefore, this acts like the framework to design schemas and instances of data within the NeXus universe. It can, however, be used as a NOMAD plugin to parse nexus files, please see the section above for details. # Contributing @@ -97,7 +94,7 @@ python -m pytest -sv tests ## Run examples A number of examples exist which document how the tools can be used. For a standalone -usage convenient jupyter notebooks are available for each tool. To use them jupyter +usage convenient jupyter notebooks are available for each tool. To use them, jupyter and related tools have to be installed in the development environment as follows: ```shell @@ -105,6 +102,9 @@ python -m pip install jupyter python -m pip install jupyterlab python -m pip install jupyterlab_h5web ``` +# Troubleshooting + +Please check this [guide](https://fairmat-nfdi.github.io/pynxtools/tutorial/troubleshooting.html) for any issues you face with the tool. If you don't find a solution there, please make a new [Github Issue](https://github.com/FAIRmat-NFDI/pynxtools/issues/new?template=bug.yaml). # Questions, suggestions? @@ -114,13 +114,4 @@ on how to build on this work, or to get your parser included into NOMAD, you can - Open an issue on the [pynxtools GitHub](https://github.com/FAIRmat-NFDI/pynxtools/issues) - Use our forums at [matsci.org](https://matsci.org/c/nomad/32) - Write to [support@nomad-lab.eu](mailto:support@nomad-lab.eu) -- Contact directly the lead developers of the individual parsers. - -### Does this software require NOMAD or NOMAD OASIS ? - -No. The data files produced here can be uploaded to Nomad. Therefore, this acts like the framework to design schemas and instances of data within the NeXus universe. It can, however, be used as a NOMAD plugin to parse nexus files, please see the section above for details. - -# Troubleshooting - -Please check this [guide](TROUBLESHOOTING.md) for any issues you face with the tool. If you don't find a solution there, please make a new [Github Issue](https://github.com/FAIRmat-NFDI/pynxtools/issues/new?template=bug.yaml). - +- Contact directly the lead developers of the individual parsers. \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index af4e86888..5ff4d8675 100644 --- a/docs/index.md +++ b/docs/index.md @@ -5,12 +5,18 @@ hide: toc # FAIRmat NeXus documentation +Within [FAIRMat](https://www.fairmat-nfdi.eu/fairmat/), we are extending the [NeXus data format standard](https://www.nexusformat.org/) to support the FAIR data principles for experimental data in materials science and and phyics. This is the documentation for both our contribution to the NeXus standard as well as for our tools for data conversion and verification. +`pynxtools`, which is the main tool under development, provides a dataconverter that maps from experimental data to the NeXus format as well as tools to verify NeXus files. It is intended as a parser for combining various instrument output formats and electronic lab notebook (ELN) formats to an HDF5 file according to NeXus application definitions. +`pynxtools` offers scientists a convenient way to use the NeXus format and solves the challenge of unstructured and non-standardized data in experimental materials science. +The new contribution to the standard, together with the tools provided through `pynxtools`, enable scientists and research groups working with data, as well as helping communities implement standardized FAIR research data. + +Additionally, the software is used as a plugin in the research data management system [NOMAD](https://nomad-lab.eu/nomad-lab/) for making experimental data searchable and publishable. NOMAD is developed by the FAIRMAT consortium, as a part of the German National Research Data Infrastructure (NFDI).
@@ -21,13 +27,14 @@ A series of tutorials giving you an overview on how to store or convert your dat - [Converting your data to NeXus](tutorial/converting-data-to-nexus.md) - [Uploading NeXus data to NOMAD](tutorial/nexus-to-nomad.md) +- [Troubleshooting guide](tutorial/troubleshooting.md)
### How-to guides -How-to guides provide step-by-step instructions for a wide range of tasks: +How-to guides provide step-by-step instructions for a wide range of tasks. - [Writing an application definition](how-tos/writing-an-appdef.md) - [Storing data in multiple application definitions](how-tos/using-multiple-appdefs.md) @@ -36,18 +43,22 @@ How-to guides provide step-by-step instructions for a wide range of tasks: - [Representing experimental geometries](how-tos/transformations.md) - [Using pynxtools test framework](how-tos/using-pynxtools-test-framework.md) -
### Learn -An introduction to NeXus and its design principles. +#### An introduction to NeXus and its design principles - [An introduction to NeXus](learn/nexus-primer.md) - [Rules for storing data in NeXus](learn/nexus-rules.md) - [The concept of multiple application definitions](learn/multiple-appdefs.md) + +#### pynxtools + +- [Data conversion in `pynxtools`](learn/dataconverter-and-readers.md) +- [NeXus verification in `pynxtools`](learn/nexus-verification.md) - [The MultiFormatReader as a reader superclass](learn/multi-format-reader.md)
@@ -55,15 +66,22 @@ An introduction to NeXus and its design principles. ### Reference +#### NeXus definitions +[Here](reference/definitions.md), you find the detailed list of application definitions and base classes and their respective fields. + +Or go directly to the [official NIAC](https://manual.nexusformat.org/classes/index.html) + or [latest FAIRmat](https://fairmat-nfdi.github.io/nexus_definitions/) definitions. + +#### pynxtools + `pynxtools` has a number of command line tools that can be used to convert data and verify NeXus files. You can more information about the API [here](reference/cli-api.md). -Within FAIRmat, we maintain a number of reader plugins for different experimental techniques. You can find more information [here](reference/plugins.md). +Within FAIRmat, we maintain a number of pynxtools readers as well as reader plugins for different experimental techniques. Here you can find more information: -[Here](reference/definitions.md), you find the detailed list of application definitions and base classes and their respective fields. +- [Built-in pynxtools readers](reference/built-in-readers.md) +- [FAIRMat-suppored pynxtools plugins](reference/plugins.md) -Or go directly to the [official NIAC](https://manual.nexusformat.org/classes/index.html) - or [latest FAIRmat](https://fairmat-nfdi.github.io/nexus_definitions/) definitions.
diff --git a/docs/learn/dataconverter-and-readers.md b/docs/learn/dataconverter-and-readers.md new file mode 100644 index 000000000..234edb68f --- /dev/null +++ b/docs/learn/dataconverter-and-readers.md @@ -0,0 +1,75 @@ +# Data conversion in pynxtools +One of the main motivations for pynxtools is to develop a tool for combining various instrument output formats and electronic lab notebook (ELN) into an [HDF5](https://support.hdfgroup.org/HDF5/) file according to [NeXus application definitions](https://fairmat-nfdi.github.io/nexus_definitions/classes/index.html). + +The `dataconverter` API in pynxtools provides exactly that: it converts experimental data to NeXus/HDF5 files based on any provided [NXDL schemas](https://manual.nexusformat.org/nxdl.html#index-1). + +The dataconverter has essentially three functionalities: + +1. read in experimental data using ```readers``` +2. validate the data and metadata against any of the NeXus application definitions +3. write a valid NeXus/HDF5 file + +For step 1, a set of readers has been which the converter calls to accomplish this task for a specific set of application definition (NXDL XML file) plus a set of experiment/method-specific file(s). These files can be files in a proprietary format, or of a certain format used in the respective scientific community, or text files. Only in combination, these files hold all the required pieces of information which the application definition demands and which are thus required to make a NeXus/HDF5 file compliant. Users can store additional pieces of information in an NeXus/HDF5 file. In this case readers will issue a warning that these data are not properly documented from the perspective of NeXus. + +There exists two different subsets of readers: + +1. [Built-in readers](../reference/built-in-readers.md), which are implemented directly in pynxtools and are typically used either as superclasses for new reader implementations or for generic reading purposes not directly related to any specific technique. +2. [Reader plugins](../reference/plugins.md) for `pynxtools, which are used for reading data of specific experimental techniques and are typically available as their own Python packages. + +## Matching to NeXus application definitions + +The purpose of the dataconverter is to create NeXus/HDF5 files with content that matches a specific NeXus application definition. Such application definitions are useful for collecting a set of pieces of information about a specific experiment in a given scientific field. The pieces of information are metadata and numerical data. The application definition is used to provide these data in a format that serves a data delivery contract: The HDF5 file, or so-called NeXus file, delivers all those pieces of information which the application definition specifies. Required and optional pieces of information are distinguished. NeXus classes can recommend the inclusion of certain pieces of information. Recommended data are essentially optional. The idea is that flagging these data as recommended motivates users to collect them but does not require to write dummy +or nonsense data if the user is unable to collect recommended data. + +## Getting started + +Each of the built-in reader comes with the main `pynxtools` package, therefore they are avaible after pip installation: +```console +user@box:~$ pip install pynxtools +``` + +The different FAIRmat-supported plugins can be installed together with pynxtools by passing the name of the plugin as an extra to the pip install call. For example, for the `pynxtools-mpes` plugin: +```console +pip install pynxtools[mpes] +``` + +In addition, it is also possible to install all of the pynxtools reader plugins which are maintained by FAIRmat by passing the `[convert]` extra to the pip install call: + +```console +pip install pynxtools[convert] +``` + +## Usage +See [here](../reference/cli-api.md#data-conversion) for the documentation of the `dataconverter` API. + +### Use with multiple input files + +```console +user@box:~$ dataconverter --nxdl nxdl metadata data.raw otherfile +``` + +### Merge partial NeXus files into one + +```console +user@box:~$ dataconverter --nxdl nxdl partial1.nxs partial2.nxs +``` + +### Map an HDF5/JSON/(Python Dict pickled in a pickle file) + +```console +user@box:~$ dataconverter --nxdl nxdl any_data.hdf5 --mapping my_custom_map.mapping.json +``` + +You can find actual examples with data files at [`examples/json_map`](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/examples/json_map/). + + +## Example data for testing and development purposes + +Before using your own data we strongly encourage you to download a set of open-source test data for testing the plug-ins. For this purpose pynxtools comes with a tests directory with a data/dataconverter sub-directory including reader-specific jupyter-notebook examples. These examples can be used for downloading test data and use specific readers as a standalone converter to translate given data into a NeXus/HDF5 file. + +Once you have practised with these tools how to convert these examples, feel free to use the tools for converting your own data. You should feel invited to contact the respective corresponding author(s) of each reader if you run into issues with the reader or feel there is a necessity to include additional data into the NeXus file for the respective application. + +We are looking forward for learning from your experience and see the interesting use cases. +You can find the contact persons in the respective README.md of each reader. + +You can read specific README's of the readers and find usage examples [here](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/examples/). \ No newline at end of file diff --git a/docs/learn/multi-format-reader.md b/docs/learn/multi-format-reader.md index 56f9872e8..40efc33ef 100644 --- a/docs/learn/multi-format-reader.md +++ b/docs/learn/multi-format-reader.md @@ -1,14 +1,14 @@ # The MultiFormatReader as a reader superclass -There are three options for building a new pynxtools reader: +There are three options for building a new `pynxtools` reader: 1. build the reader from scratch 2. inherit and extend the [**`BaseReader`**](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/dataconverter/readers/base/reader.py) 3. inherit and extend the [**`MultiFormatReader`**](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/dataconverter/readers/multi/reader.py) -While option 1 is generally not recommended, inheriting and extending the `BaseReader` has traditionally been the default solution for all existing pynxtools readers and reader plugins. The `BaseReader`, which is an abstract base class, has an essentially empty ```read``` function and is thus only helpful for implementing the correct input/ouput design of the ```reader```function of any reader which is implemented off of it. +While option 1 is generally not recommended, inheriting and extending the `BaseReader` has traditionally been the default solution for all existing pynxtools readers and reader plugins. The `BaseReader`, which is an abstract base class, has an essentially empty ```read``` function and is thus only helpful for implementing the correct input/output design of the ```read``` function of any reader which is implemented off of it. -While building on the ```BaseReader``` allows for the most flexibility, in most cases it is desirable to implement a reader that can read in multiple file formats and then populate the template based on the read data. For this purpose, `pynxtools` has the [**`MultiFormatReader`**](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/dataconverter/readers/multi/reader.py), which can be readily extended for any new data. +While building on the ```BaseReader``` allows for the most flexibility, in most cases it is desirable to implement a reader that can read in multiple file formats and then populate the NeXus file based on the read data, in compliance with a NeXus application definition. For this purpose, `pynxtools` has the [**`MultiFormatReader`**](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/dataconverter/readers/multi/reader.py), which can be readily extended for any new data. Here, we will explain the inner workings of the `MultiFormatReader`. Note that there is also a [how-to guide](../how-tos/use-multi-format-reader.md) on how to implement a new reader off of the `MultiFormatReader` using a concrete example. In case you simply want to use the `MultiFormatReader` without understanding its inner logic, we recommend you start there. diff --git a/docs/learn/nexus-rules.md b/docs/learn/nexus-rules.md index 6d8bf8700..aa4a0133b 100644 --- a/docs/learn/nexus-rules.md +++ b/docs/learn/nexus-rules.md @@ -1,7 +1,5 @@ # Rules for storing data in NeXus -!!! danger "Work in progress" - There are several rules which apply for storing single data items in NeXus. There exists a [summary](https://manual.nexusformat.org/datarules.html) in the NeXus documentation outlining most of these rules. However, this explanation is not exhaustive and thus, we have compiled here additional information. diff --git a/docs/learn/nexus-verification.md b/docs/learn/nexus-verification.md new file mode 100644 index 000000000..9c8c8488c --- /dev/null +++ b/docs/learn/nexus-verification.md @@ -0,0 +1,45 @@ +# NeXus verification +!!! info "Work in progress" + +One of the main advantages of using pynxtools is that it comes with its own verification. That is, it can be used to verify that a given NeXus/HDF5 file is compliant with a NeXus application definition. + +## As part of the dataconverter +During [data conversion](./dataconverter-and-readers.md), before writing the HDF5 file, the data is first checked against the provided application definition. + + + +## read-nexus: 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 and application definitions to which the file refers to. See [here](reference/cli-api.html#verify-nexus) for the API documentation. + +The following example dataset can be used to test the `read_nexus` module: [src/pynxtools/data/201805_WSe2_arpes.nxs](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/data/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._ + +An environmental variable can be set as follows: + +``` +export 'NEXUS_DEF_PATH'= +``` + +### 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 +``` + +## Other approaches (not part of pynxtools) +Aside from the tools we developed within FAIRmat, the [official NeXus website](https://manual.nexusformat.org/validation.htm) listed two more programs for the verification and validation of NeXus files: + +1. nxvalidate +2. punx \ No newline at end of file diff --git a/docs/reference/built-in-readers.md b/docs/reference/built-in-readers.md new file mode 100644 index 000000000..ba9ab7ab2 --- /dev/null +++ b/docs/reference/built-in-readers.md @@ -0,0 +1,88 @@ +# Built-in readers +There exists a number of [readers](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/src/pynxtools/dataconverter/readers) directly in pynxtools. These are typically used either as superclasses for new reader implementations or for generic reading purposes not directly related to any specific technique. + +## The [BaseReader](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/dataconverter/readers/base/reader.py) +This is the most simple reader, which is an abstract base class, on top of which a new reader implementation can build. It has an essentially empty read function and is thus only helpful for implementing the correct input/ouput design of the ```read``` function of any reader which is implemented off of it. +## The [MultiFormatReader](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/dataconverter/readers/multi/reader.py) +Aside from the `BaseReader`, there exists another reader which can act as the basis for any reader implementation, the `MultiFormatReader`, which can be used to implement a reader that can read in multiple file formats and then populate the template based on the read data. Note that this reader has a lot of already built-in functionality, which is extensively described [here](../learn/multi-format-reader.md). There is also a [how-to guide](../how-tos/use-multi-format-reader.md) on how to implement a new reader off of the `MultiFormatReader` using a concrete example. + +## The [JsonMapReader](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/dataconverter/readers/json_map/reader.py) +This reader is designed to allow users of `pynxtools` to convert their existing data with the help of a map file. The map file tells the reader what to pick from your data files and convert them to FAIR NeXus files. The following formats are supported as input files: + +* HDF5 (any extension works i.e. h5, hdf5, nxs, etc) +* JSON +* Python Dict Objects pickled with [pickle](https://docs.python.org/3/library/pickle.html). These can contain [xarray.DataArray](https://docs.xarray.dev/en/stable/generated/xarray.DataArray.html) objects as well as regular Python types and Numpy types. + +It accepts any NXDL file that you like as long as your mapping file contains all the fields. +Please use the `--generate-template` function of the `dataconverter` to create a `.mapping.json` file: + +```console +user@box:~$ dataconverter --nxdl NXmynxdl --generate-template > mynxdl.mapping.json +``` + +### The mapping.json file + +This file is designed to let you fill in the requirements of a NeXus Application Definition without writing any code. If you already have data in the formats listed above, you just need to use this mapping file to help the dataconverter pick your data correctly. + +The mapping files will always be based on the Template the dataconverter generates. See above on how to generate a mapping file. +The right hand side values of the Template keys are what you can modify. + +Here are the three different ways you can fill the right hand side of the Template keys: +* Write the nested path in your datafile. This is indicated by a leading `/` before the word `entry` to make `/entry/data/current_295C` below. +Example: + +```json + "/ENTRY[entry]/DATA[data]/current_295C": "/entry/data/current_295C", + "/ENTRY[entry]/NXODD_name/posint_value": "/a_level_down/another_level_down/posint_value", +``` + +* Write the values directly in the mapping file for missing data from your data file. + +```json + "/ENTRY[entry]/PROCESS[process]/program": "Bluesky", + "/ENTRY[entry]/PROCESS[process]/program/@version": "1.6.7" +``` + +* Write JSON objects with a link key. This follows the same link mechanism that the dataconverter implements. In the context of this reader, you can only use external links to your data files. In the example below, `current.nxs` is an already existing HDF5 file that we link to in our new NeXus file without copying over the data. The format is as follows: +`"link": ":"` +Note: This only works for HDF5 files currently. + +```json + "/ENTRY[entry]/DATA[data]/current_295C": {"link": "current.nxs:/entry/data/current_295C"}, + "/ENTRY[entry]/DATA[data]/current_300C": {"link": "current.nxs:/entry/data/current_300C"}, +``` + +### Examples + +#### Basic mappings + +There are some example files you can use: + +[data.mapping.json](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/tests/data/dataconverter/readers/json_map/data.mapping.json) + +[data.json](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/tests/data/dataconverter/readers/json_map/data.json) + +```console +user@box:~$ dataconverter --nxdl NXtest data.json --mapping data.mapping.json +``` + +#### Example with HDF5 files +You can find example data files for using the mapping with HDF5 files at [`examples/json_map`](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/examples/examples/json_map/). + +The example can be run by calling + + +```console +user@box:~$ dataconverter --nxdl nxdl any_data.hdf5 --mapping my_custom_map.mapping.json +``` + + +## The [YamlJsonReader](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/dataconverter/readers/json_yml/reader.py) +!!! info "Work in progress" + +## Installation + +Each of the built-in reader comes with the main `pynxtools` package, therefore they are avaible after pip installation: +```console +user@box:~$ pip install pynxtools +``` \ No newline at end of file diff --git a/docs/reference/cli-api.md b/docs/reference/cli-api.md index b87c5c744..83775e7b1 100644 --- a/docs/reference/cli-api.md +++ b/docs/reference/cli-api.md @@ -1,40 +1,43 @@ -# API for command line tools - -`pynxtools` supports a number of command line applications. This page provides documentation for their current API. - -## Data conversion -Note that simply calling `dataconverter` defaults to `dataconverter convert`. - -::: mkdocs-click - :module: pynxtools.dataconverter.convert - :command: main_cli - :prog_name: dataconverter - :depth: 2 - :style: table - :list_subcommands: True - -## NeXus file verification - - -::: mkdocs-click - :module: pynxtools.nexus.nexus - :command: main - :prog_name: read_nexus - :depth: 2 - :style: table - :list_subcommands: True - -## ELN generation -::: mkdocs-click - :module: pynxtools.eln_mapper.eln_mapper - :command: get_eln - :prog_name: generate_eln - :depth: 1 - :style: table +# API for command line tools + +`pynxtools` supports a number of command line applications. This page provides documentation for their current API. + +## Data conversion +Note that simply calling `dataconverter` defaults to `dataconverter convert`. + +::: mkdocs-click + :module: pynxtools.dataconverter.convert + :command: main_cli + :prog_name: dataconverter + :depth: 2 + :style: table + :list_subcommands: True + +## NeXus file verification + + +::: mkdocs-click + :module: pynxtools.nexus.nexus + :command: main + :prog_name: read_nexus + :depth: 2 + :style: table + :list_subcommands: True + +NOTE: Only one option from (`-d` and `-c`) is acceptable. + + +## ELN generation +::: mkdocs-click + :module: pynxtools.eln_mapper.eln_mapper + :command: get_eln + :prog_name: generate_eln + :depth: 2 + :style: table :list_subcommands: True \ No newline at end of file diff --git a/docs/reference/plugins.md b/docs/reference/plugins.md index 48e97c728..ab5b32391 100644 --- a/docs/reference/plugins.md +++ b/docs/reference/plugins.md @@ -26,16 +26,16 @@ There are a number of plugins available for pynxtools that are maintained within ## Installation -You can install each of the plugins together with pynxtools by passing the name of the plugin as an extra to the pip install call. For example, for the pynxtools-mpes plugin: +You can install each of the plugins together with pynxtools by passing the name of the plugin as an extra to the pip install call. For example, for the `pynxtools-mpes` plugin: -``` +```console pip install pynxtools[mpes] ``` -In addition, you can also install all of the pynxtools reader plugins which are maintained by FAIRmat by passing the [convert] extra to the pip install call: +In addition, you can also install all of the pynxtools reader plugins which are maintained by FAIRmat by passing the `[convert]` extra to the pip install call: -``` +```console pip install pynxtools[convert] ``` -There is also a [cookiecutter template](https://github.com/FAIRmat-NFDI/pynxtools-plugin-template) available for creating your own pynxtools plugin. + diff --git a/TROUBLESHOOTING.md b/docs/tutorial/troubleshooting.md similarity index 82% rename from TROUBLESHOOTING.md rename to docs/tutorial/troubleshooting.md index 2d8490f7d..26f0e7b77 100644 --- a/TROUBLESHOOTING.md +++ b/docs/tutorial/troubleshooting.md @@ -1,8 +1,8 @@ # Troubleshooting Guide -### If you don't find a solution here, please make a new [Github Issue](https://github.com/FAIRmat-NFDI/pynxtools/issues/new?template=bug.yaml). +!!! info "Work in progress" -
+**If you don't find a solution here, please open a new [Github Issue](https://github.com/FAIRmat-NFDI/pynxtools/issues/new?template=bug.yaml).** ## Module import error @@ -18,7 +18,7 @@ If you are working in a directory containing the repo folder, `pynxtools`, renam ``` . -├── pynxtools2 # Renamed repo folder +├── pynxtools2 # Renamed repo folder │ ├── pynxtools # Actual module code is in here │ ├── tests │ └── ... diff --git a/mkdocs.yaml b/mkdocs.yaml index 7eaa9ebd9..0e47436bb 100644 --- a/mkdocs.yaml +++ b/mkdocs.yaml @@ -10,6 +10,7 @@ nav: - Tutorials: - tutorial/converting-data-to-nexus.md - tutorial/nexus-to-nomad.md + - tutorial/troubleshooting.md - How-tos: - how-tos/writing-an-appdef.md - how-tos/using-multiple-appdefs.md @@ -18,14 +19,19 @@ nav: - how-tos/transformations.md - how-tos/using-pynxtools-test-framework.md - Learn: - - learn/nexus-primer.md - - learn/nexus-rules.md - - learn/multiple-appdefs.md - - learn/multi-format-reader.md + - NeXus: + - learn/nexus-primer.md + - learn/nexus-rules.md + - learn/multiple-appdefs.md + - pynxtools: + - learn/dataconverter-and-readers.md + - learn/nexus-verification.md + - learn/multi-format-reader.md - Reference: + - reference/definitions.md - reference/cli-api.md + - reference/built-in-readers.md - reference/plugins.md - - reference/definitions.md plugins: - search diff --git a/src/pynxtools/dataconverter/README.md b/src/pynxtools/dataconverter/README.md index 5adf9e91c..c452fb472 100644 --- a/src/pynxtools/dataconverter/README.md +++ b/src/pynxtools/dataconverter/README.md @@ -1,54 +1,17 @@ # Dataconverter -This tool converts experimental data to NeXus/HDF5 files based on any provided [NXDL schemas](https://manual.nexusformat.org/nxdl.html#index-1). -It contains a set of [readers](readers/) to convert supported data files into a compliant NeXus file. +This tool converts experimental data to NeXus/HDF5 files based on any provided [NXDL schemas](https://manual.nexusformat.org/nxdl.html#index-1). It contains a set of [readers](readers/) to convert supported data files into a compliant NeXus file. -You can read specific README's of the readers and find usage examples [here](../../examples/). - -## Installation - -```console -user@box:~$ pip install pynxtools[convert] -``` +You can find usage examples [here](../../examples/). ## Usage +`pynxtools` has a number of command line tools that can be used to convert data and verify NeXus files. You can more information about the API [here](https://fairmat-nfdi.github.io/pynxtools/reference/cli-api.html). -### Commands -- **convert**: This is the top-level command that allows you to use the converter. It can be called directly with ```dataconverter```. -- **generate-template**: This command generates a reader template dictionary for a given NXDL file. It can be called with ```dataconverter generate-template```. - -```console -Usage: dataconverter [OPTIONS] COMMAND [ARGS]... - -Commands: - convert* This command allows you to use the converter... - generate-template Generates and prints a template to use for your nxdl. - -Info: - You can see more options by using --help for specific commands. For example: - dataconverter generate-template --help -``` -#### Merge partial NeXus files into one - -```console -user@box:~$ dataconverter --nxdl nxdl partial1.nxs partial2.nxs -``` - -#### Map an HDF5/JSON/(Python Dict pickled in a pickle file) - -```console -user@box:~$ dataconverter --nxdl nxdl any_data.hdf5 --mapping my_custom_map.mapping.json -``` - -You can find actual examples with data files at [`examples/json_map`](../../examples/json_map/). - - -#### Use with multiple input files - -```console -user@box:~$ dataconverter --nxdl nxdl metadata data.raw otherfile -``` - -## Writing a Reader +## Documentation +In order to understand the dataconverter, these pages might be particularly helpful: -In case you want to write your own reader for a certain type of experiment, you can find documentation [here](https://fairmat-nfdi.github.io/pynxtools/how-tos/build-a-plugin.html) +- [Learn : The dataconverter in pynxtools](https://fairmat-nfdi.github.io/pynxtools/learn/dataconverter-and-readers.html) +- [Tutorial: Converting research data to NeXus](https://fairmat-nfdi.github.io/pynxtools/tutorial/converting-data-to-nexus.html) +- [Built-in readers of pynxtools](https://fairmat-nfdi.github.io/pynxtools/reference/built-in-readers.html) +- [Existing reader plugins for different experimental techniques](https://fairmat-nfdi.github.io/pynxtools/reference/plugins.html) +- [How-to guide for writing your own reader/plugin](https://fairmat-nfdi.github.io/pynxtools/how-tos/build-a-plugin.html) \ No newline at end of file diff --git a/src/pynxtools/dataconverter/readers/README.md b/src/pynxtools/dataconverter/readers/README.md index 94c214d0c..9563d8982 100644 --- a/src/pynxtools/dataconverter/readers/README.md +++ b/src/pynxtools/dataconverter/readers/README.md @@ -1,45 +1,4 @@ -# File/Metadata and Data Format Reader Plug-ins aka `reader` +# Built-in readers -The purpose of the dataconverter is to create NeXus/HDF5 files with content that -matches a specific NeXus application definition. -Such application definitions are useful for collecting a set of pieces of information -about a specific experiment in a given scientific field. The pieces of information -are metadata and numerical data. The application definition is used to provide -these data in a format that serves a data delivery contract: The HDF5 file, -or so-called NeXus file, delivers all those pieces of information which the -application definition specifies. Required and optional pieces of information are -distinguished. NeXus classes can recommend the inclusion of certain pieces of information. -Recommended data are essentially optional. The idea is that flagging these data as -recommended motivates users to collect them but does not require to write dummy -or nonsense data if the user is unable to collect recommended data. - -The here developed and so-called readers, are effectively software tools (plug-ins) -which the converter calls to accomplish this task for a specific set of application -definition (NXDL XML file) plus a set of experiment/method-specific file(s). -These files can be files in a proprietary format, or of a certain format used in the -respective scientific community, or text files. Only in combination, these files hold -all the required pieces of information which the application definition demands and which -are thus required to make a NeXus/HDF5 file compliant. Users can store additional -pieces of information in an NeXus/HDF5 file. In this case readers will issue a warning -that these data are not properly documented from the perspective of NeXus. - -## Getting started - -The readers get cloned as plug-in dependencies while cloning the dataconverter. -Therefore, please follow the instructions for cloning the reader as a complete package. - -## Download the example data for testing and development purposes - -Before using your own data we strongly encourage you to download a set of open-source -test data for testing the plug-ins. For this purpose pynxtools comes with -a tests directory with a data/dataconverter sub-directory including reader-specific jupyter-notebook -examples. These examples can be used for downloading test data and use specific readers -as a standalone converter to translate given data into a NeXus/HDF5 file. - -Once you have practised with these tools how to convert these examples, feel free to -use the tools for converting your own data. You should feel invited to contact the respective -corresponding author(s) of each reader if you run into issues with the reader or feel there -is a necessity to include additional data into the NeXus file for the respective application. - -We are looking forward for learning from your experience and see the interesting use cases. -You can find the contact persons in the respective README.md of each reader. +## Documentation +Documentation for the built-in readers of pynxtools can be found [here](https://fairmat-nfdi.github.io/pynxtools/reference/built-in-readers.html). \ No newline at end of file diff --git a/src/pynxtools/dataconverter/readers/base/README.md b/src/pynxtools/dataconverter/readers/base/README.md index eb3bf3404..413645a60 100644 --- a/src/pynxtools/dataconverter/readers/base/README.md +++ b/src/pynxtools/dataconverter/readers/base/README.md @@ -1,4 +1,7 @@ -# base reader +# The BaseReader + +## Documentation +Documentation for this reader can be found [here](https://fairmat-nfdi.github.io/pynxtools/reference/built-in-readers.html#the-basereader). ## Contact person in FAIRmat for this reader Sherjeel Shabih \ No newline at end of file diff --git a/src/pynxtools/dataconverter/readers/json_map/README.md b/src/pynxtools/dataconverter/readers/json_map/README.md index 85fde4834..b2129d15e 100644 --- a/src/pynxtools/dataconverter/readers/json_map/README.md +++ b/src/pynxtools/dataconverter/readers/json_map/README.md @@ -1,63 +1,9 @@ # JSON Map Reader -## What is this reader? +This reader is designed to allow users of pynxtools to convert their existing data with the help of a map file. The map file tells the reader what to pick from your data files and convert them to FAIR NeXus files. -This reader is designed to allow users of pynxtools to convert their existing data with the help of a map file. The map file tells the reader what to pick from your data files and convert them to FAIR NeXus files. The following formats are supported as input files: -* HDF5 (any extension works i.e. h5, hdf5, nxs, etc) -* JSON -* Python Dict Objects Pickled with [pickle](https://docs.python.org/3/library/pickle.html). These can contain [xarray.DataArray](https://docs.xarray.dev/en/stable/generated/xarray.DataArray.html) objects as well as regular Python types and Numpy types. - -It accepts any NXDL file that you like as long as your mapping file contains all the fields. -Please use the --generate-template function of the dataconverter to create a .mapping.json file. - -```console -user@box:~$ dataconverter --nxdl NXmynxdl --generate-template > mynxdl.mapping.json -``` - -There are some example files you can use: - -[data.mapping.json](/tests/data/dataconverter/readers/json_map/data.mapping.json) - -[data.json](/tests/data/dataconverter/readers/json_map/data.json) - -```console -user@box:~$ dataconverter --nxdl NXtest data.json --mapping data.mapping.json -``` - -##### [Example](/examples/json_map/) with HDF5 files. - -## The mapping.json file - -This file is designed to let you fill in the requirements of a NeXus Application Definition without writing any code. If you already have data in the formats listed above, you just need to use this mapping file to help the dataconverter pick your data correctly. - -The mapping files will always be based on the Template the dataconverter generates. See above on how to generate a mapping file. -The right hand side values of the Template keys are what you can modify. - -Here are the three different ways you can fill the right hand side of the Template keys: -* Write the nested path in your datafile. This is indicated by a leading `/` before the word `entry` to make `/entry/data/current_295C` below. -Example: - -```json - "/ENTRY[entry]/DATA[data]/current_295C": "/entry/data/current_295C", - "/ENTRY[entry]/NXODD_name/posint_value": "/a_level_down/another_level_down/posint_value", -``` - -* Write the values directly in the mapping file for missing data from your data file. - -```json - - "/ENTRY[entry]/PROCESS[process]/program": "Bluesky", - "/ENTRY[entry]/PROCESS[process]/program/@version": "1.6.7" -``` - -* Write JSON objects with a link key. This follows the same link mechanism that the dataconverter implements. In the context of this reader, you can only use external links to your data files. In the example below, `current.nxs` is an already existing HDF5 file that we link to in our new NeXus file without copying over the data. The format is as follows: -`"link": ":"` -Note: This only works for HDF5 files currently. - -```json - "/ENTRY[entry]/DATA[data]/current_295C": {"link": "current.nxs:/entry/data/current_295C"}, - "/ENTRY[entry]/DATA[data]/current_300C": {"link": "current.nxs:/entry/data/current_300C"}, -``` +## Documentation +Documentation for this reader can be found [here](https://fairmat-nfdi.github.io/pynxtools/reference/built-in-readers.html#the-jsonmapreader). ## Contact person in FAIRmat for this reader -Sherjeel Shabih +Sherjeel Shabih \ No newline at end of file diff --git a/src/pynxtools/dataconverter/readers/json_yml/README.md b/src/pynxtools/dataconverter/readers/json_yml/README.md index eb6ed4eef..ff59713b3 100644 --- a/src/pynxtools/dataconverter/readers/json_yml/README.md +++ b/src/pynxtools/dataconverter/readers/json_yml/README.md @@ -1,4 +1,7 @@ # JSON YAML reader +## Documentation +Documentation for this reader can be found [here](https://fairmat-nfdi.github.io/pynxtools/reference/built-in-readers.html#the-jsonmapreader). + ## Contact person in FAIRmat for this reader Sherjeel Shabih \ No newline at end of file diff --git a/src/pynxtools/dataconverter/readers/multi/README.md b/src/pynxtools/dataconverter/readers/multi/README.md new file mode 100644 index 000000000..84de26995 --- /dev/null +++ b/src/pynxtools/dataconverter/readers/multi/README.md @@ -0,0 +1,9 @@ +# Multi Format Reader + +This reader is designed to simplify the process of writing a new reader that takes in multiple file formats and then populates the NeXus file based on the read data, in compliance with a NeXus application definition. + +## Documentation +Documentation for this reader can be found [here](https://fairmat-nfdi.github.io/pynxtools/reference/built-in-readers.html#the-multiformatreader). + +## Contact person in FAIRmat for this reader +Lukas Pielsticker \ No newline at end of file From 16974585a9926e88d1d593a7696546d92d9a9b21 Mon Sep 17 00:00:00 2001 From: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> Date: Mon, 26 Aug 2024 17:00:21 +0200 Subject: [PATCH 2/6] add docs for read-nexus and generate-eln --- docs/learn/nexus-verification.md | 2 +- src/pynxtools/eln_mapper/README.md | 20 ++---------- src/pynxtools/nexus/README.md | 51 +++--------------------------- 3 files changed, 7 insertions(+), 66 deletions(-) diff --git a/docs/learn/nexus-verification.md b/docs/learn/nexus-verification.md index 9c8c8488c..f266064d7 100644 --- a/docs/learn/nexus-verification.md +++ b/docs/learn/nexus-verification.md @@ -11,7 +11,7 @@ This CLI tool can be used to verify _existing_ HDF5 files that claim to be NeXus ## read-nexus: 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 and application definitions to which the file refers to. See [here](reference/cli-api.html#verify-nexus) for the API documentation. +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. See [here](reference/cli-api.html#read-nexus) for the API documentation. The following example dataset can be used to test the `read_nexus` module: [src/pynxtools/data/201805_WSe2_arpes.nxs](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/data/201805_WSe2_arpes.nxs). diff --git a/src/pynxtools/eln_mapper/README.md b/src/pynxtools/eln_mapper/README.md index e5f9cefee..99b3b4369 100644 --- a/src/pynxtools/eln_mapper/README.md +++ b/src/pynxtools/eln_mapper/README.md @@ -4,21 +4,5 @@ Two types of ELN are supported (by passing the flag `eln-type`): - **eln**: The simple ELN generator that can be used in a console or jupyter-notebook. - **scheme_eln**: Scheme based ELN generator that can be used in NOMAD and the ELN can be used as a custom scheme in NOMAD. -``` -user@box:~$ generate_eln --help -Usage: generate_eln [OPTIONS] - - Helper tool for generating ELN files in YAML format. - -Options: - --nxdl TEXT Name of NeXus definition without extension - (.nxdl.xml). [required] - --skip-top-levels INTEGER To skip the level of parent hierarchy level. - E.g. for default 1 the part Entry[ENTRY] from - /Entry[ENTRY]/Instrument[INSTRUMENT]/... will - be skiped. [default: 1] - --output-file TEXT Name of file that is neede to generated output - file. - --eln-type [eln|scheme_eln] Choose a type of ELN output (eln or - scheme_eln). [required] - --help Show this message and exit. + Here you can find more information about the tool: + - [API documentation](https://fairmat-nfdi.github.io/pynxtools/reference/cli-api.html#generate_eln) \ No newline at end of file diff --git a/src/pynxtools/nexus/README.md b/src/pynxtools/nexus/README.md index ef4da39f3..da6c76a43 100644 --- a/src/pynxtools/nexus/README.md +++ b/src/pynxtools/nexus/README.md @@ -1,50 +1,7 @@ # 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 -and application definitions to which the file refers to. +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. -```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: `src/pynxtools/data/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._ - -An environmental variable can be set as follows: - -``` -export 'NEXUS_DEF_PATH'= -``` - -## 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 + Here you can find more information about the tool: + - [Usage guide](https://fairmat-nfdi.github.io/pynxtools/learn/nexus-verification.html##read-nexus-nexus-file-reader-and-debugger) + - [API documentation](https://fairmat-nfdi.github.io/pynxtools/reference/cli-api.html#read-nexus) \ No newline at end of file From cf9691b3455c216348b0d283e4c4fc45ba5618ec Mon Sep 17 00:00:00 2001 From: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> Date: Mon, 26 Aug 2024 17:30:53 +0200 Subject: [PATCH 3/6] change site description --- mkdocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yaml b/mkdocs.yaml index 0e47436bb..0af3a3556 100644 --- a/mkdocs.yaml +++ b/mkdocs.yaml @@ -1,6 +1,6 @@ site_name: Documentation site_description: | - The documentation the FAIRmat flavor of the NeXus definitions & pynxtools + The documentation of the FAIRmat-NeXus definitions & pynxtools site_author: The NOMAD authors repo_url: https://github.com/FAIRmat-NFDI/pynxtools edit_uri: "" From b1f8fdc1b48083604411a98948144234e177a66e Mon Sep 17 00:00:00 2001 From: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> Date: Tue, 27 Aug 2024 17:07:52 +0200 Subject: [PATCH 4/6] review comments --- README.md | 27 +++++++------- docs/index.md | 17 +++++---- docs/learn/dataconverter-and-readers.md | 35 +++++++++---------- docs/learn/nexus-rules.md | 2 +- ...us-verification.md => nexus-validation.md} | 23 ++++++------ docs/reference/built-in-readers.md | 20 +++++------ docs/reference/cli-api.md | 2 +- mkdocs.yaml | 3 +- src/pynxtools/definitions | 2 +- 9 files changed, 64 insertions(+), 67 deletions(-) rename docs/learn/{nexus-verification.md => nexus-validation.md} (62%) diff --git a/README.md b/README.md index c51afb850..8fc383298 100644 --- a/README.md +++ b/README.md @@ -12,16 +12,14 @@ It allows to develop ontologies and to create ontological instances based on the # Scope -`pynxtools` (previously called `nexusutils`) is intended as a parser for combining various instrument output formats and electronic lab notebook (ELN) formats to an hdf5 file according to NeXus application definitions. +`pynxtools` is a parser for combining various instrument output formats and electronic lab notebook (ELN) formats into an [HDF5](https://support.hdfgroup.org/HDF5/) file according to NeXus application definitions. Additionally, the software can be used as a plugin in the research data management system NOMAD for -making experimental data searchable and publishable. -NOMAD is developed by the FAIRMAT consortium, as a part of the German National Research Data Infrastructure -(NFDI). +making experimental data searchable and publishable. NOMAD is developed by the FAIRmat consortium which is a consortium of the German National Research Data Infrastructure (NFDI). # Installation -It is recommended to use python 3.10 with a dedicated virtual environment for this package. +It is recommended to use python 3.11 with a dedicated virtual environment for this package. Learn how to manage [python versions](https://github.com/pyenv/pyenv) and [virtual environments](https://realpython.com/python-virtual-environments-a-primer/). @@ -42,19 +40,20 @@ Documentation can be found [here](https://fairmat-nfdi.github.io/pynxtools/). # Repository structure -The software tools are located inside [`src/pynxtools`](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/src/pynxtools) and they are shipped with unit tests located in [`tests`](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/tests). -Some examples with real datasets are provided in [`examples`](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/examples). They guide you through the process of converting instrument raw data into the NeXus standard and visualising the files' content. +The software tools are located inside [`src/pynxtools`](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/src/pynxtools). They are shipped with unit tests located in [`tests`](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/tests). +Some examples from the scientific community are provided in [`examples`](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/examples). They guide you through the process of converting instrument data into the NeXus standard and visualising the files' content. # NOMAD integration -To use pynxtools with NOMAD, simply install it in the same environment as the `nomad-lab` package. -NOMAD will recognize pynxtools as a plugin automatically and offer automatic parsing of `.nxs` files -and a schema for NeXus application definitions. -pynxtools is already included in the NOMAD main deployment and NOMAD NeXus distribution images. +## Does this software require NOMAD or NOMAD OASIS ? + +No. The data files produced here can be uploaded to NOMAD. Therefore, this tool acts as the framework to design schemas and instances of data within the NeXus universe. It can, however, be used as a NOMAD plugin to parse nexus files, please see the section below for details. -### Does this software require NOMAD or NOMAD OASIS ? +## How to use pynxtools with NOMAD -No. The data files produced here can be uploaded to NOMAD. Therefore, this acts like the framework to design schemas and instances of data within the NeXus universe. It can, however, be used as a NOMAD plugin to parse nexus files, please see the section above for details. +To use pynxtools with NOMAD, simply install it in the same environment as the `nomad-lab` package. +NOMAD will recognize pynxtools as a plugin automatically and offer automatic parsing of `.nxs` files. In addition, NOMAD will install a schema for NeXus application definitions. +By default, `pynxtools` is already included in the NOMAD [production]https://nomad-lab.eu/prod/v1/gui/ and [staging](https://nomad-lab.eu/prod/v1/staging/gui/) deployments. # Contributing @@ -94,7 +93,7 @@ python -m pytest -sv tests ## Run examples A number of examples exist which document how the tools can be used. For a standalone -usage convenient jupyter notebooks are available for each tool. To use them, jupyter +usage convenient jupyter notebooks are available for each tool. To use these notebooks, jupyter and related tools have to be installed in the development environment as follows: ```shell diff --git a/docs/index.md b/docs/index.md index 5ff4d8675..449fc278d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -5,16 +5,16 @@ hide: toc # FAIRmat NeXus documentation -Within [FAIRMat](https://www.fairmat-nfdi.eu/fairmat/), we are extending the [NeXus data format standard](https://www.nexusformat.org/) to support the FAIR data principles for experimental data in materials science and and phyics. This is the documentation for both our contribution to the NeXus standard as well as for our tools for data conversion and verification. +Within [FAIRmat](https://www.fairmat-nfdi.eu/fairmat/), we are extending the [NeXus data format standard](https://www.nexusformat.org/) to support the FAIR data principles for experimental data in materials science (covering solid-state physics and the chemical physics of solids, as well as materials engineering). This is the documentation for both our contribution to the NeXus standard and for our tools for data conversion and verification. -`pynxtools`, which is the main tool under development, provides a dataconverter that maps from experimental data to the NeXus format as well as tools to verify NeXus files. It is intended as a parser for combining various instrument output formats and electronic lab notebook (ELN) formats to an HDF5 file according to NeXus application definitions. +`pynxtools`, the main tool under development, provides a data converter that maps experimental data and metadata to the NeXus format, performing parsing, normalization, visualization, and ontology matching. It combines various instrument output formats and electronic lab notebook (ELN) formats to an HDF5 file according to NeXus application definitions. In addition, `pynxtools` can be used to validate and verify NeXus files. -`pynxtools` offers scientists a convenient way to use the NeXus format and solves the challenge of unstructured and non-standardized data in experimental materials science. +`pynxtools` offers scientists a convenient way to use the NeXus format and solves the challenge of unstructured and non-standardized data in experimental materials science. We consider this package useful for meeting the following FAIR principle as defined in [FAIR Principles: Interpretations and Implementation Considerations](https://direct.mit.edu/dint/article/2/1-2/10/10017/FAIR-Principles-Interpretations-and-Implementation): F2-4, I2-I3, and R1. -The new contribution to the standard, together with the tools provided through `pynxtools`, enable scientists and research groups working with data, as well as helping communities implement standardized FAIR research data. +FAIRmat's contribution to the existing NeXus standard, together with the tools provided through `pynxtools`, enable scientists and research groups working with data, as well as helping communities implement standardized FAIR research data. Additionally, the software is used as a plugin in the research data management system [NOMAD](https://nomad-lab.eu/nomad-lab/) for making experimental data searchable and publishable. NOMAD is developed by the FAIRMAT consortium, as a part of the German National Research Data Infrastructure (NFDI). @@ -58,7 +58,7 @@ How-to guides provide step-by-step instructions for a wide range of tasks. #### pynxtools - [Data conversion in `pynxtools`](learn/dataconverter-and-readers.md) -- [NeXus verification in `pynxtools`](learn/nexus-verification.md) +- [Validation of NeXus files](learn/nexus-validation.md) - [The MultiFormatReader as a reader superclass](learn/multi-format-reader.md) @@ -74,13 +74,12 @@ Or go directly to the [official NIAC](https://manual.nexusformat.org/classes/ind #### pynxtools -`pynxtools` has a number of command line tools that can be used to convert data and verify NeXus files. You can more information about the -API [here](reference/cli-api.md). +`pynxtools` has a number of command line tools that can be used to convert data and verify NeXus files. You can find more information about the API [here](reference/cli-api.md). -Within FAIRmat, we maintain a number of pynxtools readers as well as reader plugins for different experimental techniques. Here you can find more information: +Within FAIRmat, we maintain a number of generic built-in pynxtools readers, together with reader plugins for different experimental techniques. Here you can find more information: - [Built-in pynxtools readers](reference/built-in-readers.md) -- [FAIRMat-suppored pynxtools plugins](reference/plugins.md) +- [FAIRMat-supported pynxtools plugins](reference/plugins.md) diff --git a/docs/learn/dataconverter-and-readers.md b/docs/learn/dataconverter-and-readers.md index 234edb68f..5460d9cd3 100644 --- a/docs/learn/dataconverter-and-readers.md +++ b/docs/learn/dataconverter-and-readers.md @@ -1,15 +1,15 @@ # Data conversion in pynxtools -One of the main motivations for pynxtools is to develop a tool for combining various instrument output formats and electronic lab notebook (ELN) into an [HDF5](https://support.hdfgroup.org/HDF5/) file according to [NeXus application definitions](https://fairmat-nfdi.github.io/nexus_definitions/classes/index.html). +One of the main motivations for pynxtools is to develop a tool for combining various instrument output formats and electronic lab notebook (ELN) into a file according to [NeXus application definitions](https://fairmat-nfdi.github.io/nexus_definitions/classes/index.html). -The `dataconverter` API in pynxtools provides exactly that: it converts experimental data to NeXus/HDF5 files based on any provided [NXDL schemas](https://manual.nexusformat.org/nxdl.html#index-1). +The `dataconverter` API in pynxtools provides exactly that: it converts experimental as well as simulation data, together with the results from analysis of such data, to NeXus files based on any provided [NXDL schemas](https://manual.nexusformat.org/nxdl.html#index-1). Here, we are using [HDF5](https://support.hdfgroup.org/HDF5/) as the serialization format. -The dataconverter has essentially three functionalities: +The dataconverter currently has essentially three functionalities: -1. read in experimental data using ```readers``` -2. validate the data and metadata against any of the NeXus application definitions -3. write a valid NeXus/HDF5 file +1. Read in experimental data using ```readers``` +2. Validate the data and metadata against a NeXus application definition of choice (i.e., check that the output data matches all existence, shape, and format constraints of application definition) +3. Write a valid NeXus/HDF5 file -For step 1, a set of readers has been which the converter calls to accomplish this task for a specific set of application definition (NXDL XML file) plus a set of experiment/method-specific file(s). These files can be files in a proprietary format, or of a certain format used in the respective scientific community, or text files. Only in combination, these files hold all the required pieces of information which the application definition demands and which are thus required to make a NeXus/HDF5 file compliant. Users can store additional pieces of information in an NeXus/HDF5 file. In this case readers will issue a warning that these data are not properly documented from the perspective of NeXus. +A set of readers has been developed which the converter calls to read in a set of experiment/method-specific file(s) and for a specific set of application definitions (NXDL XML file). These data files can be in a proprietary format, or of a certain format used in the respective scientific community, or text files. Only in combination, these files hold all the required pieces of information which the application definition demands and which are thus required to make a NeXus/HDF5 file compliant. Users can store additional pieces of information in an NeXus/HDF5 file. In this case readers will issue a warning that these data are not properly documented from the perspective of NeXus. There exists two different subsets of readers: @@ -18,12 +18,11 @@ There exists two different subsets of readers: ## Matching to NeXus application definitions -The purpose of the dataconverter is to create NeXus/HDF5 files with content that matches a specific NeXus application definition. Such application definitions are useful for collecting a set of pieces of information about a specific experiment in a given scientific field. The pieces of information are metadata and numerical data. The application definition is used to provide these data in a format that serves a data delivery contract: The HDF5 file, or so-called NeXus file, delivers all those pieces of information which the application definition specifies. Required and optional pieces of information are distinguished. NeXus classes can recommend the inclusion of certain pieces of information. Recommended data are essentially optional. The idea is that flagging these data as recommended motivates users to collect them but does not require to write dummy -or nonsense data if the user is unable to collect recommended data. +The purpose of the dataconverter is to create NeXus/HDF5 files with content that matches a specific NeXus application definition. Such application definitions are useful for collecting a set of pieces of information about a specific experiment in a given scientific field. The pieces of information are numerical and categorical (meta)data. The application definition is used to provide these data in a format that serves a data delivery contract: The HDF5 file, or so-called NeXus file, delivers all those pieces of information which the application definition specifies. Required and optional pieces of information are distinguished. NeXus classes can recommend the inclusion of certain pieces of information. Recommended data are essentially optional. The idea is that flagging these data as recommended motivates users to collect these, but does not require to write dummy or nonsense data if the recommended data is not available. ## Getting started -Each of the built-in reader comes with the main `pynxtools` package, therefore they are avaible after pip installation: +Each of the built-in readers comes with the main `pynxtools` package. Hence, they can be used after after pip installation: ```console user@box:~$ pip install pynxtools ``` @@ -39,13 +38,15 @@ In addition, it is also possible to install all of the pynxtools reader plugins pip install pynxtools[convert] ``` +Note that in this case, the latest version of the plugin from PyPI is installed. + ## Usage See [here](../reference/cli-api.md#data-conversion) for the documentation of the `dataconverter` API. ### Use with multiple input files ```console -user@box:~$ dataconverter --nxdl nxdl metadata data.raw otherfile +user@box:~$ dataconverter metadata data.raw otherfile --nxdl nxdl --reader ``` ### Merge partial NeXus files into one @@ -54,7 +55,7 @@ user@box:~$ dataconverter --nxdl nxdl metadata data.raw otherfile user@box:~$ dataconverter --nxdl nxdl partial1.nxs partial2.nxs ``` -### Map an HDF5/JSON/(Python Dict pickled in a pickle file) +### Map an HDF5 file/JSON file ```console user@box:~$ dataconverter --nxdl nxdl any_data.hdf5 --mapping my_custom_map.mapping.json @@ -65,11 +66,9 @@ You can find actual examples with data files at [`examples/json_map`](https://gi ## Example data for testing and development purposes -Before using your own data we strongly encourage you to download a set of open-source test data for testing the plug-ins. For this purpose pynxtools comes with a tests directory with a data/dataconverter sub-directory including reader-specific jupyter-notebook examples. These examples can be used for downloading test data and use specific readers as a standalone converter to translate given data into a NeXus/HDF5 file. - -Once you have practised with these tools how to convert these examples, feel free to use the tools for converting your own data. You should feel invited to contact the respective corresponding author(s) of each reader if you run into issues with the reader or feel there is a necessity to include additional data into the NeXus file for the respective application. +Before using your own data we strongly encourage you to download a set of open-source test data for testing the pynxtools readers andreader plugins. For this purpose, pynxtools and its plugins come +with `examples` and `test` directories including reader-specific examples. These examples can be used for downloading test data and use specific readers as a standalone converter to translate given data into a NeXus/HDF5 file. -We are looking forward for learning from your experience and see the interesting use cases. -You can find the contact persons in the respective README.md of each reader. +Once you have practized with these tools how to convert these examples, feel free to use the tools for converting your own data. You should feel invited to contact the respective corresponding author(s) of each reader if you run into issues with the reader or feel there is a necessity to include additional data into the NeXus file for your respective application. -You can read specific README's of the readers and find usage examples [here](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/examples/). \ No newline at end of file +We are looking forward to learning from your experience and learn from your use cases. You can find the contact persons in the respective README.md of each reader (plugin). \ No newline at end of file diff --git a/docs/learn/nexus-rules.md b/docs/learn/nexus-rules.md index aa4a0133b..c66c63d45 100644 --- a/docs/learn/nexus-rules.md +++ b/docs/learn/nexus-rules.md @@ -1,6 +1,6 @@ # Rules for storing data in NeXus -There are several rules which apply for storing single data items in NeXus. There exists a [summary](https://manual.nexusformat.org/datarules.html) in the NeXus documentation outlining most of these rules. However, this explanation is not exhaustive and thus, we have compiled here additional information. +There are several rules which apply for storing single data items in NeXus. There exists a [summary](https://manual.nexusformat.org/datarules.html) in the NeXus documentation outlining most of these rules. However, to guide data providers even further, we have compiled here additional information and explanations. ## Namefitting diff --git a/docs/learn/nexus-verification.md b/docs/learn/nexus-validation.md similarity index 62% rename from docs/learn/nexus-verification.md rename to docs/learn/nexus-validation.md index f266064d7..21f0f19e6 100644 --- a/docs/learn/nexus-verification.md +++ b/docs/learn/nexus-validation.md @@ -1,30 +1,27 @@ -# NeXus verification +# NeXus validation !!! info "Work in progress" -One of the main advantages of using pynxtools is that it comes with its own verification. That is, it can be used to verify that a given NeXus/HDF5 file is compliant with a NeXus application definition. +One of the main advantages of using pynxtools is that it comes with its own validation tools. That is, it can be used to validate that a given NeXus/HDF5 file is compliant with a NeXus application definition. ## As part of the dataconverter During [data conversion](./dataconverter-and-readers.md), before writing the HDF5 file, the data is first checked against the provided application definition. +This CLI tool can be used to validate _existing_ HDF5 files that claim to be NeXus-compliant. See [here](reference/cli-api.html#verify-nexus) for the API documentation.--> -## read-nexus: NeXus file reader and debugger +## read_nexus: 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 and application definitions to which the file refers to. See [here](reference/cli-api.html#read-nexus) for the API documentation. +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. See [here](../reference/cli-api.html#read_nexus) for the API documentation. The following example dataset can be used to test the `read_nexus` module: [src/pynxtools/data/201805_WSe2_arpes.nxs](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/data/201805_WSe2_arpes.nxs). -This is an angular-resolved photoelectron spectroscopy (ARPES) dataset and it is formatted according to +This is an angular-resolved photoelectron spectroscopy (ARPES) dataset that 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._ - -An environmental variable can be set as follows: +The environment variable "NEXUS_DEF_PATH" can be set to a directory which contains the NeXus definitions as NXDL XML files. If this environment variable is not defined, the module will use the definitions in its bundle (see `src/pynxtools/definitions`)._ +The environment variable can be set as follows: ``` export 'NEXUS_DEF_PATH'= ``` @@ -38,8 +35,10 @@ 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 ``` +This workaround was tested with Windows 11, but should very likely also work with Windows 10 and lower. + ## Other approaches (not part of pynxtools) -Aside from the tools we developed within FAIRmat, the [official NeXus website](https://manual.nexusformat.org/validation.htm) listed two more programs for the verification and validation of NeXus files: +Aside from the tools we developed within FAIRmat, the [official NeXus website](https://manual.nexusformat.org/validation.htm) listed two more programs for the validation of NeXus files: 1. nxvalidate 2. punx \ No newline at end of file diff --git a/docs/reference/built-in-readers.md b/docs/reference/built-in-readers.md index ba9ab7ab2..1bf4a70b3 100644 --- a/docs/reference/built-in-readers.md +++ b/docs/reference/built-in-readers.md @@ -2,18 +2,18 @@ There exists a number of [readers](https://github.com/FAIRmat-NFDI/pynxtools/tree/master/src/pynxtools/dataconverter/readers) directly in pynxtools. These are typically used either as superclasses for new reader implementations or for generic reading purposes not directly related to any specific technique. ## The [BaseReader](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/dataconverter/readers/base/reader.py) -This is the most simple reader, which is an abstract base class, on top of which a new reader implementation can build. It has an essentially empty read function and is thus only helpful for implementing the correct input/ouput design of the ```read``` function of any reader which is implemented off of it. +This is the most simple reader, which is an abstract base class, on top of which a new reader implementation can build. It has an essentially empty read function and is thus only helpful for implementing the correct input/ouput design of the ```read``` function of any reader that is inheriting from this base reader. ## The [MultiFormatReader](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/dataconverter/readers/multi/reader.py) -Aside from the `BaseReader`, there exists another reader which can act as the basis for any reader implementation, the `MultiFormatReader`, which can be used to implement a reader that can read in multiple file formats and then populate the template based on the read data. Note that this reader has a lot of already built-in functionality, which is extensively described [here](../learn/multi-format-reader.md). There is also a [how-to guide](../how-tos/use-multi-format-reader.md) on how to implement a new reader off of the `MultiFormatReader` using a concrete example. +Another reader that can act as the basis for any reader implementation is the `MultiFormatReader`, which can be used to implement a reader that can read in multiple file formats and then populate the NeXus file using the read data. Note that this reader has a lot of already built-in functionality, which is extensively described [here](../learn/multi-format-reader.md). There is also a [how-to guide](../how-tos/use-multi-format-reader.md) on how to implement a new reader off of the `MultiFormatReader` using a concrete example. ## The [JsonMapReader](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/dataconverter/readers/json_map/reader.py) -This reader is designed to allow users of `pynxtools` to convert their existing data with the help of a map file. The map file tells the reader what to pick from your data files and convert them to FAIR NeXus files. The following formats are supported as input files: +This reader is designed to allow users of `pynxtools` to convert their existing data with the help of a map file. The map file tells the reader which concept and instance data to pick from the data files and how to convert these to NeXus files. The following formats are supported as input files: -* HDF5 (any extension works i.e. h5, hdf5, nxs, etc) +* HDF5 * JSON -* Python Dict Objects pickled with [pickle](https://docs.python.org/3/library/pickle.html). These can contain [xarray.DataArray](https://docs.xarray.dev/en/stable/generated/xarray.DataArray.html) objects as well as regular Python types and Numpy types. +* Python Dict Objects pickled with [pickle](https://docs.python.org/3/library/pickle.html). These can contain [xarray.DataArray](https://docs.xarray.dev/en/stable/generated/xarray.DataArray.html) objects as well as regular Python types and Numpy types. Note that while it is supported, we strongly recommend note to use pickle due to its known [security concerns](https://huggingface.co/docs/hub/security-pickle). -It accepts any NXDL file that you like as long as your mapping file contains all the fields. +It accepts any XML file that follows the NXDL schema definition language file as long as your mapping file contains all the required fields. Please use the `--generate-template` function of the `dataconverter` to create a `.mapping.json` file: ```console @@ -24,10 +24,9 @@ user@box:~$ dataconverter --nxdl NXmynxdl --generate-template > mynxdl.mapping.j This file is designed to let you fill in the requirements of a NeXus Application Definition without writing any code. If you already have data in the formats listed above, you just need to use this mapping file to help the dataconverter pick your data correctly. -The mapping files will always be based on the Template the dataconverter generates. See above on how to generate a mapping file. -The right hand side values of the Template keys are what you can modify. +The mapping files will always be based on the template the dataconverter generates. See above on how to generate a mapping file. The right hand side values of the template keys are what you can modify. These keys are called NeXus template paths, because they combine the actual path that will be used in the HDF5 hierarchy with additional NeXus datatype hints to guide the dataconverter to add NX_class annotations. -Here are the three different ways you can fill the right hand side of the Template keys: +Here are the three different ways you can fill the right hand side of the template keys: * Write the nested path in your datafile. This is indicated by a leading `/` before the word `entry` to make `/entry/data/current_295C` below. Example: @@ -35,6 +34,7 @@ Example: "/ENTRY[entry]/DATA[data]/current_295C": "/entry/data/current_295C", "/ENTRY[entry]/NXODD_name/posint_value": "/a_level_down/another_level_down/posint_value", ``` +Here, `"/entry/data/current_295C"` is the path in the original HDF5 file, while the key shown here is the template path (see above). * Write the values directly in the mapping file for missing data from your data file. @@ -82,7 +82,7 @@ user@box:~$ dataconverter --nxdl nxdl any_data.hdf5 --mapping my_custom_map.mapp ## Installation -Each of the built-in reader comes with the main `pynxtools` package, therefore they are avaible after pip installation: +Each of the built-in readers are shipped/installed with the main `pynxtools` package. Hence, these readers are available after pip installation: ```console user@box:~$ pip install pynxtools ``` \ No newline at end of file diff --git a/docs/reference/cli-api.md b/docs/reference/cli-api.md index 83775e7b1..dbd561e0b 100644 --- a/docs/reference/cli-api.md +++ b/docs/reference/cli-api.md @@ -13,7 +13,7 @@ Note that simply calling `dataconverter` defaults to `dataconverter convert`. :style: table :list_subcommands: True -## NeXus file verification +## NeXus file validation +This CLI tool can be used to validate _existing_ HDF5 files that claim to be NeXus-compliant. See [here](reference/cli-api.md#verify-nexus) for the API documentation.--> ## read_nexus: 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 and application definitions to which the file refers to. See [here](../reference/cli-api.html#read_nexus) for the API documentation. +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. See [here](../reference/cli-api.md#read_nexus) for the API documentation. The following example dataset can be used to test the `read_nexus` module: [src/pynxtools/data/201805_WSe2_arpes.nxs](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/src/pynxtools/data/201805_WSe2_arpes.nxs). diff --git a/docs/reference/definitions.md b/docs/reference/definitions.md index 0e47943c4..ca04b9650 100644 --- a/docs/reference/definitions.md +++ b/docs/reference/definitions.md @@ -10,3 +10,7 @@ The FAIRmat definitions are regularly contributed to NIAC (around every 6 months a state which is still under development and may contain new or improved application definitions or base classes. Consider it as the public review stage of these application definitions. However, there might be some parts which are still under discussion and will be subject to change. + +Note: To connect NeXus concepts with semantic web tools, efforts are underway to represent them using the [W3C Web Ontology Language (OWL)](https://www.w3.org/OWL/). See the [NeXusOntology](https://github.com/FAIRmat-NFDI/NeXusOntology) for more details. + + diff --git a/docs/tutorial/troubleshooting.md b/docs/tutorial/troubleshooting.md deleted file mode 100644 index 26f0e7b77..000000000 --- a/docs/tutorial/troubleshooting.md +++ /dev/null @@ -1,38 +0,0 @@ -# Troubleshooting Guide - -!!! info "Work in progress" - -**If you don't find a solution here, please open a new [Github Issue](https://github.com/FAIRmat-NFDI/pynxtools/issues/new?template=bug.yaml).** - -## Module import error - -```python -ImportError: cannot import name 'get_nexus_version' from 'pynxtools' (unknown location) -``` - -This is, unfortunately, expected behavior. The Python import mechanism will first look for a folder with the package name in the current working directory. If it finds a folder named `pynxtools`, it will try to import from there. In this case we have the cloned repo folder with the same name, `pynxtools`. Python tries to import from this folder but the code resides in `pynxtools/pynxtools`. - -### Solution - -If you are working in a directory containing the repo folder, `pynxtools`, rename this repo folder to `pynxtools2` so your current directory looks like this: - -``` -. -├── pynxtools2 # Renamed repo folder -│ ├── pynxtools # Actual module code is in here -│ ├── tests -│ └── ... -└── my_code_imports_pynxtools.py -``` - -Then **reinstall the package** and your import will work. - -### Steps to reproduce - -``` -git clone --recurse-submodules https://github.com/FAIRmat-NFDI/pynxtools.git -cd pynxtools -pip install -e . -cd .. -``` - diff --git a/mkdocs.yaml b/mkdocs.yaml index 1e4ee7683..11f03ade5 100644 --- a/mkdocs.yaml +++ b/mkdocs.yaml @@ -10,7 +10,6 @@ nav: - Tutorials: - tutorial/converting-data-to-nexus.md - tutorial/nexus-to-nomad.md - - tutorial/troubleshooting.md - How-tos: - how-tos/writing-an-appdef.md - how-tos/using-multiple-appdefs.md