Function value_spec (o2scl_hdf)

O2scl : Function List

int o2scl_hdf::value_spec(std::string spec, double &d, int verbose = 0, bool err_on_fail = true)

A value specified by a string.

The first part of the specification is a “type” followed by a colon, followed by arguments which depend on the type. If no colon is present, then a “func:” prefix is assumed. The different types for a value specification are:

  1. <numeric value or function> - Value equal to the result of <function>, e.g. “7.6” or “sin(0.5)”. See the functions help topic for a list of functions that can be used.

    For example:

    acol -create double "sqrt(5)" -output

  2. hdf5:<file>:<object name>:[addl. spec.] - Read an HDF5 value and obtain the value from object named <object name>. For some object types, additional specifications are required to specify which value should be used. A list of object types and additional specifications and more detail is given below.

    • double: (no addl. spec.)

    • int: (no addl. spec.)

    • size_t: (no addl. spec.)

    • double[]: index

    • int[]: index

    • size_t[]: index

    • uniform_grid<double>: index

    • table: column name,row index

    For example:

    acol -create double hdf5:data/o2scl/apr98.o2:apr:rho,0 -output

  3. shell:<shell command> - Set the value equal to the first result obtained using the specified shell command. For example (using bash):

    acol -create double shell:"ls | wc | awk '{print $1}'" -output

  4. python:<python code> - Set the value equal to the result obtained using the specified python code. For example (using bash):

    acol -create double $'python:"import numpy\nprint(numpy.sin(4))"' -output