Last modified: December 2013

URL: https://cxc.cfa.harvard.edu/ciao/ahelp/paramio_plist.html
Jump to: Description · Examples · See Also


AHELP for CIAO 4.16

plist

Context: paramio

Synopsis

Get list of parameter names.

Syntax

mylist = plist(paramfile)

Description

The plist routine can be used to retrieve the list of parameter names in a parameter file. This can be used to quickly retrieve all the parameter name / value pairs.

The paramio module is not available by default; see "ahelp paramio" for information on loading the module.


Examples

Example 1

>>> pars = plist("dmcopy")
>>> pars
['infile', 'outfile', 'kernel', 'option', 'verbose', 'clobber', 'mode']
>>> values = {}
>>> for p in pars:
... values[p] = pget( "dmcopy", p )
...
>>> values
{'kernel': 'default', 'verbose': '0', 'clobber': 'no', 'outfile':
'cbe.fits', 'mode': 'ql', 'infile': 'acisf06616N003_evt2.fits',
'option': ''}
>>> values["clobber"]
'no'

The plist command is used to discover all the parameter names associated with dmcopy.par. The list of names is returned in the same order as in the .par file. It is then easy to iterate over the parameter names and using pget, retrieve the values. In this example we have stored the parameters in a Python dictionary.

Make note that pget always returns a string value regardless of the data-type associated with the parameter value.

Example 2

>>> dmc = paramopen("dmcopy")
>>> pars = plist(dmc)
>>> pars
['infile', 'outfile', 'kernel', 'option', 'verbose', 'clobber', 'mode']

Same as above except it uses the parameter object returned by dmcopy.

See Also

paramio
paccess, paramclose, paramio, paramopen, pget, pgets, pquery, pset, punlearn