Skip to content

A python module providing remote control of DDRS4PALS software enabling its full integration into any measurement environment.

License

Notifications You must be signed in to change notification settings

dpscience/pyRemoteDDRS4PALS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Support this project and keep always updated about recent software releases, bug fixes and major improvements by following on researchgate or github.

badge-researchGate

badge-followers badge-stars badge-forks

pyRemoteDDRS4PALS

badge-license badge-language badge-license

Copyright (c) 2021 Danny Petschke (danny.petschke@uni-wuerzburg.de) All rights reserved.

pyRemoteDDRS4PALS - A python module providing remote control of DDRS4PALS software enabling its full integration into any measurement environment.

Principle: Remote Control of DDRS4PALS via pyRemoteDDRS4PALS


DDRS4PALS-rc

Quickstart Guide

  • import the 'pyRemoteDDRS4PALS' module
import remoteddrs4pals as rcddrs4pals
  • initiate a session
HOST = '127.0.0.1'  # the server's hostname or IP address
PORT = 4000         # the port used by the server (set in DDRS4PALS)

my_session = rcddrs4pals.startRemoteSession(host=HOST,port=PORT)
  • optional: check if the versions of 'pyRemoteDDRS4PALS' module and DDRS4PALS are matching
valid_handshake = True

if not rcddrs4pals.handshake(my_socket=my_session):
  print('version handshake failed ...')
  
  valid_handshake = False
        
assert valid_handshake == True
  • ... do your stuff (see examples) ...

  • close your session

rcddrs4pals.closeRemoteSession(my_socket=my_session)

Available Remote Control Functions

  • initiates a remote session
startRemoteSession(host,port) : returns: socket
  • closes a remote session
closeRemoteSession(my_socket) : returns: void
  • performs a handshake between the 'pyRemoteDDRS4PALS' module (client) and DDRS4PALS (server) versions
handshake(my_socket) : returns: True/False
  • start the acquisition
startAcquisition(my_socket) : returns: True/False
  • stop the acquisition
stopAcquisition(my_socket) : returns: True/False
  • returns if an acquisition is running
isAcquisitionRunning(my_socket) : returns: True/False
  • returns the counts of spectrum A-B
getCountsOfABSpectrum(my_socket) : returns: int
  • returns the counts of spectrum B-A
getCountsOfBASpectrum(my_socket) : returns: int
  • returns the counts of the merged spectrum
getCountsOfMergedSpectrum(my_socket) : returns: int
  • returns the counts of the prompt spectrum
getCountsOfPromptSpectrum(my_socket) : returns: int
  • prompts a reset of spectrum A-B
resetABSpectrum(my_socket) : returns: True/False
  • prompts a reset of spectrum B-A
resetBASpectrum(my_socket) : returns: True/False
  • prompts a reset of the merged spectrum
resetMergedSpectrum(my_socket) : returns: True/False
  • prompts a reset of the prompt spectrum
resetPromptSpectrum(my_socket) : returns: True/False
  • prompts a reset of all spectra together
resetAllSpectra(my_socket) : returns: True/False
  • returns the data of spectrum A-B
getDataOfABSpectrum(my_socket) : returns: dictionary = {
                                          "channel-width": int,
                                          "no-of-channel": int,
                                          "integral-counts": int,
                                          "spectrum-data": np.array
                                          }
  • returns the data of spectrum B-A
getDataOfBASpectrum(my_socket) : returns: dictionary = {
                                          "channel-width": int,
                                          "no-of-channel": int,
                                          "integral-counts": int,
                                          "spectrum-data": np.array
                                          }
  • returns the data of the merged spectrum
getDataOfMergedSpectrum(my_socket) : returns: dictionary = {
                                          "channel-width": int,
                                          "no-of-channel": int,
                                          "integral-counts": int,
                                          "spectrum-data": np.array
                                          }
  • returns the data of the prompt spectrum
