GyotoPython.h
Go to the documentation of this file.
/*
Copyright 2015-2016, 2022 Thibaut Paumard
This file is part of Gyoto.
Gyoto is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gyoto is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GyotoPython_H_
#define __GyotoPython_H_
#include <GyotoSpectrum.h>
#include <GyotoMetric.h>
#include <GyotoStandardAstrobj.h>
#include <GyotoThinDisk.h>
#include <GyotoProperty.h>
#include <GyotoValue.h>
#include <GyotoScreen.h>
#include <GyotoFactoryMessenger.h>
#include <Python.h>
namespace Gyoto {
namespace Python {
class Base;
template <class O> class Object;
PyObject * PyObject_FromGyotoValue(const Gyoto::Value&);
PyObject * PyInstance_GetMethod(PyObject* pInstance, const char *name);
PyObject * PyImport_Gyoto();
void PyInstance_SetThis(PyObject * pInstance,
PyObject * pNew,
void * ptr);
bool PyCallable_HasVarArg(PyObject * pMethod);
PyObject * PyModule_NewFromPythonCode(const char * code);
PyObject * pGyotoSpectrum() ;
PyObject * pGyotoMetric() ;
PyObject * pGyotoStandardAstrobj() ;
PyObject * pGyotoThinDisk() ;
}
namespace Spectrum {
class Python;
}
namespace Metric {
class Python;
}
namespace Astrobj {
namespace Python {
class Standard;
class ThinDisk;
}
}
}
class Gyoto::Python::Base {
protected:
std::string module_;
std::string inline_module_;
std::string class_;
std::vector<double> parameters_;
PyObject * pModule_;
PyObject * pInstance_;
PyObject * pProperties_;
PyObject * pSet_;
PyObject * pGet_;
public:
Base();
Base(const Base&);
~Base();
virtual std::string module() const ;
virtual std::string inlineModule() const ;
virtual void module(const std::string&);
virtual void inlineModule(const std::string&);
virtual std::string klass() const ;
virtual void klass(const std::string& c);
virtual std::vector<double> parameters() const;
virtual void parameters(const std::vector<double>&);
virtual bool hasPythonProperty(std::string const &key) const ;
virtual void setPythonProperty(std::string const &key, Value val);
virtual Value getPythonProperty(std::string const &key) const;
virtual int pythonPropertyType(std::string const &key) const;
};
template <class O>
class Gyoto::Python::Object
: public O, public Gyoto::Python::Base
{
public:
Object() : O(), Gyoto::Python::Base() {}
Object(const Object& o) : O(o), Base(o) {}
virtual ~Object() {};
using O::set;
virtual void set(std::string const &key, Value val) {
GYOTO_DEBUG_EXPR(key);
GYOTO_DEBUG_EXPR(val.type);
if (hasPythonProperty(key)) {
GYOTO_DEBUG << "Python key " << key << " exists" << std::endl;
setPythonProperty(key, val);
} else {
GYOTO_DEBUG << "Python key " << key << " does not exist" << std::endl;
O::set(key, val);
}
}
virtual void set(Property const &p, Value val){
std::string key=p.name;
GYOTO_DEBUG_EXPR(key);
if (!hasPythonProperty(key)) {
GYOTO_DEBUG << "calling Generic::set" << std::endl;
O::set(p, val);
return;
}
setPythonProperty(key, val);
}
virtual void set(Property const &p, Value val, std::string const &unit) {
GYOTO_DEBUG_EXPR(p.name);
if (hasPythonProperty(p.name)) {
GYOTO_DEBUG << "Python key " << p.name << " exists" << std::endl;
if (unit!="") GYOTO_ERROR("units not implemented");
setPythonProperty(p.name, val);
} else {
GYOTO_DEBUG << "Python key " << p.name << " does not exist" << std::endl;
O::set(p, val, unit);
}
}
using O::get;
virtual Value get(std::string const &key) const {
GYOTO_DEBUG_EXPR(key);
if (!hasPythonProperty(key)) {
GYOTO_DEBUG << "calling Generic::get" << std::endl;
return O::get(key);
}
return getPythonProperty(key);
}
Value get(Property const &p,
std::string const &unit) const {
if (!hasPythonProperty(p.name)) {
GYOTO_DEBUG << "calling Generic::get" << std::endl;
return O::get(p, unit);
}
return getPythonProperty(p.name);
}
Value get(Property const &p) const {
if (!hasPythonProperty(p.name)) {
GYOTO_DEBUG << "calling Generic::get" << std::endl;
return O::get(p);
}
return getPythonProperty(p.name);
}
using O::setParameter;
virtual int setParameter(std::string name, std::string content, std::string unit) {
GYOTO_DEBUG_EXPR(name);
GYOTO_DEBUG_EXPR(content);
GYOTO_DEBUG_EXPR(unit);
if (hasPythonProperty(name)) {
Property p(NULL);
p.name=name;
p.type=pythonPropertyType(name);
GYOTO_DEBUG << "Calling setParameter(p, name, content, unit)" << std::endl;
setParameter(p, name, content, unit);
return 0;
}
return O::setParameter(name, content, unit);
}
virtual void fillElement(Gyoto::FactoryMessenger *fmp) const {
O::fillElement(fmp);
if (pProperties_) {
Py_ssize_t pos=0;
PyObject *pKey, *pVal;
while (PyDict_Next(pProperties_, &pos, &pKey, &pVal)) {
std::string key=PyUnicode_AsUTF8(pKey);
std::string stype=PyUnicode_AsUTF8(pVal);
Property::type_e type = Property::typeFromString(stype);
const Property p (key, type);
this->fillProperty(fmp, p);
}
}
}
void setParameters(Gyoto::FactoryMessenger *fmp) {
std::string name="", content="", unit="";
FactoryMessenger * child = NULL;
if (fmp)
while (fmp->getNextParameter(&name, &content, &unit)) {
GYOTO_DEBUG << "Setting '" << name << "' to '" << content
<< "' (unit='"<<unit<<"')" << std::endl;
const Property * prop =NULL;
bool need_delete= false;
if (hasPythonProperty(name)) {
need_delete=true;
prop = new Property(name, pythonPropertyType(name));
} else {
need_delete=false;
prop = this->property(name);
}
if (!prop) {;
GYOTO_DEBUG << "'" << name << "' not found, calling setParameter()"
<< std::endl;
// The specific setParameter() implementation may well know
// this entity
setParameter(name, content, unit);
} else {
GYOTO_DEBUG << "'" << name << "' found "<< std::endl;
std::vector<std::string> plugins;
switch (prop->type) {
case Property::metric_t:
set(*prop, fmp->metric());
break;
case Property::astrobj_t:
set(*prop, fmp->astrobj());
break;
case Property::screen_t:
set(*prop, fmp->screen());
break;
case Property::spectrum_t:
content = fmp -> getAttribute("kind");
child = fmp -> getChild();
plugins = Gyoto::split(fmp -> getAttribute("plugin"), ",");
set(*prop, (*Spectrum::getSubcontractor(content, plugins))(child, plugins) );
delete child;
break;
case Property::spectrometer_t:
content = fmp -> getAttribute("kind");
child = fmp -> getChild();
plugins = Gyoto::split(fmp -> getAttribute("plugin"), ",");
set(*prop, (*Spectrometer::getSubcontractor(content, plugins))(child, plugins) );
delete child;
break;
case Property::filename_t:
content = fmp->fullPath(content);
// no 'break;' here, we need to proceed
default:
setParameter(*prop, name, content, unit);
break;
}
}
if (need_delete) delete prop;
}
GYOTO_DEBUG << "Done processing parameters" << std::endl;
}
};
class Gyoto::Spectrum::Python
: public Gyoto::Python::Object<Gyoto::Spectrum::Generic>
{
friend class Gyoto::SmartPointer<Gyoto::Spectrum::Python>;
protected:
PyObject * pCall_;
PyObject * pIntegrate_;
bool pCall_overloaded_;
public:
GYOTO_OBJECT;
GYOTO_OBJECT_THREAD_SAFETY;
Python();
Python(const Python&);
virtual Python * clone() const;
~Python();
// For some reason we need to implement the bunch although only one
// is non-trivial
virtual std::string module() const ;
virtual void module(const std::string&);
virtual std::string inlineModule() const ;
virtual void inlineModule(const std::string&);
virtual std::string klass() const ;
virtual void klass(const std::string&);
virtual std::vector<double> parameters() const;
virtual void parameters(const std::vector<double>&);
virtual double operator()(double nu) const;
virtual double operator()(double nu, double opacity, double ds) const;
virtual double integrate(double nu1, double nu2) ;
};
class Gyoto::Metric::Python
: public Gyoto::Python::Object<Gyoto::Metric::Generic>
{
friend class Gyoto::SmartPointer<Gyoto::Metric::Python>;
private:
// Variables to cache Python objects:
PyObject * pGmunu_;
PyObject * pChristoffel_;
PyObject * pGetRmb_;
PyObject * pGetRms_;
PyObject * pGetSpecificAngularMomentum_;
PyObject * pGetPotential_;
PyObject * pIsStopCondition_;
PyObject * pCircularVelocity_;
public:
GYOTO_OBJECT;
GYOTO_OBJECT_THREAD_SAFETY;
Python();
Python(const Python&);
~Python();
virtual Python* clone() const ;
// Accessors for the Gyoto::Property members:
// Those are mere wrappers arround Generic::coordKind(), useful for
// declaring a boolen property using the macro GYOTO_PROPERTY_BOOL:
void spherical(bool);
bool spherical() const;
virtual std::string module() const ;
virtual void module(const std::string&);
virtual std::string inlineModule() const ;
virtual void inlineModule(const std::string&);
virtual std::string klass() const ;
virtual void klass(const std::string&);
virtual std::vector<double> parameters() const;
virtual void parameters(const std::vector<double>&);
using Gyoto::Metric::Generic::mass;
virtual void mass(double m);
// The minimal Gyoto::Metric API:
void gmunu(double g[4][4], const double * x) const ;
int christoffel(double dst[4][4][4], const double * x) const ;
// Little more
double getRmb() const;
double getRms() const;
double getSpecificAngularMomentum(double rr) const;
double getPotential(double const pos[4], double l_cst) const;
int isStopCondition(double const coord[8]) const;
void circularVelocity(double const pos[4], double vel[4],
double dir=1.) const ;
};
class Gyoto::Astrobj::Python::Standard
: public Gyoto::Python::Object<Gyoto::Astrobj::Standard>
{
friend class Gyoto::SmartPointer<Gyoto::Astrobj::Python::Standard>;
private:
PyObject *pEmission_, *pIntegrateEmission_, *pTransmission_, *pCall_,
*pGetVelocity_, *pGiveDelta_;
bool pEmission_overloaded_, pIntegrateEmission_overloaded_;
public:
GYOTO_OBJECT;
GYOTO_OBJECT_THREAD_SAFETY;
/* Birth and Death*/
Standard();
Standard(const Standard&);
~Standard();
Standard* clone() const;
/* Astrobj::Generic API */
virtual double emission(double nu_em, double dsem, state_t const &coord_ph,
double const coord_obj[8]=NULL) const ;
virtual void emission(double Inu[], double const nu_em[], size_t nbnu,
double dsem, state_t const &coord_ph,
double const coord_obj[8]=NULL) const ;
virtual double integrateEmission(double nu1, double nu2, double dsem,
state_t const &c_ph, double const c_obj[8]=NULL) const;
virtual void integrateEmission(double * I, double const * boundaries,
size_t const * chaninds, size_t nbnu,
double dsem, state_t const &cph, double const *co) const;
virtual double transmission(double nuem, double dsem, state_t const &cph, double const *co) const ;
/* Astrobj::Standard API */
virtual double operator()(double const coord[4]) ;
virtual void getVelocity(double const pos[4], double vel[4]) ;
virtual double giveDelta(double coord[8]);
/* Python::Base */
virtual std::string module() const ;
virtual void module(const std::string&);
virtual std::string inlineModule() const ;
virtual void inlineModule(const std::string&);
virtual std::string klass() const ;
virtual void klass(const std::string&);
virtual std::vector<double> parameters() const;
virtual void parameters(const std::vector<double>&);
virtual double criticalValue() const ;
virtual void criticalValue(double) ;
};
class Gyoto::Astrobj::Python::ThinDisk
: public Gyoto::Python::Object<Gyoto::Astrobj::ThinDisk>
{
friend class Gyoto::SmartPointer<Gyoto::Astrobj::Python::ThinDisk>;
private:
PyObject *pEmission_, *pIntegrateEmission_, *pTransmission_, *pCall_,
*pGetVelocity_, *pGiveDelta_;
bool pEmission_overloaded_, pIntegrateEmission_overloaded_;
public:
GYOTO_OBJECT;
GYOTO_OBJECT_THREAD_SAFETY;
/* Birth and Death*/
ThinDisk();
ThinDisk(const ThinDisk&);
~ThinDisk();
ThinDisk* clone() const;
/* Astrobj::Generic API */
virtual double emission(double nu_em, double dsem, state_t const &coord_ph,
double const coord_obj[8]=NULL) const ;
virtual void emission(double Inu[], double const nu_em[], size_t nbnu,
double dsem, state_t const &coord_ph,
double const coord_obj[8]=NULL) const ;
virtual double integrateEmission(double nu1, double nu2, double dsem,
state_t const &c_ph, double const c_obj[8]=NULL) const;
virtual void integrateEmission(double * I, double const * boundaries,
size_t const * chaninds, size_t nbnu,
double dsem, state_t const &cph, double const *co) const;
virtual double transmission(double nuem, double dsem, state_t const &cph ,double const *co) const ;
/* Astrobj::ThinDisk API */
virtual double operator()(double const coord[4]) ;
virtual void getVelocity(double const pos[4], double vel[4]) ;
/* Python::Base */
virtual std::string module() const ;
virtual void module(const std::string&);
virtual std::string inlineModule() const ;
virtual void inlineModule(const std::string&);
virtual std::string klass() const ;
virtual void klass(const std::string&);
virtual std::vector<double> parameters() const;
virtual void parameters(const std::vector<double>&);
};
#endif
GYOTO_DEBUG
#define GYOTO_DEBUG
Display debug message (in debug mode).
Definition GyotoDefs.h:341
GYOTO_DEBUG_EXPR
#define GYOTO_DEBUG_EXPR(a)
Output expression value in debug mode.
Definition GyotoDefs.h:280
GYOTO_ERROR
#define GYOTO_ERROR(msg)
Throw a Gyoto::Error nicely.
Definition GyotoError.h:196
GyotoFactoryMessenger.h
Factory / SmartPointee::Subcontractor_t interface.
GyotoMetric.h
Base class for metric description.
GYOTO_OBJECT
#define GYOTO_OBJECT
Declare class::properties and class::getProperties().
Definition GyotoObject.h:84
GyotoProperty.h
Introspectable properties.
GyotoScreen.h
Description of the observer screen.
GyotoSpectrum.h
Spectrum of a simple object (e.g. Star).
GyotoStandardAstrobj.h
Astronomical objects defined bya a potential/distance.
GyotoThinDisk.h
Geometrically thin disks and rings.
GyotoValue.h
Introspectable value.
Gyoto::Astrobj::Python::Standard
Coding a Gyoto::Astrobj::Standard in Python.
Definition GyotoPython.h:685
Gyoto::Astrobj::Python::Standard::getVelocity
virtual void getVelocity(double const pos[4], double vel[4])
Fluid velocity field.
Gyoto::Astrobj::Python::Standard::clone
Standard * clone() const
Cloner.
Gyoto::Astrobj::Python::Standard::module
virtual std::string module() const
Return module_.
Gyoto::Astrobj::Python::Standard::inlineModule
virtual std::string inlineModule() const
Return inline_module_.
Gyoto::Astrobj::Python::Standard::emission
virtual double emission(double nu_em, double dsem, state_t const &coord_ph, double const coord_obj[8]=NULL) const
Specific intensity Iν.
Gyoto::Astrobj::Python::Standard::giveDelta
virtual double giveDelta(double coord[8])
Maximum δ inside object.
Gyoto::Astrobj::Python::Standard::integrateEmission
virtual double integrateEmission(double nu1, double nu2, double dsem, state_t const &c_ph, double const c_obj[8]=NULL) const
∫ν1ν2 Iν dν (or jν)
Gyoto::Astrobj::Python::Standard::klass
virtual std::string klass() const
Retrieve class_.
Gyoto::Astrobj::Python::Standard::parameters
virtual std::vector< double > parameters() const
Retrieve parameters_.
Gyoto::Astrobj::Python::ThinDisk
Coding a Gyoto::Astrobj::ThinDisk in Python.
Definition GyotoPython.h:750
Gyoto::Astrobj::Python::ThinDisk::inlineModule
virtual std::string inlineModule() const
Return inline_module_.
Gyoto::Astrobj::Python::ThinDisk::getVelocity
virtual void getVelocity(double const pos[4], double vel[4])
Get fluid 4-velocity at point.
Gyoto::Astrobj::Python::ThinDisk::integrateEmission
virtual double integrateEmission(double nu1, double nu2, double dsem, state_t const &c_ph, double const c_obj[8]=NULL) const
∫ν1ν2 Iν dν (or jν)
Gyoto::Astrobj::Python::ThinDisk::emission
virtual double emission(double nu_em, double dsem, state_t const &coord_ph, double const coord_obj[8]=NULL) const
Specific intensity Iν.
Gyoto::Astrobj::Python::ThinDisk::klass
virtual std::string klass() const
Retrieve class_.
Gyoto::Astrobj::Python::ThinDisk::parameters
virtual std::vector< double > parameters() const
Retrieve parameters_.
Gyoto::Astrobj::Python::ThinDisk::clone
ThinDisk * clone() const
Cloner.
Gyoto::Astrobj::Python::ThinDisk::module
virtual std::string module() const
Return module_.
Gyoto::FactoryMessenger
Factory / SmartPointee::Subcontractor_t interface.
Definition GyotoFactoryMessenger.h:92
Gyoto::FactoryMessenger::fullPath
std::string fullPath(std::string relpath)
Transform path into full path specification.
Gyoto::FactoryMessenger::astrobj
SmartPointer< Astrobj::Generic > astrobj()
Build and get the Astrobj described in this XML file.
Gyoto::FactoryMessenger::getNextParameter
int getNextParameter(std::string *name, std::string *content, std::string *unit=NULL)
Get name and value of next parameter.
Gyoto::FactoryMessenger::metric
SmartPointer< Metric::Generic > metric()
Build and get the Metric described in this XML file.
Gyoto::FactoryMessenger::screen
SmartPointer< Screen > screen()
Build and get the Screen described in this XML file.
Gyoto::Metric::Generic::mass
virtual void mass(const double)
Set mass used in unitLength().
Gyoto::Metric::Python
Metric coded in Python.
Definition GyotoPython.h:590
Gyoto::Metric::Python::pGetPotential_
PyObject * pGetPotential_
Reference to the getPotential method.
Definition GyotoPython.h:623
Gyoto::Metric::Python::parameters
virtual std::vector< double > parameters() const
Retrieve parameters_.
Gyoto::Metric::Python::getSpecificAngularMomentum
double getSpecificAngularMomentum(double rr) const
Gyoto::Metric::Python::module
virtual std::string module() const
Return module_.
Gyoto::Metric::Python::pGetRmb_
PyObject * pGetRmb_
Reference to the getRmb method.
Definition GyotoPython.h:608
Gyoto::Metric::Python::circularVelocity
void circularVelocity(double const pos[4], double vel[4], double dir=1.) const
Yield circular velocity at a given position.
Gyoto::Metric::Python::pGetRms_
PyObject * pGetRms_
Reference to the getRms method.
Definition GyotoPython.h:613
Gyoto::Metric::Python::pIsStopCondition_
PyObject * pIsStopCondition_
Reference to the isStopCondition method.
Definition GyotoPython.h:628
Gyoto::Metric::Python::pChristoffel_
PyObject * pChristoffel_
Reference to the christoffel method.
Definition GyotoPython.h:603
Gyoto::Metric::Python::pGmunu_
PyObject * pGmunu_
Reference to the gmunu method.
Definition GyotoPython.h:598
Gyoto::Metric::Python::inlineModule
virtual std::string inlineModule() const
Return inline_module_.
Gyoto::Metric::Python::getPotential
double getPotential(double const pos[4], double l_cst) const
Gyoto::Metric::Python::getRms
double getRms() const
Gyoto::Metric::Python::pCircularVelocity_
PyObject * pCircularVelocity_
Reference to the circularVelocity method.
Definition GyotoPython.h:633
Gyoto::Metric::Python::clone
virtual Python * clone() const
Virtual copy constructor.
Gyoto::Metric::Python::mass
virtual void mass(double m)
Set mass used in unitLength().
Gyoto::Metric::Python::klass
virtual std::string klass() const
Retrieve class_.
Gyoto::Metric::Python::pGetSpecificAngularMomentum_
PyObject * pGetSpecificAngularMomentum_
Reference to the method getSpecificAngularMomentum.
Definition GyotoPython.h:618
Gyoto::Metric::Python::getRmb
double getRmb() const
Gyoto::Metric::Python::isStopCondition
int isStopCondition(double const coord[8]) const
Check whether integration should stop.
Gyoto::Property
Property that can be set and got using standard methods.
Definition GyotoProperty.h:608
Gyoto::Property::typeFromString
static type_e typeFromString(std::string stype)
Get Property::type_e value from name.
Gyoto::Property::type_e
type_e
Possible type of a Property instance.
Definition GyotoProperty.h:616
Gyoto::Property::metric_t
@ metric_t
Type is Gyoto::SmartPointer<Gyoto::Metric::Generic>.
Definition GyotoProperty.h:644
Gyoto::Property::astrobj_t
@ astrobj_t
Type is Gyoto::SmartPointer<Gyoto::Astrobj::Generic>.
Definition GyotoProperty.h:648
Gyoto::Property::filename_t
@ filename_t
Type is std::string and holds a file name.
Definition GyotoProperty.h:638
Gyoto::Property::spectrometer_t
@ spectrometer_t
Type is Gyoto::SmartPointer<Gyoto::Spectrometer::Generic>.
Definition GyotoProperty.h:652
Gyoto::Property::spectrum_t
@ spectrum_t
Type is Gyoto::SmartPointer<Gyoto::Spectrum::Generic>.
Definition GyotoProperty.h:650
Gyoto::Property::screen_t
@ screen_t
Type is Gyoto::SmartPointer<Gyoto::Screen::Generic>.
Definition GyotoProperty.h:646
Gyoto::Property::name
std::string name
Name of this instance.
Definition GyotoProperty.h:663
Gyoto::Property::type
int type
Type of this instance.
Definition GyotoProperty.h:670
Gyoto::Python::Base
Base class for classes in the Python plug-in.
Definition GyotoPython.h:192
Gyoto::Python::Base::inlineModule
virtual void inlineModule(const std::string &)
Set inline_module_ and import the Python module.
Gyoto::Python::Base::module
virtual void module(const std::string &)
Set module_ and import the Python module.
Gyoto::Python::Base::class_
std::string class_
Name of the Python class that we want to expose.
Definition GyotoPython.h:213
Gyoto::Python::Base::pGet_
PyObject * pGet_
Reference to the (optional) Get method.
Definition GyotoPython.h:247
Gyoto::Python::Base::inlineModule
virtual std::string inlineModule() const
Return inline_module_.
Gyoto::Python::Base::pProperties_
PyObject * pProperties_
Reference to the properties member.
Definition GyotoPython.h:237
Gyoto::Python::Base::module_
std::string module_
Name of the Python module that holds the class.
Definition GyotoPython.h:200
Gyoto::Python::Base::klass
virtual std::string klass() const
Retrieve class_.
Gyoto::Python::Base::pSet_
PyObject * pSet_
Reference to the (optional) Set method.
Definition GyotoPython.h:242
Gyoto::Python::Base::module
virtual std::string module() const
Return module_.
Gyoto::Python::Base::parameters_
std::vector< double > parameters_
Parameters that this class needs.
Definition GyotoPython.h:222
Gyoto::Python::Base::pInstance_
PyObject * pInstance_
Reference to the python instance once it has been instantiated.
Definition GyotoPython.h:232
Gyoto::Python::Base::klass
virtual void klass(const std::string &c)
Set class_ and instantiate the Python class.
Gyoto::Python::Base::parameters
virtual void parameters(const std::vector< double > &)
Set parameters_ and send them to pInstance_.
Gyoto::Python::Base::inline_module_
std::string inline_module_
Python source code for module that holds the class.
Definition GyotoPython.h:206
Gyoto::Python::Base::parameters
virtual std::vector< double > parameters() const
Retrieve parameters_.
Gyoto::Python::Base::pModule_
PyObject * pModule_
Reference to the python module once it has been loaded.
Definition GyotoPython.h:227
Gyoto::Python::Object
Class template to implement parts of the Gyoto::Object API.
Definition GyotoPython.h:321
Gyoto::SmartPointer
Pointers performing reference counting.
Definition GyotoSmartPointer.h:135
Gyoto::Spectrum::Python
Loader for Python classes implementing the Spectrum interface.
Definition GyotoPython.h:503
Gyoto::Spectrum::Python::pCall_
PyObject * pCall_
Reference to ___call__.
Definition GyotoPython.h:513
Gyoto::Spectrum::Python::inlineModule
virtual std::string inlineModule() const
Return inline_module_.
Gyoto::Spectrum::Python::pCall_overloaded_
bool pCall_overloaded_
Whether call is overloaded.
Definition GyotoPython.h:537
Gyoto::Spectrum::Python::clone
virtual Python * clone() const
Cloner.
Gyoto::Spectrum::Python::parameters
virtual std::vector< double > parameters() const
Retrieve parameters_.
Gyoto::Spectrum::Python::klass
virtual std::string klass() const
Retrieve class_.
Gyoto::Spectrum::Python::module
virtual std::string module() const
Return module_.
Gyoto::Spectrum::Python::integrate
virtual double integrate(double nu1, double nu2)
Integrate optically thick I_nu.
Gyoto::Spectrum::Python::pIntegrate_
PyObject * pIntegrate_
Reference to the (optional) integrate method.
Definition GyotoPython.h:518
Gyoto::Value
Container for the value of a Property.
Definition GyotoValue.h:60
Gyoto::Value::type
int type
Type of this instance.
Definition GyotoValue.h:72
Gyoto::Astrobj::Python
Classes that wrap Python classes as Gyoto Astrobj implementations.
Gyoto::Astrobj
Access to astronomical objects.
Definition GyotoAstrobj.h:49
Gyoto::Python
Helpers for the classes deriving from Gyoto::Python::Base.
Gyoto::Python::pGyotoThinDisk
PyObject * pGyotoThinDisk()
Get reference to the ThinDisk constructor in the gyoto Python extension.
Gyoto::Python::pGyotoSpectrum
PyObject * pGyotoSpectrum()
Get reference to the Spectrum constructor in the gyoto Python extension.
Gyoto::Python::PyImport_Gyoto
PyObject * PyImport_Gyoto()
Return refernce to the gyoto module, or NULL.
Gyoto::Python::PyInstance_GetMethod
PyObject * PyInstance_GetMethod(PyObject *pInstance, const char *name)
Return new reference to method, or NULL if method not found.
Gyoto::Python::PyModule_NewFromPythonCode
PyObject * PyModule_NewFromPythonCode(const char *code)
Create module from Python source code in a C string.
Gyoto::Python::pGyotoMetric
PyObject * pGyotoMetric()
Get reference to the Metric constructor in the gyoto Python extension.
Gyoto::Python::PyInstance_SetThis
void PyInstance_SetThis(PyObject *pInstance, PyObject *pNew, void *ptr)
Set "this" attribute in instance.
Gyoto::Python::PyObject_FromGyotoValue
PyObject * PyObject_FromGyotoValue(const Gyoto::Value &)
Convert Gyoto Value to Python Object.
Gyoto::Python::pGyotoStandardAstrobj
PyObject * pGyotoStandardAstrobj()
Get reference to the StandardAstrobj constructor in the gyoto Python extension.
Gyoto::Python::PyCallable_HasVarArg
bool PyCallable_HasVarArg(PyObject *pMethod)
Check whether method accepts the varargs argument.
Gyoto::Spectrometer::getSubcontractor
Gyoto::Spectrometer::Subcontractor_t * getSubcontractor(std::string name, std::vector< std::string > &plugins, int errmode=0)
Query the Spectrometer register.
Gyoto::Spectrum
Spectrum of a simple object (e.g. a Gyoto::Astrobj::Star).
Definition GyotoBlackBodySpectrum.h:35
Gyoto::Spectrum::getSubcontractor
Gyoto::Spectrum::Subcontractor_t * getSubcontractor(std::string name, std::vector< std::string > &plugins, int errmode=0)
Query the Spectrum register.
Gyoto
Namespace for the Gyoto library.
Definition GyotoAstrobj.h:44
Gyoto::split
std::vector< std::string > split(std::string const &src, std::string const &delim)
Split string.