GA-FDP / toksearch

TokSearch framework for parallel processing of fusion data
https://ga-fdp.github.io/toksearch/
Apache License 2.0
4 stars 0 forks source link

toksearch attempting to fetch_dims of a scalar signal #5

Open orozda opened 1 week ago

orozda commented 1 week ago

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

Pranav-Sureshp commented 6 days ago

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