class atomica.parameters.Parameter(name, ts)[source]

Bases: atomica.utils.NamedItem

Class to hold one set of parameter values disaggregated by populations.

  • name (str) – The name of the parameter (should match framework code name)

  • ts (dict) – A dict where the key is population name and the value is a TimeSeries instance

NamedItem constructor

A name must be a string


name (str) –



Get populations contained in the Parameter




Check if any values are present


Return interpolated parameter values for a given population


Perturb parameter based on uncertainties


Smooth the parameter's time values


Check if any values are present

Returns True if this Parameter has values specified for the given population If the Parameter has an assumption, then the time value will be nan but a y-value will be present. If the Parameter normally has a function, then the y-value will be None. If a function Parameter has a scenario overwrite applied then actual values will be present. Essentially, if this function returns True, then the interpolate() method will return usable values


pop_name (str) – The code name of a population

Return type



True if any values are present for specified population, otherwise False

interpolate(tvec, pop_name)[source]

Return interpolated parameter values for a given population

The Parameter internally stores the interpolation method. The default is linear. It is possible to set it to ‘pchip’ or ‘previous’ or some other method. However, this would also also be applied to any parameter scenarios that have modified the parameter and require interpolation. Therefore, it is STRONGLY recommended not to modify the fallback interpolation method, but to instead call Parameter.smooth() in advance with the appropriate options, if the interpolation matters.

  • tvec – A scalar, list, or array or time values

  • pop_name (str) – The population to interpolate data for

Return type



An array with the interpolated values

property pops

Get populations contained in the Parameter


Generator/list of available populations


Perturb parameter based on uncertainties

This function modifies the parameter in-place. It would normally be called via ParameterSet.sample() which is responsible for copying this instance first.


constant (bool) – If True, time series will be perturbed by a single constant offset. If False, an different perturbation will be applied to each time specific value independently.

Return type


smooth(tvec, method='smoothinterp', pop_names=None, **kwargs)[source]

Smooth the parameter’s time values

Normally, Parameter instances contain temporally-sparse values from the databook. These are then interpolated to get the input parameter values at all model time points. The default interpolation is linear. However, sometimes it may be desired to make specific assumptions about the parameter value at intermediate times. These could be added directly to the Parameter’s underlying TimeSeries.

This method applies a smoothing method to the Parameter, modifying the underlying TimeSeries in-place. The operation is

  • Interpolated or smoothed values are generated for the requested times

  • All existing time points between and including the minimum and maximum values of tvec are removed

  • The time values generated in this function are inserted

For example, to apply pchip interpolation to generate intermediate values

>>> Parameter.smooth(P.settings.tvec, method='pchip',**kwargs)

As this goes through TimeSeries.interpolate the same rules apply for the conditions under which the interpolation function gets used - specifically, interpolation is used if there are at least two finite time values present, otherwise, the assumption or single value will be used.

  • tvec – New time points to add to the TimeSeries

  • method – Method for generation of smoothed/interpolated values, default uses sciris smoothinterp

  • pop_names – Optionally specify a list of populations to modify

  • kwargs – Optionally pass arguments to the generating function/class constructor