|github workflow| |docs| |Pypi Version| |Python Versions|
.. |github workflow| image:: https://github.com/nexdatas/nxsdatawriter/actions/workflows/tests.yml/badge.svg :target: https://github.com/nexdatas/nxsdatawriter/actions :alt:
.. |docs| image:: https://img.shields.io/badge/Documentation-webpages-ADD8E6.svg :target: https://nexdatas.github.io/nxsdatawriter/index.html :alt:
.. |Pypi Version| image:: https://img.shields.io/pypi/v/nxswriter.svg :target: https://pypi.python.org/pypi/nxswriter :alt:
.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/nxswriter.svg :target: https://pypi.python.org/pypi/nxswriter/ :alt:
Authors: Jan Kotanski, Eugen Wintersberger, Halil Pasic
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
| Source code: https://github.com/nexdatas/nxsdatawriter | Project Web page: https://nexdatas.github.io/nxsdatawriter | NexDaTaS Web page: https://nexdatas.github.io
Install the dependencies:
| pninexus or h5py, tango, numpy, nxstools, sphinx
From sources """"""""""""
Download the latest NexDaTaS version from
| https://github.com/nexdatas/nxsdatawriter
Extract sources and run
.. code-block:: console
$ python3 setup.py install
Debian packages """""""""""""""
Debian bookworm
, bullseye
, buster
or Ubuntu oracular
, noble
, jammy
packages can be found in the HDRI repository.
To install the debian packages, add the PGP repository key
.. code-block:: console
$ 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
.. code-block:: console
$ cd /etc/apt/sources.list.d
$ wget http://repos.pni-hdri.de/bookworm-pni-hdri.list
To install tango server
.. code-block:: console
$ apt-get update
$ apt-get install nxswriter
or
.. code-block:: console
$ apt-get update
$ apt-get install nxswriter3
for older python3 releases.
To install only the python3 package
.. code-block:: console
$ apt-get update
$ apt-get install python3-nxswriter
and for python2
.. code-block:: console
$ apt-get update
$ apt-get install python-nxswriter
if exists.
From pip """"""""
To install it from pip you can
.. code-block:: console
$ python3 -m venv myvenv $ . myvenv/bin/activate
$ pip install nxswriter
Moreover it is also good to install
.. code-block:: console
$ 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
.. code-block:: console
$ nxsetup -x NXSDataWriter
The nxsetup command comes from the python3-nxstools package.
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.
.. code-block:: python
import tango
device = "p09/tdw/r228" dpx = tango.DeviceProxy(device) dpx.set_timeout_millis(10000)
dpx.Init()
dpx.FileName = "test.h5" dpx.OpenFile()
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()
dpx.Record('{"data": {"p09/counter/exp.01":0.1, "p09/counter/exp.02":1.1}}')
dpx.Record('{"data": {"emittance_x": 0.1}, "triggers":["trigger1", "trigger2"] }')
dpx.JSONRecord = '{"data": {"parameterB":0.3}}' dpx.CloseEntry()
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.