nxswriter


Namenxswriter JSON
Version 3.10.0 PyPI version JSON
download
home_pagehttps://github.com/nexdatas/nxsdatawriter
SummaryNexus Data writer implemented as a Tango Server
upload_time2023-11-10 14:20:41
maintainer
docs_urlNone
authorJan Kotanski, Eugen Wintersberger , Halil Pasic
requires_python
licenseGNU GENERAL PUBLIC LICENSE v3
keywords writer tango server nexus data
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Welcome to NXSDataWriter's documentation!
=========================================

|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

------------
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

| Source code: https://github.com/nexdatas/nxsdatawriter
| Project Web page: https://nexdatas.github.io/nxsdatawriter
| NexDaTaS Web page: https://nexdatas.github.io

------------
Installation
------------

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

	  $ python setup.py install

Debian packages
"""""""""""""""

Debian `bookworm`, `bullseye`, `buster`  or Ubuntu `lunar`, `jammy`, `focal`  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 **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.

.. code-block:: python

   # 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.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nexdatas/nxsdatawriter",
    "name": "nxswriter",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "writer Tango server nexus data",
    "author": "Jan Kotanski, Eugen Wintersberger , Halil Pasic",
    "author_email": "jankotan@gmail.com, eugen.wintersberger@gmail.com, halil.pasic@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/dc/92/10e440a2b5d2188d7457ea82fb94b3c8eed65f9fcb42f6713f594cc5eba4/nxswriter-3.10.0.tar.gz",
    "platform": null,
    "description": "Welcome to NXSDataWriter's documentation!\n=========================================\n\n|github workflow|\n|docs|\n|Pypi Version|\n|Python Versions|\n\n.. |github workflow| image:: https://github.com/nexdatas/nxsdatawriter/actions/workflows/tests.yml/badge.svg\n   :target: https://github.com/nexdatas/nxsdatawriter/actions\n   :alt:\n\n.. |docs| image:: https://img.shields.io/badge/Documentation-webpages-ADD8E6.svg\n   :target: https://nexdatas.github.io/nxsdatawriter/index.html\n   :alt:\n\n.. |Pypi Version| image:: https://img.shields.io/pypi/v/nxswriter.svg\n                  :target: https://pypi.python.org/pypi/nxswriter\n                  :alt:\n\n.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/nxswriter.svg\n                     :target: https://pypi.python.org/pypi/nxswriter/\n                     :alt:\n\n\nAuthors: Jan Kotanski, Eugen Wintersberger, Halil Pasic\n\n------------\nIntroduction\n------------\n\nNXSDataWriter is a Tango server which allows to store NeXuS Data in H5 files.\n\nThe server provides storing data from other Tango devices,\nvarious databases as well as passed by a user client via JSON strings.\n\nTango Server API: https://nexdatas.github.io/nxsdatawriter/doc_html\n\n| Source code: https://github.com/nexdatas/nxsdatawriter\n| Project Web page: https://nexdatas.github.io/nxsdatawriter\n| NexDaTaS Web page: https://nexdatas.github.io\n\n------------\nInstallation\n------------\n\nInstall the dependencies:\n\n|    pninexus or h5py, tango, numpy, nxstools, sphinx\n\nFrom sources\n\"\"\"\"\"\"\"\"\"\"\"\"\n\nDownload the latest NexDaTaS version from\n\n|    https://github.com/nexdatas/nxsdatawriter\n\nExtract sources and run\n\n.. code-block:: console\n\n\t  $ python setup.py install\n\nDebian packages\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\nDebian `bookworm`, `bullseye`, `buster`  or Ubuntu `lunar`, `jammy`, `focal`  packages can be found in the HDRI repository.\n\nTo install the debian packages, add the PGP repository key\n\n.. code-block:: console\n\n\t  $ sudo su\n\t  $ 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\n\t  $ chmod 644 /etc/apt/trusted.gpg.d/debian-hdri-repo.gpg\n\nand then download the corresponding source list\n\n.. code-block:: console\n\n\t  $ cd /etc/apt/sources.list.d\n\t  $ wget http://repos.pni-hdri.de/bookworm-pni-hdri.list\n\nTo install tango server\n\n.. code-block:: console\n\n\t  $ apt-get update\n\t  $ apt-get install nxswriter\n\nor\n\n.. code-block:: console\n\n\t  $ apt-get update\n\t  $ apt-get install nxswriter3\n\nfor older python3 releases.\n\nTo install only the python3 package\n\n.. code-block:: console\n\n\t  $ apt-get update\n\t  $ apt-get install python3-nxswriter\n\nand for python2\n\n.. code-block:: console\n\n\t  $ apt-get update\n\t  $ apt-get install python-nxswriter\n\nif exists.\n\n\n\nFrom pip\n\"\"\"\"\"\"\"\"\n\nTo install it from pip you can\n\n.. code-block:: console\n\n   $ python3 -m venv myvenv\n   $ . myvenv/bin/activate\n\n   $ pip install nxswriter\n\nMoreover it is also good to install\n\n.. code-block:: console\n\n   $ pip install pytango\n   $ pip install pymysqldb\n   $ pip install psycopg2-binary\n   $ pip install cx-oracle\n\nSetting NeXus Writer Server\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\nTo set up  NeXus Writer Server run\n\n.. code-block:: console\n\n          $ nxsetup -x NXSDataWriter\n\nThe *nxsetup* command comes from the **python-nxstools** package.\n\n-----------\nClient code\n-----------\n\nIn order to use Nexus Data Server one has to write a client code. Some simple client codes\nare in the  nexdatas repository. In this section we add some\ncomments related to the client code.\n\n.. code-block:: python\n\n   # To use the Tango Server we must import the tango module and\n   # create DeviceProxy for the server.\n\n   import tango\n\n   device = \"p09/tdw/r228\"\n   dpx = tango.DeviceProxy(device)\n   dpx.set_timeout_millis(10000)\n\n   dpx.Init()\n\n   # Here device corresponds to a name of our Nexus Data Server.\n   # The Init() method resets the state of the server.\n\n   dpx.FileName = \"test.h5\"\n   dpx.OpenFile()\n\n   # We set the name of the output HDF5 file and open it.\n\n   # Now we are ready to pass the XML settings describing a structure of\n   # the output file as well as defining a way of data storing.\n   # Examples of the XMLSettings can be found in the XMLExamples directory.\n\n   with open(\"test.xml\", 'r') as fl:\n       xml = fl.read()\n   dpx.XMLSettings = xml\n\n   dpx.JSONRecord = '{\"data\": {\"parameterA\":0.2},\n\t\t\t \"decoders\":{\"DESY2D\":\"desydecoders.desy2Ddec.desy2d\"},\n\t\t\t \"datasources\":{\n\t\t              \"MCLIENT\":\"sources.DataSources.LocalClientSource\"}\n   }'\n\n   dpx.OpenEntry()\n\n   # We read our XML settings settings from a file and pass them to the server via\n   # the XMLSettings attribute. Then we open an entry group related to the XML\n   # configuration. Optionally, we can also set JSONRecord, i.e. an attribute\n   # which contains a global JSON string with data needed to store during opening\n   # the entry and also other stages of recording. If external decoder for\n   # DevEncoded data is need one can registred it passing its packages and\n   # class names in JSONRecord,\n   # e.g. \"desy2d\" class of \"DESY2D\" label in \"desydecoders.desy2Ddec\" package.\n   # Similarly making use of \"datasources\" records of the JSON string one can\n   # registred additional datasources. The OpenEntry method stores data defined\n   # in the XML string with strategy=INIT.\n   # The JSONRecord attribute can be changed during recording our data.\n\n   # After finalization of the configuration process we can start recording\n   # the main experiment data in a STEP mode.\n\n   dpx.Record('{\"data\": {\"p09/counter/exp.01\":0.1, \"p09/counter/exp.02\":1.1}}')\n\n   # Every time we call the Record method all nexus fields defined with\n   # strategy=STEP are extended by one record unit and the assigned to them data\n   # is stored. As the method argument we pass a local JSON string with the client\n   # data. To record the client data one can also use the global JSONRecord string.\n   # Contrary to the global JSON string the local one is only\n   # valid during one record step.\n\n   dpx.Record('{\"data\": {\"emittance_x\": 0.1},  \"triggers\":[\"trigger1\", \"trigger2\"]  }')\n\n   # If you denote in your XML configuration string some fields by additional\n   # trigger attributes you may ask the server to store your data only in specific\n   # record steps. This can be helpful if you want to store your data in\n   # asynchronous mode. To this end you define in the local JSON string a list of\n   # triggers which are used in the current record step.\n\n   dpx.JSONRecord = '{\"data\": {\"parameterB\":0.3}}'\n   dpx.CloseEntry()\n\n   # After scanning experiment data in 'STEP' mode we close the entry.\n   # To this end we call the CloseEntry method which also stores data defined\n   # with strategy=FINAL. Since our HDF5 file can contain many entries we can again\n   # open the entry and repeat our record procedure. If we define more than one entry\n   # in one XML setting string the defined entries are recorded parallel\n   # with the same steps.\n\n   # Finally, we can close our output file by\n\n   dpx.CloseFile()\n\nAdditionally, one can use asynchronous versions of **OpenEntry**, **Record**, **CloseEntry**, i.e.\n**OpenEntryAsynch**, **RecordAsynch**, **CloseEntryAsynch**. In this case data is stored\nin a background thread and during this writing Tango Data Server has a state *RUNNING*.\n\nIn order to build the XML configurations in the easy way the authors of the server provide\nfor this purpose a specialized GUI tool, Component Designer.\nThe attached to the server XML examples\nwas created by XMLFile class defined in XMLCreator/simpleXML.py.\n\n\n",
    "bugtrack_url": null,
    "license": "GNU GENERAL PUBLIC LICENSE v3",
    "summary": "Nexus Data writer implemented as a Tango Server",
    "version": "3.10.0",
    "project_urls": {
        "Homepage": "https://github.com/nexdatas/nxsdatawriter"
    },
    "split_keywords": [
        "writer",
        "tango",
        "server",
        "nexus",
        "data"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "035a7e59be1c770a48137f72ce5d643607f74e05338cdbfa67e744e826dfe83f",
                "md5": "8f1a34ae70fda2fe9d8b5db2e69aa99a",
                "sha256": "a7ecbdbd5825f26716f3e020978447b5667a524c647515bbc21de605771d7d7e"
            },
            "downloads": -1,
            "filename": "nxswriter-3.10.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8f1a34ae70fda2fe9d8b5db2e69aa99a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 81914,
            "upload_time": "2023-11-10T14:20:39",
            "upload_time_iso_8601": "2023-11-10T14:20:39.458784Z",
            "url": "https://files.pythonhosted.org/packages/03/5a/7e59be1c770a48137f72ce5d643607f74e05338cdbfa67e744e826dfe83f/nxswriter-3.10.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dc9210e440a2b5d2188d7457ea82fb94b3c8eed65f9fcb42f6713f594cc5eba4",
                "md5": "70473ee62360dcf45f251318e6738c71",
                "sha256": "6419642f4dae46d11c242e2055a2dc7093a721cd1dc72e7b8d0bbde67de529c8"
            },
            "downloads": -1,
            "filename": "nxswriter-3.10.0.tar.gz",
            "has_sig": false,
            "md5_digest": "70473ee62360dcf45f251318e6738c71",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 464745,
            "upload_time": "2023-11-10T14:20:41",
            "upload_time_iso_8601": "2023-11-10T14:20:41.702645Z",
            "url": "https://files.pythonhosted.org/packages/dc/92/10e440a2b5d2188d7457ea82fb94b3c8eed65f9fcb42f6713f594cc5eba4/nxswriter-3.10.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-10 14:20:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nexdatas",
    "github_project": "nxsdatawriter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "nxswriter"
}
        
Elapsed time: 0.13938s