UGParameterEstimator.evaluationinput package

Submodules

UGParameterEstimator.evaluationinput.evaluation module

class UGParameterEstimator.evaluationinput.evaluation.ErroredEvaluation(parameters, reason, eval_id=None, runtime=None)

Bases: Evaluation

An Implementation of Evaluation indicating an error has occurred during Evaluation.

The reason might be found in the reason field.

getNumpyArray()

Returns stored measurements as a 1d numpy array

Returns

stored measurements as a 1d numpy array

Return type

numpy array, 1d

getNumpyArrayLike(target: Evaluation)

Used to interpolate between different evaluations, when timestamps might differ because of the used time control schemes.

Parameters

target (Evaluation) – Evaluation whichs format should be matched and interpolated to

Raises

IncompatibleFormatError – When the two Evaluations can not be interpolated between

Returns

the data of this evaulation, interpolated to the targets format

Return type

numpy array

classmethod parse(directory, evaluation_id, parameters, eval_id, runtime)

Factory method, parses the evaluation with a given id from the given folder. Sets the parameters and runtime as metaobjects for later analysis.

Parameters
  • directory (string) – directory to read the evaluation from

  • evaluation_id (int) – id of the evaluation to find the correct file fron directory

  • parameters (numpy array) – the (transformed) parameters of this evaluation

  • runtime (int) – runtime of the evaluation, in seconds

Raises

IncompatibleFormatError – When the Evaluation can not be parsed

Returns

Parsed Evaluation

Return type

Evaluation

class UGParameterEstimator.evaluationinput.evaluation.Evaluation

Bases: ABC

Base class for all Evaluation classes.

Contains metadata which all Evaluations should have, and defines the 3 methods all evaluations should implement.

exception IncompatibleFormatError

Bases: Exception

eval_id = None
abstract getNumpyArray()

Returns stored measurements as a 1d numpy array

Returns

stored measurements as a 1d numpy array

Return type

numpy array, 1d

abstract getNumpyArrayLike(target)

Used to interpolate between different evaluations, when timestamps might differ because of the used time control schemes.

Parameters

target (Evaluation) – Evaluation whichs format should be matched and interpolated to

Raises

IncompatibleFormatError – When the two Evaluations can not be interpolated between

Returns

the data of this evaulation, interpolated to the targets format

Return type

numpy array

parameters = None
abstract classmethod parse(directory, evaluation_id, parameters, runtime)

Factory method, parses the evaluation with a given id from the given folder. Sets the parameters and runtime as metaobjects for later analysis.

Parameters
  • directory (string) – directory to read the evaluation from

  • evaluation_id (int) – id of the evaluation to find the correct file fron directory

  • parameters (numpy array) – the (transformed) parameters of this evaluation

  • runtime (int) – runtime of the evaluation, in seconds

Raises

IncompatibleFormatError – When the Evaluation can not be parsed

Returns

Parsed Evaluation

Return type

Evaluation

runtime = None

UGParameterEstimator.evaluationinput.freesurface_evaluation module

class UGParameterEstimator.evaluationinput.freesurface_evaluation.BinaryReader(filename, endian='<')

Bases: object

helper class to read from a binary stram

close()
read_char()
read_double()
read_int()
property readable
class UGParameterEstimator.evaluationinput.freesurface_evaluation.FreeSurfaceEquilibriumEvaluation(data, locations, dimension, time=0)

Bases: FreeSurfaceEvaluation

Class representing the measurement of the free surface position when the free surface has reached its equlibrium state. this means this evaluation onyl contains data for one timestep, but for multiple locations.

classmethod fromCSV(filename, dim, delimiter=',', valuecolumn='Value', dimcolumns=['X', 'Y'])

Reads the free surface evaluation from a .csv file.

Parameters
  • filename (string) – filename to load

  • dim (int) – dimension of the problem

  • valuecolumn (string, optinal) – name of the column containg the measured height, defaults to “Value”

  • dimcolumns (list of strings, optional, size == dimension) – names of the columns containg the locations data, defaults to [“X”, “Y”]

classmethod fromNumpyArray(data, seriesformat)

Constructs a FreeSurfaceEquilibriumEvaluation from a numpy array and a given FreeSurfaceEquilibriumEvaluation of the same format (locations and dimension)

Parameters
Returns

the constructed FreeSurfaceEquilibriumEvaluation

Return type

FreeSurfaceEquilibriumEvaluation

classmethod fromTimedependentTimeseries(series)

