Table Of Contents

Previous topic

operationmemory.py

Next topic

predictioncaller.py

This Page

paramtablecaller.py

>>> from simo.simulation.caller.paramtablecaller import ParamTableCaller
>>> execfile('simulation/caller/test/mocks4paramtablecaller.py')

def get_indices(tind, table, sim, depthind):

Find parameter table indices for target objects

def _limit_range(table, searchrange, values, i):

Limit parameter table search range for each object with the i’th classifier of the table:

>>> import numpy
>>> from simo.simulation.caller.paramtablecaller import _limit_range
>>> table = numpy.array([[1, 1, 1],
...                      [1, 1, 2],
...                      [1, 2, 1],
...                      [1, 2, 2],
...                      [1, 2, 3],
...                      [2, 1, 1],
...                      [2, 1, 2],
...                      [2, 2, 1],
...                      [2, 2, 2],
...                      [2, 2, 3],
...                      [2, 2, 4],
...                      [2, 3, 1],
...                      [3, 1, 1],
...                      [3, 2, 1],
...                      [3, 2, 2],
...                      [3, 3, 3]], dtype=float)

Find the ranges for each object where the data values are equal to first classifier values:

>>> values = numpy.array([[1, 2, 3, 4]], dtype=float)
>>> searchrange = numpy.array([[1,0,-1],
...                            [1,0,-1],
...                            [1,0,-1],
...                            [1,0,-1]], dtype=int)
>>> _limit_range(table, searchrange,values, 0)
[None, None, None]
>>> searchrange
array([[ 1,  0,  5],
       [ 1,  5, 12],
       [ 1, 12, 16],
       [ 0,  0, -1]])

Find the ranges for each object where the data values are equal to second classifier values:

>>> values = numpy.array([[2, 2, 2, 2]], dtype=float)
>>> _limit_range(table, searchrange,values, 1)
[None, None, None]
>>> searchrange
array([[ 1,  2,  5],
       [ 1,  7, 11],
       [ 1, 13, 15],
       [ 0,  0, -1]])

Find the ranges for each object where the data values are equal to third classifier values:

>>> values = numpy.array([[3, 2, 2, 5]], dtype=float)
>>> _limit_range(table, searchrange,values, 2)
[None, None, None]
>>> searchrange
array([[ 1,  4,  5],
       [ 1,  8,  9],
       [ 1, 14, 15],
       [ 0,  0, -1]])

If the last classifier is a float, the parameter table value is interpolated using a coefficient calculated from the closest table values to the float classifier value:

>>> from simo.simulation.caller.paramtablecaller import _interpolate_value
>>> table = numpy.array([[5.],
...                      [2.],
...                      [1.],
...                      [4.],
...                      [3.]], dtype=float)
>>> searchrange = numpy.array([[1,0,-1],
...                            [1,0,-1],
...                            [1,0,-1],
...                            [1,0,-1]], dtype=int)
>>> values = numpy.array([[0.5, 1, 2.5, 5.5]], dtype=float)
>>> coeff = _interpolate_value(table, searchrange, values, 0)
>>> coeff
[0.0, 0.5]
>>> searchrange
array([[ 0,  0, -1],
       [ 1,  2,  3],
       [ 1,  1,  2],
       [ 0,  0, -1]])

class ParamTableCaller(Caller):

Parameter table model caller

Attributes:

  • ...

def __init__(self):

>>> pt = ParamTableCaller()

def execute(self):

>>> pt.execute(paramtable, None, sim, 0)
... 
Called Data.get_tind(1, 0, None, None, True, None, None)
Called Data.get_active()
Called Data.set_active(None)
Called Data.get_value(
    array([[ 0,  0,  0,  0,  0],
       [ 0,  0,  1,  0,  0],
       [ 0,  0,  2,  0,  0],
       [ 0,  0,  3,  0,  0],
       [ 0,  0,  4,  0,  0],
       [ 0,  0,  5,  0,  0],
       [ 0,  0,  6,  0,  0],
       [ 0,  0,  7,  0,  0],
       [ 0,  0,  8,  0,  0],
       [ 0,  0,  9,  0,  0],
       [ 0,  0, 10,  0,  0],
       [ 0,  0, 11,  0,  0],
       [ 0,  0, 12,  0,  0],
       [ 0,  0, 13,  0,  0],
       [ 0,  0, 14,  0,  0],
       [ 0,  0, 15,  0,  0],
       [ 0,  0, 16,  0,  0],
       [ 0,  0, 17,  0,  0],
       [ 0,  0, 18,  0,  0],
       [ 0,  0, 19,  0,  0],
       [ 0,  0, 20,  0,  0],
       [ 0,  0, 21,  0,  0],
       [ 0,  0, 22,  0,  0],
       [ 0,  0, 23,  0,  0],
       [ 0,  0, 24,  0,  0],
       [ 0,  0, 25,  0,  0],
       [ 0,  0, 26,  0,  0],
       [ 0,  0, 27,  0,  0],
       [ 0,  0, 28,  0,  0],
       [ 0,  0, 29,  0,  0]]),
    (9,))
