snowdrop.src.utils package¶
Submodules¶
snowdrop.src.utils.compareResults module¶
Created on Tue Jun 12 18:50:05 2018 Compares results of a baseline and an alternative scenarios runs. @author: agoumilevski
- snowdrop.src.utils.compareResults.compare(scenarios, output_variables=None, var_names=None, legend=None, sizes=[2, 3], b=False, Tmax=10000000000.0)[source]¶
Compare results.
- snowdrop.src.utils.compareResults.plot(dfs, header='', output_variables=None, var_names=None, b=False, legend=None, sizes=[2, 3])[source]¶
Plot 1D graphs.
- Parameters:
- param dfs:
List of Dataframe objects.
- type dfs:
list.
- param header:
Y axis label.
- type header:
str.
- param output_variables:
Output variables.
- type output_variables:
List.
- param output_variables:
Variables names.
- type output_variables:
List.
- returns:
snowdrop.src.utils.d2s module¶
- class snowdrop.src.utils.d2s.D2S[source]¶
Bases:
object
Declare member variables.
- N_backward = -1¶
- N_forward = -1¶
- N_static = -1¶
- meas_variables = None¶
- shock_variables = None¶
- systemid = None¶
- variables = None¶
snowdrop.src.utils.db module¶
Created on Fri Apr 20 18:59:56 2018
@author: agoumilevski
- snowdrop.src.utils.db.create_connection(dbfilename)[source]¶
Create a database connection to the SQLite database specified by the dbfilename.
- Parameters:
- param dbfilename:
Path to db file.
- type dbfilename:
str.
- return:
Connection object or None
- snowdrop.src.utils.db.create_sqlitefile(dbfilename, variable_names)[source]¶
Create Python sqlite database file.
- Parameters:
- param dbfilename:
Path to database file.
- type dbfilename:
str.
- param variable_names:
Variables names.
- type variable_names:
List.
- return:
Connection object or None
- snowdrop.src.utils.db.get_data(dbfilename, dt=None)[source]¶
Execute query for a specific date or all dates if date is not specified
- Parameters:
- param dbfilename:
Path to db file.
- type dbfilename:
str.
- param dt:
Date time.
- type dt:
Datetime.
- return:
Results of query execution or None
- snowdrop.src.utils.db.insert_values(conn, values, dates=None)[source]¶
Take a db connection and an array of values and inserts these values into sqlite file.
- Parameters:
- param conn:
sqlite connection object.
- type conn:
Connection.
- param values:
Variables values.
- type values:
List.
- param dates:
List of dates.
- type dates:
List.
- return:
Connection object or None
snowdrop.src.utils.decorators module¶
Created on Tue Jul 13 09:52:57 2021
@author: Alexei Goumilevski
- snowdrop.src.utils.decorators.count_calls(func)[source]¶
Decorator that counts the number of times a function is called.
- snowdrop.src.utils.decorators.deprecated(func)[source]¶
This is a decorator which can be used to mark functions as deprecated.
- snowdrop.src.utils.decorators.repeat(_func=None, *args, num_times=2)[source]¶
Repeat decorator.
If name has been called without arguments, the decorated function will be passed in as _func. If it has been called with arguments, then _func will be None, and some of the keyword arguments may have been changed from their default values. The * in the argument list means that the remaining arguments can’t be called as positional arguments.
- Parameters:
- _funcfunction object, optional
Repeats function executions. The default is None.
- argsArguments
Function arguments.
- num_timesint, optional
Number of times to reprat fuction calls. The default is 2.
- Returns:
decorator_repeat function
snowdrop.src.utils.distributions module¶
Created on Sun May 2 19:43:41 2021
@author: alexei
- class snowdrop.src.utils.distributions.StructDist(laws)[source]¶
Bases:
StructDist
Distribution with structured arrays as inputs and outputs.
- snowdrop.src.utils.distributions.compute_prior_mode(hyperparameters, distr)[source]¶
This function computes the mode of the prior distribution given the (two, three or four) hyperparameters of the prior distribution.
- INPUTS
hyperparameters [double] 1*n vector of hyper parameters.
- OUTPUTS
m [double] scalar or 2*1 vector, the prior mode.
note: [1] The size of the vector of hyperparameters is 3 when the Gamma or Inverse Gamma is shifted and 4 when
the support of the Beta distribution is not [0,1].
[2] The hyperparameters of the uniform distribution are the lower and upper bounds. [3] The uniform distribution has an infinity of modes. In this case the function returns the prior mean. [4] For the beta distribution we can have 1, 2 or an infinity of modes.
- snowdrop.src.utils.distributions.getHyperParameters(distr, mean, std, x0=(0.5, 0.5), lb=0, ub=1)[source]¶
Return hyper-parameters given distribution mean and variance.
normal_pdf,lognormal_pdf,beta_pdf,gamma_pdf,t_pdf,weibull_pdf,inv_gamma_pdf,inv_weibull_pdf,wishart_pdf,inv_wishart_pdf
- snowdrop.src.utils.distributions.getMcParameter(name, distr, params)[source]¶
Return parameter of a distribution.
- Parameters:
- namestr.
Name of parameter.
- distrstr.
Shape of distribution.
- xfloat.
Value of variable.
- paramslist.
Parameters of distribution.
- Returns:
pmc3 parameter.
- snowdrop.src.utils.distributions.getParticleParameter(distr, params)[source]¶
Return parameter of a distribution.
- Parameters:
- namestr.
Name of parameter.
- distrstr.
Shape of distribution.
- xfloat.
Value of variable.
- paramslist.
Parameters of distribution.
- Returns:
Particles parameter.
- snowdrop.src.utils.distributions.inverse_gamma_pdf(x, a, b)[source]¶
Calculate inverse gamma probability density function.
Returns the inverse gamma probability density function with shape and scale parameters a and b, respectively, at the values in x.
- Parameters:
- xfloat
Input value.
- afloat
Shape parameter.
- bfloat
Scale parameter.
- Returns:
- yfloat
Inverse gamma probability density function.
snowdrop.src.utils.equations module¶
Created on Wed May 16 16:30:50 2018 @author: agoumilevski
- snowdrop.src.utils.equations.aggregateEqs(variables, aggregation, freq, aggr_freq, m_aggr)[source]¶
Build aggregated equations and endogenous variables for M/Q/A frequencies.
- snowdrop.src.utils.equations.check_presence(symb, equations)[source]¶
Check if symbol is defined in equations.
- Parameters:
- symbstr
Symbol.
- equationsstr
Equations.
- Returns:
True if symbol is defined in equations and False otherwise
- snowdrop.src.utils.equations.findVar(txt, line, shocks=[])[source]¶
Parse text string and returns name, value of a variable.
- snowdrop.src.utils.equations.fixEquation(eq)[source]¶
Replace exponent ** operator with power() function.
- Parameters:
- param eq:
Equation.
- type eq:
str.
- snowdrop.src.utils.equations.fixEquations(eqs, endog, params=None, tagBeg='(', tagEnd=')', b=False)[source]¶
Replace curly brackets in lead/lag variables expressions.
Adds new equations and new variables if leads/lags greater than one.
- Parameters:
- param eqs:
List of equations.None
- type eqs:
list.
- param endog:
List of engogenous variables.
- type endog:
list.
- param params:
List of parameters names.
- type params:
list.
- param tagBeg:
The beginning tag of lead/lag variable.
- type tagBeg:
str.
- param tagEnd:
The ending tag of lead/lag variable.
- type tagEnd:
str.
- param b:
- Flag. If False it converts equations to a form that have variable
with leads and lags of no more than one.
- If True it converts equations to a form that have variable
with leads of no more than one and no lags.
- type b:
Bool.
- snowdrop.src.utils.equations.fixExpression(eq)[source]¶
Replace exponent ** operator with power() function.
- Parameters:
- param eq:
Equation.
- type eq:
str.
- snowdrop.src.utils.equations.getColumns(n, m, var, exclRows=None, exclColumns=None)[source]¶
Find columns number for endogenous variables.
- Parameters:
- param m:
Map of variables names and lead/lags values and equations row and column numbers.
- type m:
dict.
- param exclRows:
Rows to exclude.
- type exclRows:
list.
- param exclColumns:
Columns to exclude.
- type exclColumns:
list.
- snowdrop.src.utils.equations.getExogMatrix(eqs, exog)[source]¶
Compute matrix of exogenous variables.
Parameters¶
- eqslist
Equations.
- exoglist
Exogenous variables.
Returns¶
Matrix of exogenous variables.
- snowdrop.src.utils.equations.getForwardBackwardRowsColumns(model)[source]¶
Return row and column numbers of forward and backward endogenous variables.
- snowdrop.src.utils.equations.getIncidenceMap(endog, model=None, eqs=None, tagBeg='(', tagEnd=')')[source]¶
Get maps of variables rows and columns.
- Parameters:
- param model:
Model.
- type model:
Model object.
- param endog:
List of endogenous variables.
- type endog:
list.
- param eqs:
List of equations.
- type eqs:
list.
- param tagBeg:
The beginning tag of lead/lag variable.
- type tagBeg:
str.
- param tagEnd:
The ending tag of lead/lag variable.
- type tagEnd:
str.
- snowdrop.src.utils.equations.getLeadLagIncidence(model)[source]¶
Build lead-lag incidence matrix.
This matrix has three rows and variable number of columns (it is the same as number variables). The first row lists positions of variables in the model equations for lag variables, the second - position of current variables, and the third - position of lead variables.
- Parameters:
- param model:
The Model object.
- type model:
instance of class Model.
- snowdrop.src.utils.equations.getLeadVariables(m, endog)[source]¶
Get a list of lead endogenous variables.
- Parameters:
- param m:
Map of variables names and row and column position in Jacobian matrix.
- type m:
dict.
- param endog:
List of endogenous variables.
- type endog:
list.
- return:
List of lead endogenous variables.
- snowdrop.src.utils.equations.getMap(endog, equations, eqLabels=None)[source]¶
Get dictionary of row numbers as keys, and equation labels and endogenous variables as values.
- Parameters:
- param endog:
Endogenous variables.
- type edog:
list.
- param equations:
Equations.
- type equations:
list.
- param eqLabels:
Equations labels.
- type eqLables:
list.
- return:
Dictionary with rows numbers as keys, and equation label and an array of equation endogenous variables as values.
- snowdrop.src.utils.equations.getMaxLeadAndLag(eq, arr, variables, var_lead={}, var_lag={}, m={}, max_lead=0, min_lag=0, tagBeg=None, tagEnd=None)[source]¶
Return leads and lags and a map of leads and lags of variables in equation.
- Parameters:
- param eq:
Equation.
- type eq:
str.
- param var_lead:
Lead variables.
- type var_lead:
Dictionary.
- param var_lag:
Lag variables.
- type var_lag:
Dictionary.
- param m:
Dictionary of variables frequencies in equations.
- type m:
Dictionary.
- param max_lead:
Initial max lead.
- type max_lead:
int.
- param min_lag:
Initial min lag.
- type min_lag:
int.
- param variables:
List of variables.
- type var_lag:
list.
- return:
Max lead and minimum lag of variables in equation.
- snowdrop.src.utils.equations.getMaxLeadsLags(eqs, variables)[source]¶
Return maximum leads and minimum lags of variables in equations.
- Parameters:
- param eqs:
Model equations.
- type eqs:
list.
- param variables:
List of variables.
- type variables:
list.
- return:
Maximum leads and minimum lags of equations
- snowdrop.src.utils.equations.getRHS(eqs, variables, eqLabels=None, b=True, debug=False)[source]¶
Return right-hand-side of equations.
- Parameters:
- param eqs:
Model equations.
- type eqs:
list.
- param variables:
Endogenous variables.
- type variables:
list.
- param eqLabels:
Labels of equations.
- type eqLabels:
list.
- returns:
Right hand side terms.
- snowdrop.src.utils.equations.getRowsColumns(n1, n2, m, exclRows=None, exclColumns=None)[source]¶
Find rows number and columns number for endogenous variables.
- Parameters:
- param m:
Map of variables names and lead/lags values and equations row and column numbers.
- type m:
dict.
- param exclRows:
Rows to exclude.
- type exclRows:
list.
- param exclColumns:
Columns to exclude.
- type exclColumns:
list.
- snowdrop.src.utils.equations.getStableUnstableVariables(model, debug=True)[source]¶
Return stable and unstable endogenous variables.
- Parameters:
- param model:
Model object.
- type model:
Model.
- returns:
Array of starting values
- snowdrop.src.utils.equations.getStateVariables(eqs, variables, shocks=None, min_lag=None)[source]¶
Return state variables and equations ordering numbers that these state variables belong to.
State variables are variables that appear in equaions at the previous period and possibly at the current period.
- Parameters:
- param eqs:
Model equations.
- type eqs:
list.
- param variables:
List of variables.
- type variables:
list.
- param shocks:
List of shock variables.
- type shocks:
list.
- param min_lag:
Maximum lag of endogenous variables.
- type min_lag:
int.
- return:
State variables and equations numbers.
- snowdrop.src.utils.equations.getTopology(model, tagBeg='(', tagEnd=')')[source]¶
Get maps of variables rows and columns.
- Parameters:
- param model:
The Model object.
- type model:
instance of class Model.
- param tagBeg:
The beginning tag of lead/lag variable.
- type tagBeg:
str.
- param tagEnd:
The ending tag of lead/lag variable.
- type tagEnd:
str.
- snowdrop.src.utils.equations.getTopologyOfVariables(model, tagBeg='(', tagEnd=')')[source]¶
Define different types of endogenous variables.
This function defines topology of variables described in Sebastien Villemot’s paper: “Solving rational expectations model at first order: What Dynare does” Please see https://www.dynare.org/wp-repo/dynarewp002.pdf
- Parameters:
- param model:
The Model object.
- type model:
instance of class Model.
- param tagBeg:
The beginning tag of lead/lag variable.
- type tagBeg:
str.
- param tagEnd:
The ending tag of lead/lag variable.
- type tagEnd:
str.
- snowdrop.src.utils.equations.getVarRowsIncidence(model)[source]¶
Return variables rows incidence.
- Parameters:
- param model:
The Model object.
- type model:
instance of class Model.
- snowdrop.src.utils.equations.getVariablesOrder(model, debug=False)[source]¶
Return stable and unstable endogenous variables.
- Parameters:
- param model:
Model object.
- type model:
Model.
- returns:
Array of starting values
- snowdrop.src.utils.equations.getVariablesRowsAndColumns(lead_lags, rows, columns, include=None, exclude=None)[source]¶
Return equations rows and columns of variables.
- Parameters:
- param lead_lags:
Variables leads and lags.
- type lead_lags:
list.
- param rows:
List of rows.
- type rows:
list.
- param columns:
List of columns.
- type columns:
list.
- param include:
Comma separated list of variables to include.
- type include:
str.
- param exclude:
Comma separated list of variables to exclude.
- type exclude:
str.
- snowdrop.src.utils.equations.get_steady_state_equations(eqs, endog, params, shocks=[], exog=[])[source]¶
Build steady state equations.
Parameters¶
- eqslist
Dynamic equations.
- endoglist
Endogenous variables that exclude added auxillary variables.
- paramslist
Parameters.
- shockslist
Shocks names.
- exoglist
Exogenous variables.
Returns¶
- ss_equationslist.
Transformed equations with removed time subscript.
- snowdrop.src.utils.equations.modifyEquations(eqs, variables)[source]¶
Modify equations so that the new equations do not have lags, but only leads variables.
- Parameters:
- param eqs:
List of equations.
- type eqs:
list.
- param eqs:
List of variables.
- type eqs:
list.
- return:
New equations.
- snowdrop.src.utils.equations.normalizeEq(eq, var)[source]¶
Normalize equation such that it has the form: var = F(var,…).
- snowdrop.src.utils.equations.replaceEq(eq, arr, var, old_var, new_var)[source]¶
Replace variables in equation.
- Parameters:
- param eq:
Equation.
- type eq:
str.
- param arr:
Symbols of an equation.
- type arr:
list.
- param var:
Variable name.
- type var:
str.
- param old_var:
Old variable name.
- type old_var:
str.
- param new_var:
New variable name.
- type new_var:
str.
- return:
New equation.
- snowdrop.src.utils.equations.str2func(var_names, exog_names, param_names, eqtn)[source]¶
Convert string to Python function.
- snowdrop.src.utils.equations.topology(model)[source]¶
Find rows number and columns number for different types of endogenous variables.
- Parameters:
- param model:
The Model object.
- type model:
instance of class Model.
- snowdrop.src.utils.equations.transformEq(eqtn, var, formulas=[], b=None)[source]¶
Replace endogenous variables v in equations as following, v -> v*scale and build steady state equations.
Parameters¶
- eqtnstr
Equation.
- varlist
Endogenous variables.
- formulastr, optional
Formula, for example, percentage change ‘pchy’. The default is None.
- bbool, optional
If True normalize equation, i.e. replace variables lead/lag with var__p/m# substring. The default is None.
Returns¶
New equation and new steady-state equation.
snowdrop.src.utils.getData module¶
Created on Mon Oct 5 11:25:02 2020
@author: AGoumilevski
- snowdrop.src.utils.getData.fetchData(data_sources, meas_df=None, fpath='', freq='AS')[source]¶
Fetch data from database.
- Args:
- data_sourcesstr
Name of the data source.
- meas_dfPandas data Frame
Measurement data to be overwritten.
- fpathstr
Path of the original data file.
- freqstr
Data frequency.
- Returns:
Updated data frame.
- snowdrop.src.utils.getData.getEcosData(series, db='WEO_WEO_PUBLISHED', country=None, freq=None, transform=None)[source]¶
Retrieves ECOS time series.
- Args:
- seriesstr
Series name.
- dbstr, optional
Database name. The default is ‘WEO_WEO_PUBLISHED’.
- countrystr, optional
Country name. The default is ‘WEO_WEO_PUBLISHED’.
- freqstr, optional
Frequency. The default is None.
- Returns:
- dfPandas DataFrame
Time series.
- snowdrop.src.utils.getData.getEdiData(series, db=None, country='111', freq=None, transform=None)[source]¶
Retrieves World Bank time series.
- Args:
- seriesstr
Series name.
- dbstr, optional
Database name. The default is ‘WEO_WEO_PUBLISHED’.
- countrystr, optional
Country name. The default country name is USA.
- Returns:
- dfPandas DataFrame
Time series.
- snowdrop.src.utils.getData.getHaverData(series, db=None, country=None, freq=None, transform=None)[source]¶
Retrieves Haver database time series.
- Args:
- seriesstr
Series name.
- freqstr, optional
Frequency. The default is None.
- Returns:
- dfPandas DataFrame
Time series.
- snowdrop.src.utils.getData.getWorldBankData(series, db=None, country='111', freq=None, transform=None)[source]¶
Retrieves World Bank time series.
- Args:
- seriesstr
Series name.
- dbstr, optional
Database name. The default is ‘WEO_WEO_PUBLISHED’.
- countrystr, optional
Country name. The default country name is USA.
- Returns:
- dfPandas DataFrame
Time series.
snowdrop.src.utils.getDynareData module¶
- snowdrop.src.utils.getDynareData.getDynareModel(fpath, calibration, options={}, use_cache=False, debug=False)[source]¶
Reads Dynare model file and instantiates this model.
- Args:
- fpathstr.
Path to Iris model file.
- calibrationdict.
Map with values of calibrated parameters and starting values of endogenous variables.
- optionsdict, optional
Dictionary of options. The default is empty dictionary object.
- use_cachebool, optional
If True reads previously saved model from a file of model dump.
- debugbool, optional
If set to True prints information on Iris model file sections. The default is False.
- Returns:
- modelModel.
Model object.
snowdrop.src.utils.getIrisData module¶
- snowdrop.src.utils.getIrisData.emulateModelLanguageOperators(equation, operator)[source]¶
Emulate IRIS modelling language special operators like movavg(expr,n) for n-period moving average
- snowdrop.src.utils.getIrisData.getIrisModel(fpath, calibration={}, options={}, conditions={}, use_cache=False, tag_variables=['!variables', '!transition_variables'], tag_shocks=['!shocks', '!transition_shocks'], tag_parameters='!parameters', tag_equations=['!equations', '!transition_equations'], tag_measurement_variables='!measurement_variables', tag_measurement_equations='!measurement_equations', tag_measurement_shocks='!measurement_shocks', check=True, debug=False)[source]¶
Reads Iris model file and instantiates this model.
- Args:
- fpathstr.
Path to Iris model file.
- calibrationdict.
Map with values of calibrated parameters and starting values of endogenous variables.
- optionsdict, optional
Dictionary of options. The default is empty dictionary.
- conditionsdict, optional
Choose block of code based on logical condition. The default is empty list.
- use_cachebool, optional
If True reads previously saved model from a file of model dump.
- tag_variableslist, optional
Tag for endogenous variables section. The default is “!transition_variables”.
- tag_shocksstr, optional
Tag for shock variables section. The default is “!transition_shocks”.
- tag_parametersstr, optional
Tag for parameters section. The default is “!parameters”.
- tag_equationsTYPE, optional
Tag for equations section. The default is “!transition_equations”.
- tag_measurement_variablesstr, optional
Tag for measurement variables section. The default is “!measurement_variables”.
- tag_measurement_equationsstr, optional
Tag for measurement equations section. The default is “!measurement_equations”.
- debugbool, optional
If set to True prints information on Iris model file sections. The default is False.
- Returns:
Model object.
- snowdrop.src.utils.getIrisData.handleDiffLogOperator(n, expr)[source]¶
Handles IRIS difference of log operator.
- snowdrop.src.utils.getIrisData.handleDiffOperator(n, expr)[source]¶
Handles IRIS difference operator.
- snowdrop.src.utils.getIrisData.handleMovingAverageOperator(n, expr)[source]¶
Handles IRIS moving average operator.
- snowdrop.src.utils.getIrisData.handleMovingSumOperator(n, expr)[source]¶
Handles IRIS moving sum operator.
- snowdrop.src.utils.getIrisData.readIrisModelFile(file_path, conditions={}, bFillValues=True, strVariables=['!variables', '!transition_variables'], strShocks=['!shocks', '!transition_shocks'], strParameters='!parameters', strEquations=['!equations', '!transition_equations'], strMeasurementVariables='!measurement_variables', strMeasurementEquations='!measurement_equations', strMeasuarementShocks='!measurement_shocks', strLegend='legend')[source]¶
Read IRIS model file.
snowdrop.src.utils.getTemplateData module¶
snowdrop.src.utils.getYamlData module¶
- snowdrop.src.utils.getYamlData.getYamlModel(fpath, calibration={}, labels={}, options={}, use_cache=False, debug=False)[source]¶
Reads Yaml model file and instantiates this model.
- Args:
- fpathstr.
Path to Iris model file.
- calibrationdict.
Map with values of calibrated parameters and starting values of endogenous variables.
- optionsdict, optional
Dictionary of options. The default is empty dictionary object.
- use_cachebool, optional
If True reads previously saved model from a file of model dump.
- debugbool, optional
If set to True prints information on Iris model file sections. The default is False.
- Returns:
- modelModel.
Model object.
- snowdrop.src.utils.getYamlData.readYamlModelFile(file_path=None, strVariables='variables', strMeasVariables='measurement_variables', strMeasShocks='measurement_shocks', strShocks='shocks', strParameters='parameters', strEquations='equations', strCalibration='calibration', strOptions='options', strExogenous='exogenous', strValues='values', strRange='range', strFrequency='frequency', strLabels='labels')[source]¶
Parse YAML model file.
snowdrop.src.utils.grids module¶
- class snowdrop.src.utils.grids.EmptyGrid[source]¶
Bases:
Grid
- property n_nodes¶
- property nodes¶
- type = 'empty'¶
- class snowdrop.src.utils.grids.NonUniformCartesianGrid(list_of_nodes)[source]¶
Bases:
CartesianGrid
- type = 'NonUniformCartesian'¶
- class snowdrop.src.utils.grids.PointGrid(point)[source]¶
Bases:
Grid
- property n_nodes¶
- property nodes¶
- type = 'point'¶
- class snowdrop.src.utils.grids.ProductGrid(g1: T, g2: S, names=None)[source]¶
Bases:
Grid
,Generic
[T
,S
]
- class snowdrop.src.utils.grids.UniformCartesianGrid(min, max, n=[])[source]¶
Bases:
CartesianGrid
- type = 'UniformCartesian'¶
snowdrop.src.utils.html2pdf module¶
Created on Sat Jun 19 12:00:24 2021
@author: alexei
snowdrop.src.utils.interface module¶
Created on Tue May 15 11:58:35 2018 @author: agoumilevski
This module replicates some TROLL functionality. In TROLL user may load a steady-state and a dynamic models, set starting values of endogenous variables, preform simulations, save results in a database, and plot these results. These operations can be run as a sequence of commands in a terminal window.
snowdrop.src.utils.load module¶
Created on Mon Nov 12 19:27:09 2018
@author: agoumilevski
- snowdrop.src.utils.load.build(indices, categories, txt, out=[], n=0)[source]¶
Recursively iterates thru a list of indices and categories, substitutes an index in a variable name with a corresponding category, and builds a list of new variables.
- Parameters:
- param indices:
List of indeces.
- type indices:
list.
- param categories:
List of categories.
- type categories:
list.
- param txt:
Text.
- type txt:
string.
- param n:
Number of calls.
- type n:
int.
- returns:
list object.
- snowdrop.src.utils.load.buildEquations(sets, equations, variables=[], comments=[])[source]¶
Parse sets and equations and build a list of equations and variables.
- Parameters:
- param sets:
List of categories.
- type sets:
list.
- param equations:
List of equations.
- type equations:
list.
- param variables:
New variables.
- type variables:
list.
- returns:
list object.
- snowdrop.src.utils.load.convert(txt, labels, bEquations=False, substitute=None, conditions={})[source]¶
Convert Dynare/Iris model files to yaml format.
- param txt:
Path to model file
- type txt:
str.
- param labels:
Labels
- type labels:
dict.
- returns:
Converted text
- snowdrop.src.utils.load.getCalibration(fpath, names=None)[source]¶
Parses a model file, and builds a model calibration dictionary object.
- Parameters:
- param fpath:
Path to model files.
- type fpath:
str.
- param names:
Endogenous variables names.
- type names:
str.
- returns:
dict object.
- snowdrop.src.utils.load.loadFile(path, calibration={}, names=[], bShocks=False)[source]¶
Parse a file and populate model’s calibration dictionary.
- Parameters:
- param path:
Path to file.
- type path:
str.
- param calibration:
Map of variables names and values.
- type calibration:
dict.
- param names:
Names of variables.
- type names:
list.
- param bShocks:
True if loading shocks values file and False otherwise.
- type bShocks:
bool.
- returns:
dictionary object.
- snowdrop.src.utils.load.loadTimeSeries(path, dates=None)[source]¶
Parse a file and create a time series object.
- Parameters:
- param path:
Path to file.
- type path:
str.
- param dates:
Dates.
- type dates:
date.
- returns:
Time series object.
- snowdrop.src.utils.load.loadYaml(path, txt)[source]¶
Parses a model file, resolves reference to files and parses these files, and builds a model dictionary object.
- Parameters:
- param path:
Path to model files.
- type path:
str.
- param txt:
Text of model file.
- type txt:
str.
- returns:
dict object.
- snowdrop.src.utils.load.modifyEquation(eq, m, arr)[source]¶
Replace variables in equations.
- param eq:
Equation
- type eq:
str
- param m:
Dictionary of original and modified variables
- type m:
dict
- param arr:
Variables
- type arr:
list
- returns:
Modified equation
- snowdrop.src.utils.load.parseIfStatements(eqs, conditions={})[source]¶
Preparse @#if, @#else, @#endif directives
- param eqs:
Equations
- type eqs:
list.
- param conditions:
Directives
- type conditions:
dict.
- returns:
Preparsed list of equations
- snowdrop.src.utils.load.read_file_or_url(url, labels={}, conditions={})[source]¶
Returns content of file or url.
- param url:
Path to file or URL address.
- type url:
str.
- returns:
File or URL content.
- snowdrop.src.utils.load.sortIndex(sets, variables)[source]¶
Sorts variables by category.
- Parameters:
- param sets:
List of categories.
- type sets:
list.
- param variables:
New variables.
- type variables:
list.
- returns:
sorted list.
- snowdrop.src.utils.load.substitute(variables, keyWords, subst={})[source]¶
Replaces variables names that belong to the key words in Python.
- param variables:
Path to file or URL address.
- type variables:
str.
- param keyWords:
Path to file or URL address.
- type keyWords:
str.
- returns:
variable name appended with underscore.
snowdrop.src.utils.merge module¶
Created on Tue Dec 12 19:30:31 2017 @author: agoumilevski
This module merges PDF files
Usage: merge -output Output_File -files Comma_Separated_List
snowdrop.src.utils.merge2 module¶
Created on Tue Dec 12 19:30:31 2017
@author: agoumilevski
This module merges PDF files
Usage: merge -output Output_File -dir directory -files Comma_Separated_List -titles Comma_Separated_List -footnotes Comma_Separated_List -scale Comma_Separated_List
- snowdrop.src.utils.merge2.createPdfs(text, header=True)[source]¶
Create a pdf object with multiple pages.
snowdrop.src.utils.prettyTable module¶
- class snowdrop.src.utils.prettyTable.PrettyTable(field_names=None, **kwargs)[source]¶
Bases:
object
- add_column(fieldname, column, align='c', valign='t')[source]¶
Add a column to the table.
- Args:
- fieldname
name of the field to contain the new column of data
- column
column of data, should be a list with as many elements as the table has rows
- align
desired alignment for this column - “l” for left, “c” for centre and “r” for right
- valign
desired vertical alignment for new columns - “t” for top, “m” for middle and “b” for bottom.
- add_row(row)[source]¶
Add a row to the table
- Args:
- row
row of data, should be a list with as many elements as the table has fields.
- property align¶
- property attributes¶
A dictionary of HTML attribute name/value pairs to be included in the <table> tag when printing HTML
- Args:
- attributes
dictionary of attributes.
- property border¶
Controls printing of border around table
- Args:
- border
print a border around the table (True or False)
- clear()[source]¶
Delete all rows and field names from the table, maintaining nothing but styling options
- del_row(row_index)[source]¶
Delete a row to the table
- Args:
- row_index
The index of the row you want to delete. Indexing starts at 0.
- property end¶
End index of the range of rows to print
- Args:
- end:
index of last data row to include in output PLUS ONE (list slice style).
- property field_names¶
- property fields¶
List or tuple of field names to include in displays
- Args:
- fields
list or tuple of field names to include in displays.
- property float_format¶
Controls formatting of floating point data.
- Args:
- float_format :
floating point format string.
- property format¶
Controls whether or not HTML tables are formatted to match styling options
- Args:
- format
True or False.
- get_html_string(**kwargs)[source]¶
Return string representation of HTML formatted version of table in current state.
- Args:
- start
index of first data row to include in output
- end
index of last data row to include in output PLUS ONE (list slice style)
- fields
names of fields (columns) to include
- header
print a header showing field names (True or False)
- border
print a border around the table (True or False)
- hrules
controls printing of horizontal rules after rows. Allowed values: ALL, FRAME, HEADER, NONE
- vrules
controls printing of vertical rules between columns. Allowed values: FRAME, ALL, NONE
- int_format
controls formatting of integer data
- float_format
controls formatting of floating point data
- padding_width
number of spaces on either side of column data (only used if left and right paddings are None)
- left_padding_width
number of spaces on left hand side of column data
- right_padding_width
number of spaces on right hand side of column data
- sortby
name of field to sort rows by
- sort_key
sorting key function, applied to data points before sorting
- attributes
dictionary of name/value pairs to include as HTML attributes in the <table> tag.
- get_string(**kwargs)[source]¶
Return string representation of table in current state.
- Args:
- start
index of first data row to include in output
- end
index of last data row to include in output PLUS ONE (list slice style)
- fields
names of fields (columns) to include
- header
print a header showing field names (True or False)
- border
print a border around the table (True or False)
- hrules
controls printing of horizontal rules after rows. Allowed values: ALL, FRAME, HEADER, NONE
- vrules
controls printing of vertical rules between columns. Allowed values: FRAME, ALL, NONE
- int_format
controls formatting of integer data
- float_format
controls formatting of floating point data
- padding_width
number of spaces on either side of column data (only used if left and right paddings are None)
- left_padding_width
number of spaces on left hand side of column data
- right_padding_width
number of spaces on right hand side of column data
- vertical_char
single character string used to draw vertical lines
- horizontal_char
single character string used to draw horizontal lines
- junction_char
single character string used to draw line junctions
- sortby
name of field to sort rows by
- sort_key
sorting key function, applied to data points before sorting
- reversesort
True or False to sort in descending or ascending order.
- property header¶
Controls printing of table header with field names
- Args:
- header
print a header showing field names (True or False).
- property header_style¶
Controls stylisation applied to field names in header
- Args:
- header_style
stylisation to apply to field names in header (“cap”, “title”, “upper”, “lower” or None)
- property horizontal_char¶
The charcter used when printing table borders to draw horizontal lines
- Args:
- horizontal_char
single character string used to draw horizontal lines.
- property hrules¶
Controls printing of horizontal rules after rows
- Args:
- hrules
horizontal rules style. Allowed values: FRAME, ALL, HEADER, NONE
- property int_format¶
Controls formatting of integer data
- Args:
- int_format
integer format string
- property junction_char¶
The charcter used when printing table borders to draw line junctions
- Args:
- junction_char
single character string used to draw line junctions.
- property left_padding_width¶
The number of empty spaces between a column’s left edge and its content
- Args:
- left_padding
number of spaces, must be a positive integer.
- property max_width¶
- property padding_width¶
The number of empty spaces between a column’s edge and its content
- Args:
- padding_width
number of spaces, must be a positive integer.
- property reversesort¶
Controls direction of sorting (ascending vs descending)
- Args:
- reveresort
set to True to sort by descending order, or False to sort by ascending order
- property right_padding_width¶
The number of empty spaces between a column’s right edge and its content
- Args:
- right_padding
number of spaces, must be a positive integer.
- property sort_key¶
Sorting key function, applied to data points before sorting
- Args:
- sort_key
a function which takes one argument and returns something to be sorted.
- property sortby¶
Name of field by which to sort rows
- Args:
- sortby:
field name to sort by.
- property start¶
Start index of the range of rows to print
- Args:
- start
index of first data row to include in output.
- property valign¶
- property vertical_char¶
The charcter used when printing table borders to draw vertical lines
- Args:
- vertical_char
single character string used to draw vertical lines.
- property vrules¶
Controls printing of vertical rules between columns
- Args:
- vrules
vertical rules style. Allowed values: FRAME, ALL, NONE
- snowdrop.src.utils.prettyTable.from_html(html_code, **kwargs)[source]¶
Generates a list of PrettyTables from a string of HTML code. Each <table> in the HTML becomes one PrettyTable object.
snowdrop.src.utils.progressbar module¶
- snowdrop.src.utils.progressbar.progress_bar(iters)[source]¶
Simulation progress bar.
A simple progress bar to monitor MCMC sampling progress. Modified from original code by Corey Goldberg (2010).
- Args:
iters (
int
): Number of iterations in simulation.
Example display:
[-------- 21% ] 2109 of 10000 complete in 0.5 sec
Note
Will display a progress bar as simulation runs, providing feedback as to the status of the simulation. Depending on the available resources, the appearance of the progress bar may differ.
snowdrop.src.utils.sortSchur module¶
Python version of the following original work: Title: Sorting Real Schur Forms Author: Jan Brandts E-Mail: brandts-AT-science.uva.nl http://m2matlabdb.ma.tum.de/download.jsp?MC_ID=3&MP_ID=119 http://dx.doi.org/10.1002/nla.274 Institution: University of Amsterdam Description: In Matlab 6, there exists a command to generate a real Schur form, wheras another transforms a real Schur form into a complex one. There do not exist commands to prescribe the order in which the eigenvalues appear on the diagonal of the upper (quasi-) triangular factor T. For the complex case, a routine is sketched in Golub and Van Loan (1996), that orders the diagonal of T according to their distance to a target value. In the reference below, we give a Matlab routine to sort real Schur forms in Matlab. It is based on a block-swapping procedure by Bai and Demmel (1993).
Sorting real Schur forms, both partially and completely, has important applications in the computation of real invariant subspaces. J.H. Brandts Matlab code for sorted real Schur forms Numerical Linear Algebra with Applications 9(3):249-261 (2002) Keywords: Real Schur Form, sorting, Bai-Demmel algorithm, swapping Based on the original Matlab File Version: 1.0
Git: https://gist.github.com/fabian-paul/14679b43ed27aa25fdb8a2e8f021bad5
- snowdrop.src.utils.sortSchur.lu_complpiv(A, overwrite=False)[source]¶
Computes the LU-decomposition of A with complete pivoting, i. e. PAQ=LU, with permutations symbolized by vectors.
- Parameters:
- param A:
- return:
- snowdrop.src.utils.sortSchur.normalize(U, S, v, inplace=False)[source]¶
Applies a Givens rotation such that the two-by-two diagonal block of S situated at diagonal positions v[0], v[1] is in standardized form.
- Parameters:
- param U:
- param S:
- param v:
- return:
- snowdrop.src.utils.sortSchur.rot(X)[source]¶
Computes a Givens rotation needed in normalize
- Parameters:
- param X:
- return:
- snowdrop.src.utils.sortSchur.select(p, z, bOrig=False)[source]¶
Determined which element is next in the ordering.
- Parameters:
- param p:
- param z:
- return:
- snowdrop.src.utils.sortSchur.sort_schur_decomposition(Q, R, z, b, inplace=False)[source]¶
- Parameters:
- param Q:
np.array((N, N)) orthogonal real Q such that AQ=QR
- param R:
np.array((N, N)) quasi-triangular real R such that AQ=QR
- param z:
complex target z in the complex plane if z==float(‘inf’), order eigenvalues decreasingly by magnitude
- param b:
float determines the length of the ordering with respect to z to be produced * if b < 0 then -b blocks will be sorted, * if b > 0 then b or b+1 eigenvalues will be sorted, depending on the sizes of the blocks, * if b = 0 then the whole Schur form will be sorted.
- return:
Q, R, ap
A vector ap warns for inaccuracy of the solution if an entry of ap exceeds one.
- snowdrop.src.utils.sortSchur.swap(U, S, v, w, inplace=False)[source]¶
Swaps the two diagonal blocks at positions symbolized by the entries of v and w.
- Parameters:
- param U:
- param S:
- param v:
- param w:
- return:
- snowdrop.src.utils.sortSchur.swaplist(p, s, z, b)[source]¶
- Produces the list v of swaps of neighboring blocks needed to order the eigenvalues assembled in the vector v
from closest to z to farthest away from z, taking into account the parameter b.
- Parameters:
- param p:
list list of eigenvalues (only one copy for each complex-conjugate pair)
- param s:
list list of the the-top left positions of each block
- param z:
complex target z in the complex plane
- param b:
float determines the length of the ordering with respect to z to be produced * if b < 0 then -b blocks will be sorted, * if b > 0 then b or b+1 eigenvalues will be sorted, depending on the sizes of the blocks, * if b = 0 then the whole Schur form will be sorted.
- return:
snowdrop.src.utils.table module¶
Created on Thu May 2 18:05:37 2019
@author: AGoumilevski
- class snowdrop.src.utils.table.TB(text)[source]¶
Bases:
Flowable
Use bold italic font for a text in a table cell.
- snowdrop.src.utils.table.matrix_to_pdf(headers, colNames, rowNames, matrices, fout)[source]¶
Create a simple pdf document from a two-dimensional array.
- Parameters:
- param header:
Header of a table.
- type header:
str.
- param colNames:
Names of table columns.
- type colNames:
list.
- param rowNames:
Names of table rows.
- type rowNames:
list.
- param matrices:
Two dimensional matrix.
- type matrices:
np.array.
- param table_rng:
Range of dates.
- type table_rng:
list.
- param fout:
Path to pdf document.
- type fout:
str.
- returns:
Simulation results.
- snowdrop.src.utils.table.table_to_pdf(header, colNames, rowNames, matrix, table_rng, fout, date=None)[source]¶
Create a pdf document from a two-dimensional matrix.
- Parameters:
- param header:
Header of a table.
- type header:
str.
- param colNames:
Names of table columns.
- type colNames:
list.
- param rowNames:
Names of table rows.
- type rowNames:
list.
- param matrix:
Two dimensional matrix.
- type matrix:
np.array.
- param table_rng:
Range of dates.
- type table_rng:
list.
- param fout:
Path to pdf document.
- type fout:
str.
- param date:
Date at which vertical line in a table is drawn.
- type date:
datetime.date.
- returns:
Simulation results.
snowdrop.src.utils.util module¶
- class snowdrop.src.utils.util.Encoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶
Bases:
JSONEncoder
- default(obj)[source]¶
Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
- class snowdrop.src.utils.util.MyDict(*args, **kwargs)[source]¶
Bases:
dict
Dictionary class with keys diagnostics.
- snowdrop.src.utils.util.Output(b, file_path, description, variables_names, shock_names, new_param_names, eqs, param_names, param_values, exog_var, variables_init_values, time_range, freq, periods, shock_values, param_range, eqsLabels=[], varLabels={}, comments=[], bInp=False)[source]¶
Output text to YAML model file.
- snowdrop.src.utils.util.SaveToYaml(file=None, description='YAML Model', shock_names=[], shock_values=[], variables_names=[], variables_init_values=[], param_names=[], param_values=[], exog_var=[], equations=[], varLabels={}, eqsLabels=[], comments=None, time_range='', freq='0', periods='', param_range='', bInp=False)[source]¶
Write GUI form data to YAML template text file.
- Parameters:
- param file:
Path to output yaml file.
- type file:
str.
- param description:
Description of model.
- type description:
str.
- param shock_names:
List of shock names.
- type shock_names:
List.
- param shock_values:
List of shock values.
- type shock_values:
List.
- param variables_names:
Variables names.
- type variables_names:
List.
- param variables_init_values:
Initial values of variables.
- type variables_init_values:
List.
- param param_names:
Names of parameters.
- type param_names:
List.
- param param_values:
Values of parameters.
- type param_values:
List.
- param exog_var:
Exogenous variables.
- type exog_var:
List.
- param equations:
Model equations.
- type equations:
List.
- param varLabels:
Variables labels.
- type varLabels:
List.
- param eqsLabels:
Equations labels.
- type eqsLabels:
List.
- param comments:
Equations comments.
- type comments:
List.
- param time_range:
Time range.
- type time_range:
str.
- param freq:
Frequency of time series.
- type freq:
str.
- param periods:
Periods in which shocks are applied.
- type periods:
List.
- param param_range:
Range of parameters.
- type param_range:
List.
- param bInp:
Flag that is used to indicate that a steady-state and a dynamic models should be generated.
- type bInp:
bool.
- snowdrop.src.utils.util.compare(save, fnames, legends)[source]¶
Compare time series in two excel files.
- snowdrop.src.utils.util.compareTrollFiles(fpath1, fpath2)[source]¶
Compare steady state values in two excel files.
- snowdrop.src.utils.util.correctHeaderOfCsvFile(fin, fout)[source]¶
Correct header of Csv files so that names of variables are consistent with names of variables of Fame reports.
- snowdrop.src.utils.util.correctLabel(lbl)[source]¶
Correct a variable name.
For example, variable name x_minus_1 will be changed to x(-1)
- snowdrop.src.utils.util.correctVariablesNames(variable_names)[source]¶
Correct names of FSGM model variables so that they are consistent with names of variables of Fame reports.
- snowdrop.src.utils.util.create_config_file(T, variables_names, initial_values, shock_names, shock_values, parameters_names, parameters_values, options)[source]¶
Create files with data fot initial endogenous variables value, parameters and shock values.
These files are created when model option GENERATE_CPP_CODE is set to True.
- Parameters:
- Tint.
Number of time steps.
- variables_nameslist.
Names of endogenous variables.
- variables_nameslist.
Names of endogenous variables.
- initial_valuesnumpy array.
Initial values of endogenous variables.
- shock_nameslist.
Names of shock variables.
- shock_valueslist.
Shocks values.
- parameters_nameslist.
Names of model parameters.
- parameters_valuesnumpy array.
Parameters values.
- shocksdictionary.
Model options.
- Returns:
None.
- snowdrop.src.utils.util.deleteFiles(path_to_dir, pattern)[source]¶
Delete files in a directory matching a pattern.
- snowdrop.src.utils.util.findVariableLag(x)[source]¶
Find lag of a variable given its name.
- Parameters:
- param x:
Variable name.
- type x:
str.
- return:
Lag of a variable.
- snowdrop.src.utils.util.findVariableLead(x)[source]¶
Find lead of a variable given its name.
- Parameters:
- param x:
Variable name.
- type x:
str.
- return:
Lead of a variable.
- snowdrop.src.utils.util.getExogenousSeries(model, debug=False)[source]¶
Convert exogenous series to 2D array.
- Parameters:
- param model:
Model object.
- type model:
Model.f
- return:
Pandas data frame.
- snowdrop.src.utils.util.getMap(file_path)[source]¶
Return map of model variable names to report variable names.
- snowdrop.src.utils.util.getNamesValues(arr)[source]¶
Return list of names and values.
- Parameters:
- param arr:
Array
- type arr:
List.
- return:
Variables names and values
- snowdrop.src.utils.util.getPeriods(model, T, rng=None)[source]¶
Return list of periods.
- Parameters:
- param model:
Model object.
- type model:
Model.
- param T:
Time span of simulations.
- type T:
int.
- return:
List of periods.
- snowdrop.src.utils.util.getVariableValue(eqs: list, v: str, var_names: list, m: dict) float [source]¶
Replaces variables in STEADY_STATE function with values.
- Parameters:
- eqslist
Equations.
- vstr
Name of a variable.
- var_nameslist
List of variables names.
- mdict
Map of varaiables names and values.
- Returns:
Value of a variable.
- snowdrop.src.utils.util.importModel(file_path, startDate, endDate, shocks=None)[source]¶
Write GUI form data to YAML template text file.
- Parameters:
- param file_path:
Path to output yaml file.
- type file_path:
str.
- param startDate:
Start date of simulation.
- type startDate:
str.
- param endDate:
End date of simulation.
- type endDate:
str.
- param shocks:
Dictionary of dates and corresponding shocks.
- type shocks:
dict.
- return:
Model object.
- snowdrop.src.utils.util.isPositiveDefinite(B)[source]¶
Return true when input is positive-definite, via Cholesky.
- snowdrop.src.utils.util.nearestPositiveDefinite(A)[source]¶
Find the nearest positive-definite matrix to input.
A Python/Numpy port of John D’Errico’s nearestSPD MATLAB code [1], which credits [2].
Referemces:
[1] https://www.mathworks.com/matlabcentral/fileexchange/42885-nearestspd
[2] N.J. Higham, “Computing a nearest symmetric positive semidefinite matrix” (1988): https://doi.org/10.1016/0024-3795(88)90223-6
- snowdrop.src.utils.util.read(fname=None, Output=True)[source]¶
Read data either from a database or an excel file based on file name extension.
- Parameters:
- param fname:
Path to input file.
- type fname:
str.
- param Output:
Boolean variable.
- type Output:
bool.
- snowdrop.src.utils.util.readDataFromDatabase(fname=None, Output=True)[source]¶
Read data from database.
- Parameters:
- param fname:
Path to input file.
- type fname:
str.
- param Output:
Boolean variable.
- type Output:
bool.
- returns:
rows and column names from database.
- snowdrop.src.utils.util.readDataFromExcel(fname=None, Output=True)[source]¶
Read data from excel file.
- Parameters:
- param fname:
Path to input file.
- type fname:
str.
- param Output:
Boolean variable.
- type Output:
bool.
- snowdrop.src.utils.util.read_and_combine_text(fpath: str, _if_='!if', _else_='!else', _end_='!end', _import_='!import', transition_variables='!transition_variables', transition_shocks='!transition_shocks', measurement_variables='!measurement_variables', measurement_shocks='!measurement_shocks', parameters='!parameters', transition_equations='!transition_equations', measurement_equations='!measurement_equations', stop='!stop', Legend='Legend', conditions: dict = None, debug=False) str [source]¶
Combine separate parts of file text.
- snowdrop.src.utils.util.replaceExpressions(eqs: list, m: dict) list [source]¶
Replaces variables in STEADY_STATE function with values.
- Parameters:
- eqslist
Equations.
- mdict
Map of varaiables names and values.
- Returns:
Equations with replaced steady state values.
- snowdrop.src.utils.util.save(fname, data, variable_names, dates=None)[source]¶
Save results either to a database or to an excel file based on file name extension.
- Parameters:
- param fname:
The path to output file.
- type fname:
str.
- param data:
The 2D array of data.
- type data:
array.
- param variable_names:
List of output variables names.
- type variable_names:
list.
- param dates:
List of dates.
- type dates:
list.
- snowdrop.src.utils.util.saveLeadLagIncidence(lli, isLinearModel)[source]¶
Store lead lag incidence matrix in a file.
If model is non-linear delete the lead lag incidence file.
- Parameters:
- llinumpy.array
Matrix of variables leads and lags.
- isLinearModelbool
True if model is linear and False otherwise.
- Returns:
None.
- snowdrop.src.utils.util.saveScenariosToExcel(fname, scenarios, par_values, variables_names, variables_labels, output_variables=None, par_names=None, rng=None)[source]¶
Save results to excel file.
- Parameters:
- param fname:
Path to output excel file.
- type fname:
str.
- type scenarios:
Scenarios.
- param scenarios:
list.
- type par_values:
Data array.
- param par_values:
list.
- param variables_names:
Variables names.
- type variables_names:
list.
- param output_variables:
List of output variables names.
- type output_variables:
list.
- param par_names:
List of parameters names.
- type par_names:
list.
- param rng:
List of dates.
- type rng:
list.
- snowdrop.src.utils.util.saveTimeSeries(fname, data, sheetName='Sheet1', variables=None, prefix='', postfix='')[source]¶
Save time series to excel file.
- Parameters:
- param fname:
Path to output excel file.
- type fname:
str.
- param data:
Data.
- type data:
pd.Series, list, dict.
- snowdrop.src.utils.util.saveToDatabase(dbfilename, data, columns, dates=None)[source]¶
Save data to Python sqlite database.
- Parameters:
- param dbfilename:
Path to output sqlite database file.
- type fname:
str.
- param data:
The 2D array of data.
- type data:
array.
- param columns:
List of output variables names.
- type columns:
list.
- param dates:
List of dates.
- type dates:
list.
- snowdrop.src.utils.util.saveToExcel(fname, data, par_values, variable_names, var_labels={}, output_variables=None, par_names=None, rng=None, Npaths=1)[source]¶
Save results to excel file.
- Parameters:
- param fname:
Path to output excel file.
- type fname:
str.
- type data:
Data array.
- param data:
numpy.array.
- type par_values:
Parameters values.
- param par_values:
list.
- param variable_names:
Variables names.
- type variable_names:
list.
- param var_labels:
Variables labels.
- type var_labels:
list.
- param variable_names:
Variables names.
- type variable_names:
list.
- param output_variables:
List of output variables names.
- type output_variables:
list.
- param par_names:
List of parameters names.
- type par_names:
list.
- param rng:
List of dates.
- type rng:
list.
- param Npaths:
Number of simulation paths.
- type Npaths:
int.