atomica.parameters.ParameterSet¶
- class atomica.parameters.ParameterSet(framework, data, name='default')[source]¶
Bases:
NamedItem
Collection of model parameters to run a simulation
A ParameterSet contains a collection of Parameters required to run the simulation. The parameters contain scale factors used for calibration, so often a project will contain multiple ParameterSets corresponding to different calibrations.
Although parameters are constructed from ProjectData, there are two key differences
The ParameterSet contains calibration scale factors
The ParameterSet expands transfers and interactions into per-population parameters so they are stored on an equal basis (whereas ProjectData segregates them in
TimeDependentValuesEntry
andTimeDependentConnections
due to the difference in how they are formatted in the databook
- Parameters:
framework – A
ProjectFramework
instancedata – A
ProjectData
instancename – Optionally specify the name of the parset
NamedItem constructor
A name must be a string
- Parameters:
name –
Attributes
Return y-values in a dictionary
Methods
Return an iterator over all Parameters
Return y-values in a spreadsheet
copy
Retrieve parameter instance
Load calibration y-factors
Return a sampled copy of the ParameterSet
Save y-values to file
- all_pars()[source]¶
Return an iterator over all Parameters
This is useful because transfers and interaction
Parameter
instances are stored in nested dictionaries, so it’s not trivial to iterate over all of them.- Returns:
Generator over all
Parameter
instances contained in theParameterSet
- calibration_spreadsheet()[source]¶
Return y-values in a spreadsheet
Note that the tabular structure contains missing entries for any interactions that don’t exist (e.g. due to missing population types) - these can be identified with
pd.isna
- Return type:
- Returns:
Spreadsheet containing y-factors in tabular form
- get_par(name, pop=None)[source]¶
Retrieve parameter instance
The parameter values for interactions and transfers are stored keyed by the source/from population. Thus, if the quantity name is an interaction or transfer, it is also necessary to specify the source population in order to return a
Parameter
instance.
- load_calibration(spreadsheet)[source]¶
Load calibration y-factors
This function reads a spreadsheet created by
ParameterSet.save_calibration()
and inserts the y-factors. It is permissive in thatIf y-factors are present in the spreadsheet and not in the
ParameterSet
then they will be skippedIf y-factors are missing in the spreadsheet, the existing values will be maintained
- Parameters:
spreadsheet (
Spreadsheet
) –- Return type:
- Returns:
- sample(constant=True)[source]¶
Return a sampled copy of the ParameterSet
- Parameters:
constant – 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.
- Returns:
A new
ParameterSet
with perturbed values
- save_calibration(fname)[source]¶
Save y-values to file
- Parameters:
fname –
str
orPath
specifying location of file to save- Return type:
- property y_factors: dict¶
Return y-values in a dictionary
Note that any missing populations reflect population types. For example, the dictionary for a parameter in one population type will not contain any entries for populations that belong to another type
- Returns:
Dictionary keyed by
(par, pop)
containing a dict of y-values