Called Data.set_active(None)
Called Data.get_value(
    array([[ 0,  0,  0,  0,  0],
       [ 0,  0,  1,  0,  0],
       [ 0,  0,  2,  0,  0],
       [ 0,  0,  3,  0,  0],
       [ 0,  0,  4,  0,  0],
       [ 0,  0,  5,  0,  0],
       [ 0,  0,  6,  0,  0],
       [ 0,  0,  7,  0,  0],
       [ 0,  0,  8,  0,  0],
       [ 0,  0,  9,  0,  0],
       [ 0,  0, 10,  0,  0],
       [ 0,  0, 11,  0,  0],
       [ 0,  0, 12,  0,  0],
       [ 0,  0, 13,  0,  0],
       [ 0,  0, 14,  0,  0],
       [ 0,  0, 15,  0,  0],
       [ 0,  0, 16,  0,  0],
       [ 0,  0, 17,  0,  0],
       [ 0,  0, 18,  0,  0],
       [ 0,  0, 19,  0,  0],
       [ 0,  0, 20,  0,  0],
       [ 0,  0, 21,  0,  0],
       [ 0,  0, 22,  0,  0],
       [ 0,  0, 23,  0,  0],
       [ 0,  0, 24,  0,  0],
       [ 0,  0, 25,  0,  0],
       [ 0,  0, 26,  0,  0],
       [ 0,  0, 27,  0,  0],
       [ 0,  0, 28,  0,  0],
       [ 0,  0, 29,  0,  0]]),
    (10,))
Called Data.set_value(
    1,
    array([[ 0,  0,  0,  0,  0],
       [ 0,  0,  1,  0,  0],
       [ 0,  0,  2,  0,  0],
       [ 0,  0,  3,  0,  0],
       [ 0,  0,  4,  0,  0],
       [ 0,  0,  5,  0,  0],
       [ 0,  0,  6,  0,  0],
       [ 0,  0,  7,  0,  0],
       [ 0,  0,  8,  0,  0],
       [ 0,  0,  9,  0,  0],
       [ 0,  0, 10,  0,  0],
       [ 0,  0, 11,  0,  0],
       [ 0,  0, 12,  0,  0],
       [ 0,  0, 13,  0,  0],
       [ 0,  0, 14,  0,  0],
       [ 0,  0, 15,  0,  0],
       [ 0,  0, 16,  0,  0],
       [ 0,  0, 17,  0,  0],
       [ 0,  0, 18,  0,  0],
       [ 0,  0, 19,  0,  0],
       [ 0,  0, 20,  0,  0],
       [ 0,  0, 21,  0,  0],
       [ 0,  0, 22,  0,  0],
       [ 0,  0, 23,  0,  0],
       [ 0,  0, 24,  0,  0],
       [ 0,  0, 25,  0,  0],
       [ 0,  0, 26,  0,  0],
       [ 0,  0, 27,  0,  0],
       [ 0,  0, 28,  0,  0],
       [ 0,  0, 29,  0,  0]]),
    <Mock ... ParamTableTarget.variable>,
    array([ 0.7,  0.7,  0.7,  0.7,  0.7,  0.7,  0.7,  0.7,  0.7,  0.7,  0.7,
        0.7,  0.7,  0.7,  0.7,  0.7,  0.7,  0.7,  0.7,  0.7,  0.7,  0.7,
        0.7,  0.7,  0.7,  0.7,  0.7,  0.7,  0.7,  0.7]),
    'biomass_collection_proportions',
    False)
Called Data.set_value(
    1,
    array([[ 0,  0,  0,  0,  0],
       [ 0,  0,  1,  0,  0],
       [ 0,  0,  2,  0,  0],
       [ 0,  0,  3,  0,  0],
       [ 0,  0,  4,  0,  0],
       [ 0,  0,  5,  0,  0],
       [ 0,  0,  6,  0,  0],
       [ 0,  0,  7,  0,  0],
       [ 0,  0,  8,  0,  0],
       [ 0,  0,  9,  0,  0],
       [ 0,  0, 10,  0,  0],
       [ 0,  0, 11,  0,  0],
       [ 0,  0, 12,  0,  0],
       [ 0,  0, 13,  0,  0],
       [ 0,  0, 14,  0,  0],
       [ 0,  0, 15,  0,  0],
       [ 0,  0, 16,  0,  0],
       [ 0,  0, 17,  0,  0],
       [ 0,  0, 18,  0,  0],
       [ 0,  0, 19,  0,  0],
       [ 0,  0, 20,  0,  0],
       [ 0,  0, 21,  0,  0],
       [ 0,  0, 22,  0,  0],
       [ 0,  0, 23,  0,  0],
       [ 0,  0, 24,  0,  0],
       [ 0,  0, 25,  0,  0],
       [ 0,  0, 26,  0,  0],
       [ 0,  0, 27,  0,  0],
       [ 0,  0, 28,  0,  0],
       [ 0,  0, 29,  0,  0]]),
    <Mock ... ParamTableTarget.variable>,
    array([ 0.75,  0.75,  0.75,  0.75,  0.75,  0.75,  0.75,  0.75,  0.75,
        0.75,  0.75,  0.75,  0.75,  0.75,  0.75,  0.75,  0.75,  0.75,
        0.75,  0.75,  0.75,  0.75,  0.75,  0.75,  0.75,  0.75,  0.75,
        0.75,  0.75,  0.75]),
    'biomass_collection_proportions',
    False)
