Giter Site home page Giter Site logo

nexdatas / nxselector Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 2.83 MB

Component Selector GUI -- selector of user configuration for NeXus/HDF5 files

License: GNU General Public License v3.0

Python 85.10% Shell 2.96% Dockerfile 11.94%
nexusformat pyqt python sardana taurus

nxselector's Introduction

Welcome to NXSDataWriter's documentation!

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

$ 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/bookworm-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.

nxselector's People

Contributors

jkotan avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

lexia-wisdom

nxselector's Issues

dictionary changed size during iteration

the bug needs to be fixed

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nxsselector/Storage.py", line 336, in __groups
    self.__descgroups()
  File "/usr/lib/python3/dist-packages/nxsselector/Storage.py", line 418, in __descgroups
    self.__updateGroup(self.state.idsgroup, dform.datasources, True)
  File "/usr/lib/python3/dist-packages/nxsselector/Storage.py", line 433, in __updateGroup
    for k, st in group.items():
RuntimeError: dictionary changed size during iteration

fix saving profile in qt5

Since output of qt5 Qt.QFileDialog.getSaveFileName is different then for qt4 the Save button does not work anymore

timer wrongly selected

It looks like timers are wrongly selected when two calls of updateForm are executed simultaneously

Release 3.20.0

In the v3.20.0 release

  • taurus.core.util.argparse to argparse changed (#88)

unable to add a string tango attribute as a descriptor

Hello,

I've just encounter a very strange behaviour of the descriptors panel. I could successfully create DataSource from the tango attributes and add it as a Descriptor. But it did not work for all strings attributes, but only for the strings which were rather short. For example I could add a attribute with a string /mnt/nvme_raid0/DATA/ but could not add an attribute with a longer string /mnt/nvme_raid0/DATA/MOENCH/PETRA_BEAMTIME/180523/run_180523_d0_f0_531.raw.

Is it just a coincidence or there is any kind of size check of the attribute's value? I could add this attribute at the detector tab though. So I guess that the tango device configuration is not an issue itself.

P. S. this kind of descriptor do not exist in the Sardana as entities and are custom designed in this package, right?

add more tests

It would be good to add more tests e.g. with qt-checker

Add a File Ext. widget

We've received a request to add a File Extension widget to have possibility of defining file extension from a file name (common).

Release 3.18.2

In the v3.18.2 release

  • warn user if apply is pressed during door running (#63)

Release 3.19.0

In the v3.19.0 release

  • CheckDisSelView to switch the checkboxes order added (#81)
  • checkbox for scanID editable added (#79)

Support for referable counter?

Hi all,

in the nxselector GUI I didn't find a way to enable value referencing for sardana counters that implement the Referable scheme. Am I missing something here?

Many thanks and cheers,

Michael

Release v3.16.0

In the v3.16.0 release

  • detectors to a scroll area moved
  • descriptions to a scroll area moved

Release 3.18.4

In the v3.18.4 release

  • additional spacing in the checkbox view added (#74)

ScanID is not editable from the GUI and will not recover after Sardana restart

After we have our sardana restarted the configuration in the nxselector was lost (it is fine) but then we could not edit the ScanID anymore. I am aware, there is an option to set it in Sardana internally with spock %setenv ScanID XXX.

However, I afraid that unexperienced user which could begin the measurement without setting the ScanID. We use a sample_name_%05 filename which includes the ScanID as a parameter to write the scans into separate files. Then, I assume, if ScanID was empty it would be set automatically to 0. Then the next scan could overwrite the already existing file.

I did not tried this out but could you please check this. Otherwise, it can be really dangerous for the people who has no experience with Sardana control system.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.