Constructs a FreeSurfaceEquilibriumEvaluation from a timedependent evaluation by only using the last measurement. Only use this if the timedependent evaluation was in a equilibrium state!

Parameters

series (FreeSurfaceTimeDependentEvaluation) – evaluation to convert

Returns

the constructed FreeSurfaceEquilibriumEvaluation

Return type

FreeSurfaceEquilibriumEvaluation

getNumpyArrayLike(target)

Used to interpolate between different evaluations, when timestamps might differ because of the used time control schemes.

Parameters

target (FreeSurfaceEvaluation) – FreeSurfaceEvaluation whichs format should be matched and interpolated to

Raises

IncompatibleFormatError – When the two Evaluations can not be interpolated between

Returns

the data of this evaulation, interpolated to the targets format

Return type

numpy array with the dimensions 1 x target.totalCount

static writePlots(series, filename, yaxislabel='$m(l,t,\\vec{\\theta})$ {[m]}')

write multiple plots as latex to a file. This uses the tikzpicture/pgfplots package in the generated latex code.

Parameters
  • series (dictionary<string, FreeSurfaceEquilibriumEvaluation>) – multiple evaluations to plot, given as a dictionary. The key will be used as the name in the legend, the value being the evaluation.

  • filename (string) – filename to save to

  • yaxislabel (string) – label of the y axis

class UGParameterEstimator.evaluationinput.freesurface_evaluation.FreeSurfaceEvaluation

Bases: Evaluation

Base class for all Evaluation classes containing measurements of free surface positions.

class NaNHandling(value)

Bases: Enum

An enumeration.

none = 1
replace = 2
data = [[]]
dimension = -1
getNumpyArray()

Returns stored measurements as a 1d numpy array

Returns

stored measurements as a 1d numpy array

Return type

numpy array with size totalCount

getNumpyArrayLike(target)

Used to interpolate between different evaluations, when timestamps might differ because of the used time control schemes.

Parameters

target (FreeSurfaceEvaluation) – FreeSurfaceEvaluation whichs format should be matched and interpolated to

Raises

IncompatibleFormatError – When the two Evaluations can not be interpolated between

Returns

the data of this evaulation, interpolated to the targets format

Return type

numpy array with the dimensions 1 x target.totalCount

static hasSameLocations(A, B)

Compares the locations of 2 free surface measurement objects

Parameters
Returns

true, if the 2 objects have the same locations, false, if not

Return type

boolean

property locationCount

Returns the number of locations/measurements points for every measurement in this object

Returns

Number of measurement points for each measurement stored in this object

Return type

Integer

locations = []
nanhandling = 1
nanreplacevalue = 0.0
classmethod parse(directory, evaluation_id, parameters, runtime)

Factory method, parses the evaluation with a given id from the given folder. Sets the parameters and runtime as metaobjects for later analysis.

Parameters
  • directory (string) – directory to read the evaluation from

  • evaluation_id (int) – id of the evaluation to find the correct file fron directory

  • parameters (numpy array) – the (transformed) parameters of this evaluation

  • runtime (int) – runtime of the evaluation, in seconds

Raises

IncompatibleFormatError – When the Evaluation can not be parsed

Returns

Parsed FreeSurfaceEvaluation

Return type

FreeSurfaceEvaluation

property timeCount

Returns the number of measurements stored in this object

Returns

Number of measurements stored in this object

Return type

Integer

times = []
property totalCount

Returns the number of measured free surface heights stored.

Returns

number of measured free surface heights stored.

Return type

Integer

class UGParameterEstimator.evaluationinput.freesurface_evaluation.FreeSurfaceTimeDependentEvaluation(data, times, locations, dimension, eval_id=-1, parameters=None, runtime=None)

Bases: FreeSurfaceEvaluation

Class representing the measurement of the free surface position at multiple time points. The underlying data is a 2d array.

EQUILIBRIUM_CONSTANT = 10
classmethod fromNumpyArray(data, seriesformat)

Constructs a FreeSurfaceTimeDependentEvaluation from a numpy array and a given FreeSurfaceTimeDependentEvaluation of the same format (locations and dimension)

Parameters
Returns

the constructed FreeSurfaceTimeDependentEvaluation

Return type

FreeSurfaceTimeDependentEvaluation

getFactorOfEquilibrium()

Calculate the equilibrium factor of the evaluation, a measurment for if the free surface has stopped moving.

Returns

the equilibrium factor

Return type

number

getNumpyArrayLike(target: FreeSurfaceEvaluation)

Used to interpolate between different evaluations, when timestamps might differ because of the used time control schemes.