getDataOfPromptSpectrum(my_socket) : returns: dictionary = {
                                          "channel-width": int,
                                          "no-of-channel": int,
                                          "integral-counts": int,
                                          "spectrum-data": np.array
                                          }
  • halts until the desired 'counts' are reached in spectrum A-B
waitUntilCountsForABSpectrum(my_socket,counts) : returns: void
  • halts until the desired 'counts' are reached in spectrum B-A
waitUntilCountsForBASpectrum(my_socket,counts) : returns: void
  • halts until the desired 'counts' are reached in the merged spectrum
waitUntilCountsForMergedSpectrum(my_socket,counts) : returns: void
  • halts until the desired 'counts' are reached in the prompt spectrum
waitUntilCountsForPromptSpectrum(my_socket,counts) : returns: void
  • returns the currently loaded settings in DDRS4PALS
getSettings(my_socket,counts) : returns: xml-string

Examples

Examples can be found in the folder '/examples'.

Example 1: in-situ measurement

import remoteddrs4pals as rcddrs4pals

import matplotlib.pyplot as plt
import numpy as np
from datetime import datetime

HOST = '127.0.0.1'  # the server's hostname or IP address
PORT = 4000         # the port used by the server (set in DDRS4PALS)

number_of_runs           = 1000
number_of_counts_per_run = 1E5

if __name__ == '__main__':
    rcddrs4pals.__information__()
    
    # initiate a remote session to communicate with DDRS4PALS ...
    my_session = rcddrs4pals.startRemoteSession(host=HOST,port=PORT)
    
    # check for the correct protocol versions between DDRS4PALS and the remoteddrs4pals module ... 
    valid_handshake = True
    if not rcddrs4pals.handshake(my_socket=my_session):
        print('version handshake failed ...')
        valid_handshake = False
        
    assert valid_handshake == True
    
    # start the aquisition ...
    if not rcddrs4pals.isAcquisitionRunning(my_socket=my_session):
        rcddrs4pals.startAcquisition(my_socket=my_session)
        
    # start in-situ runs ...
    for i in range(0,number_of_runs):
    
        # reset spectrum of A-B ...
        rcddrs4pals.resetABSpectrum(my_socket=my_session)
    
        # wait until the spectrum of A-B reached the desired counts ...
        rcddrs4pals.waitUntilCountsForABSpectrum(my_socket=my_session,counts=number_of_counts_per_run)

        # request the data of spectrum A-B ...
        spectrum_data = rcddrs4pals.getDataOfABSpectrum(my_socket=my_session)
        
        # save your spectrum ...
        filename = 'your_directory/spec{}_{}.txt'.format(i,datetime.now().strftime("%m_%d_%Y_%H_%M_%S"))
        
        np.savetxt(filename,spectrum_data["spectrum-data"],fmt='%0d',newline='\n',header='counts at channel-width {}ps'.format(spectrum_data["channel-width"]))
    
    # stop the acquisition ...
    rcddrs4pals.stopAcquisition(my_socket=my_session)
    
    # don't forget to close the session at the end ...
    rcddrs4pals.closeRemoteSession(my_socket=my_session)

How to cite this Program?

  • When running this software for your research purposes you should at least cite the following publication.

DOI

DDRS4PALS: A software for the acquisition and simulation of lifetime spectra using the DRS4 evaluation board

  • Additionally, you must cite the applied version of this software in your study.

You can cite all released software versions by using the DOI 10.5281/zenodo..4767301. This DOI represents all versions, and will always resolve to the latest one.

DOI

v1.x

pyRemoteDDRS4PALS v1.0 (minimum required version DDRS4PALS v1.17)
DOI

License of pyRemoteDDRS4PALS (GNU General Public License)

Copyright (c) 2021 Danny Petschke (danny.petschke@uni-wuerzburg.de) All rights reserved.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

For more details see GNU General Public License v3

About

A python module providing remote control of DDRS4PALS software enabling its full integration into any measurement environment.

Resources

License

Stars

Watchers

Forks

Languages