ValueAxis

Linear array of values which are used as variables of numerical functions and parameter dependent matrices

Properties

start : float
Starting value of the axis
step : float
Step between consecutive values of the axis
length : int
Length of the data array
data : numpy.array of float
Values of the axis

Examples

Creation of the ValueAxis object

>>> va = ValueAxis(0.0,100,1.0)

Its standard attributes are the following:

>>> print(va.length)
100
>>> print(va.step)
1.0
>>> print(va.start)
0.0

The attribute data is an array of floats

>>> print(va.data[3:5])
[ 3.  4.]

Attributes min and max are provided for convenience

>>> print(va.min)
0.0
>>> print(va.max)
99.0

You can locate an index of a specific value. The lower neighbor and the difference to it is returned.

>>> i,diff = va.locate(16.3)
>>> print(i)
16
>>> print("{0:.1f}".format(diff))
0.3

The following returns the nearest index on the axis

>>> i = va.nearest(16.3)
>>> print(i)
16
>>> i = va.nearest(16.7)
>>> print(i)
17
>>> i = va.nearest(16.5)
>>> print(i)
17

Mutual compatibility of the two ValueAxis objects can be tested as follows

>>> va1 = ValueAxis(0.0, 2000, 1.0)
>>> va2 = ValueAxis(0.0, 1000, 1.0)
>>> va2.is_subsection_of(va1)
True
>>> va1.is_subsection_of(va2)
False
>>> va1.is_extension_of(va2)
True
>>> va2.is_subsection_of(va1)
True
>>> va2.is_extension_of(va1)
False
>>> va1.is_equal_to(va2)
False
>>> va1.is_equal_to(va1)
True
>>> va3 = ValueAxis(0.0, 2000, 1.0)
>>> va3.is_equal_to(va1)
True

Class Details

class quantarhei.core.valueaxis.ValueAxis(start=0.0, length=1, step=1.0)[source]

Linear array of values which are used as variables of numerical functions and parameter dependent matrices

Parameters:
  • start (float) – Beginning of the axis
  • lenght (int) – Number of points in the DFunction
  • step (float) – Step size on the axis
Attributes:
length
max

Returns the maximum value on the axis

min

Returns the minimum value on the axis

start
step

Methods

copy() Returns a shallow copy of the self
deepcopy() Returns a deep copy of the self
is_equal_to(axis) Returns True if the axis is equal to this ValueAxis
is_extension_of(axis) Returns True if the axis is contained in this ValueAxis
is_subsection_of(axis) Returns True if the axis contains this ValueAxis
is_subset_of(axis) Returns True if the ValueAxis is a subset of axis
is_superset_of(axis) Returns True if the ValueAxis is a superset of axis
load(filename[, test]) Loads an object from a file and returns it
loaddir(dirname) Returns a directory of objects saved into a directory
locate(val) Returns the index of the lower neigbor of the val
nearest(val) Returns the index of the nearest neighbor to val
save(filename[, comment, test]) Saves the object with all its content into a file
savedir(dirname[, tag, comment, test]) Saves an object into directory containing a file with unique name
scopy() Creates a copy of the object by saving and loading it
is_equal_to(axis)[source]

Returns True if the axis is equal to this ValueAxis

is_extension_of(axis)[source]

Returns True if the axis is contained in this ValueAxis

is_subsection_of(axis)[source]

Returns True if the axis contains this ValueAxis

is_subset_of(axis)[source]

Returns True if the ValueAxis is a subset of axis

We check if all values of this axis are also values of the submitted axis object.

Examples

>>> ta1 = ValueAxis(0.0, 1000, 1.0)
>>> ta2 = ValueAxis(0.0, 490, 2.0)
>>> ta2.is_subset_of(ta1)
True
>>> ta1 = ValueAxis(0.0, 1000, 1.0)
>>> ta2 = ValueAxis(3.0, 900, 1.0)
>>> ta2.is_subset_of(ta1)
True
>>> ta1 = ValueAxis(0.0, 1000, 1.0)
>>> ta2 = ValueAxis(3.0, 400, 2.0)
>>> ta2.is_subset_of(ta1)
True
>>> ta1 = ValueAxis(0.0, 1000, 1.12345)
>>> ta2 = ValueAxis(3*1.12345, 400, 2*1.12345)
>>> ta2.is_subset_of(ta1)
True
>>> ta1 = ValueAxis(0.0, 1000, 1.12345)
>>> ta2 = ValueAxis(3.0, 400, 2*1.12345)
>>> ta2.is_subset_of(ta1)
False
>>> ta1 = ValueAxis(0.0, 1000, 1.0)
>>> ta2 = ValueAxis(3.0, 500, 2.0)
>>> ta2.is_subset_of(ta1)
False
is_superset_of(axis)[source]

Returns True if the ValueAxis is a superset of axis

We check if all values of this axis are also values of the submitted axis object.

Examples

>>> ta1 = ValueAxis(0.0, 1000, 1.0)
>>> ta2 = ValueAxis(0.0, 490, 2.0)
>>> ta1.is_superset_of(ta2)
True
>>> ta1 = ValueAxis(0.0, 1000, 1.0)
>>> ta2 = ValueAxis(3.0, 900, 1.0)
>>> ta1.is_superset_of(ta2)
True
>>> ta1 = ValueAxis(0.0, 1000, 1.0)
>>> ta2 = ValueAxis(3.0, 400, 2.0)
>>> ta1.is_superset_of(ta2)
True
>>> ta1 = ValueAxis(0.0, 1000, 1.12345)
>>> ta2 = ValueAxis(3*1.12345, 400, 2*1.12345)
>>> ta1.is_superset_of(ta2)
True
>>> ta1 = ValueAxis(0.0, 1000, 1.12345)
>>> ta2 = ValueAxis(3.0, 400, 2*1.12345)
>>> ta1.is_superset_of(ta2)
False
>>> ta1 = ValueAxis(0.0, 1000, 1.0)
>>> ta2 = ValueAxis(3.0, 500, 2.0)
>>> ta1.is_superset_of(ta2)
False
locate(val)[source]

Returns the index of the lower neigbor of the val

Returns the index of the lower neigbor of the value x and the remaining distance to the value of val

Parameters:val (float) – A value within the min and max values of the axis
max

Returns the maximum value on the axis

min

Returns the minimum value on the axis

nearest(val)[source]

Returns the index of the nearest neighbor to val

Returns the index of the nearest neighbor of val. If val is out of the upper bounds within the self.step from the upper limit, the lower neighbor index is returned.

Parameters:val (float) – A value within the min and max values of the axis