[Thread Prev][Thread Next][Index]

Re: [ferret_users] get variable name



Hi Dalton,

Unfortunately, pyferret.getdata only returns numeric arrays at this time.  Returning string arrays is an the enhancement request list.

You can pass string arrays to PyFerret external functions written in Python.  If you could do whatever you are wanting to do in such an external function, then that would be one way. 

Otherwise I think you would have to write the string array to a file with the ferret commands:
    cancel list /head
    list /file=names.txt /clobber /format=(A)
then read the names from file using standard python methods (such as file.readlines).  Not an elegant solution, but it would work.

Karl



On Fri, Jun 14, 2013 at 6:35 AM, Dalton Kei Sasaki <dalton.sasaki@xxxxxxxxx> wrote:
Hello all,

I am using pyferret and I've been trying to get an array of strings with the variables' names only. The best I've got in ferret is:

yes? use anom.nc 
yes? let names = ..varnames
yes? list names

VARIABLE : ..VARNAMES
FILENAME : anom.nc
SUBSET   :3 points (X)
 1   / 1:"Q_SEN_AN"  
 2   / 2:"TAUX_AN"   
 3   / 3:"TAUY_AN"   

In python I'd like to have an array like:

var = ['Q_SEN_AN', 'TAUX_AN', 'TAUY_AN']

Any Ideas?
Thanks!


--
Jai Guru Dev

Dalton Kei Sasaki



--
Karl M. Smith, Ph.D.
JISAO Univ. Wash. and TMAP/PMEL NOAA
"The contents of this message are mine personally and do
not necessarily reflect any position of the Government
or the National Oceanic and Atmospheric Administration."

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement