[fca6936] | 1 | #include "dispersion_visitor.hh" |
---|
| 2 | #include "parameters.hh" |
---|
| 3 | |
---|
| 4 | #ifndef __MODELS_STANDALONE__ |
---|
| 5 | extern "C" { |
---|
| 6 | #include <Python.h> |
---|
| 7 | } |
---|
| 8 | #endif |
---|
| 9 | |
---|
| 10 | void DispersionVisitor:: dispersion_to_dict(void* dispersion, void* dictionary) { |
---|
| 11 | #ifndef __MODELS_STANDALONE__ |
---|
| 12 | DispersionModel * disp = (DispersionModel*)dispersion; |
---|
| 13 | PyObject * dict = (PyObject*)dictionary; |
---|
| 14 | |
---|
| 15 | PyDict_SetItemString(dict, "type", Py_BuildValue("s", "flat")); |
---|
| 16 | PyDict_SetItemString(dict, "npts", Py_BuildValue("i", disp->npts)); |
---|
| 17 | PyDict_SetItemString(dict, "width", Py_BuildValue("d", disp->width)); |
---|
| 18 | #endif |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | void DispersionVisitor:: gaussian_to_dict(void* dispersion, void* dictionary) { |
---|
| 22 | #ifndef __MODELS_STANDALONE__ |
---|
| 23 | GaussianDispersion * disp = (GaussianDispersion*)dispersion; |
---|
| 24 | PyObject * dict = (PyObject*)dictionary; |
---|
| 25 | |
---|
| 26 | PyDict_SetItemString(dict, "type", Py_BuildValue("s", "gaussian")); |
---|
| 27 | PyDict_SetItemString(dict, "npts", Py_BuildValue("i", disp->npts)); |
---|
| 28 | PyDict_SetItemString(dict, "width", Py_BuildValue("d", disp->width)); |
---|
| 29 | PyDict_SetItemString(dict, "nsigmas", Py_BuildValue("i", disp->nsigmas)); |
---|
| 30 | #endif |
---|
| 31 | } |
---|
| 32 | |
---|
[eba9885] | 33 | void DispersionVisitor:: lognormal_to_dict(void* dispersion, void* dictionary) { |
---|
| 34 | #ifndef __MODELS_STANDALONE__ |
---|
| 35 | LogNormalDispersion * disp = (LogNormalDispersion*)dispersion; |
---|
| 36 | PyObject * dict = (PyObject*)dictionary; |
---|
| 37 | |
---|
| 38 | PyDict_SetItemString(dict, "type", Py_BuildValue("s", "lognormal")); |
---|
| 39 | PyDict_SetItemString(dict, "npts", Py_BuildValue("i", disp->npts)); |
---|
| 40 | PyDict_SetItemString(dict, "width", Py_BuildValue("d", disp->width)); |
---|
| 41 | PyDict_SetItemString(dict, "nsigmas", Py_BuildValue("i", disp->nsigmas)); |
---|
| 42 | #endif |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | void DispersionVisitor:: schulz_to_dict(void* dispersion, void* dictionary) { |
---|
| 47 | #ifndef __MODELS_STANDALONE__ |
---|
| 48 | SchulzDispersion * disp = (SchulzDispersion*)dispersion; |
---|
| 49 | PyObject * dict = (PyObject*)dictionary; |
---|
| 50 | |
---|
| 51 | PyDict_SetItemString(dict, "type", Py_BuildValue("s", "schulz")); |
---|
| 52 | PyDict_SetItemString(dict, "npts", Py_BuildValue("i", disp->npts)); |
---|
| 53 | PyDict_SetItemString(dict, "width", Py_BuildValue("d", disp->width)); |
---|
| 54 | PyDict_SetItemString(dict, "nsigmas", Py_BuildValue("i", disp->nsigmas)); |
---|
| 55 | #endif |
---|
| 56 | } |
---|
| 57 | |
---|
[fca6936] | 58 | void DispersionVisitor:: array_to_dict(void* dispersion, void* dictionary) { |
---|
| 59 | #ifndef __MODELS_STANDALONE__ |
---|
| 60 | ArrayDispersion * disp = (ArrayDispersion*)dispersion; |
---|
| 61 | PyObject * dict = (PyObject*)dictionary; |
---|
| 62 | |
---|
| 63 | PyDict_SetItemString(dict, "type", Py_BuildValue("s", "array")); |
---|
| 64 | #endif |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | void DispersionVisitor:: dispersion_from_dict(void* dispersion, void* dictionary) { |
---|
| 68 | #ifndef __MODELS_STANDALONE__ |
---|
| 69 | DispersionModel * disp = (DispersionModel*)dispersion; |
---|
| 70 | PyObject * dict = (PyObject*)dictionary; |
---|
| 71 | |
---|
| 72 | disp->npts = PyInt_AsLong( PyDict_GetItemString(dict, "npts") ); |
---|
| 73 | disp->width = PyFloat_AsDouble( PyDict_GetItemString(dict, "width") ); |
---|
| 74 | #endif |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | void DispersionVisitor:: gaussian_from_dict(void* dispersion, void* dictionary) { |
---|
| 78 | #ifndef __MODELS_STANDALONE__ |
---|
| 79 | GaussianDispersion * disp = (GaussianDispersion*)dispersion; |
---|
| 80 | PyObject * dict = (PyObject*)dictionary; |
---|
| 81 | |
---|
| 82 | disp->npts = PyInt_AsLong( PyDict_GetItemString(dict, "npts") ); |
---|
| 83 | disp->width = PyFloat_AsDouble( PyDict_GetItemString(dict, "width") ); |
---|
| 84 | disp->nsigmas = PyFloat_AsDouble( PyDict_GetItemString(dict, "nsigmas") ); |
---|
| 85 | #endif |
---|
| 86 | } |
---|
| 87 | |
---|
[eba9885] | 88 | void DispersionVisitor:: lognormal_from_dict(void* dispersion, void* dictionary) { |
---|
| 89 | #ifndef __MODELS_STANDALONE__ |
---|
| 90 | LogNormalDispersion * disp = (LogNormalDispersion*)dispersion; |
---|
| 91 | PyObject * dict = (PyObject*)dictionary; |
---|
| 92 | |
---|
| 93 | disp->npts = PyInt_AsLong( PyDict_GetItemString(dict, "npts") ); |
---|
| 94 | disp->width = PyFloat_AsDouble( PyDict_GetItemString(dict, "width") ); |
---|
| 95 | disp->nsigmas = PyFloat_AsDouble( PyDict_GetItemString(dict, "nsigmas") ); |
---|
| 96 | #endif |
---|
| 97 | } |
---|
| 98 | void DispersionVisitor:: schulz_from_dict(void* dispersion, void* dictionary) { |
---|
| 99 | #ifndef __MODELS_STANDALONE__ |
---|
| 100 | SchulzDispersion * disp = (SchulzDispersion*)dispersion; |
---|
| 101 | PyObject * dict = (PyObject*)dictionary; |
---|
| 102 | |
---|
| 103 | disp->npts = PyInt_AsLong( PyDict_GetItemString(dict, "npts") ); |
---|
| 104 | disp->width = PyFloat_AsDouble( PyDict_GetItemString(dict, "width") ); |
---|
| 105 | disp->nsigmas = PyFloat_AsDouble( PyDict_GetItemString(dict, "nsigmas") ); |
---|
| 106 | #endif |
---|
| 107 | } |
---|
| 108 | |
---|
[fca6936] | 109 | void DispersionVisitor:: array_from_dict(void* dispersion, void* dictionary) {} |
---|