Function value_spec (o2scl_hdf)¶
-
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:
<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
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[]
: indexint[]
: indexsize_t[]
: indexuniform_grid<double>
: indextable
: column name,row index
For example:
acol -create double hdf5:data/o2scl/apr98.o2:apr:rho,0 -output
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
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