mcalf.utils.misc.load_parameter(parameter, wl=None)[source]

Load parameters from file, optionally evaluating variables from strings.

Loads the parameter from string or file.

  • parameter (str) – Parameter to load, either string of Python list/number or filename string. Supported filename extensions are ‘.fits’, ‘.fit’, ‘.fts’, ‘.csv’, ‘.txt’, ‘.npy’, ‘.npz’, and ‘.sav’. If the file does not exist, it will assume the string is a Python expression.

  • wl (float, optional, default=None) – Central line core wavelength to replace ‘wl’ in strings. Will only replace occurrences in the parameter variable itself or in files with extension “.csv” or “.txt”. When using wl, also use ‘inf’ and ‘nan’ as required.


value – Value of parameter in easily computable format (not string).

Return type

numpy.ndarray or list of floats


>>> load_parameter("wl + 4.2", wl=7.1)
>>> load_parameter("[wl + 4.2, 5.2 - inf, 5 > 3]", wl=7.1)
[11.3, -inf, 1.0]

Filenames are given as follows:

>>> x = load_parameter("datafile.csv", wl=12.4)  
>>> x = load_parameter("datafile.fits")  

If the file does not exist, the function will assume that the string is a Python expression, possibly leading to an error:

>>> load_parameter("nonexistant.csv")
Traceback (most recent call last):
TypeError: 'NoneType' object is not subscriptable