Skip to main content

Authors: Jan Kotanski, Eugen Wintersberger, Halil Pasic

Introduction

NXSDataWriter is a Tango server which allows to store NeXuS Data in H5 files.

The server provides storing data from other Tango devices, various databases as well as passed by a user client via JSON strings.

Tango Server API: https://nexdatas.github.io/nxsdatawriter/doc_html

Installation

Install the dependencies:

pninexus or h5py, tango, numpy, nxstools, sphinx

From sources

Download the latest NexDaTaS version from

Extract sources and run

$ python setup.py install

Debian packages

Debian bullseye, buster, stretch or Ubuntu focal, bionic packages can be found in the HDRI repository.

To install the debian packages, add the PGP repository key

$ sudo su
$ curl -s http://repos.pni-hdri.de/debian_repo.pub.gpg | gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/debian-hdri-repo.gpg --import
$ chmod 644 /etc/apt/trusted.gpg.d/debian-hdri-repo.gpg

and then download the corresponding source list

$ cd /etc/apt/sources.list.d
$ wget http://repos.pni-hdri.de/bullseye-pni-hdri.list

To install tango server

$ apt-get update
$ apt-get install nxswriter

or

$ apt-get update
$ apt-get install nxswriter3

for older python3 releases.

To install only the python3 package

$ apt-get update
$ apt-get install python3-nxswriter

and for python2

$ apt-get update
$ apt-get install python-nxswriter

if exists.

From pip

To install it from pip you can

$ python3 -m venv myvenv
$ . myvenv/bin/activate

$ pip install nxswriter

Moreover it is also good to install

$ pip install pytango
$ pip install pymysqldb
$ pip install psycopg2-binary
$ pip install cx-oracle

Setting NeXus Writer Server

To set up NeXus Writer Server run

$ nxsetup -x NXSDataWriter

The nxsetup command comes from the python-nxstools package.

Client code

In order to use Nexus Data Server one has to write a client code. Some simple client codes are in the nexdatas repository. In this section we add some comments related to the client code.

# To use the Tango Server we must import the tango module and
# create DeviceProxy for the server.

import tango

device = "p09/tdw/r228"
dpx = tango.DeviceProxy(device)
dpx.set_timeout_millis(10000)

dpx.Init()

# Here device corresponds to a name of our Nexus Data Server.
# The Init() method resets the state of the server.

dpx.FileName = "test.h5"
dpx.OpenFile()

# We set the name of the output HDF5 file and open it.

# Now we are ready to pass the XML settings describing a structure of
# the output file as well as defining a way of data storing.
# Examples of the XMLSettings can be found in the XMLExamples directory.

with open("test.xml", 'r') as fl:
    xml = fl.read()
dpx.XMLSettings = xml

dpx.JSONRecord = '{"data": {"parameterA":0.2},
                      "decoders":{"DESY2D":"desydecoders.desy2Ddec.desy2d"},
                      "datasources":{
                           "MCLIENT":"sources.DataSources.LocalClientSource"}
}'

dpx.OpenEntry()

# We read our XML settings settings from a file and pass them to the server via
# the XMLSettings attribute. Then we open an entry group related to the XML
# configuration. Optionally, we can also set JSONRecord, i.e. an attribute
# which contains a global JSON string with data needed to store during opening
# the entry and also other stages of recording. If external decoder for
# DevEncoded data is need one can registred it passing its packages and
# class names in JSONRecord,
# e.g. "desy2d" class of "DESY2D" label in "desydecoders.desy2Ddec" package.
# Similarly making use of "datasources" records of the JSON string one can
# registred additional datasources. The OpenEntry method stores data defined
# in the XML string with strategy=INIT.
# The JSONRecord attribute can be changed during recording our data.

# After finalization of the configuration process we can start recording
# the main experiment data in a STEP mode.

dpx.Record('{"data": {"p09/counter/exp.01":0.1, "p09/counter/exp.02":1.1}}')

# Every time we call the Record method all nexus fields defined with
# strategy=STEP are extended by one record unit and the assigned to them data
# is stored. As the method argument we pass a local JSON string with the client
# data. To record the client data one can also use the global JSONRecord string.
# Contrary to the global JSON string the local one is only
# valid during one record step.

dpx.Record('{"data": {"emittance_x": 0.1},  "triggers":["trigger1", "trigger2"]  }')

# If you denote in your XML configuration string some fields by additional
# trigger attributes you may ask the server to store your data only in specific
# record steps. This can be helpful if you want to store your data in
# asynchronous mode. To this end you define in the local JSON string a list of
# triggers which are used in the current record step.

dpx.JSONRecord = '{"data": {"parameterB":0.3}}'
dpx.CloseEntry()

# After scanning experiment data in 'STEP' mode we close the entry.
# To this end we call the CloseEntry method which also stores data defined
# with strategy=FINAL. Since our HDF5 file can contain many entries we can again
# open the entry and repeat our record procedure. If we define more than one entry
# in one XML setting string the defined entries are recorded parallel
# with the same steps.

# Finally, we can close our output file by

dpx.CloseFile()

Additionally, one can use asynchronous versions of OpenEntry, Record, CloseEntry, i.e. OpenEntryAsynch, RecordAsynch, CloseEntryAsynch. In this case data is stored in a background thread and during this writing Tango Data Server has a state RUNNING.

In order to build the XML configurations in the easy way the authors of the server provide for this purpose a specialized GUI tool, Component Designer. The attached to the server XML examples was created by XMLFile class defined in XMLCreator/simpleXML.py.

Release files for nxswriter 3.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nxswriter 3.5.1
File Size Uploaded
nxswriter-3.5.1.tar.gz 453.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nxswriter 3.5.1
File Interpreter ABI Platform
nxswriter-3.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 533.5 kB

Release files / nxswriter-3.5.1.tar.gz

Download URL nxswriter-3.5.1.tar.gz
Size 453.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f6075f5d4be43cadede84c18cc8458fd6c9356b647d443f91a1084ef6f813ab5
BLAKE2b-256 checksum
How to use checksums
7c003c254b6754f34b858ef3d393940b7090944a4c3684a99ada057c87723828
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

Release files / nxswriter-3.5.1-py3-none-any.whl

Download URL nxswriter-3.5.1-py3-none-any.whl
Size 80.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6635e4ce5ec2d5abef5904e899a38cb23b853aee6bdacd712b0ef0eb796cb840
BLAKE2b-256 checksum
How to use checksums
cd0179e9e4c6ceac8d37723da5a49657a4d9557349b8291191855adff4891e66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

Release history Release notifications | RSS feed

3.24.0

2 release files

3.23.1

2 release files

3.23.0

2 release files

3.22.0

2 release files

3.21.0

2 release files

3.20.0

2 release files

3.18.1

2 release files

3.17.2

2 release files

3.17.1

2 release files

3.17.0

2 release files

3.15.0

2 release files

3.13.0

2 release files

3.12.0

2 release files

3.11.1

2 release files

3.11.0

2 release files

3.10.0

2 release files

3.9.0

2 release files

3.8.2

2 release files

3.8.1

2 release files

3.8.0

2 release files

3.7.0

2 release files

3.6.0

2 release files

3.5.3

2 release files

3.5.2

2 release files

This release

3.5.1 This release

2 release files

3.4.2

2 release files

3.4.1

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.2

2 release files

3.1.0

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.27.0

2 release files

2.25.3

2 release files

2.25.1

1 release file

2.25.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page