Important Note: Care has to be taken with the simulation time frames. If the target timeframe lasts longer or starts earlier, the next suitable timestep (i.e. the first or last one) will be used automatically. This is not always desirable!

Parameters

target (FreeSurfaceEvaluation) – FreeSurfaceEvaluation whichs format should be matched and interpolated to

Returns

the data of this evaulation, interpolated to the targets format

Return type

numpy array with the dimensions 1 x target.totalCount

isInEquilibrium()

Return if the free surface measured in this evaluation has reached the statically set equlibrium factor.

Returns

only true if the equilibrium factor of this measurment is higher than the statically set factor.

Return type

boolean

classmethod parse(directory, evaluation_id, parameters=None, runtime=None)

Factory method to parse a measurement file. Parses the measurement as binary, if the corresponding file exists, or as csv, if not. This uses the format defined in fs_measurement.hpp in the d3f-plugin.

Parameters
  • directory (string) – directory of the evaluation to parse

  • evaluation_id (int) – id of the evaluation to parse

  • parameters (numpy array, optional) – (transformed) parameters of the evaluation this data resulted from

  • runtime (int, optional) – runtime of the evaluation this data resulted from, in seconds

classmethod parseBinary(file, evaluation_id=-1, parameters=None, runtime=None)

Factory method to parse a binary measurement file. This uses the format defined in fs_measurement.hpp in the d3f-plugin.

Parameters
  • file (string) – file to parse

  • evaluation_id (int, optional) – id of the evaluation this data resulted from

  • parameters (numpy array, optional) – (transformed) parameters of the evaluation this data resulted from

  • runtime (int, optional) – runtime of the evaluation this data resulted from, in seconds

classmethod parseFromCSV(filename, evaluation_id=-1, parameters=None, runtime=None)

Factory method to parse a csv measurement file. This uses the format defined in fs_measurement.hpp in the d3f-plugin.

Parameters
  • filename (string) – file to parse

  • evaluation_id (int, optional) – id of the evaluation this data resulted from

  • parameters (numpy array, optional) – (transformed) parameters of the evaluation this data resulted from

  • runtime (int, optional) – runtime of the evaluation this data resulted from, in seconds

write3dPlot(filename, zlabel='$m(l,t,\\beta)$', scale=1, stride=3)

Writes a 3d plot in latex of this evaluation. On the x-axis will be time, on the yaxis location and the z-axis will represent the data stored. The generated requires tikzpicture/pgfplots to compile. Only 2d cases are supported.

Parameters
  • filename (string) – filename to write to

  • zlabel (string) – label of the z axis

  • scale (number, optional) – scale, will be passes to pgfplots, defualts to 1

  • stride (int, optional) – only plot every x-th timestep, defaults to 3

writeCSV(filename)

Writes a tsv with all times and locations measured. The data will be “flattened”, with an table entry for every combination of time and location, with the columns time, location and value.

Parameters

filename (string) – filename to write to

writeCSVAtLocation(filename, location)

Writes a tsv with a entry for every timestep measured. The entry will be the measured height at the given location.

Parameters
  • filename (string) – filename to write to

  • location (number (2d) or tuple of numbers (3d)) – location to use

writeCSVAtTimestep(filename, timestep)

Writes a tsv with a entry for every location measured. The entry will be the measured height at the location for a given timestep.

Parameters
  • filename (string) – filename to write to

  • timestep (int) – timestep (index) to use

writeCSVAveragedOverLocation(filename)

Writes a tsv with a entry for every timestep measured. The entry will be the average measured height over all locations at this timestep.

Parameters

filename (string) – filename to write to

writeCSVAveragedOverTimesteps(filename)

Writes a tsv with a entry for every location measured. The entry will be the average measured height over all timesteps at this location.

Parameters

filename (string) – filename to write to

writeDifferentialPlot(filename)

Writes a plot in latex to show the amount the free surface moves in dependency of the time. On the x-axis will be time. The y-axis will represent the norm of the difference vector between two measurements. The generated requires tikzpicture/pgfplots to compile.

Parameters

filename (string) – filename to write to

writePlots(filename, num)

Writes ‘num’ 2d plots in latex in one diagram of this evaluation to show the timedependency of the problem. On the x-axis will be location. The timesteps are chosen to be linear distributed in the time space, with ‘num’ entries. The generated requires tikzpicture/pgfplots to compile. Only 2d cases are supported.

Parameters
  • filename (string) – filename to write to

  • num (int) – number of plots

Module contents