Browse Source

Work towards full forward modelling support

master
T-bone 6 years ago
parent
commit
7949026144
3 changed files with 52 additions and 8 deletions
  1. 5
    2
      examples/ForwardFID.cpp
  2. 23
    2
      include/LayeredEarthMR.h
  3. 24
    4
      src/LayeredEarthMR.cpp

+ 5
- 2
examples/ForwardFID.cpp View File

@@ -26,17 +26,20 @@ int main(int argc, char** argv) {
26 26
         std::cout << "./ForwardFID Kernel.yaml TxString RxString  vtkoutput<true/false> \n";
27 27
     //    return(EXIT_FAILURE);
28 28
     }
29
+    auto Kernel = KernelV0::DeSerialize(YAML::LoadFile(argv[1]));
30
+    //    std::cout << *Kernel;
29 31
 
30 32
     auto Model = LayeredEarthMR::NewSP();
31
-        Model->SetNumberOfLayers(20);
33
+        Model->AlignWithKernel(Kernel);
32 34
         Model->SetT2StarBins(10, 500, 20);
33 35
         std::cout << *Model << std::endl;
34 36
 
37
+/*
35 38
     auto Forward = ForwardFID::NewSP();
36 39
         //Forward->SetWindowEdges( VectorXr::LinSpaced(10,0,1) );
37 40
         Forward->SetLogSpacedWindows(10,1000,30);
38 41
         //auto FID =  Forward->ForwardModel(Model);
39 42
     //std::cout << *Forward << std::endl;
40
-
43
+*/
41 44
     return EXIT_SUCCESS;
42 45
 }

+ 23
- 2
include/LayeredEarthMR.h View File

@@ -24,6 +24,7 @@
24 24
 #pragma once
25 25
 #include "LayeredEarth.h"
26 26
 #include "MerlinConfig.h"
27
+#include "KernelV0.h"
27 28
 
28 29
 namespace Lemma {
29 30
 
@@ -83,7 +84,7 @@ namespace Lemma {
83 84
          */
84 85
         virtual YAML::Node Serialize() const;
85 86
 
86
-        /*
87
+        /**
87 88
          *  Factory method for generating concrete class.
88 89
          *  @return a std::shared_ptr of type LayeredEarthMR
89 90
          */
@@ -102,10 +103,21 @@ namespace Lemma {
102 103
         // ====================  ACCESS        =======================
103 104
 
104 105
 
105
-        void SetNumberOfLayers(const int& nlay);
106 106
 
107
+        /**
108
+         *  Sets the T2StarBins to solve for, these are log spaced
109
+         *  @param[in] first is the beginning of the bins
110
+         *  @param[in] last is the end of the bins
111
+         *  @param[in] nT2 is the number of bins
112
+         */
107 113
         void SetT2StarBins(const Real& first, const Real& last, const int& nT2);
108 114
 
115
+        /**
116
+         *  Convenience method, that aligns model with a Kernel
117
+         *  @param[in] Kern input kernel to align with
118
+         */
119
+        void AlignWithKernel( std::shared_ptr<KernelV0> Kern );
120
+
109 121
         // ====================  INQUIRY       =======================
110 122
         /**
111 123
          *  Returns the name of the underlying class, similiar to Python's type
@@ -129,8 +141,17 @@ namespace Lemma {
129 141
         /** ASCII string representation of the class name */
130 142
         static constexpr auto CName = "LayeredEarthMR";
131 143
 
144
+        /**
145
+         * Sets the number of layers
146
+         */
147
+        void SetNumberOfLayers(const int& nlay);
148
+
149
+        /** Initializes the model matrix */
150
+        void InitModelMat();
151
+
132 152
         VectorXr T2StarBins;
133 153
         VectorXr T2StarBinEdges;  // Convenience for pcolor
154
+        MatrixXr ModelMat;
134 155
 
135 156
     }; // -----  end of class  LayeredEarthMR  -----
136 157
 }  // -----  end of namespace Lemma ----

+ 24
- 4
src/LayeredEarthMR.cpp View File

@@ -77,6 +77,7 @@ namespace Lemma {
77 77
         node["Merlin_VERSION"] = MERLIN_VERSION;
78 78
         node["T2StarBins"] = T2StarBins;
79 79
         node["T2StarBinEdges"] = T2StarBinEdges;
80
+        node["ModelMat"] = ModelMat;
80 81
         return node;
81 82
     }		// -----  end of method LayeredEarthMR::Serialize  -----
82 83
 
@@ -96,9 +97,22 @@ namespace Lemma {
96 97
     //      Method:  SetNumberOfLayers
97 98
     //--------------------------------------------------------------------------------------
98 99
     void LayeredEarthMR::SetNumberOfLayers ( const int& nlay  ) {
100
+        NumberOfLayers = nlay;
101
+        NumberOfInterfaces = nlay+1;
99 102
         return ;
100 103
     }		// -----  end of method LayeredEarthMR::SetNumberOfLayers  -----
101 104
 
105
+    //--------------------------------------------------------------------------------------
106
+    //       Class:  LayeredEarthMR
107
+    //      Method:  AlignWithKernel
108
+    //--------------------------------------------------------------------------------------
109
+    void LayeredEarthMR::AlignWithKernel ( std::shared_ptr<KernelV0> Kern ) {
110
+        int nlay = Kern->GetInterfaces().size()-1;
111
+        SetNumberOfLayers( nlay );
112
+        LayerThickness = Kern->GetInterfaces().tail(nlay) - Kern->GetInterfaces().head(nlay) ;
113
+        SetMagneticFieldComponents( Kern->GetSigmaModel()->GetMagneticField(), TESLA);
114
+        return ;
115
+    }		// -----  end of method LayeredEarthMR::AlignWithKernel  -----
102 116
 
103 117
     //--------------------------------------------------------------------------------------
104 118
     //       Class:  LayeredEarthMR
@@ -113,15 +127,21 @@ namespace Lemma {
113 127
             T2StarBinEdges[i] = T2StarBinEdges[i-1]*quotient;
114 128
         }
115 129
         T2StarBins = (T2StarBinEdges.head(nT2) + T2StarBinEdges.tail(nT2)) / 2;
130
+        InitModelMat();
116 131
         return;
117 132
     }		// -----  end of method LayeredEarthMR::SetNumberOfT2StarBins  -----
118 133
 
119 134
 
120
-} // ----  end of namespace Lemma  ----
121
-
122
-
123
-
135
+    //--------------------------------------------------------------------------------------
136
+    //       Class:  LayeredEarthMR
137
+    //      Method:  InitModelMat
138
+    //--------------------------------------------------------------------------------------
139
+    void LayeredEarthMR::InitModelMat (  ) {
140
+        ModelMat = MatrixXr::Zero( T2StarBins.size(), NumberOfLayers );
141
+        return ;
142
+    }		// -----  end of method LayeredEarthMR::InitModelMat  -----
124 143
 
144
+} // ----  end of namespace Lemma  ----
125 145
 
126 146
 /* vim: set tabstop=4 expandtab: */
127 147
 /* vim: set filetype=cpp: */

Loading…
Cancel
Save