Called Data.set_value(
    1,
    array([[ 0,  0,  0,  0,  0],
       [ 0,  0,  1,  0,  0],
       [ 0,  0,  2,  0,  0],
       [ 0,  0,  3,  0,  0],
       [ 0,  0,  4,  0,  0],
       [ 0,  0,  5,  0,  0],
       [ 0,  0,  6,  0,  0],
       [ 0,  0,  7,  0,  0],
       [ 0,  0,  8,  0,  0],
       [ 0,  0,  9,  0,  0],
       [ 0,  0, 10,  0,  0],
       [ 0,  0, 11,  0,  0],
       [ 0,  0, 12,  0,  0],
       [ 0,  0, 13,  0,  0],
       [ 0,  0, 14,  0,  0],
       [ 0,  0, 15,  0,  0],
       [ 0,  0, 16,  0,  0],
       [ 0,  0, 17,  0,  0],
       [ 0,  0, 18,  0,  0],
       [ 0,  0, 19,  0,  0],
       [ 0,  0, 20,  0,  0],
       [ 0,  0, 21,  0,  0],
       [ 0,  0, 22,  0,  0],
       [ 0,  0, 23,  0,  0],
       [ 0,  0, 24,  0,  0],
       [ 0,  0, 25,  0,  0],
       [ 0,  0, 26,  0,  0],
       [ 0,  0, 27,  0,  0],
       [ 0,  0, 28,  0,  0],
       [ 0,  0, 29,  0,  0]]),
    <Mock ... ParamTableTarget.variable>,
    array([ 15.,  15.,  15.,  15.,  15.,  15.,  15.,  15.,  15.,  15.,  15.,
        15.,  15.,  15.,  15.,  15.,  15.,  15.,  15.,  15.,  15.,  15.,
        15.,  15.,  15.,  15.,  15.,  15.,  15.,  15.]),
    'biomass_collection_proportions',
    False)
True
>>> data.get_value.mock_returns =  None, ([('errormessage', 0)], tind)
>>> pt.execute(paramtable, None, sim, 0)
... 
Called Data.get_tind(1, 0, None, None, True, None, None)
Called Data.get_active()
Called Data.set_active(None)
Called Data.get_value(
    array([[ 0,  0,  0,  0,  0],
       [ 0,  0,  1,  0,  0],
       [ 0,  0,  2,  0,  0],
       [ 0,  0,  3,  0,  0],
       [ 0,  0,  4,  0,  0],
       [ 0,  0,  5,  0,  0],
       [ 0,  0,  6,  0,  0],
       [ 0,  0,  7,  0,  0],
       [ 0,  0,  8,  0,  0],
       [ 0,  0,  9,  0,  0],
       [ 0,  0, 10,  0,  0],
       [ 0,  0, 11,  0,  0],
       [ 0,  0, 12,  0,  0],
       [ 0,  0, 13,  0,  0],
       [ 0,  0, 14,  0,  0],
       [ 0,  0, 15,  0,  0],
       [ 0,  0, 16,  0,  0],
       [ 0,  0, 17,  0,  0],
       [ 0,  0, 18,  0,  0],
       [ 0,  0, 19,  0,  0],
       [ 0,  0, 20,  0,  0],
       [ 0,  0, 21,  0,  0],
       [ 0,  0, 22,  0,  0],
       [ 0,  0, 23,  0,  0],
       [ 0,  0, 24,  0,  0],
       [ 0,  0, 25,  0,  0],
       [ 0,  0, 26,  0,  0],
       [ 0,  0, 27,  0,  0],
       [ 0,  0, 28,  0,  0],
       [ 0,  0, 29,  0,  0]]),
    (9,))
Called Simulator.add_error(
    'parameter_table caller: errormessage',
    1,
    array([0, 0, 0, 0, 0]))
Called Simulator.add_error(
    "parameter_table caller: cannot find table classifier values for parameter table 'biomass_collection_proportions'",
    1,
    None)
False