Problem with np.array and list with parquet
From @hbartosi
please find attached a small script running pyjapcscout in which I find a bug. The example acquires a BCT signal and without saving the data it has a structure such that myMonitor.lastData['BR1.BCT-ST/Samples']['value']['samples’] is a numpy array. the same is true when saving to pickledict. However, when saving as parquet, it changes into a list of lists.
more explicitly: the examplie script below prints the type and you can see that it changes like that: no saving: np.array type saving as pickledict: np.array type saving as parquet: list type
Can we avoid this change of type?
thanks for your help!
cheers, Hannes
=========================
import glob import time from datetime import datetime import matplotlib.pyplot as plt import numpy as np
from pyjapcscout import PyJapcScout from pyjapcscout import PyJapcScoutData
start PyJapcScout and so incaify Python instance
myPyJapc = PyJapcScout(incaAcceleratorName='PSB')
Get and RBAC tocken
#myPyJapc.rbacLogin()
signalsToMonitor = [] rings = ['R1'] signalsToMonitor.append('BR1.BCT-ST/Samples')
mySelector = 'PSB.USER.LHC1A'
def myCallback(data, h): global n_shots, n_shots_max if h.saveData: n_shots += 1 now_str = datetime.now().strftime('%H:%M:%S') out_str = '>> %s %s - '%(h._myPyJapc.getSelector(),now_str) if h.saveData: out_str += 'recorded shot %s'%n_shots else: out_str += 'no data saved' print(out_str) if n_shots >= n_shots_max: h.stopMonitor() print('Measurement finished and monitor stopped.')
a = myMonitor.lastData['BR1.BCT-ST/Samples']['value']['samples']
print(type(a))
myMonitor = myPyJapc.PyJapcScoutMonitor(mySelector, signalsToMonitor, onValueReceived=myCallback, selectorOverride=mySelector, groupStrategy='extended',strategyTimeout=5400)
saving data configuration
myMonitor.saveDataPath = './testdata/' myMonitor.saveData = False myMonitor.saveDataFormat = 'parquet' # #myMonitor.saveDataFormat = 'pickledict'
define number of shots
n_shots = 0 n_shots_max = 500
start acquisition
myMonitor.startMonitor()
''' if 0: ## for controlling data acquisition: # myMonitor.saveData = True # myMonitor.saveData = False
## to stop the monitor
#myMonitor.stopMonitor()
## to reload the data (here assuming parquet)
myData = PyJapcScoutData()
myData.load('./Data/', fileFormat='parquet')
# everything in a Pandas dataframe:
myData.df
#rsync -avh Data sterbini@lxplus:/eos/user/s/sterbini/test
''' """ import jpype as jp System = jp.JClass("java.lang.System") System.exit(0) # to exit from console """