Main Lemma Repository
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pyLemmaCore.cpp 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* This file is part of Lemma, a geophysical modelling and inversion API.
  2. * More information is available at http://lemmasoftware.org
  3. */
  4. /* This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file
  10. * @date 22/04/19 14:06:32
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email Trevor.Irons@utah.edu
  14. * @copyright Copyright (c) 2019, University of Utah
  15. * @copyright Copyright (c) 2019, Lemma Software, LLC
  16. */
  17. #include <pybind11/pybind11.h>
  18. #include <pybind11/iostream.h>
  19. #include <pybind11/eigen.h>
  20. #include "LemmaCore"
  21. namespace py = pybind11;
  22. PYBIND11_MODULE(pyLemmaCore, m) {
  23. py::add_ostream_redirect(m, "ostream_redirect");
  24. m.doc() = "Python binding of LemmaCore, additional details can be found at https://lemmasoftware.org";
  25. py::class_<Lemma::RectilinearGrid, std::shared_ptr<Lemma::RectilinearGrid> >(m, "RectilinearGrid")
  26. // lifecycle
  27. .def(py::init(&Lemma::RectilinearGrid::NewSP))
  28. // print
  29. .def("__repr__", &Lemma::RectilinearGrid::Print)
  30. .def("Serialize", &Lemma::RectilinearGrid::Print, "YAML representation of the class")
  31. // accessors
  32. .def("GetName", &Lemma::RectilinearGrid::GetName, "Returns the name of the class")
  33. .def("GetNx", &Lemma::RectilinearGrid::GetNx, "Returns the number of cells in the x direction")
  34. .def("GetNy", &Lemma::RectilinearGrid::GetNy, "Returns the number of cells in the y direction")
  35. .def("GetNz", &Lemma::RectilinearGrid::GetNz, "Returns the number of cells in the z direction")
  36. .def("GetOx", &Lemma::RectilinearGrid::GetOx, "Returns the grid origin offset in the x direction")
  37. .def("GetOy", &Lemma::RectilinearGrid::GetOy, "Returns the grid origin offset in the y direction")
  38. .def("GetOz", &Lemma::RectilinearGrid::GetOz, "Returns the grid origin offset in the z direction")
  39. .def("GetDx", &Lemma::RectilinearGrid::GetDx, "Returns the grid spacing in the x direction")
  40. .def("GetDy", &Lemma::RectilinearGrid::GetDy, "Returns the grid spacing in the y direction")
  41. .def("GetDz", &Lemma::RectilinearGrid::GetDz, "Returns the grid spacing in the z direction")
  42. // modifiers
  43. .def("SetDimensions", &Lemma::RectilinearGrid::SetDimensions, "Sets the number of cells in x, y, and z")
  44. .def("SetOffset", &Lemma::RectilinearGrid::SetOffset, "Sets the origin offset in x, y, and z")
  45. .def("SetSpacing", &Lemma::RectilinearGrid::SetSpacing, "Sets the grid spacing in x, y, and z");
  46. py::class_<Lemma::ASCIIParser, std::shared_ptr<Lemma::ASCIIParser> >(m, "ASCIIParser")
  47. // lifecycle
  48. .def(py::init(&Lemma::ASCIIParser::NewSP))
  49. // print
  50. .def("__repr__", &Lemma::ASCIIParser::Print)
  51. .def("Serialize", &Lemma::ASCIIParser::Print, "YAML representation of the class")
  52. // accessors
  53. .def("GetName", &Lemma::ASCIIParser::GetName, "Returns the name of the class")
  54. .def("GetFileLocation", &Lemma::ASCIIParser::GetFileLocation, "Returns the current file location")
  55. // modifiers
  56. .def("SetCommentString", &Lemma::ASCIIParser::SetCommentString, "Sets the comment string after which all text is ignored")
  57. .def("SetBufferSize", &Lemma::ASCIIParser::SetBufferSize, "Sets the buffer size")
  58. // methods
  59. .def("Open", &Lemma::ASCIIParser::Open, "Opens file specified by argument")
  60. .def("Close", &Lemma::ASCIIParser::Close, "Closes current file object")
  61. .def("ReadReals", &Lemma::ASCIIParser::ReadReals, "Returns vector of nr reals")
  62. .def("ReadInts", &Lemma::ASCIIParser::ReadInts, "Returns vector of ni ints")
  63. .def("ReadStrings", &Lemma::ASCIIParser::ReadStrings, "Returns vector of ns strings")
  64. .def("JumpToLocation", &Lemma::ASCIIParser::JumpToLocation, "File object jumps to specified location")
  65. ;
  66. }
  67. /*
  68. BOOST_PYTHON_MODULE(pyLemmaCore)
  69. {
  70. Py_Initialize();
  71. np::initialize();
  72. bp::class_<Lemma::RectilinearGrid, boost::noncopyable> ("RectilinearGrid", boost::python::no_init)
  73. // print
  74. .def(boost::python::self_ns::str(bp::self))
  75. // Lifecycle
  76. .def("__init__", boost::python::make_constructor(&Lemma::RectilinearGrid::NewSP))
  77. //.def("Serialize", &Lemma::RectilinearGrid::Serialize)
  78. //.def("DeSerialize", &Lemma::RectilinearGrid::DeSerialize)
  79. // Accessors
  80. ;
  81. }
  82. */