UGParameterEstimator.dataanalysis package
Submodules
UGParameterEstimator.dataanalysis.result module
- class UGParameterEstimator.dataanalysis.result.Result(filename=None)
Bases:
objectThis class saves all data created during the calibration process. This includes temporary results of the optimization algorithm (here called metrics, stored every iteration) logging entries, metadata (additional data stored for the whole optimization process) and evaluations.
Arbitrary metrics and metadata fields can be added using the respecitive methods. they are stored a key-value-pairs. Only requirement is that they need to be picklable
If a filename is specified, the results object will be saved whenever new data is available.
- Parameters
filename (string, optional) – filename to save. if a path is specified, the directories will be create if not yet existant.
- addEvaluations(evaluations, tag=None)
Adds evaluations to the current iteration. The evaluations can be tagged with an additional string for later analysis.
- Parameters
evaluations (string) – the evaluations to add
tag (string) – additional tag for this iteration
- addMetric(name, value)
Adds a metric to the current evaluation
- Parameters
name (string) – name of the metric to add
value (any picklable python type) – value for this metric key
- addRunMetadata(name, value)
Adds an object as metadata.
- Parameters
name (string) – the key for this metadata
value (any picklable python type) – value for this metadata key
- commitIteration()
Stores the current iteration to iterations array. If a filename was specified at construction, also saves the results object.
- static getLatexString(number)
Returns a number as a string formatted for usage in latex. This gives the scientific notation with 4 significant digits.
- Parameters
number (number) – the number to convert
- Returns
number formatted for usage in latex.
- Return type
string
- property iterationCount
Returns the number of iterations stored in this object
- Returns
Number of iterations store din this object
- Return type
Integer
- classmethod load(filename, printInfo=True)
Loads a result object stored pickled in a file.
- Parameters
filename (string) – path to the file to load.
printInfo (bool, optional) – print information about the loaded results object (default: true)
- log(text)
Adds an logentry.
The logentry is printed in the process. Logs are addionally written to a separate file “<filename>_log” in plain text format to allow for easier debugging.
- Parameters
text (string) – logtext to add.
- plotComparison(filename, force2d=False)
Saves a latex document plotting a comparison between target data, the evealuation using the initial parameters and the evaluation using the calibrated parameters. This works if the target is a FreeSurfaceTimeDependentEvaluation or a FreeSurfaceEquilibriumEvaluation.
- Parameters
filename (string) – the name of the file the result should be written to
force2d (bool, optional) – In timedependent case: Print the last evaluation for all 3 plots as a 2d plot. If false, 3 3d plots will be printed.
- static plotMultipleRuns(resultnames, outputfilename, log=True, paramnames=None)
Saves a plot describing the optimization success of multiple different optimization runs with the same parameters, starting at different initial values. This uses the tikzpicture latex package in the generated code.
- Parameters
resultnames (array of strings) – paths to the files to load.
outputfilename (string) – filename to save to
log (bool, optional) – use a logarithmic y axis
paramnames (array of string, optional, size has to equal the number of parameters) – optionally override the parameternames using this array of names
- printlog()
Prints all logentries stored in the object.
- save(filename=None)
Saves the results object in pickle format to a file.
- Parameters
filename (string) – filename to save to. if not specified, the filename set when constructing this object will be used.
- writeErrorTable(file)
writes the error data as a latex table. Includes all parameter data for each iteration, standard errors for the parameters, and an estimated confidence interval Only can be used if the errors are stored in the results object (currently only by GaussNewtonOptimizer) :param filename: the name of the file the result should be written to :type filename: string
- writeLatexTable(filename, metrics=[], nameoverride=None)
writes the iteration data as a latex table. Includes all parameter data for each iteration, and optionally metrics stored during the optimization. :param filename: the name of the file the result should be written to :type filename: string :param metrics: the metrics fields to include in the table as columns, additionally to the parameters, optional :type metrics: Array containing tuples, optional: First string the table header, second string the name of the metrics to store there :param nameoverride: allows the user to provide better readable names as parameter names :type nameoverride: Array containing new parameter names, optional
- writeMatrix(file, name, symbol, iterations_to_print=[-1])
Writes an numpy matrix stored as iteration data to a file, formatted for direct use in latex using a pmatrix element. The matrix has to be saved by the optimizer. Can be used to print the matrix from multiple iterations.
- Parameters
filename (string) – the name of the file the result should be written to
name (string) – the name of the matrix, as stored with addMetric
symbol (string) – the name of the matrix, as printed in latex. this can be any valid latex code. Will be subscripted by the iteration index
iterations_to_print (Array of Integers, optional) – array of iterations to print this meteric for. If unspecified, will print the data fromthe last iteration.
- writeSensitivityPlots(filename, iteration, averaged=True, zlabel=<function Result.<lambda>>)
prints a sensitivity plot in latex describing the sensitivity of the calibrated values to each parameter. This works if the target is a FreeSurfaceTimeDependentEvaluation or a FreeSurfaceEquilibriumEvaluation. Uses tikzpicture package in the generated latex code.
- Parameters
filename (string) – the name of the file the result should be written to
iteration (integer) – the iteration the data will be used of. if -1 is specified, the data from the last iteration will be used.
averaged (bool, optional) – print averaged sensitivity over all timesteps and over all locations (for timedependent case). If false a 3d plot will be printed instead.
zlabel (function integer => string, optional) – label of the z axis, dependent on the current iteration. Has to be valid latex code.
- writeSimpleErrorTable(file, metrics, nameoverride=None)
writes the error data as a latex table. Includes all parameter data for each iteration, standard errors for the parameters, and optionally metadata stored during the optimization. Only can be used if the errors are stored in the results object (currently only by GaussNewtonOptimizer) :param filename: the name of the file the result should be written to :type filename: string :param metrics: the metrics fields to include in the table as columns, additionally to the parameters :type metrics: Array containing tuples: First string the table header, second string the name of the metadata to store there :param nameoverride: allows the user to provide better readable names as parameter names :type nameoverride: Array containing new parameter names, optional
- writeTable(filename, metrics=[])
writes the iteration data as a simple tab-separated-text file for postprocessing. Includes all parameter data for each iteration, and optionally metrics stored during the optimization. :param filename: the name of the file the result should be written to :type filename: string :param metrics: the metadata fields to include in the table as columns, additionally to the parameters :type metrics: Array containing tuples: First string the table header, second string the name of the metadata to store there
- UGParameterEstimator.dataanalysis.result.fexp(f)
- UGParameterEstimator.dataanalysis.result.fman(f)