Beispiel #1
0
bool PicParams::extractProfile(InputData &ifile, PyObject *mypy, ProfileStructure &P)
{
    double val;
    // If the profile is only a double, then convert to a constant function
    if( PyTools::convert(mypy, val) ) {
        // Extract the function "constant"
        PyObject* constantFunction = ifile.extract_py("constant");
        // Create the argument which has the value of the profile
        PyObject* arg = PyTuple_New(1);
        PyTuple_SET_ITEM(arg, 0, PyFloat_FromDouble(val));
        // Create the constant anonymous function
        PyObject * tmp = PyObject_Call(constantFunction, arg, NULL);
        P.py_profile = tmp;
        return true;
    } else if (mypy && PyCallable_Check(mypy)) {
        P.py_profile=mypy;
        return true;
    }
    return false;
}
Beispiel #2
0
bool PicParams::extractOneProfile(InputData &ifile, string varname, ProfileStructure &P, int ispec) {
    PyObject *mypy = ifile.extract_py(varname, "Species", ispec);
    if( !extractProfile(ifile, mypy, P) ) return false;
    return true;
}