Browse Source

Beginning of python wrapper for Merlin

master
Trevor Irons 3 years ago
parent
commit
f29523a616
7 changed files with 383 additions and 3 deletions
  1. 5
    0
      CMakeLists.txt
  2. 1
    1
      examples/KernelV0.cpp
  3. 9
    1
      include/KernelV0.h
  4. 14
    0
      python/CMakeLists.txt
  5. 0
    0
      python/__init__.py
  6. 342
    0
      python/pyMerlin.cpp
  7. 12
    1
      src/KernelV0.cpp

+ 5
- 0
CMakeLists.txt View File

@@ -34,6 +34,11 @@ if (LEMMA_ENABLE_TESTING)
34 34
 	add_subdirectory(testing)
35 35
 endif()
36 36
 
37
+# Python Bindings
38
+if (LEMMA_PYTHON3_BINDINGS)
39
+	add_subdirectory(python)
40
+endif()
41
+
37 42
 # Install
38 43
 install ( TARGETS merlin DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
39 44
 install ( FILES include/Merlin  DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma ) 

+ 1
- 1
examples/KernelV0.cpp View File

@@ -58,7 +58,7 @@ int main(int argc, char** argv) {
58 58
 
59 59
         Kern->SetIntegrationSize( (Vector3r() << 200,200,200).finished() );
60 60
         Kern->SetIntegrationOrigin( (Vector3r() << 0,0,0).finished() );
61
-        Kern->SetTolerance( 1e-11 ); // 1e-12
61
+        Kern->SetTolerance( 1e-12 ); // 1e-12
62 62
 
63 63
         auto AkvoDataNode = YAML::LoadFile(argv[4]);
64 64
         Kern->AlignWithAkvoDataset( AkvoDataNode );

+ 9
- 1
include/KernelV0.h View File

@@ -35,8 +35,8 @@
35 35
 #include "vtkHyperTree.h"
36 36
 #include "vtkHyperTree.h"
37 37
 #include "vtkHyperTreeGrid.h"
38
-#include "vtkHyperTreeCursor.h"
39 38
 #include "vtkXMLHyperTreeGridWriter.h"
39
+#include "vtkHyperTreeCursor.h"  // not in VTK 8.90
40 40
 //#include "vtkHyperTreeGridLevelEntry.h" VTK 9
41 41
 #include "vtkDoubleArray.h"
42 42
 #endif
@@ -129,6 +129,14 @@ namespace Lemma {
129 129
          */
130 130
         static std::shared_ptr<KernelV0> DeSerialize(const YAML::Node& node);
131 131
 
132
+        /**
133
+         *   Constructs an object from a string representation of a YAML::Node. This is primarily
134
+         *   used in Python wrapping
135
+         */
136
+        static std::shared_ptr<KernelV0> DeSerialize( const std::string& node ) {
137
+            return KernelV0::DeSerialize(YAML::Load(node));
138
+        }
139
+
132 140
         // ====================  OPERATORS     =======================
133 141
 
134 142
         // ====================  OPERATIONS    =======================

+ 14
- 0
python/CMakeLists.txt View File

@@ -0,0 +1,14 @@
1
+
2
+add_library(pyMerlin MODULE pyMerlin.cpp)
3
+target_link_libraries(pyMerlin PRIVATE pybind11::module lemmacore fdem1d merlin )
4
+set_target_properties(pyMerlin PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
5
+                                       SUFFIX "${PYTHON_MODULE_EXTENSION}"
6
+                                                      OUTPUT_NAME "Merlin"
7
+)
8
+
9
+install(TARGETS pyMerlin
10
+	COMPONENT python
11
+	RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/pyLemma/pyLemma/"
12
+	LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/pyLemma/pyLemma/"
13
+	ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/pyLemma/pyLemma/"
14
+)

+ 0
- 0
python/__init__.py View File


+ 342
- 0
python/pyMerlin.cpp View File

@@ -0,0 +1,342 @@
1
+/* This file is part of Lemma, a geophysical modelling and inversion API.
2
+ * More information is available at http://lemmasoftware.org
3
+ */
4
+
5
+/* This Source Code Form is subject to the terms of the Mozilla Public
6
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
7
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
+ */
9
+
10
+/**
11
+ * @file
12
+ * @date      22/04/19 14:06:32
13
+ * @version   $Id$
14
+ * @author    Trevor Irons (ti)
15
+ * @email     Trevor.Irons@utah.edu
16
+ * @copyright Copyright (c) 2019, University of Utah
17
+ * @copyright Copyright (c) 2019, Lemma Software, LLC
18
+ */
19
+
20
+#include <pybind11/pybind11.h>
21
+#include <pybind11/iostream.h>
22
+#include <pybind11/eigen.h>
23
+#include "Merlin"
24
+
25
+namespace py = pybind11;
26
+
27
+PYBIND11_MODULE(Merlin, m) {
28
+
29
+    py::add_ostream_redirect(m, "ostream_redirect");
30
+
31
+    m.doc() = "Python binding of Lemma::Merlin, additional details can be found at https://lemmasoftware.org";
32
+
33
+    py::class_<Lemma::KernelV0, std::shared_ptr<Lemma::KernelV0> > KernelV0(m, "KernelV0");
34
+
35
+        // lifecycle
36
+        KernelV0.def(py::init(&Lemma::KernelV0::NewSP))
37
+            .def_static("DeSerialize", py::overload_cast<const std::string&>(&Lemma::KernelV0::DeSerialize),
38
+            "Construct object from yaml representation")
39
+
40
+            // print
41
+            .def("Serialize", &Lemma::KernelV0::Print, "YAML representation of the class")
42
+            .def("__repr__", &Lemma::KernelV0::Print)
43
+
44
+            // modifiers
45
+            .def("PushCoil", &Lemma::KernelV0::PushCoil, "Adds a coil to the sNMR instrument")
46
+            .def("SetLayeredEarthEM", &Lemma::KernelV0::SetLayeredEarthEM, "Sets the EM model used in kernel calculation")
47
+            .def("SetIntegrationSize", &Lemma::KernelV0::SetIntegrationSize, "Sets the size of the volume to integrate the kernel")
48
+            .def("SetIntegrationOrigin", &Lemma::KernelV0::SetIntegrationOrigin, "Sets the origin of the integration volume")
49
+            .def("SetPulseCurrent", &Lemma::KernelV0::SetPulseCurrent, "Sets the current of the pulses")
50
+            .def("SetTemperature", &Lemma::KernelV0::SetTemperature, "Sets the temperature, in K")
51
+            .def("SetTolerance", &Lemma::KernelV0::SetTolerance, "Sets the tolerance used in octree splitting")
52
+            .def("SetPulseDuration", &Lemma::KernelV0::SetPulseDuration, "Sets the duration of the pulse")
53
+            .def("SetDepthLayerInteraces", &Lemma::KernelV0::SetDepthLayerInterfaces, "Sets the layer depth interfaces")
54
+
55
+            // accessors
56
+            .def("GetName", &Lemma::KernelV0::GetName, "Returns the name of the class")
57
+            .def("GetSigmaModel", &Lemma::KernelV0::GetSigmaModel, "Returns the conductivity model")
58
+            .def("GetKernel", &Lemma::KernelV0::GetKernel, "Returns the imaging kernel in matrix form")
59
+            .def("GetTolerance", &Lemma::KernelV0::GetTolerance, "Returns the tolerance which was used to construct the kernel")
60
+            .def("GetInterfaces", &Lemma::KernelV0::GetInterfaces, "Returns the layer interfaces")
61
+            .def("GetPulseCurrent", &Lemma::KernelV0::GetPulseCurrent, "Returns the pulse current")
62
+            .def("GetPulseDuration", &Lemma::KernelV0::GetPulseDuration, "Returns the length of the pulse moment")
63
+
64
+            // operations
65
+            .def("CalculateK0", &Lemma::KernelV0::CalculateK0, "Calculates an intial amplitude kernel")
66
+
67
+            //.def("AlignWithAkvoDataset", &Lemma::KernelV0::AlignWithAkvoDataset, "Aligns the kernel parameters with a dataset")
68
+
69
+
70
+
71
+        ;
72
+//
73
+//     py::class_<Lemma::PolygonalWireAntenna, std::shared_ptr<Lemma::PolygonalWireAntenna> > PolygonalWireAntenna(m,
74
+//             "PolygonalWireAntenna", KernelV0);
75
+//
76
+//         // lifecycle
77
+//         PolygonalWireAntenna.def(py::init(&Lemma::PolygonalWireAntenna::NewSP))
78
+//         .def_static("DeSerialize", py::overload_cast<const std::string&>(&Lemma::PolygonalWireAntenna::DeSerialize),
79
+//             "Construct object from yaml representation")
80
+//
81
+//         // print
82
+//         .def("__repr__", &Lemma::PolygonalWireAntenna::Print)
83
+//         .def("Serialize", &Lemma::PolygonalWireAntenna::Print, "YAML representation of the class")
84
+//
85
+//         // accessors
86
+//         .def("GetName", &Lemma::PolygonalWireAntenna::GetName, "Returns the name of the class")
87
+//
88
+//         // operations
89
+//         .def("ApproximateWithElectricDipoles", &Lemma::PolygonalWireAntenna::ApproximateWithElectricDipoles,
90
+//             "Approximates loop with series of electric dipoles around loop")
91
+//
92
+//         // modifiers
93
+//         .def("SetMinDipoleRatio", &Lemma::PolygonalWireAntenna::SetMinDipoleRatio,
94
+//             "Sets the minimum dipole ratio use, smaller values increase precision")
95
+//         .def("SetMinDipoleMoment", &Lemma::PolygonalWireAntenna::SetMinDipoleMoment,
96
+//             "Sets the minimum dipole moment which will be used, smaller values increase precision and computational time")
97
+//         .def("SetMaxDipoleMoment", &Lemma::PolygonalWireAntenna::SetMaxDipoleMoment,
98
+//             "Sets the maximum dipole moment which will be used, smaller values increase precision and computational time")
99
+//     ;
100
+//
101
+//     py::class_<Lemma::DipoleSource, std::shared_ptr<Lemma::DipoleSource> > DipoleSource(m, "DipoleSource");
102
+//
103
+//         // lifecycle
104
+//         DipoleSource.def(py::init(&Lemma::DipoleSource::NewSP))
105
+//         .def_static("DeSerialize", py::overload_cast<const std::string&>(&Lemma::DipoleSource::DeSerialize),
106
+//             "Construct object from yaml representation")
107
+//
108
+//         // print
109
+//         .def("Serialize", &Lemma::DipoleSource::Print, "YAML representation of the class")
110
+//         .def("__repr__", &Lemma::DipoleSource::Print)
111
+//
112
+//         // accessors
113
+//         .def("GetName", &Lemma::DipoleSource::GetName, "Returns the name of the class")
114
+//         .def("GetNumberOfFrequencies", &Lemma::DipoleSource::GetNumberOfFrequencies,
115
+//                 "Returns the number of frequencies")
116
+//         .def("GetFrequencies", &Lemma::DipoleSource::GetFrequencies, "Returns an array of frequencies")
117
+//         .def("GetFrequency", &Lemma::DipoleSource::GetFrequency, "Returns the frequency of the argument index")
118
+//         .def("GetAngularFrequency", &Lemma::DipoleSource::GetAngularFrequency,
119
+//             "Returns the angular frequency of the argument index")
120
+//         .def("GetPhase", &Lemma::DipoleSource::GetPhase, "Returns the phase of the dipole")
121
+//         .def("GetMoment", &Lemma::DipoleSource::GetMoment, "Returns the moment of the dipole")
122
+//         .def("GetLocation", py::overload_cast< >(&Lemma::DipoleSource::GetLocation), "Returns the location of the dipole")
123
+//         .def("GetPolarisation", &Lemma::DipoleSource::GetPolarisation, "Returns the polarisation of the dipole")
124
+//
125
+//         // modifiers
126
+//         .def("SetLocation", py::overload_cast<const Lemma::Vector3r&> (&Lemma::DipoleSource::SetLocation),
127
+//             "Sets the location of the dipole")
128
+//         .def("SetPolarisation", py::overload_cast<const Lemma::Vector3r&> (&Lemma::DipoleSource::SetPolarisation),
129
+//             "Sets the polarisation of the dipole")
130
+//         .def("SetType", &Lemma::DipoleSource::SetType, "Sets the type")
131
+//         .def("SetMoment", &Lemma::DipoleSource::SetMoment, "Sets the moment of the dipole")
132
+//         .def("SetPhase", &Lemma::DipoleSource::SetPhase, "Sets the phase of the dipole")
133
+//         .def("SetNumberOfFrequencies", &Lemma::DipoleSource::SetNumberOfFrequencies,
134
+//             "Sets the number of frequencies to calculate for the dipole")
135
+//         .def("SetFrequency", &Lemma::DipoleSource::SetFrequency,
136
+//             "Sets a single frequency, first argument is index, second argument is frequency")
137
+//         .def("SetFrequencies", &Lemma::DipoleSource::SetFrequencies,
138
+//             "Sets all frequencies, argument is numpy array of frequencies")
139
+//         ;
140
+//
141
+//     py::class_<Lemma::LayeredEarthEM, std::shared_ptr<Lemma::LayeredEarthEM> >
142
+//         LayeredEarthEM(m, "LayeredEarthEM");
143
+//
144
+//         // lifecycle
145
+//         LayeredEarthEM.def(py::init(&Lemma::LayeredEarthEM::NewSP))
146
+//         .def_static("DeSerialize", py::overload_cast<const std::string&>
147
+//             (&Lemma::LayeredEarthEM::DeSerialize),"Construct object from yaml representation")
148
+//
149
+//         // print
150
+//         .def("Serialize", &Lemma::LayeredEarthEM::Print, "YAML representation of the class")
151
+//         .def("__repr__", &Lemma::LayeredEarthEM::Print)
152
+//
153
+//         // accessors
154
+//         .def("GetName", &Lemma::LayeredEarthEM::GetName, "Returns the name of the class")
155
+//
156
+//         .def("GetLayerConductivity", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerConductivity),
157
+//             "Returns the conductivity of all layers")
158
+//         .def("GetLayerConductivity1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerConductivity),
159
+//             "Returns the conductivity of the specified layer")
160
+//
161
+//         .def("GetLayerSusceptibility", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerSusceptibility),
162
+//             "Returns the susceptibility of all layers")
163
+//         .def("GetLayerSusceptibility1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerSusceptibility),
164
+//             "Returns the susceptibilty of the specified layer")
165
+//         .def("GetLayerLowFreqSusceptibility", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerLowFreqSusceptibility),
166
+//             "Returns the low frequqncy permitivity of all layers")
167
+//         .def("GetLayerLowFreqSusceptibility1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerLowFreqSusceptibility),
168
+//             "Returns the low frequency permitivity of the specified layer")
169
+//         .def("GetLayerHighFreqSusceptibility", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerHighFreqSusceptibility),
170
+//             "Returns the low frequency permitivity of all layers")
171
+//         .def("GetLayerHighFreqSusceptibility1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerHighFreqSusceptibility),
172
+//             "Returns the low frequency permitivity of the specified layer")
173
+//         .def("GetLayerTauSusceptibility", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerTauSusceptibility),
174
+//             "Returns the tau permitivity of all layers")
175
+//         .def("GetLayerTauSusceptibility1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerTauSusceptibility),
176
+//             "Returns the tau permitivity of the specified layer")
177
+//         .def("GetLayerBreathSusceptibility", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerBreathSusceptibility),
178
+//             "Returns the breth permitivity of all layers")
179
+//         .def("GetLayerBreathSusceptibility1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerBreathSusceptibility),
180
+//             "Returns the breath permitivity of the specified layer")
181
+//
182
+//         .def("GetLayerPermitivity", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerPermitivity),
183
+//             "Returns the permitivity of all layers")
184
+//         .def("GetLayerPermitivity1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerPermitivity),
185
+//             "Returns the permitivity of the specified layer")
186
+//         .def("GetLayerLowFreqPermitivity", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerLowFreqPermitivity),
187
+//             "Returns the low frequqncy permitivity of all layers")
188
+//         .def("GetLayerLowFreqPermitivity1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerLowFreqPermitivity),
189
+//             "Returns the low frequency permitivity of the specified layer")
190
+//         .def("GetLayerHighFreqPermitivity", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerHighFreqPermitivity),
191
+//             "Returns the low frequency permitivity of all layers")
192
+//         .def("GetLayerHighFreqPermitivity1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerHighFreqPermitivity),
193
+//             "Returns the low frequency permitivity of the specified layer")
194
+//         .def("GetLayerTauPermitivity", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerTauPermitivity),
195
+//             "Returns the tau permitivity of all layers")
196
+//         .def("GetLayerTauPermitivity1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerTauPermitivity),
197
+//             "Returns the tau permitivity of the specified layer")
198
+//         .def("GetLayerBreathPermitivity", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerBreathPermitivity),
199
+//             "Returns the breth permitivity of all layers")
200
+//         .def("GetLayerBreathPermitivity1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerBreathPermitivity),
201
+//             "Returns the breath permitivity of the specified layer")
202
+//
203
+//
204
+//         // modifiers
205
+//         .def("SetNumberOfLayers", &Lemma::LayeredEarthEM::SetNumberOfLayers,
206
+//             "Sets the number of layers in the model")
207
+//         .def("SetLayerConductivity", py::overload_cast< const Lemma::VectorXcr& >(&Lemma::LayeredEarthEM::SetLayerConductivity),
208
+//             "Sets the conductivity of the layers, the input is a complex array of conductivity")
209
+//         .def("SetLayerConductivity1", py::overload_cast< const int&, const Lemma::Complex& >(&Lemma::LayeredEarthEM::SetLayerConductivity),
210
+//             "Sets the conductivity of a single layer, the first input is the layer index, and the secondinput is a complex conductivity")
211
+//         .def("SetLayerThickness", &Lemma::LayeredEarthEM::SetLayerThickness,
212
+//             "Sets the thickness of layers, excluding the air and bottom which are infinite")
213
+//
214
+//         .def("SetLayerHighFreqSusceptibility", &Lemma::LayeredEarthEM::SetLayerHighFreqSusceptibility,
215
+//             "Sets the high frequency susceptibility for Cole-COle model")
216
+//         .def("SetLayerLowFreqSusceptibility", &Lemma::LayeredEarthEM::SetLayerLowFreqSusceptibility,
217
+//             "Sets the low frequency susceptibility for Cole-COle model")
218
+//         .def("SetLayerBreathSusceptibility", &Lemma::LayeredEarthEM::SetLayerBreathSusceptibility,
219
+//             "Sets thesusceptibility breath for Cole-COle model")
220
+//
221
+//         .def("SetLayerHighFreqPermitivity", &Lemma::LayeredEarthEM::SetLayerHighFreqPermitivity,
222
+//             "Sets the high frequency permitivity for Cole-COle model")
223
+//         .def("SetLayerLowFreqPermitivity", &Lemma::LayeredEarthEM::SetLayerLowFreqPermitivity,
224
+//             "Sets the low frequency permitivity for Cole-COle model")
225
+//         .def("SetLayerBreathPermitivity", &Lemma::LayeredEarthEM::SetLayerBreathPermitivity,
226
+//             "Sets the permitivity breath for Cole-COle model")
227
+//
228
+//
229
+//         // methods
230
+//         .def("EvaluateColeColeModel", &Lemma::LayeredEarthEM::EvaluateColeColeModel,
231
+//             "Calculates complex resistivity based on cole-cole parameters")
232
+//         ;
233
+//
234
+//     py::class_<Lemma::EMEarth1D, std::shared_ptr<Lemma::EMEarth1D> >
235
+//         EMEarth1D(m, "EMEarth1D");
236
+//
237
+//         // lifecycle
238
+//         EMEarth1D.def(py::init(&Lemma::EMEarth1D::NewSP))
239
+//         //.def_static("DeSerialize", py::overload_cast<const std::string&>
240
+//         //    (&Lemma::EMEarth1D::DeSerialize),"Construct object from yaml representation")
241
+//
242
+//         // print
243
+//         .def("Serialize", &Lemma::EMEarth1D::Print, "YAML representation of the class")
244
+//         .def("__repr__", &Lemma::EMEarth1D::Print)
245
+//
246
+//         // accessors
247
+//         .def("GetName", &Lemma::EMEarth1D::GetName, "Returns the name of the class")
248
+//         .def("GetFieldPoints", &Lemma::EMEarth1D::GetFieldPoints, "Returns the FieldPoint class")
249
+//
250
+//         // modifiers
251
+//         .def("AttachWireAntenna", &Lemma::EMEarth1D::AttachWireAntenna,
252
+//             "Sets the wire antenna to use for calculations")
253
+//         .def("AttachDipoleSOurce", &Lemma::EMEarth1D::AttachDipoleSource,
254
+//             "Sets a DipoleSource to use for calculations")
255
+//         .def("AttachFieldPoints", &Lemma::EMEarth1D::AttachFieldPoints,
256
+//             "Sets the FieldPoints to use for calculations")
257
+//         .def("AttachLayeredEarthEM", &Lemma::EMEarth1D::AttachLayeredEarthEM,
258
+//             "Sets the LayeredEarthEM to use for calculations")
259
+//
260
+//         .def("SetFieldToCalculate", &Lemma::EMEarth1D::SetFieldsToCalculate,
261
+//             "Sets which fields to calculate")
262
+//         .def("SetHankelTransformMethod", &Lemma::EMEarth1D::SetHankelTransformMethod,
263
+//             "Sets which Hankel transform to use")
264
+//         .def("SetTxRxMode", &Lemma::EMEarth1D::SetTxRxMode,
265
+//             "Sets the TxRx mode flag")
266
+//
267
+//         //methods
268
+// #ifdef KIHALEE_EM1D
269
+//         .def("MakeCalc", &Lemma::EMEarth1D::MakeCalc, "Calls KiHa Lee's EM1D FORTRAN77 code")
270
+// #endif
271
+//
272
+//         .def("MakeCalc3", &Lemma::EMEarth1D::MakeCalc3, "Native Lemma EM calculation")
273
+//         .def("CalculateWireAntennaFields", &Lemma::EMEarth1D::CalculateWireAntennaFields,
274
+//             "Native Lemma calculation of a wire antenna")
275
+//         ;
276
+//
277
+//     py::class_<Lemma::FieldPoints, std::shared_ptr<Lemma::FieldPoints> >
278
+//         FieldPoints(m, "FieldPoints");
279
+//
280
+//         // lifecycle
281
+//         FieldPoints.def(py::init(&Lemma::FieldPoints::NewSP))
282
+//         .def_static("DeSerialize", py::overload_cast<const std::string&>
283
+//             (&Lemma::FieldPoints::DeSerialize),"Construct object from yaml representation")
284
+//
285
+//         // print
286
+//         .def("Serialize", &Lemma::FieldPoints::Print, "YAML representation of the class")
287
+//         .def("__repr__", &Lemma::FieldPoints::Print)
288
+//
289
+//         // modifiers
290
+//         .def("SetNumberOfPoints", &Lemma::FieldPoints::SetNumberOfPoints,
291
+//             "Sets the number of locations to make calculations on.")
292
+//         .def("SetLocation", py::overload_cast< const int&, const Lemma::Vector3r& >
293
+//             (&Lemma::FieldPoints::SetLocation), "Sets the location of the index-specified point." )
294
+//         .def("SetLocation", py::overload_cast< const int&,
295
+//                     const Lemma::Real&, const Lemma::Real&, const Lemma::Real& >
296
+//             (&Lemma::FieldPoints::SetLocation),
297
+//             "Sets the location of the index-specified point with the three coordinates")
298
+//
299
+//         // accessors
300
+//         .def("GetNumberOfPoints", &Lemma::FieldPoints::GetNumberOfPoints,
301
+//             "Returns the number of locations to make calculations on.")
302
+//         .def("GetLocations", &Lemma::FieldPoints::GetLocations,
303
+//             "Returns the locations which calculations are made on.")
304
+//         .def("GetLocationsMat", &Lemma::FieldPoints::GetLocationsMat,
305
+//             "Returns a matrix of the locations which calculations are made on.")
306
+//         .def("GetLocation", &Lemma::FieldPoints::GetLocation,
307
+//             "Returns the location of the specified index.")
308
+//         .def("GetLocationX", &Lemma::FieldPoints::GetLocationX,
309
+//             "Returns the northing (x) location of the specified index.")
310
+//         .def("GetLocationY", &Lemma::FieldPoints::GetLocationY,
311
+//             "Returns the easting (y) location of the specified index.")
312
+//         .def("GetLocationZ", &Lemma::FieldPoints::GetLocationZ,
313
+//             "Returns the altitude/depth (z) location of the specified index.")
314
+//         .def("GetEfield", py::overload_cast<  > (&Lemma::FieldPoints::GetEfield),
315
+//             "Returns the electric field for all frequencies.")
316
+//         .def("GetEfield", py::overload_cast< const int& > (&Lemma::FieldPoints::GetEfield),
317
+//             "Returns the electric field for the specified frequency index.")
318
+//         .def("GetEfield", py::overload_cast< const int&, const int& > (&Lemma::FieldPoints::GetEfield),
319
+//             "Returns the electric field for the specified frequency and location index.")
320
+//         .def("GetEfieldMat", &Lemma::FieldPoints::GetEfieldMat,
321
+//             "Returns the electric field for the specified frequency.")
322
+//         .def("GetHfield", py::overload_cast<  > (&Lemma::FieldPoints::GetHfield),
323
+//             "Returns the H field for all frequencies.")
324
+//         .def("GetHfield", py::overload_cast< const int& > (&Lemma::FieldPoints::GetHfield),
325
+//             "Returns the H field for the specified frequency index.")
326
+//         .def("GetHfield", py::overload_cast< const int&, const int& > (&Lemma::FieldPoints::GetHfield),
327
+//             "Returns the H field for the specified frequency and location index.")
328
+//         //.def("GetBfield", py::overload_cast< const int&, const int& > (&Lemma::FieldPoints::GetBfield),
329
+//         //    "Returns the magnetic (B) field for the specified frequency and location index.")
330
+//         .def("GetHfieldMat", &Lemma::FieldPoints::GetHfieldMat,
331
+//             "Returns the H field for the specified frequency.")
332
+//         .def("GetMask", &Lemma::FieldPoints::MaskPoint, "Return the mask boolean value for the specified index")
333
+//
334
+//         // methods
335
+//         .def("ClearFields", &Lemma::FieldPoints::ClearFields, "Clears calculated fields")
336
+//         .def("MaskPoint", &Lemma::FieldPoints::MaskPoint, "Masks the index resulting in no calculation")
337
+//         .def("UnMaskPoint", &Lemma::FieldPoints::UnMaskPoint, "Unmasks the index resulting in a calculation")
338
+//
339
+//         ;
340
+}
341
+
342
+

+ 12
- 1
src/KernelV0.cpp View File

@@ -49,6 +49,8 @@ namespace Lemma {
49 49
     //--------------------------------------------------------------------------------------
50 50
     KernelV0::KernelV0 (const YAML::Node& node, const ctor_key& key) : MerlinObject(node, key) {
51 51
 
52
+        std::cout << "DESERIALIZING" << std::endl;
53
+
52 54
         //node["PulseType"] = "FID";
53 55
         Larmor = node["Larmor"].as<Real>();
54 56
         Temperature = node["Temperature"].as<Real>();
@@ -60,13 +62,15 @@ namespace Lemma {
60 62
         Origin = node["IntegrationOrigin"].as<Vector3r>();
61 63
 
62 64
         if (node["AlignWithAkvoData"]) {
65
+            std::cout << "About to align" << std::endl;
63 66
             // Match pulse info with dataset
64
-            AlignWithAkvoDataset( YAML::LoadFile( node["AlignWithAkvoData"].as<std::string>()));
67
+            AlignWithAkvoDataset( YAML::LoadFile( node["AlignWithAkvoData"].as<std::string>()) );
65 68
         } else {
66 69
             // Read Pulse info direct from Kernel file
67 70
             PulseI = node["PulseI"].as<VectorXr>();
68 71
             Taup = node["Taup"].as<Real>();
69 72
         }
73
+        std::cout << "Aligned!!!" << std::endl;
70 74
 
71 75
         if (node["SigmaModel"]) {
72 76
             if (node["SigmaModel"].Tag() == "LayeredEarthEM") {
@@ -81,6 +85,7 @@ namespace Lemma {
81 85
                 if ( coil.second.Tag() == "PolygonalWireAntenna" ) {
82 86
                     TxRx[ coil.first.as<std::string>() ] = PolygonalWireAntenna::DeSerialize( coil.second );
83 87
                 } else {
88
+                    std::cout << "Reading in coil file " << std::endl;
84 89
                     TxRx[ coil.first.as<std::string>() ] =
85 90
                         PolygonalWireAntenna::DeSerialize( YAML::LoadFile(coil.second.as<std::string>()) );
86 91
                 }
@@ -191,8 +196,14 @@ namespace Lemma {
191 196
     //--------------------------------------------------------------------------------------
192 197
     void KernelV0::CalculateK0 (const std::vector< std::string>& Tx,
193 198
                                 const std::vector<std::string >& Rx, bool vtkOutput ) {
199
+
200
+        std::cout << "Calculating Kernel" << std::endl;
201
+        std::cout << *this << std::endl;
202
+
194 203
         // Set up
195 204
         Larmor = SigmaModel->GetMagneticFieldMagnitude()*GAMMA; // in rad  2246.*2.*PI;
205
+        std::cout << std::endl;
206
+        std::cout << "Calculated Larmor Frequency " << Larmor / (2.*PI)  << std::endl;
196 207
 
197 208
         // All EM calculations will share same field points
198 209
         cpoints = FieldPoints::NewSP();

Loading…
Cancel
Save