toksearch attempting to fetch_dims of a scalar signal
orozda opened this issue · 1 comments
Error raised when fetching scalar signals in toksearch. Bug encountered by @Pranav-Sureshp
from toksearch import MdsSignal, Pipeline
shots = [170325]
volts_sig = MdsSignal(r'\NB15L:NBVAC_SCALAR','NB',location="remote://atlas.gat.com")
pipeline = Pipeline(shots)
pipeline.fetch('volts', volts_sig)
records = pipeline.compute_serial()
print(vars(records))
#########################################################
#MDS code that works for the identical shot and signal
from MDSplus import *
c = Connection('atlas.gat.com')
c.openTree('NB',170325)
volts = c.get('NB15L:NBVAC_SCALAR').data()
print(volts)
Error Raised:
'Traceback (most recent call last):\n File "toksearch/pipeline/pipeline_funcs.py", line 23, in toksearch.pipeline.pipeline_funcs._SafeFetch.__call__\n File "toksearch/signal/signal.py", line 145, in toksearch.signal.signal.Signal.fetch\n File "toksearch/datasource/mds_datasource.py", line 205, in toksearch.datasource.mds_datasource.MdsRemoteDataSource.fetch\n File "toksearch/datasource/mds_datasource.py", line 215, in toksearch.datasource.mds_datasource.MdsRemoteDataSource._fetch_dim\n File "/opt/toksearch/deps/mdsplus/mdsobjects/MDSplus/connection.py", line 245, in get\n ans = self.__getAnswer__()\n File "/opt/toksearch/deps/mdsplus/mdsobjects/MDSplus/connection.py", line 132, in __getAnswer__\n raise MdsIpException(str(ans))\nMDSplus.connection.MdsIpException: %MDSPLUS-?-UNKNOWN, %TDI-E-INVCLADSC, Storage class not valid, must be scalar or array\n'
Most likely culprit:
Use of "dim_of()" on a scalar MdsPlus signal somewhere around:
toksearch/toksearch/signal/mds.py
Line 398: https://github.com/GA-FDP/toksearch/blob/main/toksearch/signal/mds.py#L398
or
https://github.com/GA-FDP/toksearch/blob/main/toksearch/signal/mds.py#L399
suggestion:
check rank of signal before calling dims_of(,)
def _rank_of_expression(expression):
return "rank({})".format(expression)
rank_expression = _rank_of_expression(expression)
rank = connection.get(dim_expression)
if rank > 0:
....
or use getnci(expression) and check the type is numeric
As suggested by @orozda , replacing the expression
volts_sig = MdsSignal(r'\NB15L:NBVAC_SCALAR','NB',location="remote://atlas.gat.com")
with an additional argument for dims
as None
, fixes the problem , as follows:
volts_sig = MdsSignal(r'\NB15L:NBVAC_SCALAR','NB',location="remote://atlas.gat.com",dims=None)
Output:
volts: data: 80259.1796875 units: {'data': 'V'}