NOAA-PMEL/PyFerret

Get list of variables defined from putdata

Opened this issue · 1 comments

I cannot list the python variables defined by previous pyferret.putdata commands without loading first a dataset

import numpy as np
import pyferret

b = {}
b['name']='myvar1'
x=np.linspace(-np.pi*4, np.pi*4, 500)
b['data']=np.sin(x)/x
b.keys()

pyferret.start()

# Why to do need the following line to load a dataset and to get the list of python variables
pyferret.run('use levitus_climatology')

pyferret.putdata(b)
pyferret.run('show data')

I get

     currently SET data sets:
    1> /opt/ferret_dsets/data/levitus_climatology.cdf  (default)
 name     title                             I         J         K         L
 TEMP     TEMPERATURE                      1:360     1:180     1:20      ...
 SALT     SALINITY                         1:360     1:180     1:20      ...
 ------ Python Variables ------
 MYVAR1   myvar1                           1:500     ...       ...       ...       ...       ...

I would like to get only (without any load command)

 ------ Python Variables ------
 MYVAR1   myvar1                           1:500     ...       ...       ...       ...       ...

The current code only adds variables to the default existing dataset. Code needs to be added to allow the data to be added to any existing dataset, or to create a dataset and add it to that new dataset. Thus, marking it as both an enhancement that is needed as well as a bug.