initial upload

This commit is contained in:
2025-12-17 10:56:55 +08:00
parent e1fe067eb2
commit 4972f2a1e3
83 changed files with 133343 additions and 1 deletions

1
.gitignore vendored
View File

@@ -32,3 +32,4 @@
*.out
*.app
.DS_Store

28
LICENSE Normal file
View File

@@ -0,0 +1,28 @@
BSD 3-Clause License
Copyright (c) 2024, Yoshiya Usui
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -1,2 +1,51 @@
# TracMT
# TRACMT
Robust transfer function analysis code for magnetotellurics.
In TRACMT, you can use the RRMS estimator developed by Usui et al. (2024) and the fast and robust bootstrap method evaluated by Usui et al (2025).
_Yoshiya Usui, Makoto Uyeshima, Shin'ya Sakanaka, Tasuku Hashimoto, Masahiro Ichiki, Toshiki Kaida, Yusuke Yamaya, Yasuo Ogawa, Masataka Masuda, Takahiro Akiyama, 2024. New robust remote reference estimator using robust multivariate linear regression, Geophysical Journal International, 238(2), [https://doi.org/10.1093/gji/ggae19_9](https://doi.org/10.1093/gji/ggae199)_
_Yoshiya Usui, 2024. Prewhitening of magnetotelluric data using a robust filter and robust PARCOR. Bull. Earthq. Res. Inst. Univ. Tokyo, 99, [https://doi.org/10.15083/0002012817](https://doi.org/10.15083/0002012817)_
_Yoshiya Usui, Makoto Uyeshima, Shin'ya Sakanaka, Tasuku Hashimoto, Masahiro Ichiki, Toshiki Kaida, Yusuke Yamaya, Yasuo Ogawa, Masataka Masuda, Takahiro Akiyama, 2025, Application of the fast and robust bootstrap method to the uncertainty analysis of the magnetotelluric transfer function, Geophysical Journal International, 242(1), [https://doi.org/10.1093/gji/ggaf162](https://doi.org/10.1093/gji/ggaf162)_
We developed the RRMS estimator by applying the robust multivariate linear regression S-estimator to the two-input-multiple-output relationship between the local EM field and the reference magnetic field that leads to the same equation as by the original remote reference method.
The RRMS estimator can give an unbiased estimate of the MT transfer function and suppress the influence of outliers in the electric field and magnetic
field.
## How to compile TRACMT
1) Download all source files of TRACMT to a directory.
2) Download source files of CLAPACK (https://www.netlib.org/clapack/) to another directory and make library files.
3) Copy library files of CLAPACK (blas_LINUX.a, lapack_LINUX.a, and libf2c.a) to "lib" directory and copy header files (blaswrap.h, clapack.h, and f2c.h) to "include" directory.
4) If your compiler supports C++11, you can compile TRACMT by "make -f Makefile_C++11" command.
If your compiler does NOT support C++11, download mt19937-64.tgz from http://math.sci.hiroshima-u.ac.jp/m-mat/MT/mt64.html and rename mt19937-64.c to mt19937-64.cpp.
After copying mt19937-64.cpp and mt64.h to the source-file directory of TRACMT, you can compile TRACMT by the make command (Make -f Makefile).
5) To read MTH5 files (Peacock et al., 2022), please use "Makefile_C++11_MTH5" or "Makefile_MTH5". Before compiling TRACMT, HDF5 library should be installed and path to HDF5 libraries should be added as follows.<br>
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/hdf5-1.10.5/lib"<br>
export LIBRARY_PATH="${LIBRARY_PATH}:/usr/local/hdf5-1.10.5/lib"<br>
export PATH="${PATH}:/usr/local/hdf5-1.10.5/lib"<br>
## Functional Overview
**Input file format**: Text (Ascii) file / .ats files of Metronix instruments / MTH5 files (Peacock et al., 2022) / .dat files of ELOG-MT
**Prewhitening**: Non-robust prewhitening / Robust prewhitening / Robust prewhitening with robust filter
**Transfer function estimation method**: Ordinary least square / Non-robust remote reference / Robust remote reference / RRMS estimator
**Error estimation method**: Parametric approach / Bootstrap method / Jackknife method
## Release note
_**v1.2.0**_ June. 13, 2024: Initial release.
_**v1.3.4**_ July. 14, 2024: A parametric error estimation method was added for the RRMS estimator. Some bugs relating to the ELOG reading option and calibration were fixed.
_**v1.3.6**_ August. 15, 2024: A function to read ELOG-DUAL binary files was modified.
_**v2.0.0**_ January. 1, 2025: The fast and robust bootstrap method was added. Some equations of the parametric error estimation method were modified.
_**v2.1.0**_ January. 14, 2025: The equation of the AIC is modified.
_**v2.2.0**_ February. 10, 2025: The option for reading MTH5 files is added.
_**v2.3.0**_ October. 22, 2025: The computational efficiency of the RRMS estimator was improved.

View File

@@ -0,0 +1,420 @@
================================================================================
Now Frequency(Hz): 0.00146484, Period(s): 682.667
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 83
Squared coherence: 0.88469
Estimated response function: ( 3.7554e-01, 4.2087e-01), ( 3.3244e-01, 4.4139e-01)
Amplitude of the estimated response function: 5.6406e-01, 5.5257e-01
Phase(deg.) of the estimated response function: 48.3, 53.0
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 83
Squared coherence: 0.943059
Estimated response function: ( -6.7784e-01, -8.3556e-01), ( -1.5476e-01, -1.5345e-01)
Amplitude of the estimated response function: 1.0759e+00, 2.1794e-01
Phase(deg.) of the estimated response function: -129.1, -135.2
================================================================================
Now Frequency(Hz): 0.00195312, Period(s): 512
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 83
Squared coherence: 0.881175
Estimated response function: ( 4.5545e-01, 4.7352e-01), ( 3.8421e-01, 5.4449e-01)
Amplitude of the estimated response function: 6.5701e-01, 6.6640e-01
Phase(deg.) of the estimated response function: 46.1, 54.8
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 83
Squared coherence: 0.952068
Estimated response function: ( -8.0225e-01, -1.0040e+00), ( -1.8291e-01, -2.1313e-01)
Amplitude of the estimated response function: 1.2852e+00, 2.8086e-01
Phase(deg.) of the estimated response function: -128.6, -130.6
================================================================================
Now Frequency(Hz): 0.00292969, Period(s): 341.333
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 167
Squared coherence: 0.810574
Estimated response function: ( 4.7326e-01, 5.9456e-01), ( 4.3491e-01, 7.6086e-01)
Amplitude of the estimated response function: 7.5992e-01, 8.7639e-01
Phase(deg.) of the estimated response function: 51.5, 60.2
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 167
Squared coherence: 0.917953
Estimated response function: ( -9.3048e-01, -1.3085e+00), ( -1.8189e-01, -2.2954e-01)
Amplitude of the estimated response function: 1.6056e+00, 2.9286e-01
Phase(deg.) of the estimated response function: -125.4, -128.4
================================================================================
Now Frequency(Hz): 0.00390625, Period(s): 256
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 167
Squared coherence: 0.795293
Estimated response function: ( 6.0472e-01, 7.0462e-01), ( 4.3766e-01, 9.1245e-01)
Amplitude of the estimated response function: 9.2854e-01, 1.0120e+00
Phase(deg.) of the estimated response function: 49.4, 64.4
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 167
Squared coherence: 0.898233
Estimated response function: ( -1.2107e+00, -1.5316e+00), ( -2.0797e-01, -2.9546e-01)
Amplitude of the estimated response function: 1.9524e+00, 3.6131e-01
Phase(deg.) of the estimated response function: -128.3, -125.1
================================================================================
Now Frequency(Hz): 0.00585938, Period(s): 170.667
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 336
Squared coherence: 0.69714
Estimated response function: ( 8.2872e-01, 9.2629e-01), ( 6.3990e-01, 1.1135e+00)
Amplitude of the estimated response function: 1.2429e+00, 1.2843e+00
Phase(deg.) of the estimated response function: 48.2, 60.1
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 336
Squared coherence: 0.858605
Estimated response function: ( -1.5595e+00, -1.8754e+00), ( -3.0034e-01, -3.2833e-01)
Amplitude of the estimated response function: 2.4391e+00, 4.4498e-01
Phase(deg.) of the estimated response function: -129.7, -132.5
================================================================================
Now Frequency(Hz): 0.0078125, Period(s): 128
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 336
Squared coherence: 0.662431
Estimated response function: ( 1.0339e+00, 1.0460e+00), ( 8.5128e-01, 1.3658e+00)
Amplitude of the estimated response function: 1.4707e+00, 1.6093e+00
Phase(deg.) of the estimated response function: 45.3, 58.1
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 336
Squared coherence: 0.81653
Estimated response function: ( -1.7951e+00, -2.2401e+00), ( -4.1262e-01, -3.9622e-01)
Amplitude of the estimated response function: 2.8706e+00, 5.7205e-01
Phase(deg.) of the estimated response function: -128.7, -136.2
================================================================================
Now Frequency(Hz): 0.0117188, Period(s): 85.3333
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 674
Squared coherence: 0.562555
Estimated response function: ( 1.3891e+00, 1.2224e+00), ( 1.0533e+00, 1.8187e+00)
Amplitude of the estimated response function: 1.8504e+00, 2.1017e+00
Phase(deg.) of the estimated response function: 41.3, 59.9
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 674
Squared coherence: 0.758964
Estimated response function: ( -2.4524e+00, -2.9277e+00), ( -4.3863e-01, -5.8231e-01)
Amplitude of the estimated response function: 3.8192e+00, 7.2903e-01
Phase(deg.) of the estimated response function: -130.0, -127.0
================================================================================
Now Frequency(Hz): 0.015625, Period(s): 64
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 674
Squared coherence: 0.488236
Estimated response function: ( 1.5185e+00, 1.3183e+00), ( 1.3435e+00, 2.1202e+00)
Amplitude of the estimated response function: 2.0109e+00, 2.5100e+00
Phase(deg.) of the estimated response function: 41.0, 57.6
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 674
Squared coherence: 0.671128
Estimated response function: ( -2.9422e+00, -3.2299e+00), ( -5.5561e-01, -5.7310e-01)
Amplitude of the estimated response function: 4.3691e+00, 7.9821e-01
Phase(deg.) of the estimated response function: -132.3, -134.1
================================================================================
Now Frequency(Hz): 0.0234375, Period(s): 42.6667
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 1349
Squared coherence: 0.285299
Estimated response function: ( 1.8094e+00, 1.5365e+00), ( 1.7851e+00, 2.7188e+00)
Amplitude of the estimated response function: 2.3738e+00, 3.2525e+00
Phase(deg.) of the estimated response function: 40.3, 56.7
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 1349
Squared coherence: 0.541271
Estimated response function: ( -3.7694e+00, -3.9053e+00), ( -8.2834e-01, -9.5551e-01)
Amplitude of the estimated response function: 5.4277e+00, 1.2646e+00
Phase(deg.) of the estimated response function: -134.0, -130.9
================================================================================
Now Frequency(Hz): 0.03125, Period(s): 32
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 1349
Squared coherence: 0.182882
Estimated response function: ( 2.4038e+00, 1.7105e+00), ( 2.2720e+00, 3.4053e+00)
Amplitude of the estimated response function: 2.9502e+00, 4.0937e+00
Phase(deg.) of the estimated response function: 35.4, 56.3
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 1349
Squared coherence: 0.416897
Estimated response function: ( -4.5305e+00, -4.3722e+00), ( -1.0212e+00, -1.1243e+00)
Amplitude of the estimated response function: 6.2961e+00, 1.5189e+00
Phase(deg.) of the estimated response function: -136.0, -132.2
================================================================================
Now Frequency(Hz): 0.046875, Period(s): 21.3333
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 2699
Squared coherence: 0
Estimated response function: ( 3.4951e+00, 2.1127e+00), ( 2.7520e+00, 4.2758e+00)
Amplitude of the estimated response function: 4.0841e+00, 5.0849e+00
Phase(deg.) of the estimated response function: 31.2, 57.2
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 2699
Squared coherence: 0.137491
Estimated response function: ( -5.7019e+00, -4.8532e+00), ( -1.0653e+00, -1.0137e+00)
Amplitude of the estimated response function: 7.4877e+00, 1.4705e+00
Phase(deg.) of the estimated response function: -139.6, -136.4
================================================================================
Now Frequency(Hz): 0.0625, Period(s): 16
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 2699
Squared coherence: 0
Estimated response function: ( 3.8661e+00, 2.4595e+00), ( 3.7929e+00, 5.6612e+00)
Amplitude of the estimated response function: 4.5821e+00, 6.8144e+00
Phase(deg.) of the estimated response function: 32.5, 56.2
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 2699
Squared coherence: 0
Estimated response function: ( -5.7741e+00, -5.9493e+00), ( -1.3897e+00, -1.3007e+00)
Amplitude of the estimated response function: 8.2906e+00, 1.9034e+00
Phase(deg.) of the estimated response function: -134.1, -136.9
================================================================================
Now Frequency(Hz): 0.09375, Period(s): 10.6667
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 5399
Squared coherence: 0
Estimated response function: ( 3.9019e+00, 2.2656e+00), ( 4.4292e+00, 7.3770e+00)
Amplitude of the estimated response function: 4.5120e+00, 8.6045e+00
Phase(deg.) of the estimated response function: 30.1, 59.0
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 5399
Squared coherence: 0
Estimated response function: ( -6.8066e+00, -7.2849e+00), ( -4.3713e-01, -2.5180e+00)
Amplitude of the estimated response function: 9.9699e+00, 2.5557e+00
Phase(deg.) of the estimated response function: -133.1, -99.8
================================================================================
Now Frequency(Hz): 0.125, Period(s): 8
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 5399
Squared coherence: 0
Estimated response function: ( 5.2436e+00, 1.8981e+00), ( 5.8367e+00, 7.6169e+00)
Amplitude of the estimated response function: 5.5766e+00, 9.5961e+00
Phase(deg.) of the estimated response function: 19.9, 52.5
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 5399
Squared coherence: 0
Estimated response function: ( -9.2962e+00, -8.5980e+00), ( 2.5354e-02, -1.6449e+00)
Amplitude of the estimated response function: 1.2663e+01, 1.6451e+00
Phase(deg.) of the estimated response function: -137.2, -89.1
================================================================================
Now Frequency(Hz): 0.1875, Period(s): 5.33333
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 10799
Squared coherence: 0
Estimated response function: ( 4.7388e+00, 3.6659e+00), ( 8.5635e+00, 9.6804e+00)
Amplitude of the estimated response function: 5.9912e+00, 1.2925e+01
Phase(deg.) of the estimated response function: 37.7, 48.5
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 10799
Squared coherence: 0
Estimated response function: ( -1.1045e+01, -1.1288e+01), ( -2.2411e-01, -5.9487e-01)
Amplitude of the estimated response function: 1.5793e+01, 6.3568e-01
Phase(deg.) of the estimated response function: -134.4, -110.6
================================================================================
Now Frequency(Hz): 0.25, Period(s): 4
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 10799
Squared coherence: 0
Estimated response function: ( 5.8663e+00, 4.0237e+00), ( 1.1449e+01, 8.7057e+00)
Amplitude of the estimated response function: 7.1136e+00, 1.4383e+01
Phase(deg.) of the estimated response function: 34.4, 37.2
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 10799
Squared coherence: 0
Estimated response function: ( -1.5791e+01, -8.7705e+00), ( -2.1661e+00, 6.6073e-01)
Amplitude of the estimated response function: 1.8063e+01, 2.2646e+00
Phase(deg.) of the estimated response function: -151.0, 163.0
================================================================================
Now Frequency(Hz): 0.375, Period(s): 2.66667
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 21599
Squared coherence: 0
Estimated response function: ( -3.4466e+00, -5.2926e+00), ( 2.3350e+01, 8.4248e+00)
Amplitude of the estimated response function: 6.3159e+00, 2.4823e+01
Phase(deg.) of the estimated response function: -123.1, 19.8
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 21599
Squared coherence: 0
Estimated response function: ( -1.3650e+01, -3.9352e+00), ( -4.6476e-02, -1.1209e+01)
Amplitude of the estimated response function: 1.4206e+01, 1.1209e+01
Phase(deg.) of the estimated response function: -163.9, -90.2
================================================================================
Now Frequency(Hz): 0.5, Period(s): 2
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 21599
Squared coherence: 0
Estimated response function: ( 1.2138e+00, -1.2061e+00), ( 2.1695e+01, 6.6378e+00)
Amplitude of the estimated response function: 1.7112e+00, 2.2687e+01
Phase(deg.) of the estimated response function: -44.8, 17.0
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 21599
Squared coherence: 0
Estimated response function: ( -5.3388e+00, -5.2437e+00), ( -6.0756e+00, 1.4369e+00)
Amplitude of the estimated response function: 7.4833e+00, 6.2432e+00
Phase(deg.) of the estimated response function: -135.5, 166.7
================================================================================
Now Frequency(Hz): 0.75, Period(s): 1.33333
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 43199
Squared coherence: 0
Estimated response function: ( -2.1007e+01, 2.5791e+00), ( 1.6554e+01, 1.0975e+01)
Amplitude of the estimated response function: 2.1164e+01, 1.9862e+01
Phase(deg.) of the estimated response function: 173.0, 33.5
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 43199
Squared coherence: 0
Estimated response function: ( 4.6419e+00, -4.1036e+00), ( -1.1865e+01, -1.0362e+01)
Amplitude of the estimated response function: 6.1958e+00, 1.5753e+01
Phase(deg.) of the estimated response function: -41.5, -138.9
================================================================================
Now Frequency(Hz): 1, Period(s): 1
================================================================================
--------------------------------------------------------------------------------
Calculate response functions for output variable 0
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 43199
Squared coherence: 0
Estimated response function: ( 1.1221e+01, 1.0270e+01), ( 2.1550e+01, -2.5333e+01)
Amplitude of the estimated response function: 1.5211e+01, 3.3259e+01
Phase(deg.) of the estimated response function: 42.5, -49.6
--------------------------------------------------------------------------------
Calculate response functions for output variable 1
--------------------------------------------------------------------------------
Calculate response functions by the ordinary least square method
Sum of weights: 43199
Squared coherence: 0
Estimated response function: ( -1.1946e+01, -5.6520e+00), ( -2.0656e+01, -1.9537e+01)
Amplitude of the estimated response function: 1.3216e+01, 2.8432e+01
Phase(deg.) of the estimated response function: -154.7, -136.6

View File

@@ -0,0 +1,418 @@
Start TRACMT Version v2.0
Read parameters. ( 0 sec )
================================================================================
Summary of control parameters
================================================================================
Number of threads : 1
Procedure type : ordinary remote reference
The first M-estimator : not to be used
The second M-estimator : not to be used
Error estimation method : parametric
Number of output variables : 2
Number of input variables : 2
Number of remote reference variables : 2
Sampling frequency (Hz) : 32
Number of time-series sections : 1
Ratio of overlapping part to whole segment length : 0.5
Output level : 0
Output apparent resistivity and phase to a seperate csv file
Information about the segment lengths and frequencies :
Segment# Length Index Frequency(Hz) Period(sec)
0 65536 3 1.464843750e-03 6.826666667e+02
0 65536 4 1.953125000e-03 5.120000000e+02
1 32768 3 2.929687500e-03 3.413333333e+02
1 32768 4 3.906250000e-03 2.560000000e+02
2 16384 3 5.859375000e-03 1.706666667e+02
2 16384 4 7.812500000e-03 1.280000000e+02
3 8192 3 1.171875000e-02 8.533333333e+01
3 8192 4 1.562500000e-02 6.400000000e+01
4 4096 3 2.343750000e-02 4.266666667e+01
4 4096 4 3.125000000e-02 3.200000000e+01
5 2048 3 4.687500000e-02 2.133333333e+01
5 2048 4 6.250000000e-02 1.600000000e+01
6 1024 3 9.375000000e-02 1.066666667e+01
6 1024 4 1.250000000e-01 8.000000000e+00
7 512 3 1.875000000e-01 5.333333333e+00
7 512 4 2.500000000e-01 4.000000000e+00
8 256 3 3.750000000e-01 2.666666667e+00
8 256 4 5.000000000e-01 2.000000000e+00
9 128 3 7.500000000e-01 1.333333333e+00
9 128 4 1.000000000e+00 1.000000000e+00
Information about the time-series data :
Section# Channel# Type NSkip NData File
0 0 Out0 0 2764800 ../ex.txt
0 1 Out1 0 2764800 ../ey.txt
0 2 Inp0 0 2764800 ../hx.txt
0 3 Inp1 0 2764800 ../hy.txt
0 4 RR0 0 2764800 ../hrx.txt
0 5 RR1 0 2764800 ../hry.txt
Rotation angle (deg.) : 0
Channel# Type Azimuth(deg.)
0 Out0 0
1 Out1 90
2 Inp0 0
3 Inp1 90
4 RR0 0
5 RR1 90
Parameters for robust prewhitening :
Least square estimator is used
Maximum degree of AR model: 10
================================================================================
Read data from ../ex.txt ( 0 sec )
Read data from ../ey.txt ( 1 sec )
Read data from ../hx.txt ( 2 sec )
Read data from ../hy.txt ( 3 sec )
Read data from ../hrx.txt ( 4 sec )
Read data from ../hry.txt ( 4 sec )
Perform preprocessing ( 5 sec )
Secton 0, Channel 0 ( 5 sec )
Subtract mean (-0.889991) ( 5 sec )
Secton 0, Channel 1 ( 5 sec )
Subtract mean (1.69968) ( 5 sec )
Secton 0, Channel 2 ( 5 sec )
Subtract mean (0.0092652) ( 5 sec )
Secton 0, Channel 3 ( 5 sec )
Subtract mean (1.30261) ( 5 sec )
Secton 0, Channel 4 ( 5 sec )
Subtract mean (0.0346805) ( 5 sec )
Secton 0, Channel 5 ( 5 sec )
Subtract mean (1.2857) ( 5 sec )
Perform prewhitening for channel 0 ( 5 sec )
Degree of AR model: 1, Sigma: 7.6076, AIC: 1.90665e+07 ( 5 sec )
Degree of AR model: 2, Sigma: 7.60293, AIC: 1.90631e+07 ( 5 sec )
Degree of AR model: 3, Sigma: 7.59862, AIC: 1.906e+07 ( 5 sec )
Degree of AR model: 4, Sigma: 7.5946, AIC: 1.90571e+07 ( 5 sec )
Degree of AR model: 5, Sigma: 7.59088, AIC: 1.90544e+07 ( 5 sec )
Degree of AR model: 6, Sigma: 7.58783, AIC: 1.90521e+07 ( 5 sec )
Degree of AR model: 7, Sigma: 7.58446, AIC: 1.90497e+07 ( 5 sec )
Degree of AR model: 8, Sigma: 7.58162, AIC: 1.90476e+07 ( 5 sec )
Degree of AR model: 9, Sigma: 7.57884, AIC: 1.90456e+07 ( 5 sec )
Degree of AR model: 10, Sigma: 7.57665, AIC: 1.9044e+07 ( 6 sec )
The AR model of 10 degress gives the minimum AIC (1.9044e+07) ( 6 sec )
AR coefficients: 0.0320459 0.0276236 0.0274305 0.0273417 0.0271195 0.0250291 0.0274279 0.0257729 0.0263083 0.0240252 ( 6 sec )
Perform prewhitening for channel 1 ( 6 sec )
Degree of AR model: 1, Sigma: 7.54273, AIC: 1.90192e+07 ( 6 sec )
Degree of AR model: 2, Sigma: 7.52209, AIC: 1.9004e+07 ( 6 sec )
Degree of AR model: 3, Sigma: 7.50561, AIC: 1.89919e+07 ( 6 sec )
Degree of AR model: 4, Sigma: 7.49133, AIC: 1.89814e+07 ( 6 sec )
Degree of AR model: 5, Sigma: 7.47891, AIC: 1.89722e+07 ( 6 sec )
Degree of AR model: 6, Sigma: 7.46782, AIC: 1.8964e+07 ( 6 sec )
Degree of AR model: 7, Sigma: 7.45798, AIC: 1.89567e+07 ( 6 sec )
Degree of AR model: 8, Sigma: 7.44899, AIC: 1.895e+07 ( 6 sec )
Degree of AR model: 9, Sigma: 7.44151, AIC: 1.89444e+07 ( 6 sec )
Degree of AR model: 10, Sigma: 7.43417, AIC: 1.8939e+07 ( 6 sec )
The AR model of 10 degress gives the minimum AIC (1.8939e+07) ( 6 sec )
AR coefficients: 0.0497931 0.0484711 0.0453945 0.0449254 0.0443603 0.0443792 0.0440958 0.0444201 0.0425092 0.0444076 ( 6 sec )
Perform prewhitening for channel 2 ( 6 sec )
Degree of AR model: 1, Sigma: 1.15041, AIC: 8.62097e+06 ( 6 sec )
Degree of AR model: 2, Sigma: 0.999605, AIC: 7.84398e+06 ( 6 sec )
Degree of AR model: 3, Sigma: 0.94325, AIC: 7.5231e+06 ( 6 sec )
Degree of AR model: 4, Sigma: 0.913582, AIC: 7.34638e+06 ( 6 sec )
Degree of AR model: 5, Sigma: 0.895124, AIC: 7.23352e+06 ( 6 sec )
Degree of AR model: 6, Sigma: 0.882753, AIC: 7.15657e+06 ( 6 sec )
Degree of AR model: 7, Sigma: 0.873879, AIC: 7.1007e+06 ( 6 sec )
Degree of AR model: 8, Sigma: 0.867031, AIC: 7.0572e+06 ( 6 sec )
Degree of AR model: 9, Sigma: 0.861586, AIC: 7.02236e+06 ( 6 sec )
Degree of AR model: 10, Sigma: 0.857167, AIC: 6.99392e+06 ( 6 sec )
The AR model of 10 degress gives the minimum AIC (6.99392e+06) ( 6 sec )
AR coefficients: 0.100812 0.0994283 0.099345 0.0994338 0.100341 0.0991599 0.0983786 0.0996401 0.100555 0.101158 ( 6 sec )
Perform prewhitening for channel 3 ( 6 sec )
Degree of AR model: 1, Sigma: 1.15933, AIC: 8.66365e+06 ( 6 sec )
Degree of AR model: 2, Sigma: 1.01002, AIC: 7.90131e+06 ( 6 sec )
Degree of AR model: 3, Sigma: 0.95364, AIC: 7.58368e+06 ( 6 sec )
Degree of AR model: 4, Sigma: 0.923737, AIC: 7.40751e+06 ( 6 sec )
Degree of AR model: 5, Sigma: 0.905428, AIC: 7.29681e+06 ( 6 sec )
Degree of AR model: 6, Sigma: 0.892914, AIC: 7.21985e+06 ( 6 sec )
Degree of AR model: 7, Sigma: 0.884029, AIC: 7.16455e+06 ( 6 sec )
Degree of AR model: 8, Sigma: 0.877216, AIC: 7.12177e+06 ( 6 sec )
Degree of AR model: 9, Sigma: 0.871841, AIC: 7.08779e+06 ( 6 sec )
Degree of AR model: 10, Sigma: 0.867445, AIC: 7.05983e+06 ( 7 sec )
The AR model of 10 degress gives the minimum AIC (7.05983e+06) ( 7 sec )
AR coefficients: 0.0992426 0.0997661 0.0999695 0.100685 0.0994892 0.0998831 0.0983119 0.0990847 0.0994668 0.100303 ( 7 sec )
Perform prewhitening for channel 4 ( 7 sec )
Degree of AR model: 1, Sigma: 1.16254, AIC: 8.67898e+06 ( 7 sec )
Degree of AR model: 2, Sigma: 1.00903, AIC: 7.89586e+06 ( 7 sec )
Degree of AR model: 3, Sigma: 0.952405, AIC: 7.57651e+06 ( 7 sec )
Degree of AR model: 4, Sigma: 0.922235, AIC: 7.39851e+06 ( 7 sec )
Degree of AR model: 5, Sigma: 0.90364, AIC: 7.28588e+06 ( 7 sec )
Degree of AR model: 6, Sigma: 0.891244, AIC: 7.2095e+06 ( 7 sec )
Degree of AR model: 7, Sigma: 0.882213, AIC: 7.15318e+06 ( 7 sec )
Degree of AR model: 8, Sigma: 0.875262, AIC: 7.10944e+06 ( 7 sec )
Degree of AR model: 9, Sigma: 0.869864, AIC: 7.07523e+06 ( 7 sec )
Degree of AR model: 10, Sigma: 0.865547, AIC: 7.04772e+06 ( 7 sec )
The AR model of 10 degress gives the minimum AIC (7.04772e+06) ( 7 sec )
AR coefficients: 0.0989261 0.10121 0.0987917 0.100744 0.100552 0.0988028 0.0993482 0.100374 0.0999452 0.0995135 ( 7 sec )
Perform prewhitening for channel 5 ( 7 sec )
Degree of AR model: 1, Sigma: 1.16036, AIC: 8.66857e+06 ( 7 sec )
Degree of AR model: 2, Sigma: 1.01086, AIC: 7.90589e+06 ( 7 sec )
Degree of AR model: 3, Sigma: 0.953982, AIC: 7.58566e+06 ( 7 sec )
Degree of AR model: 4, Sigma: 0.924434, AIC: 7.41168e+06 ( 7 sec )
Degree of AR model: 5, Sigma: 0.906107, AIC: 7.30095e+06 ( 7 sec )
Degree of AR model: 6, Sigma: 0.893431, AIC: 7.22305e+06 ( 7 sec )
Degree of AR model: 7, Sigma: 0.884431, AIC: 7.16707e+06 ( 7 sec )
Degree of AR model: 8, Sigma: 0.877486, AIC: 7.12347e+06 ( 7 sec )
Degree of AR model: 9, Sigma: 0.872098, AIC: 7.08941e+06 ( 7 sec )
Degree of AR model: 10, Sigma: 0.867816, AIC: 7.0622e+06 ( 7 sec )
The AR model of 10 degress gives the minimum AIC (7.0622e+06) ( 7 sec )
AR coefficients: 0.0995885 0.098903 0.101124 0.0988656 0.0991358 0.100713 0.0990429 0.100438 0.0997109 0.0989688 ( 7 sec )
===============================================================================
Perform analysis for segment length : 65536 ( 7 sec )
Convert time-series data to frequency-domain ( 7 sec )
Total number of segments : 83 ( 7 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.00146484, Period(s): 682.667 ( 10 sec )
Perform calibration correction ( 10 sec )
Calculate rotated fields ( 10 sec )
Calculate response functions by ordinary remote reference ( 10 sec )
Calculate response functions for output variable 0 ( 10 sec )
Calculate response functions by the ordinary least square method ( 10 sec )
Parametric error estimation is performed ( 10 sec )
Calculate response functions for output variable 1 ( 10 sec )
Calculate response functions by the ordinary least square method ( 10 sec )
Parametric error estimation is performed ( 10 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.00195312, Period(s): 512 ( 10 sec )
Perform calibration correction ( 10 sec )
Calculate rotated fields ( 10 sec )
Calculate response functions by ordinary remote reference ( 10 sec )
Calculate response functions for output variable 0 ( 10 sec )
Calculate response functions by the ordinary least square method ( 10 sec )
Parametric error estimation is performed ( 10 sec )
Calculate response functions for output variable 1 ( 10 sec )
Calculate response functions by the ordinary least square method ( 10 sec )
Parametric error estimation is performed ( 10 sec )
===============================================================================
Perform analysis for segment length : 32768 ( 10 sec )
Convert time-series data to frequency-domain ( 10 sec )
Total number of segments : 167 ( 10 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.00292969, Period(s): 341.333 ( 12 sec )
Perform calibration correction ( 12 sec )
Calculate rotated fields ( 12 sec )
Calculate response functions by ordinary remote reference ( 12 sec )
Calculate response functions for output variable 0 ( 12 sec )
Calculate response functions by the ordinary least square method ( 12 sec )
Parametric error estimation is performed ( 12 sec )
Calculate response functions for output variable 1 ( 12 sec )
Calculate response functions by the ordinary least square method ( 12 sec )
Parametric error estimation is performed ( 12 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.00390625, Period(s): 256 ( 12 sec )
Perform calibration correction ( 12 sec )
Calculate rotated fields ( 12 sec )
Calculate response functions by ordinary remote reference ( 12 sec )
Calculate response functions for output variable 0 ( 12 sec )
Calculate response functions by the ordinary least square method ( 12 sec )
Parametric error estimation is performed ( 12 sec )
Calculate response functions for output variable 1 ( 12 sec )
Calculate response functions by the ordinary least square method ( 12 sec )
Parametric error estimation is performed ( 12 sec )
===============================================================================
Perform analysis for segment length : 16384 ( 12 sec )
Convert time-series data to frequency-domain ( 12 sec )
Total number of segments : 336 ( 12 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.00585938, Period(s): 170.667 ( 14 sec )
Perform calibration correction ( 14 sec )
Calculate rotated fields ( 14 sec )
Calculate response functions by ordinary remote reference ( 14 sec )
Calculate response functions for output variable 0 ( 14 sec )
Calculate response functions by the ordinary least square method ( 14 sec )
Parametric error estimation is performed ( 14 sec )
Calculate response functions for output variable 1 ( 14 sec )
Calculate response functions by the ordinary least square method ( 14 sec )
Parametric error estimation is performed ( 14 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.0078125, Period(s): 128 ( 14 sec )
Perform calibration correction ( 14 sec )
Calculate rotated fields ( 14 sec )
Calculate response functions by ordinary remote reference ( 14 sec )
Calculate response functions for output variable 0 ( 14 sec )
Calculate response functions by the ordinary least square method ( 14 sec )
Parametric error estimation is performed ( 14 sec )
Calculate response functions for output variable 1 ( 14 sec )
Calculate response functions by the ordinary least square method ( 14 sec )
Parametric error estimation is performed ( 14 sec )
===============================================================================
Perform analysis for segment length : 8192 ( 14 sec )
Convert time-series data to frequency-domain ( 14 sec )
Total number of segments : 674 ( 14 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.0117188, Period(s): 85.3333 ( 16 sec )
Perform calibration correction ( 16 sec )
Calculate rotated fields ( 16 sec )
Calculate response functions by ordinary remote reference ( 16 sec )
Calculate response functions for output variable 0 ( 16 sec )
Calculate response functions by the ordinary least square method ( 16 sec )
Parametric error estimation is performed ( 16 sec )
Calculate response functions for output variable 1 ( 16 sec )
Calculate response functions by the ordinary least square method ( 16 sec )
Parametric error estimation is performed ( 16 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.015625, Period(s): 64 ( 16 sec )
Perform calibration correction ( 16 sec )
Calculate rotated fields ( 16 sec )
Calculate response functions by ordinary remote reference ( 16 sec )
Calculate response functions for output variable 0 ( 16 sec )
Calculate response functions by the ordinary least square method ( 16 sec )
Parametric error estimation is performed ( 16 sec )
Calculate response functions for output variable 1 ( 16 sec )
Calculate response functions by the ordinary least square method ( 16 sec )
Parametric error estimation is performed ( 16 sec )
===============================================================================
Perform analysis for segment length : 4096 ( 16 sec )
Convert time-series data to frequency-domain ( 16 sec )
Total number of segments : 1349 ( 16 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.0234375, Period(s): 42.6667 ( 17 sec )
Perform calibration correction ( 17 sec )
Calculate rotated fields ( 17 sec )
Calculate response functions by ordinary remote reference ( 17 sec )
Calculate response functions for output variable 0 ( 17 sec )
Calculate response functions by the ordinary least square method ( 17 sec )
Parametric error estimation is performed ( 17 sec )
Calculate response functions for output variable 1 ( 17 sec )
Calculate response functions by the ordinary least square method ( 17 sec )
Parametric error estimation is performed ( 17 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.03125, Period(s): 32 ( 17 sec )
Perform calibration correction ( 17 sec )
Calculate rotated fields ( 17 sec )
Calculate response functions by ordinary remote reference ( 17 sec )
Calculate response functions for output variable 0 ( 17 sec )
Calculate response functions by the ordinary least square method ( 17 sec )
Parametric error estimation is performed ( 17 sec )
Calculate response functions for output variable 1 ( 17 sec )
Calculate response functions by the ordinary least square method ( 17 sec )
Parametric error estimation is performed ( 17 sec )
===============================================================================
Perform analysis for segment length : 2048 ( 17 sec )
Convert time-series data to frequency-domain ( 17 sec )
Total number of segments : 2699 ( 17 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.046875, Period(s): 21.3333 ( 19 sec )
Perform calibration correction ( 19 sec )
Calculate rotated fields ( 19 sec )
Calculate response functions by ordinary remote reference ( 19 sec )
Calculate response functions for output variable 0 ( 19 sec )
Calculate response functions by the ordinary least square method ( 19 sec )
Parametric error estimation is performed ( 19 sec )
Calculate response functions for output variable 1 ( 19 sec )
Calculate response functions by the ordinary least square method ( 19 sec )
Parametric error estimation is performed ( 19 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.0625, Period(s): 16 ( 19 sec )
Perform calibration correction ( 19 sec )
Calculate rotated fields ( 19 sec )
Calculate response functions by ordinary remote reference ( 19 sec )
Calculate response functions for output variable 0 ( 19 sec )
Calculate response functions by the ordinary least square method ( 19 sec )
Parametric error estimation is performed ( 19 sec )
Calculate response functions for output variable 1 ( 19 sec )
Calculate response functions by the ordinary least square method ( 19 sec )
Parametric error estimation is performed ( 19 sec )
===============================================================================
Perform analysis for segment length : 1024 ( 19 sec )
Convert time-series data to frequency-domain ( 19 sec )
Total number of segments : 5399 ( 19 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.09375, Period(s): 10.6667 ( 20 sec )
Perform calibration correction ( 20 sec )
Calculate rotated fields ( 20 sec )
Calculate response functions by ordinary remote reference ( 20 sec )
Calculate response functions for output variable 0 ( 20 sec )
Calculate response functions by the ordinary least square method ( 20 sec )
Parametric error estimation is performed ( 20 sec )
Calculate response functions for output variable 1 ( 20 sec )
Calculate response functions by the ordinary least square method ( 20 sec )
Parametric error estimation is performed ( 20 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.125, Period(s): 8 ( 20 sec )
Perform calibration correction ( 20 sec )
Calculate rotated fields ( 20 sec )
Calculate response functions by ordinary remote reference ( 20 sec )
Calculate response functions for output variable 0 ( 20 sec )
Calculate response functions by the ordinary least square method ( 20 sec )
Parametric error estimation is performed ( 20 sec )
Calculate response functions for output variable 1 ( 20 sec )
Calculate response functions by the ordinary least square method ( 20 sec )
Parametric error estimation is performed ( 20 sec )
===============================================================================
Perform analysis for segment length : 512 ( 20 sec )
Convert time-series data to frequency-domain ( 20 sec )
Total number of segments : 10799 ( 20 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.1875, Period(s): 5.33333 ( 22 sec )
Perform calibration correction ( 22 sec )
Calculate rotated fields ( 22 sec )
Calculate response functions by ordinary remote reference ( 22 sec )
Calculate response functions for output variable 0 ( 22 sec )
Calculate response functions by the ordinary least square method ( 22 sec )
Parametric error estimation is performed ( 22 sec )
Calculate response functions for output variable 1 ( 22 sec )
Calculate response functions by the ordinary least square method ( 22 sec )
Parametric error estimation is performed ( 22 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.25, Period(s): 4 ( 22 sec )
Perform calibration correction ( 22 sec )
Calculate rotated fields ( 22 sec )
Calculate response functions by ordinary remote reference ( 22 sec )
Calculate response functions for output variable 0 ( 22 sec )
Calculate response functions by the ordinary least square method ( 22 sec )
Parametric error estimation is performed ( 22 sec )
Calculate response functions for output variable 1 ( 22 sec )
Calculate response functions by the ordinary least square method ( 22 sec )
Parametric error estimation is performed ( 22 sec )
===============================================================================
Perform analysis for segment length : 256 ( 22 sec )
Convert time-series data to frequency-domain ( 22 sec )
Total number of segments : 21599 ( 22 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.375, Period(s): 2.66667 ( 24 sec )
Perform calibration correction ( 24 sec )
Calculate rotated fields ( 24 sec )
Calculate response functions by ordinary remote reference ( 24 sec )
Calculate response functions for output variable 0 ( 24 sec )
Calculate response functions by the ordinary least square method ( 24 sec )
Parametric error estimation is performed ( 24 sec )
Calculate response functions for output variable 1 ( 24 sec )
Calculate response functions by the ordinary least square method ( 24 sec )
Parametric error estimation is performed ( 24 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.5, Period(s): 2 ( 24 sec )
Perform calibration correction ( 24 sec )
Calculate rotated fields ( 24 sec )
Calculate response functions by ordinary remote reference ( 24 sec )
Calculate response functions for output variable 0 ( 24 sec )
Calculate response functions by the ordinary least square method ( 24 sec )
Parametric error estimation is performed ( 24 sec )
Calculate response functions for output variable 1 ( 24 sec )
Calculate response functions by the ordinary least square method ( 24 sec )
Parametric error estimation is performed ( 24 sec )
===============================================================================
Perform analysis for segment length : 128 ( 24 sec )
Convert time-series data to frequency-domain ( 24 sec )
Total number of segments : 43199 ( 24 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.75, Period(s): 1.33333 ( 25 sec )
Perform calibration correction ( 25 sec )
Calculate rotated fields ( 25 sec )
Calculate response functions by ordinary remote reference ( 25 sec )
Calculate response functions for output variable 0 ( 25 sec )
Calculate response functions by the ordinary least square method ( 25 sec )
Parametric error estimation is performed ( 25 sec )
Calculate response functions for output variable 1 ( 25 sec )
Calculate response functions by the ordinary least square method ( 25 sec )
Parametric error estimation is performed ( 25 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 1, Period(s): 1 ( 25 sec )
Perform calibration correction ( 25 sec )
Calculate rotated fields ( 25 sec )
Calculate response functions by ordinary remote reference ( 25 sec )
Calculate response functions for output variable 0 ( 25 sec )
Calculate response functions by the ordinary least square method ( 25 sec )
Parametric error estimation is performed ( 25 sec )
Calculate response functions for output variable 1 ( 25 sec )
Calculate response functions by the ordinary least square method ( 25 sec )
Parametric error estimation is performed ( 25 sec )
End TRACMT ( 25 sec )

View File

@@ -0,0 +1,21 @@
frequency,period,app_res_0_2,phase_0_2,app_res_0_3,phase_0_3,coherence_0_2+3,app_res_1_2,phase_1_2,app_res_1_3,phase_1_3,coherence_1_2+3,dapp_res_0_2,dphase_0_2,dapp_res_0_3,dphase_0_3,dapp_res_1_2,dphase_1_2,dapp_res_1_3,dphase_1_3
1.4648437500e-03,6.8266666667e+02,4.3439931212e+01,4.8258024132e+01,4.1688452809e+01,5.3014214814e+01,8.8469008246e-01,1.5805526300e+02,-1.2905058619e+02,6.4849560945e+00,-1.3524485798e+02,9.4305915727e-01,3.3690232144e+00,2.2223702517e+00,3.4635140769e+00,2.3807774441e+00,6.2136295221e+00,1.1263075660e+00,1.3208211789e+00,5.8449817321e+00
1.9531250000e-03,5.1200000000e+02,4.4201790775e+01,4.6114671043e+01,4.5475091489e+01,5.4792118884e+01,8.8117476976e-01,1.6913516599e+02,-1.2862575255e+02,8.0773816625e+00,-1.3063638437e+02,9.5206812438e-01,3.6600424768e+00,2.3728104457e+00,4.0482366560e+00,2.5511057134e+00,6.2247090309e+00,1.0543924593e+00,1.4833727938e+00,5.2684701321e+00
2.9296875000e-03,3.4133333333e+02,3.9422126341e+01,5.1480630538e+01,5.2432599053e+01,6.0247384811e+01,8.1057433654e-01,1.7599584294e+02,-1.2541588946e+02,5.8552117518e+00,-1.2839384516e+02,9.1795261351e-01,2.8192223353e+00,2.0491535694e+00,3.7894049717e+00,2.0708890615e+00,5.8225755132e+00,9.4781846380e-01,1.2377879501e+00,6.0674792759e+00
3.9062500000e-03,2.5600000000e+02,4.4143542485e+01,4.9363170827e+01,5.2434467640e+01,6.4375151174e+01,7.9529312750e-01,1.9515981731e+02,-1.2832541387e+02,6.6839689192e+00,-1.2514079521e+02,8.9823309221e-01,3.3801634274e+00,2.1941651353e+00,4.4135400945e+00,2.4120768517e+00,7.3597276715e+00,1.0804127890e+00,1.6317675464e+00,7.0113387294e+00
5.8593750000e-03,1.7066666667e+02,5.2729192716e+01,4.8182052659e+01,5.6301329724e+01,6.0116226115e+01,6.9714037413e-01,2.0306618106e+02,-1.2974416401e+02,6.7586186926e+00,-1.3245111721e+02,8.5860507996e-01,3.3124269277e+00,1.7999450940e+00,4.2331392213e+00,2.1544622365e+00,6.3747196406e+00,8.9936081000e-01,1.4383141127e+00,6.1081738115e+00
7.8125000000e-03,1.2800000000e+02,5.5373578002e+01,4.5333555005e+01,6.6303173500e+01,5.8064666615e+01,6.6243101745e-01,2.1095797199e+02,-1.2870685937e+02,8.3774706370e+00,-1.3616142787e+02,8.1652992410e-01,3.9364069731e+00,2.0369554542e+00,5.2652867417e+00,2.2755926948e+00,7.8105239459e+00,1.0607222319e+00,1.9025883137e+00,6.5202211360e+00
1.1718750000e-02,8.5333333333e+01,5.8437573450e+01,4.1348027239e+01,7.5383241750e+01,5.9922540845e+01,5.6255496758e-01,2.4893409741e+02,-1.2995152666e+02,9.0707118284e+00,-1.2698899909e+02,7.5896390227e-01,3.6840792837e+00,1.8063478075e+00,5.1720678440e+00,1.9659264221e+00,7.7422263542e+00,8.9102854844e-01,1.8267885581e+00,5.7793133809e+00
1.5625000000e-02,6.4000000000e+01,5.1760990943e+01,4.0963272318e+01,8.0640264680e+01,5.7638466973e+01,4.8823618087e-01,2.4433951559e+02,-1.3233082051e+02,8.1554356349e+00,-1.3411193012e+02,6.7112788794e-01,4.0194513109e+00,2.2251843996e+00,6.3182040702e+00,2.2451506574e+00,9.4708442748e+00,1.1104904161e+00,2.1790521255e+00,7.6773879253e+00
2.3437500000e-02,4.2666666667e+01,4.8083059538e+01,4.0337977971e+01,9.0272215363e+01,5.6711840247e+01,2.8529865609e-01,2.5139035783e+02,-1.3398485460e+02,1.3646001184e+01,-1.3092226722e+02,5.4127075001e-01,3.5795687954e+00,2.1332001001e+00,6.6589253788e+00,2.1136895315e+00,8.9021145539e+00,1.0145183185e+00,2.8158790988e+00,5.9220871332e+00
3.1250000000e-02,3.2000000000e+01,5.5704971072e+01,3.5435669997e+01,1.0725112638e+02,5.6289234236e+01,1.8288167094e-01,2.5370444257e+02,-1.3601879048e+02,1.4764311300e+01,-1.3224793142e+02,4.1689718636e-01,5.0225304352e+00,2.5838570119e+00,9.1700701378e+00,2.4501676819e+00,1.1254288242e+01,1.2709199982e+00,3.5723723600e+00,6.9486637394e+00
4.6875000000e-02,2.1333333333e+01,7.1166112619e+01,3.1151888685e+01,1.1031797611e+02,5.7234235225e+01,0.0000000000e+00,2.3921212412e+02,-1.3959727801e+02,9.2260852110e+00,-1.3642252652e+02,1.3749136535e-01,6.1173036659e+00,2.4632768659e+00,9.9861813035e+00,2.5941446459e+00,1.1697062865e+01,1.4009723052e+00,3.0119436807e+00,9.3944140839e+00
6.2500000000e-02,1.6000000000e+01,6.7186815892e+01,3.2462794842e+01,1.4859458243e+02,5.6178846629e+01,0.0000000000e+00,2.1995117514e+02,-1.3414376018e+02,1.1593824880e+01,-1.3689299548e+02,0.0000000000e+00,8.7410625152e+00,3.7297486912e+00,1.7841539826e+01,3.4417808559e+00,1.5789500836e+01,2.0569704208e+00,4.9753916696e+00,1.2390346059e+01
9.3750000000e-02,1.0666666667e+01,4.3429860513e+01,3.0140602239e+01,1.5794748034e+02,5.9018744701e+01,0.0000000000e+00,2.1205209697e+02,-1.3305620911e+02,1.3933591532e+01,-9.9848555846e+01,0.0000000000e+00,8.6086422504e+00,5.6879062616e+00,2.2782719944e+01,4.1358303983e+00,1.9281914266e+01,2.6058531973e+00,6.8591322543e+00,1.4249010152e+01
1.2500000000e-01,8.0000000000e+00,4.9756690032e+01,1.9899467883e+01,1.4733574563e+02,5.2537500448e+01,0.0000000000e+00,2.5655127865e+02,-1.3723463362e+02,4.3301730676e+00,-8.9116917318e+01,0.0000000000e+00,1.4944799814e+01,8.6372883093e+00,3.0368940619e+01,5.9154252456e+00,3.6583247388e+01,4.0885503014e+00,5.6125343002e+00,4.0396452284e+01
1.8750000000e-01,5.3333333333e+00,3.8287795343e+01,3.7725280039e+01,1.7817974707e+02,4.8503439711e+01,0.0000000000e+00,2.6603859751e+02,-1.3437444590e+02,4.3102862340e-01,-1.1064334081e+02,0.0000000000e+00,2.1191952025e+01,1.6066063085e+01,5.2553779861e+01,8.4805726387e+00,5.9528113316e+01,6.4236266607e+00,2.7544624445e+00,3.6000000000e+02
2.5000000000e-01,4.0000000000e+00,4.0483046079e+01,3.4446274250e+01,1.6548963640e+02,3.7249895138e+01,0.0000000000e+00,2.6101784068e+02,-1.5095164189e+02,4.1029062342e+00,1.6303682644e+02,0.0000000000e+00,3.1821660337e+01,2.3142825901e+01,7.6642870554e+01,1.3389166013e+01,8.9078314793e+01,9.8248255834e+00,1.3304017548e+01,3.6000000000e+02
3.7500000000e-01,2.6666666667e+00,2.1275077719e+01,-1.2307247151e+02,3.2863961430e+02,1.9839626363e+01,0.0000000000e+00,1.0763695474e+02,-1.6391873627e+02,6.7011511919e+01,-9.0237564498e+01,0.0000000000e+00,4.3429979397e+01,3.6000000000e+02,2.6886698296e+02,2.4145831783e+01,7.1747554228e+01,1.9468280361e+01,8.9171193704e+01,4.1708594952e+01
5.0000000000e-01,2.0000000000e+00,1.1712247875e+00,-4.4816155073e+01,2.0588790332e+02,1.7012371582e+01,0.0000000000e+00,2.2399698921e+01,-1.3551513404e+02,1.5590968093e+01,1.6669346345e+02,0.0000000000e+00,7.5753105221e+00,3.6000000000e+02,2.1428080610e+02,3.1357893175e+01,1.7702730579e+01,2.3275675508e+01,3.1509626435e+01,3.6000000000e+02
7.5000000000e-01,1.3333333333e+00,1.1944686208e+02,1.7300053406e+02,1.0519975799e+02,3.3543938500e+01,0.0000000000e+00,1.0236687330e+01,-4.1477825957e+01,6.6177497072e+01,-1.3886878892e+02,0.0000000000e+00,1.6964566872e+02,4.5245516761e+01,1.8535393568e+02,6.1758602935e+01,3.1572335160e+01,3.6000000000e+02,9.3459013428e+01,4.4920407031e+01
1.0000000000e+00,1.0000000000e+00,4.6277191207e+01,4.2464688138e+01,2.2123687969e+02,-4.9613047546e+01,0.0000000000e+00,3.4931890994e+01,-1.5468047827e+02,1.6167769729e+02,-1.3659513255e+02,0.0000000000e+00,1.2325192597e+02,3.6000000000e+02,5.7971489516e+02,3.6000000000e+02,9.2340982943e+01,3.6000000000e+02,4.2735026826e+02,3.6000000000e+02
1 frequency period app_res_0_2 phase_0_2 app_res_0_3 phase_0_3 coherence_0_2+3 app_res_1_2 phase_1_2 app_res_1_3 phase_1_3 coherence_1_2+3 dapp_res_0_2 dphase_0_2 dapp_res_0_3 dphase_0_3 dapp_res_1_2 dphase_1_2 dapp_res_1_3 dphase_1_3
2 1.4648437500e-03 6.8266666667e+02 4.3439931212e+01 4.8258024132e+01 4.1688452809e+01 5.3014214814e+01 8.8469008246e-01 1.5805526300e+02 -1.2905058619e+02 6.4849560945e+00 -1.3524485798e+02 9.4305915727e-01 3.3690232144e+00 2.2223702517e+00 3.4635140769e+00 2.3807774441e+00 6.2136295221e+00 1.1263075660e+00 1.3208211789e+00 5.8449817321e+00
3 1.9531250000e-03 5.1200000000e+02 4.4201790775e+01 4.6114671043e+01 4.5475091489e+01 5.4792118884e+01 8.8117476976e-01 1.6913516599e+02 -1.2862575255e+02 8.0773816625e+00 -1.3063638437e+02 9.5206812438e-01 3.6600424768e+00 2.3728104457e+00 4.0482366560e+00 2.5511057134e+00 6.2247090309e+00 1.0543924593e+00 1.4833727938e+00 5.2684701321e+00
4 2.9296875000e-03 3.4133333333e+02 3.9422126341e+01 5.1480630538e+01 5.2432599053e+01 6.0247384811e+01 8.1057433654e-01 1.7599584294e+02 -1.2541588946e+02 5.8552117518e+00 -1.2839384516e+02 9.1795261351e-01 2.8192223353e+00 2.0491535694e+00 3.7894049717e+00 2.0708890615e+00 5.8225755132e+00 9.4781846380e-01 1.2377879501e+00 6.0674792759e+00
5 3.9062500000e-03 2.5600000000e+02 4.4143542485e+01 4.9363170827e+01 5.2434467640e+01 6.4375151174e+01 7.9529312750e-01 1.9515981731e+02 -1.2832541387e+02 6.6839689192e+00 -1.2514079521e+02 8.9823309221e-01 3.3801634274e+00 2.1941651353e+00 4.4135400945e+00 2.4120768517e+00 7.3597276715e+00 1.0804127890e+00 1.6317675464e+00 7.0113387294e+00
6 5.8593750000e-03 1.7066666667e+02 5.2729192716e+01 4.8182052659e+01 5.6301329724e+01 6.0116226115e+01 6.9714037413e-01 2.0306618106e+02 -1.2974416401e+02 6.7586186926e+00 -1.3245111721e+02 8.5860507996e-01 3.3124269277e+00 1.7999450940e+00 4.2331392213e+00 2.1544622365e+00 6.3747196406e+00 8.9936081000e-01 1.4383141127e+00 6.1081738115e+00
7 7.8125000000e-03 1.2800000000e+02 5.5373578002e+01 4.5333555005e+01 6.6303173500e+01 5.8064666615e+01 6.6243101745e-01 2.1095797199e+02 -1.2870685937e+02 8.3774706370e+00 -1.3616142787e+02 8.1652992410e-01 3.9364069731e+00 2.0369554542e+00 5.2652867417e+00 2.2755926948e+00 7.8105239459e+00 1.0607222319e+00 1.9025883137e+00 6.5202211360e+00
8 1.1718750000e-02 8.5333333333e+01 5.8437573450e+01 4.1348027239e+01 7.5383241750e+01 5.9922540845e+01 5.6255496758e-01 2.4893409741e+02 -1.2995152666e+02 9.0707118284e+00 -1.2698899909e+02 7.5896390227e-01 3.6840792837e+00 1.8063478075e+00 5.1720678440e+00 1.9659264221e+00 7.7422263542e+00 8.9102854844e-01 1.8267885581e+00 5.7793133809e+00
9 1.5625000000e-02 6.4000000000e+01 5.1760990943e+01 4.0963272318e+01 8.0640264680e+01 5.7638466973e+01 4.8823618087e-01 2.4433951559e+02 -1.3233082051e+02 8.1554356349e+00 -1.3411193012e+02 6.7112788794e-01 4.0194513109e+00 2.2251843996e+00 6.3182040702e+00 2.2451506574e+00 9.4708442748e+00 1.1104904161e+00 2.1790521255e+00 7.6773879253e+00
10 2.3437500000e-02 4.2666666667e+01 4.8083059538e+01 4.0337977971e+01 9.0272215363e+01 5.6711840247e+01 2.8529865609e-01 2.5139035783e+02 -1.3398485460e+02 1.3646001184e+01 -1.3092226722e+02 5.4127075001e-01 3.5795687954e+00 2.1332001001e+00 6.6589253788e+00 2.1136895315e+00 8.9021145539e+00 1.0145183185e+00 2.8158790988e+00 5.9220871332e+00
11 3.1250000000e-02 3.2000000000e+01 5.5704971072e+01 3.5435669997e+01 1.0725112638e+02 5.6289234236e+01 1.8288167094e-01 2.5370444257e+02 -1.3601879048e+02 1.4764311300e+01 -1.3224793142e+02 4.1689718636e-01 5.0225304352e+00 2.5838570119e+00 9.1700701378e+00 2.4501676819e+00 1.1254288242e+01 1.2709199982e+00 3.5723723600e+00 6.9486637394e+00
12 4.6875000000e-02 2.1333333333e+01 7.1166112619e+01 3.1151888685e+01 1.1031797611e+02 5.7234235225e+01 0.0000000000e+00 2.3921212412e+02 -1.3959727801e+02 9.2260852110e+00 -1.3642252652e+02 1.3749136535e-01 6.1173036659e+00 2.4632768659e+00 9.9861813035e+00 2.5941446459e+00 1.1697062865e+01 1.4009723052e+00 3.0119436807e+00 9.3944140839e+00
13 6.2500000000e-02 1.6000000000e+01 6.7186815892e+01 3.2462794842e+01 1.4859458243e+02 5.6178846629e+01 0.0000000000e+00 2.1995117514e+02 -1.3414376018e+02 1.1593824880e+01 -1.3689299548e+02 0.0000000000e+00 8.7410625152e+00 3.7297486912e+00 1.7841539826e+01 3.4417808559e+00 1.5789500836e+01 2.0569704208e+00 4.9753916696e+00 1.2390346059e+01
14 9.3750000000e-02 1.0666666667e+01 4.3429860513e+01 3.0140602239e+01 1.5794748034e+02 5.9018744701e+01 0.0000000000e+00 2.1205209697e+02 -1.3305620911e+02 1.3933591532e+01 -9.9848555846e+01 0.0000000000e+00 8.6086422504e+00 5.6879062616e+00 2.2782719944e+01 4.1358303983e+00 1.9281914266e+01 2.6058531973e+00 6.8591322543e+00 1.4249010152e+01
15 1.2500000000e-01 8.0000000000e+00 4.9756690032e+01 1.9899467883e+01 1.4733574563e+02 5.2537500448e+01 0.0000000000e+00 2.5655127865e+02 -1.3723463362e+02 4.3301730676e+00 -8.9116917318e+01 0.0000000000e+00 1.4944799814e+01 8.6372883093e+00 3.0368940619e+01 5.9154252456e+00 3.6583247388e+01 4.0885503014e+00 5.6125343002e+00 4.0396452284e+01
16 1.8750000000e-01 5.3333333333e+00 3.8287795343e+01 3.7725280039e+01 1.7817974707e+02 4.8503439711e+01 0.0000000000e+00 2.6603859751e+02 -1.3437444590e+02 4.3102862340e-01 -1.1064334081e+02 0.0000000000e+00 2.1191952025e+01 1.6066063085e+01 5.2553779861e+01 8.4805726387e+00 5.9528113316e+01 6.4236266607e+00 2.7544624445e+00 3.6000000000e+02
17 2.5000000000e-01 4.0000000000e+00 4.0483046079e+01 3.4446274250e+01 1.6548963640e+02 3.7249895138e+01 0.0000000000e+00 2.6101784068e+02 -1.5095164189e+02 4.1029062342e+00 1.6303682644e+02 0.0000000000e+00 3.1821660337e+01 2.3142825901e+01 7.6642870554e+01 1.3389166013e+01 8.9078314793e+01 9.8248255834e+00 1.3304017548e+01 3.6000000000e+02
18 3.7500000000e-01 2.6666666667e+00 2.1275077719e+01 -1.2307247151e+02 3.2863961430e+02 1.9839626363e+01 0.0000000000e+00 1.0763695474e+02 -1.6391873627e+02 6.7011511919e+01 -9.0237564498e+01 0.0000000000e+00 4.3429979397e+01 3.6000000000e+02 2.6886698296e+02 2.4145831783e+01 7.1747554228e+01 1.9468280361e+01 8.9171193704e+01 4.1708594952e+01
19 5.0000000000e-01 2.0000000000e+00 1.1712247875e+00 -4.4816155073e+01 2.0588790332e+02 1.7012371582e+01 0.0000000000e+00 2.2399698921e+01 -1.3551513404e+02 1.5590968093e+01 1.6669346345e+02 0.0000000000e+00 7.5753105221e+00 3.6000000000e+02 2.1428080610e+02 3.1357893175e+01 1.7702730579e+01 2.3275675508e+01 3.1509626435e+01 3.6000000000e+02
20 7.5000000000e-01 1.3333333333e+00 1.1944686208e+02 1.7300053406e+02 1.0519975799e+02 3.3543938500e+01 0.0000000000e+00 1.0236687330e+01 -4.1477825957e+01 6.6177497072e+01 -1.3886878892e+02 0.0000000000e+00 1.6964566872e+02 4.5245516761e+01 1.8535393568e+02 6.1758602935e+01 3.1572335160e+01 3.6000000000e+02 9.3459013428e+01 4.4920407031e+01
21 1.0000000000e+00 1.0000000000e+00 4.6277191207e+01 4.2464688138e+01 2.2123687969e+02 -4.9613047546e+01 0.0000000000e+00 3.4931890994e+01 -1.5468047827e+02 1.6167769729e+02 -1.3659513255e+02 0.0000000000e+00 1.2325192597e+02 3.6000000000e+02 5.7971489516e+02 3.6000000000e+02 9.2340982943e+01 3.6000000000e+02 4.2735026826e+02 3.6000000000e+02

View File

@@ -0,0 +1,51 @@
NUM_OUT
2
SAMPLING_FREQ
32
NUM_SECTION
1
SEGMENT
10
65536 2 3 4
32768 2 3 4
16384 2 3 4
8192 2 3 4
4096 2 3 4
2048 2 3 4
1024 2 3 4
512 2 3 4
256 2 3 4
128 2 3 4
ROTATION
0.0
AZIMUTH
0.0 90.0
0.0 90.0
0.0 90.0
MESTIMATORS
-1
-1
OUTPUT_RHOA_PHS
PREWHITENING
0
10
5
PROCEDURE
0
ERROR_ESTIMATION
0
DATA_FILES
2764800
../ex.txt
0
../ey.txt
0
../hx.txt
0
../hy.txt
0
../hrx.txt
0
../hry.txt
0
END

View File

@@ -0,0 +1,21 @@
frequency,period,resp_real_0_2,resp_imag_0_2,resp_real_0_3,resp_imag_0_3,coherence_0_2+3,resp_real_1_2,resp_imag_1_2,resp_real_1_3,resp_imag_1_3,coherence_1_2+3,dresp_0_2,dresp_0_3,dresp_1_2,dresp_1_3
1.4648437500e-03,6.8266666667e+02,3.7553820017e-01,4.2087363768e-01,3.3243638090e-01,4.4138577273e-01,8.8469008246e-01,-6.7784440534e-01,-8.3555866519e-01,-1.5476304204e-01,-1.5344587919e-01,9.4305915727e-01,2.1873087828e-02,2.2954071290e-02,2.1149082551e-02,2.2194285161e-02
1.9531250000e-03,5.1200000000e+02,4.5544857553e-01,4.7352371439e-01,3.8421100852e-01,5.4449480370e-01,8.8117476976e-01,-8.0225452024e-01,-1.0040409803e+00,-1.8290990486e-01,-2.1313058674e-01,9.5206812438e-01,2.7201084488e-02,2.9661911055e-02,2.3649508781e-02,2.5789031546e-02
2.9296875000e-03,3.4133333333e+02,4.7325994887e-01,5.9455662019e-01,4.3491283983e-01,7.6085903553e-01,8.1057433654e-01,-9.3047711320e-01,-1.3085398150e+00,-1.8188757126e-01,-2.2953565043e-01,9.1795261351e-01,2.7172209868e-02,3.1669119087e-02,2.6560092321e-02,3.0955698147e-02
3.9062500000e-03,2.5600000000e+02,6.0472014875e-01,7.0462195953e-01,4.3765943304e-01,9.1244995303e-01,7.9529312750e-01,-1.2107121638e+00,-1.5316302550e+00,-2.0796664613e-01,-2.9545920539e-01,8.9823309221e-01,3.5549961220e-02,4.2590591203e-02,3.6813030195e-02,4.4103809574e-02
5.8593750000e-03,1.7066666667e+02,8.2872344233e-01,9.2629262330e-01,6.3989762316e-01,1.1135457113e+00,6.9714037413e-01,-1.5594640887e+00,-1.8754402895e+00,-3.0034351832e-01,-3.2832937427e-01,8.5860507996e-01,3.9039243982e-02,4.8281847422e-02,3.8284496690e-02,4.7348412502e-02
7.8125000000e-03,1.2800000000e+02,1.0338873781e+00,1.0459958318e+00,8.5127811729e-01,1.3657574023e+00,6.6243101745e-01,-1.7951117014e+00,-2.2401160150e+00,-4.1261865410e-01,-3.9622063683e-01,8.1652992410e-01,5.2275563242e-02,6.3900593401e-02,5.3141305459e-02,6.4958859213e-02
1.1718750000e-02,8.5333333333e+01,1.3891345140e+00,1.2224491283e+00,1.0532910900e+00,1.8186711360e+00,5.6255496758e-01,-2.4524326255e+00,-2.9277220646e+00,-4.3863034994e-01,-5.8231472358e-01,7.5896390227e-01,5.8328194320e-02,7.2097874138e-02,5.9390820027e-02,7.3411356500e-02
1.5625000000e-02,6.4000000000e+01,1.5185112514e+00,1.3183136943e+00,1.3434936737e+00,2.1201522179e+00,4.8823618087e-01,-2.9421960630e+00,-3.2299391608e+00,-5.5560572962e-01,-5.7310180788e-01,6.7112788794e-01,7.8078327300e-02,9.8329243113e-02,8.4675322809e-02,1.0663727938e-01
2.3437500000e-02,4.2666666667e+01,1.8093730204e+00,1.5365229620e+00,1.7851365055e+00,2.7188348414e+00,2.8529865609e-01,-3.7693573785e+00,-3.9053492175e+00,-8.2833789941e-01,-9.5550881111e-01,5.4127075001e-01,8.8357885759e-02,1.1996035627e-01,9.6101356857e-02,1.3047339134e-01
3.1250000000e-02,3.2000000000e+01,2.4037562191e+00,1.7105138905e+00,2.2719800121e+00,3.4053039984e+00,1.8288167094e-01,-4.5304948017e+00,-4.3721774900e+00,-1.0211877886e+00,-1.1243216359e+00,4.1689718636e-01,1.3300121794e-01,1.7500551855e-01,1.3964777332e-01,1.8375118186e-01
4.6875000000e-02,2.1333333333e+01,3.4951354558e+00,2.1127199981e+00,2.7519546708e+00,4.2758064900e+00,0.0000000000e+00,-5.7019240790e+00,-4.8531848706e+00,-1.0652917315e+00,-1.0136652544e+00,1.3749136535e-01,1.7552907521e-01,2.3014521543e-01,1.8306734250e-01,2.4002902613e-01
6.2500000000e-02,1.6000000000e+01,3.8661238649e+00,2.4594646221e+00,3.7929013994e+00,5.6612459746e+00,0.0000000000e+00,-5.7741092844e+00,-5.9493196421e+00,-1.3896584759e+00,-1.3007380964e+00,0.0000000000e+00,2.9806927530e-01,4.0909659139e-01,2.9757762442e-01,4.0842180630e-01
9.3750000000e-02,1.0666666667e+01,3.9019206664e+00,2.2655600254e+00,4.4292457294e+00,7.3769684613e+00,0.0000000000e+00,-6.8066230237e+00,-7.2848681162e+00,-4.3713076268e-01,-2.5179927972e+00,0.0000000000e+00,4.4717867795e-01,6.2056869745e-01,4.5328307822e-01,6.2904003098e-01
1.2500000000e-01,8.0000000000e+00,5.2435831843e+00,1.8980955348e+00,5.8367421539e+00,7.6169076432e+00,0.0000000000e+00,-9.2962168092e+00,-8.5979591876e+00,2.5354448993e-02,-1.6449058694e+00,0.0000000000e+00,8.3747986432e-01,9.8897563629e-01,9.0282832323e-01,1.0661452931e+00
1.8750000000e-01,5.3333333333e+00,4.7387832652e+00,3.6658888826e+00,8.5634725028e+00,9.6804158779e+00,0.0000000000e+00,-1.1044579801e+01,-1.1288420713e+01,-2.2410881813e-01,-5.9486517134e-01,0.0000000000e+00,1.6580454254e+00,1.9060330681e+00,1.7668734138e+00,2.0311380510e+00
2.5000000000e-01,4.0000000000e+00,5.8663087458e+00,4.0237084012e+00,1.1448673553e+01,8.7057405984e+00,0.0000000000e+00,-1.5790867096e+01,-8.7704513688e+00,-2.1661192484e+00,6.6072701972e-01,0.0000000000e+00,2.7958331837e+00,3.3305148333e+00,3.0822077414e+00,3.6716563284e+00
3.7500000000e-01,2.6666666667e+00,-3.4465905605e+00,-5.2926160103e+00,2.3350002398e+01,8.4247649729e+00,0.0000000000e+00,-1.3650415635e+01,-3.9351547786e+00,-4.6476456345e-02,-1.1209122391e+01,0.0000000000e+00,6.4465103767e+00,1.0154257166e+01,4.7347498661e+00,7.4579679465e+00
5.0000000000e-01,2.0000000000e+00,1.2138476800e+00,-1.2060828241e+00,2.1694670304e+01,6.6378489509e+00,0.0000000000e+00,-5.3388269985e+00,-5.2436793936e+00,-6.0755766250e+00,1.4369373350e+00,0.0000000000e+00,5.5337600149e+00,1.1806138254e+01,2.9570534728e+00,6.3087994474e+00
7.5000000000e-01,1.3333333333e+00,-2.1006524904e+01,2.5790781806e+00,1.6554229461e+01,1.0975271268e+01,0.0000000000e+00,4.6419465867e+00,-4.1036458635e+00,-1.1865446987e+01,-1.0362276864e+01,0.0000000000e+00,1.5029379184e+01,1.7497664286e+01,9.5546024925e+00,1.1123761318e+01
1.0000000000e+00,1.0000000000e+00,1.1221334153e+01,1.0269742736e+01,2.1550278604e+01,-2.5333177664e+01,0.0000000000e+00,-1.1946320447e+01,-5.6519804277e+00,-2.0656437395e+01,-1.9537146173e+01,0.0000000000e+00,2.0256538096e+01,4.3575331878e+01,1.7467809685e+01,3.7576292680e+01
1 frequency period resp_real_0_2 resp_imag_0_2 resp_real_0_3 resp_imag_0_3 coherence_0_2+3 resp_real_1_2 resp_imag_1_2 resp_real_1_3 resp_imag_1_3 coherence_1_2+3 dresp_0_2 dresp_0_3 dresp_1_2 dresp_1_3
2 1.4648437500e-03 6.8266666667e+02 3.7553820017e-01 4.2087363768e-01 3.3243638090e-01 4.4138577273e-01 8.8469008246e-01 -6.7784440534e-01 -8.3555866519e-01 -1.5476304204e-01 -1.5344587919e-01 9.4305915727e-01 2.1873087828e-02 2.2954071290e-02 2.1149082551e-02 2.2194285161e-02
3 1.9531250000e-03 5.1200000000e+02 4.5544857553e-01 4.7352371439e-01 3.8421100852e-01 5.4449480370e-01 8.8117476976e-01 -8.0225452024e-01 -1.0040409803e+00 -1.8290990486e-01 -2.1313058674e-01 9.5206812438e-01 2.7201084488e-02 2.9661911055e-02 2.3649508781e-02 2.5789031546e-02
4 2.9296875000e-03 3.4133333333e+02 4.7325994887e-01 5.9455662019e-01 4.3491283983e-01 7.6085903553e-01 8.1057433654e-01 -9.3047711320e-01 -1.3085398150e+00 -1.8188757126e-01 -2.2953565043e-01 9.1795261351e-01 2.7172209868e-02 3.1669119087e-02 2.6560092321e-02 3.0955698147e-02
5 3.9062500000e-03 2.5600000000e+02 6.0472014875e-01 7.0462195953e-01 4.3765943304e-01 9.1244995303e-01 7.9529312750e-01 -1.2107121638e+00 -1.5316302550e+00 -2.0796664613e-01 -2.9545920539e-01 8.9823309221e-01 3.5549961220e-02 4.2590591203e-02 3.6813030195e-02 4.4103809574e-02
6 5.8593750000e-03 1.7066666667e+02 8.2872344233e-01 9.2629262330e-01 6.3989762316e-01 1.1135457113e+00 6.9714037413e-01 -1.5594640887e+00 -1.8754402895e+00 -3.0034351832e-01 -3.2832937427e-01 8.5860507996e-01 3.9039243982e-02 4.8281847422e-02 3.8284496690e-02 4.7348412502e-02
7 7.8125000000e-03 1.2800000000e+02 1.0338873781e+00 1.0459958318e+00 8.5127811729e-01 1.3657574023e+00 6.6243101745e-01 -1.7951117014e+00 -2.2401160150e+00 -4.1261865410e-01 -3.9622063683e-01 8.1652992410e-01 5.2275563242e-02 6.3900593401e-02 5.3141305459e-02 6.4958859213e-02
8 1.1718750000e-02 8.5333333333e+01 1.3891345140e+00 1.2224491283e+00 1.0532910900e+00 1.8186711360e+00 5.6255496758e-01 -2.4524326255e+00 -2.9277220646e+00 -4.3863034994e-01 -5.8231472358e-01 7.5896390227e-01 5.8328194320e-02 7.2097874138e-02 5.9390820027e-02 7.3411356500e-02
9 1.5625000000e-02 6.4000000000e+01 1.5185112514e+00 1.3183136943e+00 1.3434936737e+00 2.1201522179e+00 4.8823618087e-01 -2.9421960630e+00 -3.2299391608e+00 -5.5560572962e-01 -5.7310180788e-01 6.7112788794e-01 7.8078327300e-02 9.8329243113e-02 8.4675322809e-02 1.0663727938e-01
10 2.3437500000e-02 4.2666666667e+01 1.8093730204e+00 1.5365229620e+00 1.7851365055e+00 2.7188348414e+00 2.8529865609e-01 -3.7693573785e+00 -3.9053492175e+00 -8.2833789941e-01 -9.5550881111e-01 5.4127075001e-01 8.8357885759e-02 1.1996035627e-01 9.6101356857e-02 1.3047339134e-01
11 3.1250000000e-02 3.2000000000e+01 2.4037562191e+00 1.7105138905e+00 2.2719800121e+00 3.4053039984e+00 1.8288167094e-01 -4.5304948017e+00 -4.3721774900e+00 -1.0211877886e+00 -1.1243216359e+00 4.1689718636e-01 1.3300121794e-01 1.7500551855e-01 1.3964777332e-01 1.8375118186e-01
12 4.6875000000e-02 2.1333333333e+01 3.4951354558e+00 2.1127199981e+00 2.7519546708e+00 4.2758064900e+00 0.0000000000e+00 -5.7019240790e+00 -4.8531848706e+00 -1.0652917315e+00 -1.0136652544e+00 1.3749136535e-01 1.7552907521e-01 2.3014521543e-01 1.8306734250e-01 2.4002902613e-01
13 6.2500000000e-02 1.6000000000e+01 3.8661238649e+00 2.4594646221e+00 3.7929013994e+00 5.6612459746e+00 0.0000000000e+00 -5.7741092844e+00 -5.9493196421e+00 -1.3896584759e+00 -1.3007380964e+00 0.0000000000e+00 2.9806927530e-01 4.0909659139e-01 2.9757762442e-01 4.0842180630e-01
14 9.3750000000e-02 1.0666666667e+01 3.9019206664e+00 2.2655600254e+00 4.4292457294e+00 7.3769684613e+00 0.0000000000e+00 -6.8066230237e+00 -7.2848681162e+00 -4.3713076268e-01 -2.5179927972e+00 0.0000000000e+00 4.4717867795e-01 6.2056869745e-01 4.5328307822e-01 6.2904003098e-01
15 1.2500000000e-01 8.0000000000e+00 5.2435831843e+00 1.8980955348e+00 5.8367421539e+00 7.6169076432e+00 0.0000000000e+00 -9.2962168092e+00 -8.5979591876e+00 2.5354448993e-02 -1.6449058694e+00 0.0000000000e+00 8.3747986432e-01 9.8897563629e-01 9.0282832323e-01 1.0661452931e+00
16 1.8750000000e-01 5.3333333333e+00 4.7387832652e+00 3.6658888826e+00 8.5634725028e+00 9.6804158779e+00 0.0000000000e+00 -1.1044579801e+01 -1.1288420713e+01 -2.2410881813e-01 -5.9486517134e-01 0.0000000000e+00 1.6580454254e+00 1.9060330681e+00 1.7668734138e+00 2.0311380510e+00
17 2.5000000000e-01 4.0000000000e+00 5.8663087458e+00 4.0237084012e+00 1.1448673553e+01 8.7057405984e+00 0.0000000000e+00 -1.5790867096e+01 -8.7704513688e+00 -2.1661192484e+00 6.6072701972e-01 0.0000000000e+00 2.7958331837e+00 3.3305148333e+00 3.0822077414e+00 3.6716563284e+00
18 3.7500000000e-01 2.6666666667e+00 -3.4465905605e+00 -5.2926160103e+00 2.3350002398e+01 8.4247649729e+00 0.0000000000e+00 -1.3650415635e+01 -3.9351547786e+00 -4.6476456345e-02 -1.1209122391e+01 0.0000000000e+00 6.4465103767e+00 1.0154257166e+01 4.7347498661e+00 7.4579679465e+00
19 5.0000000000e-01 2.0000000000e+00 1.2138476800e+00 -1.2060828241e+00 2.1694670304e+01 6.6378489509e+00 0.0000000000e+00 -5.3388269985e+00 -5.2436793936e+00 -6.0755766250e+00 1.4369373350e+00 0.0000000000e+00 5.5337600149e+00 1.1806138254e+01 2.9570534728e+00 6.3087994474e+00
20 7.5000000000e-01 1.3333333333e+00 -2.1006524904e+01 2.5790781806e+00 1.6554229461e+01 1.0975271268e+01 0.0000000000e+00 4.6419465867e+00 -4.1036458635e+00 -1.1865446987e+01 -1.0362276864e+01 0.0000000000e+00 1.5029379184e+01 1.7497664286e+01 9.5546024925e+00 1.1123761318e+01
21 1.0000000000e+00 1.0000000000e+00 1.1221334153e+01 1.0269742736e+01 2.1550278604e+01 -2.5333177664e+01 0.0000000000e+00 -1.1946320447e+01 -5.6519804277e+00 -2.0656437395e+01 -1.9537146173e+01 0.0000000000e+00 2.0256538096e+01 4.3575331878e+01 1.7467809685e+01 3.7576292680e+01

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,484 @@
Start TRACMT Version v2.0
Read parameters. ( 0 sec )
================================================================================
Summary of control parameters
================================================================================
Number of threads : 1
Procedure type : ordinary remote reference
The first M-estimator : Hubur
Threshould value for downweighting : 3
Maximum number of iteration : 10
Convergence criteria : 0.01
The second M-estimator : Tukey's biweights
Maximum number of iteration : 10
Convergence criteria : 0.01
Error estimation method : fixed-weights bootstrap
Number or repetitions in bootstrap : 1000
Number of output variables : 2
Number of input variables : 2
Number of remote reference variables : 2
Sampling frequency (Hz) : 32
Number of time-series sections : 1
Ratio of overlapping part to whole segment length : 0.5
Output level : 0
Output apparent resistivity and phase to a seperate csv file
Information about the segment lengths and frequencies :
Segment# Length Index Frequency(Hz) Period(sec)
0 65536 3 1.464843750e-03 6.826666667e+02
0 65536 4 1.953125000e-03 5.120000000e+02
1 32768 3 2.929687500e-03 3.413333333e+02
1 32768 4 3.906250000e-03 2.560000000e+02
2 16384 3 5.859375000e-03 1.706666667e+02
2 16384 4 7.812500000e-03 1.280000000e+02
3 8192 3 1.171875000e-02 8.533333333e+01
3 8192 4 1.562500000e-02 6.400000000e+01
4 4096 3 2.343750000e-02 4.266666667e+01
4 4096 4 3.125000000e-02 3.200000000e+01
5 2048 3 4.687500000e-02 2.133333333e+01
5 2048 4 6.250000000e-02 1.600000000e+01
6 1024 3 9.375000000e-02 1.066666667e+01
6 1024 4 1.250000000e-01 8.000000000e+00
7 512 3 1.875000000e-01 5.333333333e+00
7 512 4 2.500000000e-01 4.000000000e+00
8 256 3 3.750000000e-01 2.666666667e+00
8 256 4 5.000000000e-01 2.000000000e+00
9 128 3 7.500000000e-01 1.333333333e+00
9 128 4 1.000000000e+00 1.000000000e+00
Information about the time-series data :
Section# Channel# Type NSkip NData File
0 0 Out0 0 2764800 ../ex.txt
0 1 Out1 0 2764800 ../ey.txt
0 2 Inp0 0 2764800 ../hx.txt
0 3 Inp1 0 2764800 ../hy.txt
0 4 RR0 0 2764800 ../hrx.txt
0 5 RR1 0 2764800 ../hry.txt
Rotation angle (deg.) : 0
Channel# Type Azimuth(deg.)
0 Out0 0
1 Out1 90
2 Inp0 0
3 Inp1 90
4 RR0 0
5 RR1 90
Parameters for robust prewhitening :
Least square estimator is used
Maximum degree of AR model: 10
================================================================================
Read data from ../ex.txt ( 0 sec )
Read data from ../ey.txt ( 1 sec )
Read data from ../hx.txt ( 1 sec )
Read data from ../hy.txt ( 2 sec )
Read data from ../hrx.txt ( 3 sec )
Read data from ../hry.txt ( 4 sec )
Perform preprocessing ( 5 sec )
Secton 0, Channel 0 ( 5 sec )
Subtract mean (-0.889991) ( 5 sec )
Secton 0, Channel 1 ( 5 sec )
Subtract mean (1.69968) ( 5 sec )
Secton 0, Channel 2 ( 5 sec )
Subtract mean (0.0092652) ( 5 sec )
Secton 0, Channel 3 ( 5 sec )
Subtract mean (1.30261) ( 5 sec )
Secton 0, Channel 4 ( 5 sec )
Subtract mean (0.0346805) ( 5 sec )
Secton 0, Channel 5 ( 5 sec )
Subtract mean (1.2857) ( 5 sec )
Perform prewhitening for channel 0 ( 5 sec )
Degree of AR model: 1, Sigma: 7.6076, AIC: 1.90665e+07 ( 5 sec )
Degree of AR model: 2, Sigma: 7.60293, AIC: 1.90631e+07 ( 5 sec )
Degree of AR model: 3, Sigma: 7.59862, AIC: 1.906e+07 ( 5 sec )
Degree of AR model: 4, Sigma: 7.5946, AIC: 1.90571e+07 ( 5 sec )
Degree of AR model: 5, Sigma: 7.59088, AIC: 1.90544e+07 ( 5 sec )
Degree of AR model: 6, Sigma: 7.58783, AIC: 1.90521e+07 ( 5 sec )
Degree of AR model: 7, Sigma: 7.58446, AIC: 1.90497e+07 ( 5 sec )
Degree of AR model: 8, Sigma: 7.58162, AIC: 1.90476e+07 ( 5 sec )
Degree of AR model: 9, Sigma: 7.57884, AIC: 1.90456e+07 ( 5 sec )
Degree of AR model: 10, Sigma: 7.57665, AIC: 1.9044e+07 ( 5 sec )
The AR model of 10 degress gives the minimum AIC (1.9044e+07) ( 5 sec )
AR coefficients: 0.0320459 0.0276236 0.0274305 0.0273417 0.0271195 0.0250291 0.0274279 0.0257729 0.0263083 0.0240252 ( 5 sec )
Perform prewhitening for channel 1 ( 5 sec )
Degree of AR model: 1, Sigma: 7.54273, AIC: 1.90192e+07 ( 5 sec )
Degree of AR model: 2, Sigma: 7.52209, AIC: 1.9004e+07 ( 5 sec )
Degree of AR model: 3, Sigma: 7.50561, AIC: 1.89919e+07 ( 5 sec )
Degree of AR model: 4, Sigma: 7.49133, AIC: 1.89814e+07 ( 5 sec )
Degree of AR model: 5, Sigma: 7.47891, AIC: 1.89722e+07 ( 5 sec )
Degree of AR model: 6, Sigma: 7.46782, AIC: 1.8964e+07 ( 5 sec )
Degree of AR model: 7, Sigma: 7.45798, AIC: 1.89567e+07 ( 5 sec )
Degree of AR model: 8, Sigma: 7.44899, AIC: 1.895e+07 ( 5 sec )
Degree of AR model: 9, Sigma: 7.44151, AIC: 1.89444e+07 ( 5 sec )
Degree of AR model: 10, Sigma: 7.43417, AIC: 1.8939e+07 ( 5 sec )
The AR model of 10 degress gives the minimum AIC (1.8939e+07) ( 5 sec )
AR coefficients: 0.0497931 0.0484711 0.0453945 0.0449254 0.0443603 0.0443792 0.0440958 0.0444201 0.0425092 0.0444076 ( 5 sec )
Perform prewhitening for channel 2 ( 5 sec )
Degree of AR model: 1, Sigma: 1.15041, AIC: 8.62097e+06 ( 5 sec )
Degree of AR model: 2, Sigma: 0.999605, AIC: 7.84398e+06 ( 5 sec )
Degree of AR model: 3, Sigma: 0.94325, AIC: 7.5231e+06 ( 5 sec )
Degree of AR model: 4, Sigma: 0.913582, AIC: 7.34638e+06 ( 6 sec )
Degree of AR model: 5, Sigma: 0.895124, AIC: 7.23352e+06 ( 6 sec )
Degree of AR model: 6, Sigma: 0.882753, AIC: 7.15657e+06 ( 6 sec )
Degree of AR model: 7, Sigma: 0.873879, AIC: 7.1007e+06 ( 6 sec )
Degree of AR model: 8, Sigma: 0.867031, AIC: 7.0572e+06 ( 6 sec )
Degree of AR model: 9, Sigma: 0.861586, AIC: 7.02236e+06 ( 6 sec )
Degree of AR model: 10, Sigma: 0.857167, AIC: 6.99392e+06 ( 6 sec )
The AR model of 10 degress gives the minimum AIC (6.99392e+06) ( 6 sec )
AR coefficients: 0.100812 0.0994283 0.099345 0.0994338 0.100341 0.0991599 0.0983786 0.0996401 0.100555 0.101158 ( 6 sec )
Perform prewhitening for channel 3 ( 6 sec )
Degree of AR model: 1, Sigma: 1.15933, AIC: 8.66365e+06 ( 6 sec )
Degree of AR model: 2, Sigma: 1.01002, AIC: 7.90131e+06 ( 6 sec )
Degree of AR model: 3, Sigma: 0.95364, AIC: 7.58368e+06 ( 6 sec )
Degree of AR model: 4, Sigma: 0.923737, AIC: 7.40751e+06 ( 6 sec )
Degree of AR model: 5, Sigma: 0.905428, AIC: 7.29681e+06 ( 6 sec )
Degree of AR model: 6, Sigma: 0.892914, AIC: 7.21985e+06 ( 6 sec )
Degree of AR model: 7, Sigma: 0.884029, AIC: 7.16455e+06 ( 6 sec )
Degree of AR model: 8, Sigma: 0.877216, AIC: 7.12177e+06 ( 6 sec )
Degree of AR model: 9, Sigma: 0.871841, AIC: 7.08779e+06 ( 6 sec )
Degree of AR model: 10, Sigma: 0.867445, AIC: 7.05983e+06 ( 6 sec )
The AR model of 10 degress gives the minimum AIC (7.05983e+06) ( 6 sec )
AR coefficients: 0.0992426 0.0997661 0.0999695 0.100685 0.0994892 0.0998831 0.0983119 0.0990847 0.0994668 0.100303 ( 6 sec )
Perform prewhitening for channel 4 ( 6 sec )
Degree of AR model: 1, Sigma: 1.16254, AIC: 8.67898e+06 ( 6 sec )
Degree of AR model: 2, Sigma: 1.00903, AIC: 7.89586e+06 ( 6 sec )
Degree of AR model: 3, Sigma: 0.952405, AIC: 7.57651e+06 ( 6 sec )
Degree of AR model: 4, Sigma: 0.922235, AIC: 7.39851e+06 ( 6 sec )
Degree of AR model: 5, Sigma: 0.90364, AIC: 7.28588e+06 ( 6 sec )
Degree of AR model: 6, Sigma: 0.891244, AIC: 7.2095e+06 ( 6 sec )
Degree of AR model: 7, Sigma: 0.882213, AIC: 7.15318e+06 ( 6 sec )
Degree of AR model: 8, Sigma: 0.875262, AIC: 7.10944e+06 ( 6 sec )
Degree of AR model: 9, Sigma: 0.869864, AIC: 7.07523e+06 ( 6 sec )
Degree of AR model: 10, Sigma: 0.865547, AIC: 7.04772e+06 ( 6 sec )
The AR model of 10 degress gives the minimum AIC (7.04772e+06) ( 6 sec )
AR coefficients: 0.0989261 0.10121 0.0987917 0.100744 0.100552 0.0988028 0.0993482 0.100374 0.0999452 0.0995135 ( 6 sec )
Perform prewhitening for channel 5 ( 6 sec )
Degree of AR model: 1, Sigma: 1.16036, AIC: 8.66857e+06 ( 6 sec )
Degree of AR model: 2, Sigma: 1.01086, AIC: 7.90589e+06 ( 6 sec )
Degree of AR model: 3, Sigma: 0.953982, AIC: 7.58566e+06 ( 6 sec )
Degree of AR model: 4, Sigma: 0.924434, AIC: 7.41168e+06 ( 7 sec )
Degree of AR model: 5, Sigma: 0.906107, AIC: 7.30095e+06 ( 7 sec )
Degree of AR model: 6, Sigma: 0.893431, AIC: 7.22305e+06 ( 7 sec )
Degree of AR model: 7, Sigma: 0.884431, AIC: 7.16707e+06 ( 7 sec )
Degree of AR model: 8, Sigma: 0.877486, AIC: 7.12347e+06 ( 7 sec )
Degree of AR model: 9, Sigma: 0.872098, AIC: 7.08941e+06 ( 7 sec )
Degree of AR model: 10, Sigma: 0.867816, AIC: 7.0622e+06 ( 7 sec )
The AR model of 10 degress gives the minimum AIC (7.0622e+06) ( 7 sec )
AR coefficients: 0.0995885 0.098903 0.101124 0.0988656 0.0991358 0.100713 0.0990429 0.100438 0.0997109 0.0989688 ( 7 sec )
===============================================================================
Perform analysis for segment length : 65536 ( 7 sec )
Convert time-series data to frequency-domain ( 7 sec )
Total number of segments : 83 ( 7 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.00146484, Period(s): 682.667 ( 9 sec )
Perform calibration correction ( 9 sec )
Calculate rotated fields ( 9 sec )
Calculate response functions by ordinary remote reference ( 9 sec )
Calculate response functions for output variable 0 ( 9 sec )
Calculate response functions by the ordinary least square method ( 9 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 9 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 9 sec )
Calculate response functions for output variable 1 ( 9 sec )
Calculate response functions by the ordinary least square method ( 9 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 9 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 9 sec )
Estimate errors by fixed-weights bootstrap ( 9 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.00195312, Period(s): 512 ( 9 sec )
Perform calibration correction ( 9 sec )
Calculate rotated fields ( 9 sec )
Calculate response functions by ordinary remote reference ( 9 sec )
Calculate response functions for output variable 0 ( 9 sec )
Calculate response functions by the ordinary least square method ( 9 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 9 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 9 sec )
Calculate response functions for output variable 1 ( 9 sec )
Calculate response functions by the ordinary least square method ( 9 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 9 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 9 sec )
Estimate errors by fixed-weights bootstrap ( 9 sec )
===============================================================================
Perform analysis for segment length : 32768 ( 9 sec )
Convert time-series data to frequency-domain ( 9 sec )
Total number of segments : 167 ( 9 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.00292969, Period(s): 341.333 ( 11 sec )
Perform calibration correction ( 11 sec )
Calculate rotated fields ( 11 sec )
Calculate response functions by ordinary remote reference ( 11 sec )
Calculate response functions for output variable 0 ( 11 sec )
Calculate response functions by the ordinary least square method ( 11 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 11 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 11 sec )
Calculate response functions for output variable 1 ( 11 sec )
Calculate response functions by the ordinary least square method ( 11 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 11 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 11 sec )
Estimate errors by fixed-weights bootstrap ( 11 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.00390625, Period(s): 256 ( 11 sec )
Perform calibration correction ( 11 sec )
Calculate rotated fields ( 11 sec )
Calculate response functions by ordinary remote reference ( 11 sec )
Calculate response functions for output variable 0 ( 11 sec )
Calculate response functions by the ordinary least square method ( 11 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 11 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 11 sec )
Calculate response functions for output variable 1 ( 11 sec )
Calculate response functions by the ordinary least square method ( 11 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 11 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 11 sec )
Estimate errors by fixed-weights bootstrap ( 11 sec )
===============================================================================
Perform analysis for segment length : 16384 ( 11 sec )
Convert time-series data to frequency-domain ( 11 sec )
Total number of segments : 336 ( 11 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.00585938, Period(s): 170.667 ( 13 sec )
Perform calibration correction ( 13 sec )
Calculate rotated fields ( 13 sec )
Calculate response functions by ordinary remote reference ( 13 sec )
Calculate response functions for output variable 0 ( 13 sec )
Calculate response functions by the ordinary least square method ( 13 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 13 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 13 sec )
Calculate response functions for output variable 1 ( 13 sec )
Calculate response functions by the ordinary least square method ( 13 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 13 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 13 sec )
Estimate errors by fixed-weights bootstrap ( 13 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.0078125, Period(s): 128 ( 13 sec )
Perform calibration correction ( 13 sec )
Calculate rotated fields ( 13 sec )
Calculate response functions by ordinary remote reference ( 13 sec )
Calculate response functions for output variable 0 ( 13 sec )
Calculate response functions by the ordinary least square method ( 13 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 13 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 13 sec )
Calculate response functions for output variable 1 ( 13 sec )
Calculate response functions by the ordinary least square method ( 13 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 13 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 13 sec )
Estimate errors by fixed-weights bootstrap ( 13 sec )
===============================================================================
Perform analysis for segment length : 8192 ( 13 sec )
Convert time-series data to frequency-domain ( 13 sec )
Total number of segments : 674 ( 13 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.0117188, Period(s): 85.3333 ( 15 sec )
Perform calibration correction ( 15 sec )
Calculate rotated fields ( 15 sec )
Calculate response functions by ordinary remote reference ( 15 sec )
Calculate response functions for output variable 0 ( 15 sec )
Calculate response functions by the ordinary least square method ( 15 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 15 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 15 sec )
Calculate response functions for output variable 1 ( 15 sec )
Calculate response functions by the ordinary least square method ( 15 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 15 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 15 sec )
Estimate errors by fixed-weights bootstrap ( 15 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.015625, Period(s): 64 ( 15 sec )
Perform calibration correction ( 15 sec )
Calculate rotated fields ( 15 sec )
Calculate response functions by ordinary remote reference ( 15 sec )
Calculate response functions for output variable 0 ( 15 sec )
Calculate response functions by the ordinary least square method ( 15 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 15 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 15 sec )
Calculate response functions for output variable 1 ( 15 sec )
Calculate response functions by the ordinary least square method ( 15 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 15 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 15 sec )
Estimate errors by fixed-weights bootstrap ( 15 sec )
===============================================================================
Perform analysis for segment length : 4096 ( 15 sec )
Convert time-series data to frequency-domain ( 15 sec )
Total number of segments : 1349 ( 15 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.0234375, Period(s): 42.6667 ( 17 sec )
Perform calibration correction ( 17 sec )
Calculate rotated fields ( 17 sec )
Calculate response functions by ordinary remote reference ( 17 sec )
Calculate response functions for output variable 0 ( 17 sec )
Calculate response functions by the ordinary least square method ( 17 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 17 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 17 sec )
Calculate response functions for output variable 1 ( 17 sec )
Calculate response functions by the ordinary least square method ( 17 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 17 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 17 sec )
Estimate errors by fixed-weights bootstrap ( 17 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.03125, Period(s): 32 ( 17 sec )
Perform calibration correction ( 17 sec )
Calculate rotated fields ( 17 sec )
Calculate response functions by ordinary remote reference ( 17 sec )
Calculate response functions for output variable 0 ( 17 sec )
Calculate response functions by the ordinary least square method ( 17 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 17 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 17 sec )
Calculate response functions for output variable 1 ( 17 sec )
Calculate response functions by the ordinary least square method ( 17 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 17 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 17 sec )
Estimate errors by fixed-weights bootstrap ( 17 sec )
===============================================================================
Perform analysis for segment length : 2048 ( 17 sec )
Convert time-series data to frequency-domain ( 17 sec )
Total number of segments : 2699 ( 17 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.046875, Period(s): 21.3333 ( 18 sec )
Perform calibration correction ( 18 sec )
Calculate rotated fields ( 18 sec )
Calculate response functions by ordinary remote reference ( 18 sec )
Calculate response functions for output variable 0 ( 18 sec )
Calculate response functions by the ordinary least square method ( 18 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 18 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 18 sec )
Calculate response functions for output variable 1 ( 18 sec )
Calculate response functions by the ordinary least square method ( 18 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 18 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 18 sec )
Estimate errors by fixed-weights bootstrap ( 18 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.0625, Period(s): 16 ( 18 sec )
Perform calibration correction ( 18 sec )
Calculate rotated fields ( 18 sec )
Calculate response functions by ordinary remote reference ( 18 sec )
Calculate response functions for output variable 0 ( 18 sec )
Calculate response functions by the ordinary least square method ( 18 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 18 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 18 sec )
Calculate response functions for output variable 1 ( 18 sec )
Calculate response functions by the ordinary least square method ( 18 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 18 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 18 sec )
Estimate errors by fixed-weights bootstrap ( 18 sec )
===============================================================================
Perform analysis for segment length : 1024 ( 19 sec )
Convert time-series data to frequency-domain ( 19 sec )
Total number of segments : 5399 ( 19 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.09375, Period(s): 10.6667 ( 20 sec )
Perform calibration correction ( 20 sec )
Calculate rotated fields ( 20 sec )
Calculate response functions by ordinary remote reference ( 20 sec )
Calculate response functions for output variable 0 ( 20 sec )
Calculate response functions by the ordinary least square method ( 20 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 20 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 20 sec )
Calculate response functions for output variable 1 ( 20 sec )
Calculate response functions by the ordinary least square method ( 20 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 20 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 20 sec )
Estimate errors by fixed-weights bootstrap ( 20 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.125, Period(s): 8 ( 20 sec )
Perform calibration correction ( 20 sec )
Calculate rotated fields ( 20 sec )
Calculate response functions by ordinary remote reference ( 20 sec )
Calculate response functions for output variable 0 ( 20 sec )
Calculate response functions by the ordinary least square method ( 20 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 20 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 20 sec )
Calculate response functions for output variable 1 ( 20 sec )
Calculate response functions by the ordinary least square method ( 20 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 20 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 20 sec )
Estimate errors by fixed-weights bootstrap ( 20 sec )
===============================================================================
Perform analysis for segment length : 512 ( 20 sec )
Convert time-series data to frequency-domain ( 20 sec )
Total number of segments : 10799 ( 20 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.1875, Period(s): 5.33333 ( 22 sec )
Perform calibration correction ( 22 sec )
Calculate rotated fields ( 22 sec )
Calculate response functions by ordinary remote reference ( 22 sec )
Calculate response functions for output variable 0 ( 22 sec )
Calculate response functions by the ordinary least square method ( 22 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 22 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 22 sec )
Calculate response functions for output variable 1 ( 22 sec )
Calculate response functions by the ordinary least square method ( 22 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 22 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 22 sec )
Estimate errors by fixed-weights bootstrap ( 22 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.25, Period(s): 4 ( 22 sec )
Perform calibration correction ( 22 sec )
Calculate rotated fields ( 22 sec )
Calculate response functions by ordinary remote reference ( 22 sec )
Calculate response functions for output variable 0 ( 22 sec )
Calculate response functions by the ordinary least square method ( 22 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 22 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 22 sec )
Calculate response functions for output variable 1 ( 22 sec )
Calculate response functions by the ordinary least square method ( 22 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 22 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 22 sec )
Estimate errors by fixed-weights bootstrap ( 22 sec )
===============================================================================
Perform analysis for segment length : 256 ( 23 sec )
Convert time-series data to frequency-domain ( 23 sec )
Total number of segments : 21599 ( 23 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.375, Period(s): 2.66667 ( 24 sec )
Perform calibration correction ( 24 sec )
Calculate rotated fields ( 24 sec )
Calculate response functions by ordinary remote reference ( 24 sec )
Calculate response functions for output variable 0 ( 24 sec )
Calculate response functions by the ordinary least square method ( 24 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 24 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 24 sec )
Calculate response functions for output variable 1 ( 24 sec )
Calculate response functions by the ordinary least square method ( 24 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 24 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 24 sec )
Estimate errors by fixed-weights bootstrap ( 24 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.5, Period(s): 2 ( 25 sec )
Perform calibration correction ( 25 sec )
Calculate rotated fields ( 25 sec )
Calculate response functions by ordinary remote reference ( 25 sec )
Calculate response functions for output variable 0 ( 25 sec )
Calculate response functions by the ordinary least square method ( 25 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 25 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 25 sec )
Calculate response functions for output variable 1 ( 25 sec )
Calculate response functions by the ordinary least square method ( 25 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 25 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 25 sec )
Estimate errors by fixed-weights bootstrap ( 25 sec )
===============================================================================
Perform analysis for segment length : 128 ( 26 sec )
Convert time-series data to frequency-domain ( 26 sec )
Total number of segments : 43199 ( 26 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.75, Period(s): 1.33333 ( 27 sec )
Perform calibration correction ( 27 sec )
Calculate rotated fields ( 27 sec )
Calculate response functions by ordinary remote reference ( 27 sec )
Calculate response functions for output variable 0 ( 27 sec )
Calculate response functions by the ordinary least square method ( 27 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 27 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 27 sec )
Calculate response functions for output variable 1 ( 27 sec )
Calculate response functions by the ordinary least square method ( 27 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 27 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 27 sec )
Estimate errors by fixed-weights bootstrap ( 28 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 1, Period(s): 1 ( 29 sec )
Perform calibration correction ( 29 sec )
Calculate rotated fields ( 29 sec )
Calculate response functions by ordinary remote reference ( 29 sec )
Calculate response functions for output variable 0 ( 29 sec )
Calculate response functions by the ordinary least square method ( 29 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 29 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 29 sec )
Calculate response functions for output variable 1 ( 29 sec )
Calculate response functions by the ordinary least square method ( 29 sec )
Calculate response functions by iteratively reweighted remote reference using Huber weight ( 29 sec )
Calculate response functions by iteratively reweighted remote reference using Tukey's biweights weight ( 29 sec )
Estimate errors by fixed-weights bootstrap ( 29 sec )
End TRACMT ( 31 sec )

View File

@@ -0,0 +1,21 @@
frequency,period,app_res_0_2,phase_0_2,app_res_0_3,phase_0_3,coherence_0_2+3,app_res_1_2,phase_1_2,app_res_1_3,phase_1_3,coherence_1_2+3,dapp_res_0_2,dphase_0_2,dapp_res_0_3,dphase_0_3,dapp_res_1_2,dphase_1_2,dapp_res_1_3,dphase_1_3
1.4648437500e-03,6.8266666667e+02,4.3916578744e+01,5.0669393911e+01,3.9866612485e+01,5.4334231062e+01,9.3703783930e-01,1.5456339509e+02,-1.2900295429e+02,6.7884721742e+00,-1.3703647180e+02,9.6777102021e-01,2.4854563945e+00,1.6215422252e+00,2.3021754416e+00,1.6545583241e+00,4.4928675803e+00,8.3276966682e-01,1.0164047781e+00,4.2933252333e+00
1.9531250000e-03,5.1200000000e+02,4.4602963314e+01,4.5868238738e+01,4.6150130862e+01,5.4009382035e+01,9.4713584089e-01,1.7149384900e+02,-1.2903509690e+02,7.3508615241e+00,-1.3422485420e+02,9.7812451678e-01,2.2780369087e+00,1.4633118644e+00,2.5641349832e+00,1.5919024849e+00,3.9269908759e+00,6.5601454740e-01,9.5544958395e-01,3.7262188383e+00
2.9296875000e-03,3.4133333333e+02,4.1754396591e+01,5.0058719414e+01,5.3726794317e+01,5.5681889067e+01,8.9731712202e-01,1.7520883461e+02,-1.2568862112e+02,5.7317388697e+00,-1.2756902877e+02,9.5727358041e-01,1.9933856295e+00,1.3678012605e+00,2.6967321541e+00,1.4380868724e+00,3.8692138267e+00,6.3265681711e-01,8.9178474545e-01,4.4617507114e+00
3.9062500000e-03,2.5600000000e+02,4.4488224389e+01,4.7185418176e+01,5.3161735598e+01,6.3901347854e+01,8.9070287796e-01,2.0099596093e+02,-1.2766359117e+02,7.6834484659e+00,-1.1971813064e+02,9.5726589115e-01,2.3522166693e+00,1.5148704265e+00,2.8846813478e+00,1.5546929428e+00,4.3757123205e+00,6.2368118823e-01,1.0391444974e+00,3.8774297740e+00
5.8593750000e-03,1.7066666667e+02,5.1774203042e+01,4.7440771808e+01,5.7274837364e+01,5.9415047539e+01,8.3042293519e-01,2.0874810738e+02,-1.2927378961e+02,7.2436361994e+00,-1.2926015226e+02,9.3530975654e-01,2.1278502223e+00,1.1774726799e+00,2.8321419694e+00,1.4167331238e+00,4.1154772056e+00,5.6480342862e-01,9.8590342546e-01,3.9021698724e+00
7.8125000000e-03,1.2800000000e+02,5.5708230210e+01,4.7388789482e+01,6.3769971191e+01,5.6154957202e+01,8.1516231821e-01,2.2069384348e+02,-1.2860895066e+02,8.1782369959e+00,-1.3171631924e+02,9.1372864287e-01,2.4787695806e+00,1.2748094265e+00,3.3817962657e+00,1.5194092278e+00,5.2323173096e+00,6.7921405477e-01,1.1557258299e+00,4.0518168610e+00
1.1718750000e-02,8.5333333333e+01,5.7519638366e+01,4.2099297862e+01,7.6021780683e+01,5.8393300210e+01,7.4253979355e-01,2.5202113576e+02,-1.3002408914e+02,1.0370786127e+01,-1.2720068414e+02,8.6986047149e-01,2.2057474592e+00,1.0986488147e+00,3.3104603416e+00,1.2476055798e+00,5.0220784109e+00,5.7088199677e-01,1.2557059495e+00,3.4708397355e+00
1.5625000000e-02,6.4000000000e+01,5.3160335157e+01,4.0800971837e+01,7.8407781210e+01,5.6752169437e+01,6.7359698857e-01,2.4433190941e+02,-1.3220276475e+02,9.3418269907e+00,-1.3223419171e+02,8.4011322251e-01,2.6379799873e+00,1.4217426524e+00,4.0306302763e+00,1.4728355757e+00,5.8978484044e+00,6.9153887278e-01,1.4171428922e+00,4.3500251295e+00
2.3437500000e-02,4.2666666667e+01,5.3526011330e+01,3.9631077277e+01,9.2513383065e+01,5.5515373983e+01,5.2672472969e-01,2.4472877520e+02,-1.3409309138e+02,1.4828695660e+01,-1.2819306726e+02,7.4677283848e-01,2.3910983486e+00,1.2798565991e+00,4.4170162477e+00,1.3679125350e+00,5.7086443129e+00,6.6826763945e-01,1.8802928956e+00,3.6350180321e+00
3.1250000000e-02,3.2000000000e+01,5.6226852546e+01,3.6900808411e+01,1.0923477535e+02,5.5374504809e+01,4.6888670969e-01,2.4484321789e+02,-1.3551876227e+02,1.1787860307e+01,-1.3116906830e+02,6.5115695393e-01,3.2526259988e+00,1.6574619476e+00,5.9337108895e+00,1.5563651908e+00,7.1377846836e+00,8.3518633732e-01,2.1092569673e+00,5.1329641925e+00
4.6875000000e-02,2.1333333333e+01,6.7240460822e+01,3.1637647150e+01,1.0512648167e+02,5.8327222230e+01,2.4699526389e-01,2.4177992529e+02,-1.3856133764e+02,8.7472556149e+00,-1.2636959698e+02,4.4573046006e-01,4.0656329049e+00,1.7324323957e+00,6.4387704255e+00,1.7548958738e+00,8.2655879283e+00,9.7941623502e-01,1.9900071212e+00,6.5315535451e+00
6.2500000000e-02,1.6000000000e+01,6.8975508029e+01,3.1744364808e+01,1.2889377981e+02,5.9897901848e+01,2.0815230286e-02,2.2650220665e+02,-1.3668558155e+02,1.2838265591e+01,-1.3616612124e+02,2.5481400477e-01,6.1779942597e+00,2.5667909928e+00,1.1322667525e+01,2.5173822753e+00,1.1757449660e+01,1.4872435644e+00,3.5154255507e+00,7.8691968575e+00
9.3750000000e-02,1.0666666667e+01,4.1242878924e+01,2.8229573399e+01,1.5321293475e+02,5.7429532831e+01,0.0000000000e+00,2.0447526735e+02,-1.3493111906e+02,1.8394579599e+01,-1.2185553732e+02,8.5359546249e-02,5.7758846544e+00,4.0152974227e+00,1.4724714655e+01,2.7543008286e+00,1.1791546484e+01,1.6522768390e+00,5.0080100791e+00,7.8238130657e+00
1.2500000000e-01,8.0000000000e+00,4.1154003574e+01,2.3444482821e+01,1.5551735286e+02,5.4024177622e+01,0.0000000000e+00,2.0396201683e+02,-1.3542646155e+02,1.0455630803e+01,-1.1214940902e+02,0.0000000000e+00,9.0346660991e+00,6.3018584616e+00,2.3427266406e+01,4.3196334146e+00,1.9082151459e+01,2.6811999052e+00,6.0039023899e+00,1.6685215222e+01
1.8750000000e-01,5.3333333333e+00,2.7732078222e+01,3.0399714384e+01,1.9079198273e+02,5.6665962665e+01,0.0000000000e+00,2.0060698048e+02,-1.3316072972e+02,5.4153083214e-01,-8.1701954851e+01,0.0000000000e+00,9.6969453853e+00,1.0068919453e+01,3.2701304050e+01,4.9162122205e+00,2.4573022610e+01,3.5113738291e+00,1.5671365234e+00,3.6000000000e+02
2.5000000000e-01,4.0000000000e+00,4.1447542662e+01,6.5869668461e+01,2.2152885208e+02,6.0238133196e+01,0.0000000000e+00,2.4614698806e+02,-1.4007961966e+02,1.3481589795e+00,-1.6572703095e+02,0.0000000000e+00,2.2817477713e+01,1.5977348392e+01,6.4292557409e+01,8.3437084287e+00,4.5673752551e+01,5.3234088635e+00,4.0015197356e+00,3.6000000000e+02
3.7500000000e-01,2.6666666667e+00,2.4214693360e+01,1.6952132220e+01,2.5058694999e+02,4.9498566524e+01,0.0000000000e+00,1.5171275780e+02,-1.2996484645e+02,1.0101958322e+01,-1.1882962847e+02,0.0000000000e+00,2.2268619448e+01,2.7375251696e+01,1.1015695360e+02,1.2697160961e+01,7.7556221316e+01,1.4809269686e+01,3.2079816265e+01,3.6000000000e+02
5.0000000000e-01,2.0000000000e+00,3.1774873271e+01,1.7466799702e+01,2.3335821884e+02,4.1684474445e+01,0.0000000000e+00,1.2261437653e+02,-1.2752779445e+02,2.2631887058e+01,-1.2077735089e+02,0.0000000000e+00,1.1320774225e+02,3.6000000000e+02,4.2753958524e+02,6.6356505890e+01,6.3232915320e+01,1.4942691670e+01,4.2322240537e+01,6.9230328501e+01
7.5000000000e-01,1.3333333333e+00,7.9986506745e+01,-1.4261672608e+02,1.9045684514e+02,5.9005625149e+01,0.0000000000e+00,2.4317159411e+01,-1.1670695183e+02,2.7713923912e+01,-1.3672427061e+02,0.0000000000e+00,7.9383267970e+01,2.9750832711e+01,1.6885202180e+02,2.6313446952e+01,3.7409740250e+01,5.0282513485e+01,5.6969356722e+01,3.6000000000e+02
1.0000000000e+00,1.0000000000e+00,1.5362764242e+02,-2.0110441186e+01,1.9755648893e+03,1.0380387118e+02,0.0000000000e+00,1.5489629805e+01,-1.1910561777e+02,2.4536022333e+02,-1.0714168640e+02,0.0000000000e+00,3.6085726080e+02,3.6000000000e+02,3.9174246578e+03,8.2510822215e+01,6.9969305568e+01,3.6000000000e+02,5.7738276480e+02,3.6000000000e+02
1 frequency period app_res_0_2 phase_0_2 app_res_0_3 phase_0_3 coherence_0_2+3 app_res_1_2 phase_1_2 app_res_1_3 phase_1_3 coherence_1_2+3 dapp_res_0_2 dphase_0_2 dapp_res_0_3 dphase_0_3 dapp_res_1_2 dphase_1_2 dapp_res_1_3 dphase_1_3
2 1.4648437500e-03 6.8266666667e+02 4.3916578744e+01 5.0669393911e+01 3.9866612485e+01 5.4334231062e+01 9.3703783930e-01 1.5456339509e+02 -1.2900295429e+02 6.7884721742e+00 -1.3703647180e+02 9.6777102021e-01 2.4854563945e+00 1.6215422252e+00 2.3021754416e+00 1.6545583241e+00 4.4928675803e+00 8.3276966682e-01 1.0164047781e+00 4.2933252333e+00
3 1.9531250000e-03 5.1200000000e+02 4.4602963314e+01 4.5868238738e+01 4.6150130862e+01 5.4009382035e+01 9.4713584089e-01 1.7149384900e+02 -1.2903509690e+02 7.3508615241e+00 -1.3422485420e+02 9.7812451678e-01 2.2780369087e+00 1.4633118644e+00 2.5641349832e+00 1.5919024849e+00 3.9269908759e+00 6.5601454740e-01 9.5544958395e-01 3.7262188383e+00
4 2.9296875000e-03 3.4133333333e+02 4.1754396591e+01 5.0058719414e+01 5.3726794317e+01 5.5681889067e+01 8.9731712202e-01 1.7520883461e+02 -1.2568862112e+02 5.7317388697e+00 -1.2756902877e+02 9.5727358041e-01 1.9933856295e+00 1.3678012605e+00 2.6967321541e+00 1.4380868724e+00 3.8692138267e+00 6.3265681711e-01 8.9178474545e-01 4.4617507114e+00
5 3.9062500000e-03 2.5600000000e+02 4.4488224389e+01 4.7185418176e+01 5.3161735598e+01 6.3901347854e+01 8.9070287796e-01 2.0099596093e+02 -1.2766359117e+02 7.6834484659e+00 -1.1971813064e+02 9.5726589115e-01 2.3522166693e+00 1.5148704265e+00 2.8846813478e+00 1.5546929428e+00 4.3757123205e+00 6.2368118823e-01 1.0391444974e+00 3.8774297740e+00
6 5.8593750000e-03 1.7066666667e+02 5.1774203042e+01 4.7440771808e+01 5.7274837364e+01 5.9415047539e+01 8.3042293519e-01 2.0874810738e+02 -1.2927378961e+02 7.2436361994e+00 -1.2926015226e+02 9.3530975654e-01 2.1278502223e+00 1.1774726799e+00 2.8321419694e+00 1.4167331238e+00 4.1154772056e+00 5.6480342862e-01 9.8590342546e-01 3.9021698724e+00
7 7.8125000000e-03 1.2800000000e+02 5.5708230210e+01 4.7388789482e+01 6.3769971191e+01 5.6154957202e+01 8.1516231821e-01 2.2069384348e+02 -1.2860895066e+02 8.1782369959e+00 -1.3171631924e+02 9.1372864287e-01 2.4787695806e+00 1.2748094265e+00 3.3817962657e+00 1.5194092278e+00 5.2323173096e+00 6.7921405477e-01 1.1557258299e+00 4.0518168610e+00
8 1.1718750000e-02 8.5333333333e+01 5.7519638366e+01 4.2099297862e+01 7.6021780683e+01 5.8393300210e+01 7.4253979355e-01 2.5202113576e+02 -1.3002408914e+02 1.0370786127e+01 -1.2720068414e+02 8.6986047149e-01 2.2057474592e+00 1.0986488147e+00 3.3104603416e+00 1.2476055798e+00 5.0220784109e+00 5.7088199677e-01 1.2557059495e+00 3.4708397355e+00
9 1.5625000000e-02 6.4000000000e+01 5.3160335157e+01 4.0800971837e+01 7.8407781210e+01 5.6752169437e+01 6.7359698857e-01 2.4433190941e+02 -1.3220276475e+02 9.3418269907e+00 -1.3223419171e+02 8.4011322251e-01 2.6379799873e+00 1.4217426524e+00 4.0306302763e+00 1.4728355757e+00 5.8978484044e+00 6.9153887278e-01 1.4171428922e+00 4.3500251295e+00
10 2.3437500000e-02 4.2666666667e+01 5.3526011330e+01 3.9631077277e+01 9.2513383065e+01 5.5515373983e+01 5.2672472969e-01 2.4472877520e+02 -1.3409309138e+02 1.4828695660e+01 -1.2819306726e+02 7.4677283848e-01 2.3910983486e+00 1.2798565991e+00 4.4170162477e+00 1.3679125350e+00 5.7086443129e+00 6.6826763945e-01 1.8802928956e+00 3.6350180321e+00
11 3.1250000000e-02 3.2000000000e+01 5.6226852546e+01 3.6900808411e+01 1.0923477535e+02 5.5374504809e+01 4.6888670969e-01 2.4484321789e+02 -1.3551876227e+02 1.1787860307e+01 -1.3116906830e+02 6.5115695393e-01 3.2526259988e+00 1.6574619476e+00 5.9337108895e+00 1.5563651908e+00 7.1377846836e+00 8.3518633732e-01 2.1092569673e+00 5.1329641925e+00
12 4.6875000000e-02 2.1333333333e+01 6.7240460822e+01 3.1637647150e+01 1.0512648167e+02 5.8327222230e+01 2.4699526389e-01 2.4177992529e+02 -1.3856133764e+02 8.7472556149e+00 -1.2636959698e+02 4.4573046006e-01 4.0656329049e+00 1.7324323957e+00 6.4387704255e+00 1.7548958738e+00 8.2655879283e+00 9.7941623502e-01 1.9900071212e+00 6.5315535451e+00
13 6.2500000000e-02 1.6000000000e+01 6.8975508029e+01 3.1744364808e+01 1.2889377981e+02 5.9897901848e+01 2.0815230286e-02 2.2650220665e+02 -1.3668558155e+02 1.2838265591e+01 -1.3616612124e+02 2.5481400477e-01 6.1779942597e+00 2.5667909928e+00 1.1322667525e+01 2.5173822753e+00 1.1757449660e+01 1.4872435644e+00 3.5154255507e+00 7.8691968575e+00
14 9.3750000000e-02 1.0666666667e+01 4.1242878924e+01 2.8229573399e+01 1.5321293475e+02 5.7429532831e+01 0.0000000000e+00 2.0447526735e+02 -1.3493111906e+02 1.8394579599e+01 -1.2185553732e+02 8.5359546249e-02 5.7758846544e+00 4.0152974227e+00 1.4724714655e+01 2.7543008286e+00 1.1791546484e+01 1.6522768390e+00 5.0080100791e+00 7.8238130657e+00
15 1.2500000000e-01 8.0000000000e+00 4.1154003574e+01 2.3444482821e+01 1.5551735286e+02 5.4024177622e+01 0.0000000000e+00 2.0396201683e+02 -1.3542646155e+02 1.0455630803e+01 -1.1214940902e+02 0.0000000000e+00 9.0346660991e+00 6.3018584616e+00 2.3427266406e+01 4.3196334146e+00 1.9082151459e+01 2.6811999052e+00 6.0039023899e+00 1.6685215222e+01
16 1.8750000000e-01 5.3333333333e+00 2.7732078222e+01 3.0399714384e+01 1.9079198273e+02 5.6665962665e+01 0.0000000000e+00 2.0060698048e+02 -1.3316072972e+02 5.4153083214e-01 -8.1701954851e+01 0.0000000000e+00 9.6969453853e+00 1.0068919453e+01 3.2701304050e+01 4.9162122205e+00 2.4573022610e+01 3.5113738291e+00 1.5671365234e+00 3.6000000000e+02
17 2.5000000000e-01 4.0000000000e+00 4.1447542662e+01 6.5869668461e+01 2.2152885208e+02 6.0238133196e+01 0.0000000000e+00 2.4614698806e+02 -1.4007961966e+02 1.3481589795e+00 -1.6572703095e+02 0.0000000000e+00 2.2817477713e+01 1.5977348392e+01 6.4292557409e+01 8.3437084287e+00 4.5673752551e+01 5.3234088635e+00 4.0015197356e+00 3.6000000000e+02
18 3.7500000000e-01 2.6666666667e+00 2.4214693360e+01 1.6952132220e+01 2.5058694999e+02 4.9498566524e+01 0.0000000000e+00 1.5171275780e+02 -1.2996484645e+02 1.0101958322e+01 -1.1882962847e+02 0.0000000000e+00 2.2268619448e+01 2.7375251696e+01 1.1015695360e+02 1.2697160961e+01 7.7556221316e+01 1.4809269686e+01 3.2079816265e+01 3.6000000000e+02
19 5.0000000000e-01 2.0000000000e+00 3.1774873271e+01 1.7466799702e+01 2.3335821884e+02 4.1684474445e+01 0.0000000000e+00 1.2261437653e+02 -1.2752779445e+02 2.2631887058e+01 -1.2077735089e+02 0.0000000000e+00 1.1320774225e+02 3.6000000000e+02 4.2753958524e+02 6.6356505890e+01 6.3232915320e+01 1.4942691670e+01 4.2322240537e+01 6.9230328501e+01
20 7.5000000000e-01 1.3333333333e+00 7.9986506745e+01 -1.4261672608e+02 1.9045684514e+02 5.9005625149e+01 0.0000000000e+00 2.4317159411e+01 -1.1670695183e+02 2.7713923912e+01 -1.3672427061e+02 0.0000000000e+00 7.9383267970e+01 2.9750832711e+01 1.6885202180e+02 2.6313446952e+01 3.7409740250e+01 5.0282513485e+01 5.6969356722e+01 3.6000000000e+02
21 1.0000000000e+00 1.0000000000e+00 1.5362764242e+02 -2.0110441186e+01 1.9755648893e+03 1.0380387118e+02 0.0000000000e+00 1.5489629805e+01 -1.1910561777e+02 2.4536022333e+02 -1.0714168640e+02 0.0000000000e+00 3.6085726080e+02 3.6000000000e+02 3.9174246578e+03 8.2510822215e+01 6.9969305568e+01 3.6000000000e+02 5.7738276480e+02 3.6000000000e+02

View File

@@ -0,0 +1,48 @@
NUM_OUT
2
SAMPLING_FREQ
32
NUM_SECTION
1
SEGMENT
10
65536 2 3 4
32768 2 3 4
16384 2 3 4
8192 2 3 4
4096 2 3 4
2048 2 3 4
1024 2 3 4
512 2 3 4
256 2 3 4
128 2 3 4
ROTATION
0.0
AZIMUTH
0.0 90.0
0.0 90.0
0.0 90.0
OUTPUT_RHOA_PHS
PREWHITENING
0
10
5
PROCEDURE
0
ERROR_ESTIMATION
1
DATA_FILES
2764800
../ex.txt
0
../ey.txt
0
../hx.txt
0
../hy.txt
0
../hrx.txt
0
../hry.txt
0
END

View File

@@ -0,0 +1,21 @@
frequency,period,resp_real_0_2,resp_imag_0_2,resp_real_0_3,resp_imag_0_3,coherence_0_2+3,resp_real_1_2,resp_imag_1_2,resp_real_1_3,resp_imag_1_3,coherence_1_2+3,dresp_0_2,dresp_0_3,dresp_1_2,dresp_1_3
1.4648437500e-03,6.8266666667e+02,3.5945384161e-01,4.3868846033e-01,3.1506164709e-01,4.3900791473e-01,9.3703783930e-01,-6.6962773524e-01,-8.2683421105e-01,-1.6317430404e-01,-1.5196842331e-01,9.6777102021e-01,1.6048799672e-02,1.5602148500e-02,1.5463968345e-02,1.6692882431e-02
1.9531250000e-03,5.1200000000e+02,4.5955235266e-01,4.7369552329e-01,3.9450932921e-01,5.4318252997e-01,9.4713584089e-01,-8.1503153615e-01,-1.0052204804e+00,-1.8687380382e-01,-1.9199983989e-01,9.7812451678e-01,1.6853842289e-02,1.8649811281e-02,1.4816841815e-02,1.7412401829e-02
2.9296875000e-03,3.4133333333e+02,5.0209196256e-01,5.9961681927e-01,5.0015692469e-01,7.3270501521e-01,8.9731712202e-01,-9.3459860610e-01,-1.3011768169e+00,-1.7667171011e-01,-2.2966960061e-01,9.5727358041e-01,1.8668347339e-02,2.2264246654e-02,1.7689289359e-02,2.2541483611e-02
3.9062500000e-03,2.5600000000e+02,6.3351781168e-01,6.8378784347e-01,4.4826658939e-01,9.1508044085e-01,8.9070287796e-01,-1.2106456513e+00,-1.5684512963e+00,-1.9203986422e-01,-3.3643430770e-01,9.5726589115e-01,2.4642786300e-02,2.7646063085e-02,2.1567018977e-02,2.6195872905e-02
5.8593750000e-03,1.7066666667e+02,8.3299066116e-01,9.0716531745e-01,6.5910222764e-01,1.1151493193e+00,8.3042293519e-01,-1.5654673858e+00,-1.9144135061e+00,-2.9153092108e-01,-3.5668701453e-01,9.3530975654e-01,2.5308417907e-02,3.2026814245e-02,2.4377523326e-02,3.1349939981e-02
7.8125000000e-03,1.2800000000e+02,9.9871410827e-01,1.0856670173e+00,8.7902926960e-01,1.3108478336e+00,8.1516231821e-01,-1.8321493941e+00,-2.2943587031e+00,-3.7611505425e-01,-4.2190028279e-01,9.1372864287e-01,3.2819087269e-02,4.1849411148e-02,3.4805588888e-02,3.9936959277e-02
1.1718750000e-02,8.5333333333e+01,1.3621605359e+00,1.2307761718e+00,1.1061061528e+00,1.7974788985e+00,7.4253979355e-01,-2.4713208784e+00,-2.9426920566e+00,-4.7130909956e-01,-6.2091141260e-01,8.6986047149e-01,3.5200056890e-02,4.5953121953e-02,3.8287821641e-02,4.7193019380e-02
1.5625000000e-02,6.4000000000e+01,1.5426789538e+00,1.3316504157e+00,1.3569454780e+00,2.0698567285e+00,6.7359698857e-01,-2.9349241417e+00,-3.2364565044e+00,-5.7422915306e-01,-6.3252755941e-01,8.4011322251e-01,5.0564144158e-02,6.3614834278e-02,5.2731306343e-02,6.4798171717e-02
2.3437500000e-02,4.2666666667e+01,1.9288933315e+00,1.5974823844e+00,1.8642379645e+00,2.7140429049e+00,5.2672472969e-01,-3.7263525497e+00,-3.8462254250e+00,-8.1508089006e-01,-1.0360409815e+00,7.4677283848e-01,5.5940410337e-02,7.8602681934e-02,6.2459875621e-02,8.3576595896e-02
3.1250000000e-02,3.2000000000e+01,2.3702604133e+00,1.7796941545e+00,2.3474660392e+00,3.3996083368e+00,4.6888670969e-01,-4.4130191821e+00,-4.3338221575e+00,-8.9338828261e-01,-1.0216215294e+00,6.5115695393e-01,8.5731862694e-02,1.1220854724e-01,9.0156993571e-02,1.2142050069e-01
4.6875000000e-02,2.1333333333e+01,3.3798364092e+00,2.0823517600e+00,2.6063139374e+00,4.2244700024e+00,2.4699526389e-01,-5.6432955740e+00,-4.9820061275e+00,-8.4906348936e-01,-1.1529220380e+00,4.4573046006e-01,1.2001581231e-01,1.5201012724e-01,1.2867354840e-01,1.6287122712e-01
6.2500000000e-02,1.6000000000e+01,3.9481872939e+00,2.4426754495e+00,3.1830881100e+00,5.4906517168e+00,2.0815230286e-02,-6.1214458031e+00,-5.7714678253e+00,-1.4448565495e+00,-1.3872085454e+00,2.5481400477e-01,2.0791942319e-01,2.7875828914e-01,2.1835941617e-01,2.7423301734e-01
9.3750000000e-02,1.0666666667e+01,3.8739171543e+00,2.0797512777e+00,4.5621773383e+00,7.1417855680e+00,0.0000000000e+00,-6.9143808667e+00,-6.9310258117e+00,-1.5497725809e+00,-2.4941259259e+00,8.5359546249e-02,3.0788226281e-01,4.0723004891e-01,2.8228709193e-01,3.9972462673e-01
1.2500000000e-01,8.0000000000e+00,4.6529305755e+00,2.0177931741e+00,5.7915627945e+00,7.9784801771e+00,0.0000000000e+00,-8.0428179884e+00,-7.9239724461e+00,-9.6379153156e-01,-2.3676729367e+00,0.0000000000e+00,5.5669340220e-01,7.4257821051e-01,5.2815658970e-01,7.3395344993e-01
1.8750000000e-01,5.3333333333e+00,4.3978873728e+00,2.5801957269e+00,7.3493444861e+00,1.1173836380e+01,0.0000000000e+00,-9.3809063444e+00,-1.0003381446e+01,1.0283266572e-01,-7.0506070518e-01,0.0000000000e+00,8.9145491519e-01,1.1461478750e+00,8.3992634269e-01,1.0309815199e+00
2.5000000000e-01,4.0000000000e+00,2.9425901845e+00,6.5689109701e+00,8.2603547580e+00,1.4445677706e+01,0.0000000000e+00,-1.3452776410e+01,-1.1256400043e+01,-1.2580808829e+00,-3.2004877214e-01,0.0000000000e+00,1.9812681234e+00,2.4147410420e+00,1.6274004904e+00,1.9265461623e+00
3.7500000000e-01,2.6666666667e+00,6.4453603275e+00,1.9646578068e+00,1.4077871566e+01,1.6482234782e+01,0.0000000000e+00,-1.0833316527e+01,-1.2926742587e+01,-2.0986340598e+00,-3.8127295913e+00,0.0000000000e+00,3.0983069919e+00,4.7643464239e+00,4.3109822052e+00,6.9103449406e+00
5.0000000000e-01,2.0000000000e+00,8.5017961095e+00,2.6751908510e+00,1.8038340161e+01,1.6062808950e+01,0.0000000000e+00,-1.0665034205e+01,-1.3884991420e+01,-3.8490059806e+00,-6.4625746113e+00,0.0000000000e+00,1.5877211289e+01,2.2126095860e+01,4.5145297237e+00,7.0331240290e+00
7.5000000000e-01,1.3333333333e+00,-1.3761574635e+01,-1.0515154011e+01,1.3762023456e+01,2.2908947590e+01,0.0000000000e+00,-4.2917220900e+00,-8.5305609015e+00,-7.4222183768e+00,-6.9884110525e+00,0.0000000000e+00,8.5942156423e+00,1.1846596878e+01,7.3453739429e+00,1.0477989132e+01
1.0000000000e+00,1.0000000000e+00,2.6025548855e+01,-9.5293766268e+00,-2.3713704362e+01,9.6516758504e+01,0.0000000000e+00,-4.2807304557e+00,-7.6891804367e+00,-1.0323328544e+01,-3.3469837233e+01,0.0000000000e+00,3.2550358169e+01,9.8539421788e+01,1.9876597846e+01,4.1211340682e+01
1 frequency period resp_real_0_2 resp_imag_0_2 resp_real_0_3 resp_imag_0_3 coherence_0_2+3 resp_real_1_2 resp_imag_1_2 resp_real_1_3 resp_imag_1_3 coherence_1_2+3 dresp_0_2 dresp_0_3 dresp_1_2 dresp_1_3
2 1.4648437500e-03 6.8266666667e+02 3.5945384161e-01 4.3868846033e-01 3.1506164709e-01 4.3900791473e-01 9.3703783930e-01 -6.6962773524e-01 -8.2683421105e-01 -1.6317430404e-01 -1.5196842331e-01 9.6777102021e-01 1.6048799672e-02 1.5602148500e-02 1.5463968345e-02 1.6692882431e-02
3 1.9531250000e-03 5.1200000000e+02 4.5955235266e-01 4.7369552329e-01 3.9450932921e-01 5.4318252997e-01 9.4713584089e-01 -8.1503153615e-01 -1.0052204804e+00 -1.8687380382e-01 -1.9199983989e-01 9.7812451678e-01 1.6853842289e-02 1.8649811281e-02 1.4816841815e-02 1.7412401829e-02
4 2.9296875000e-03 3.4133333333e+02 5.0209196256e-01 5.9961681927e-01 5.0015692469e-01 7.3270501521e-01 8.9731712202e-01 -9.3459860610e-01 -1.3011768169e+00 -1.7667171011e-01 -2.2966960061e-01 9.5727358041e-01 1.8668347339e-02 2.2264246654e-02 1.7689289359e-02 2.2541483611e-02
5 3.9062500000e-03 2.5600000000e+02 6.3351781168e-01 6.8378784347e-01 4.4826658939e-01 9.1508044085e-01 8.9070287796e-01 -1.2106456513e+00 -1.5684512963e+00 -1.9203986422e-01 -3.3643430770e-01 9.5726589115e-01 2.4642786300e-02 2.7646063085e-02 2.1567018977e-02 2.6195872905e-02
6 5.8593750000e-03 1.7066666667e+02 8.3299066116e-01 9.0716531745e-01 6.5910222764e-01 1.1151493193e+00 8.3042293519e-01 -1.5654673858e+00 -1.9144135061e+00 -2.9153092108e-01 -3.5668701453e-01 9.3530975654e-01 2.5308417907e-02 3.2026814245e-02 2.4377523326e-02 3.1349939981e-02
7 7.8125000000e-03 1.2800000000e+02 9.9871410827e-01 1.0856670173e+00 8.7902926960e-01 1.3108478336e+00 8.1516231821e-01 -1.8321493941e+00 -2.2943587031e+00 -3.7611505425e-01 -4.2190028279e-01 9.1372864287e-01 3.2819087269e-02 4.1849411148e-02 3.4805588888e-02 3.9936959277e-02
8 1.1718750000e-02 8.5333333333e+01 1.3621605359e+00 1.2307761718e+00 1.1061061528e+00 1.7974788985e+00 7.4253979355e-01 -2.4713208784e+00 -2.9426920566e+00 -4.7130909956e-01 -6.2091141260e-01 8.6986047149e-01 3.5200056890e-02 4.5953121953e-02 3.8287821641e-02 4.7193019380e-02
9 1.5625000000e-02 6.4000000000e+01 1.5426789538e+00 1.3316504157e+00 1.3569454780e+00 2.0698567285e+00 6.7359698857e-01 -2.9349241417e+00 -3.2364565044e+00 -5.7422915306e-01 -6.3252755941e-01 8.4011322251e-01 5.0564144158e-02 6.3614834278e-02 5.2731306343e-02 6.4798171717e-02
10 2.3437500000e-02 4.2666666667e+01 1.9288933315e+00 1.5974823844e+00 1.8642379645e+00 2.7140429049e+00 5.2672472969e-01 -3.7263525497e+00 -3.8462254250e+00 -8.1508089006e-01 -1.0360409815e+00 7.4677283848e-01 5.5940410337e-02 7.8602681934e-02 6.2459875621e-02 8.3576595896e-02
11 3.1250000000e-02 3.2000000000e+01 2.3702604133e+00 1.7796941545e+00 2.3474660392e+00 3.3996083368e+00 4.6888670969e-01 -4.4130191821e+00 -4.3338221575e+00 -8.9338828261e-01 -1.0216215294e+00 6.5115695393e-01 8.5731862694e-02 1.1220854724e-01 9.0156993571e-02 1.2142050069e-01
12 4.6875000000e-02 2.1333333333e+01 3.3798364092e+00 2.0823517600e+00 2.6063139374e+00 4.2244700024e+00 2.4699526389e-01 -5.6432955740e+00 -4.9820061275e+00 -8.4906348936e-01 -1.1529220380e+00 4.4573046006e-01 1.2001581231e-01 1.5201012724e-01 1.2867354840e-01 1.6287122712e-01
13 6.2500000000e-02 1.6000000000e+01 3.9481872939e+00 2.4426754495e+00 3.1830881100e+00 5.4906517168e+00 2.0815230286e-02 -6.1214458031e+00 -5.7714678253e+00 -1.4448565495e+00 -1.3872085454e+00 2.5481400477e-01 2.0791942319e-01 2.7875828914e-01 2.1835941617e-01 2.7423301734e-01
14 9.3750000000e-02 1.0666666667e+01 3.8739171543e+00 2.0797512777e+00 4.5621773383e+00 7.1417855680e+00 0.0000000000e+00 -6.9143808667e+00 -6.9310258117e+00 -1.5497725809e+00 -2.4941259259e+00 8.5359546249e-02 3.0788226281e-01 4.0723004891e-01 2.8228709193e-01 3.9972462673e-01
15 1.2500000000e-01 8.0000000000e+00 4.6529305755e+00 2.0177931741e+00 5.7915627945e+00 7.9784801771e+00 0.0000000000e+00 -8.0428179884e+00 -7.9239724461e+00 -9.6379153156e-01 -2.3676729367e+00 0.0000000000e+00 5.5669340220e-01 7.4257821051e-01 5.2815658970e-01 7.3395344993e-01
16 1.8750000000e-01 5.3333333333e+00 4.3978873728e+00 2.5801957269e+00 7.3493444861e+00 1.1173836380e+01 0.0000000000e+00 -9.3809063444e+00 -1.0003381446e+01 1.0283266572e-01 -7.0506070518e-01 0.0000000000e+00 8.9145491519e-01 1.1461478750e+00 8.3992634269e-01 1.0309815199e+00
17 2.5000000000e-01 4.0000000000e+00 2.9425901845e+00 6.5689109701e+00 8.2603547580e+00 1.4445677706e+01 0.0000000000e+00 -1.3452776410e+01 -1.1256400043e+01 -1.2580808829e+00 -3.2004877214e-01 0.0000000000e+00 1.9812681234e+00 2.4147410420e+00 1.6274004904e+00 1.9265461623e+00
18 3.7500000000e-01 2.6666666667e+00 6.4453603275e+00 1.9646578068e+00 1.4077871566e+01 1.6482234782e+01 0.0000000000e+00 -1.0833316527e+01 -1.2926742587e+01 -2.0986340598e+00 -3.8127295913e+00 0.0000000000e+00 3.0983069919e+00 4.7643464239e+00 4.3109822052e+00 6.9103449406e+00
19 5.0000000000e-01 2.0000000000e+00 8.5017961095e+00 2.6751908510e+00 1.8038340161e+01 1.6062808950e+01 0.0000000000e+00 -1.0665034205e+01 -1.3884991420e+01 -3.8490059806e+00 -6.4625746113e+00 0.0000000000e+00 1.5877211289e+01 2.2126095860e+01 4.5145297237e+00 7.0331240290e+00
20 7.5000000000e-01 1.3333333333e+00 -1.3761574635e+01 -1.0515154011e+01 1.3762023456e+01 2.2908947590e+01 0.0000000000e+00 -4.2917220900e+00 -8.5305609015e+00 -7.4222183768e+00 -6.9884110525e+00 0.0000000000e+00 8.5942156423e+00 1.1846596878e+01 7.3453739429e+00 1.0477989132e+01
21 1.0000000000e+00 1.0000000000e+00 2.6025548855e+01 -9.5293766268e+00 -2.3713704362e+01 9.6516758504e+01 0.0000000000e+00 -4.2807304557e+00 -7.6891804367e+00 -1.0323328544e+01 -3.3469837233e+01 0.0000000000e+00 3.2550358169e+01 9.8539421788e+01 1.9876597846e+01 4.1211340682e+01

520
Samples/RRMS/TRACMT.cvg Normal file
View File

@@ -0,0 +1,520 @@
================================================================================
Now Frequency(Hz): 0.00146484, Period(s): 682.667
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.13035, Parameter c: 6.44795
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.00146484(Hz)
Response functions:
( 3.7058e-01, 4.1305e-01), ( 3.1084e-01, 3.6824e-01)
( -6.6764e-01, -8.5137e-01), ( -1.4337e-01, -1.1723e-01)
( 1.0083e+00, 1.1389e-02), ( -1.3077e-02, -7.4257e-03)
( -1.0731e-02, -9.1421e-03), ( 8.8798e-01, -4.7033e-02)
Scale: 0.00822998
Covariance matrix without scale:
7.0868e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 6.5392e+00 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.1930e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 1.8088e-01
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.00195312, Period(s): 512
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.13035, Parameter c: 6.44795
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.00195312(Hz)
Response functions:
( 4.4820e-01, 4.7670e-01), ( 3.6621e-01, 4.4235e-01)
( -8.0252e-01, -1.0317e+00), ( -1.6708e-01, -1.5485e-01)
( 1.0140e+00, 1.5732e-02), ( -1.0886e-02, -9.5520e-03)
( -1.1840e-02, -7.4501e-03), ( 8.7759e-01, -5.4934e-02)
Scale: 0.0075017
Covariance matrix without scale:
8.2958e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 5.8926e+00 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.4899e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 1.3730e-01
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.00292969, Period(s): 341.333
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.0742, Parameter c: 6.22496
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.00292969(Hz)
Response functions:
( 4.9932e-01, 6.0005e-01), ( 4.4578e-01, 5.8760e-01)
( -9.1835e-01, -1.3259e+00), ( -1.6362e-01, -1.6386e-01)
( 1.0029e+00, 1.7745e-02), ( -2.2270e-02, -1.7374e-02)
( -1.6547e-02, -1.5790e-02), ( 8.5921e-01, -4.4379e-02)
Scale: 0.0106855
Covariance matrix without scale:
6.3646e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 7.0234e+00 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.5520e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 1.4414e-01
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.00390625, Period(s): 256
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.0742, Parameter c: 6.22496
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.00390625(Hz)
Response functions:
( 6.2870e-01, 7.0256e-01), ( 4.4481e-01, 7.1476e-01)
( -1.1810e+00, -1.5725e+00), ( -1.6914e-01, -2.1374e-01)
( 1.0088e+00, 2.5192e-02), ( -1.5339e-02, -1.6230e-02)
( -1.7235e-02, -1.7612e-02), ( 8.4992e-01, -4.3911e-02)
Scale: 0.0105011
Covariance matrix without scale:
7.1573e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 7.0459e+00 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.7118e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 1.1584e-01
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.00585938, Period(s): 170.667
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.04576, Parameter c: 6.11911
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.00585938(Hz)
Response functions:
( 8.2966e-01, 9.2566e-01), ( 5.7677e-01, 8.9138e-01)
( -1.5316e+00, -1.9854e+00), ( -2.5108e-01, -2.2433e-01)
( 1.0146e+00, 2.6705e-02), ( -1.4792e-02, -1.3108e-02)
( -2.1491e-02, -2.8939e-02), ( 8.2930e-01, -3.5456e-02)
Scale: 0.0154722
Covariance matrix without scale:
6.7019e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 6.5431e+00 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.6974e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 1.3434e-01
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.0078125, Period(s): 128
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.04576, Parameter c: 6.11911
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.0078125(Hz)
Response functions:
( 9.7762e-01, 1.0646e+00), ( 6.9014e-01, 1.0247e+00)
( -1.7969e+00, -2.3468e+00), ( -2.9436e-01, -2.3041e-01)
( 1.0194e+00, 3.1520e-02), ( -2.5522e-02, -1.2464e-02)
( -2.9621e-02, -3.5519e-02), ( 8.1093e-01, -2.6489e-02)
Scale: 0.0149237
Covariance matrix without scale:
6.9002e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 6.3757e+00 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.6616e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 1.3680e-01
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.0117188, Period(s): 85.3333
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.03151, Parameter c: 6.06788
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.0117188(Hz)
Response functions:
( 1.3680e+00, 1.2284e+00), ( 8.8052e-01, 1.3322e+00)
( -2.3571e+00, -2.9889e+00), ( -3.3867e-01, -3.1967e-01)
( 1.0184e+00, 3.6961e-02), ( -3.6054e-02, -1.9506e-02)
( -4.0394e-02, -3.5835e-02), ( 7.9770e-01, -1.9685e-02)
Scale: 0.0213775
Covariance matrix without scale:
6.7231e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 7.6178e+00 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.5493e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 1.2603e-01
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.015625, Period(s): 64
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.03151, Parameter c: 6.06788
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.015625(Hz)
Response functions:
( 1.5420e+00, 1.3539e+00), ( 1.0247e+00, 1.5430e+00)
( -2.7998e+00, -3.3080e+00), ( -4.2295e-01, -2.5968e-01)
( 9.9824e-01, 3.7950e-02), ( -4.1825e-02, -1.4152e-02)
( -3.4571e-02, -3.3532e-02), ( 7.7444e-01, -5.8188e-03)
Scale: 0.0211478
Covariance matrix without scale:
6.9401e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 7.9500e+00 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.5330e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 1.1823e-01
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.0234375, Period(s): 42.6667
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.02439, Parameter c: 6.04266
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.0234375(Hz)
Response functions:
( 1.7683e+00, 1.3758e+00), ( 1.1824e+00, 1.7909e+00)
( -3.4362e+00, -3.7891e+00), ( -4.0657e-01, -4.5945e-01)
( 9.6281e-01, 3.2739e-02), ( -3.7156e-02, -1.9639e-02)
( -5.3358e-02, -3.8313e-02), ( 7.0137e-01, 8.0755e-03)
Scale: 0.030262
Covariance matrix without scale:
6.7592e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 8.6270e+00 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.3999e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 1.2251e-01
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.03125, Period(s): 32
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.02439, Parameter c: 6.04266
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.03125(Hz)
Response functions:
( 2.1049e+00, 1.4229e+00), ( 1.2594e+00, 2.0384e+00)
( -3.8258e+00, -4.0601e+00), ( -4.0857e-01, -3.9035e-01)
( 8.9655e-01, 4.5184e-02), ( -4.5584e-02, -2.1391e-02)
( -4.7594e-02, -3.7817e-02), ( 6.3689e-01, 2.2577e-02)
Scale: 0.0300554
Covariance matrix without scale:
7.1503e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 8.5113e+00 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.3940e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 1.1787e-01
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.046875, Period(s): 21.3333
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.02083, Parameter c: 6.03006
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.046875(Hz)
Response functions:
( 2.1337e+00, 1.1790e+00), ( 1.2440e+00, 2.2960e+00)
( -3.9003e+00, -3.6418e+00), ( -4.6242e-01, -4.4726e-01)
( 7.2944e-01, 1.7028e-02), ( -1.2928e-02, -1.5650e-02)
( -7.8386e-02, -8.8658e-03), ( 5.3995e-01, 2.4729e-02)
Scale: 0.0417988
Covariance matrix without scale:
7.3536e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 9.1494e+00 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.3253e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 1.1214e-01
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.0625, Period(s): 16
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.02083, Parameter c: 6.03006
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.0625(Hz)
Response functions:
( 1.8966e+00, 8.7189e-01), ( 1.2398e+00, 2.1257e+00)
( -3.3450e+00, -3.1552e+00), ( -3.5709e-01, -1.9636e-01)
( 5.6775e-01, -6.0974e-03), ( -3.7855e-02, -2.0796e-02)
( -7.1993e-02, -2.5304e-03), ( 4.2134e-01, 1.4262e-02)
Scale: 0.0404616
Covariance matrix without scale:
7.8033e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 9.7290e+00 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.2780e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 1.0307e-01
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.09375, Period(s): 10.6667
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.01906, Parameter c: 6.02377
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.09375(Hz)
Response functions:
( 1.1128e+00, 4.3977e-01), ( 1.0145e+00, 1.8175e+00)
( -2.4990e+00, -2.3000e+00), ( -2.4585e-01, -3.0278e-01)
( 3.6971e-01, -1.5093e-02), ( -3.0602e-02, -1.4935e-02)
( -5.0005e-02, 9.7930e-03), ( 2.6507e-01, 1.2915e-02)
Scale: 0.054374
Covariance matrix without scale:
8.0507e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 1.0058e+01 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.2053e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 1.0245e-01
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.125, Period(s): 8
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.01906, Parameter c: 6.02377
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.125(Hz)
Response functions:
( 9.4278e-01, 2.7535e-01), ( 8.8142e-01, 1.4381e+00)
( -1.9821e+00, -1.6299e+00), ( -4.2897e-02, -2.6497e-01)
( 2.3808e-01, -8.4785e-03), ( -1.3353e-02, 1.0955e-02)
( -1.6764e-02, 7.4497e-03), ( 1.7746e-01, -1.8394e-03)
Scale: 0.0525039
Covariance matrix without scale:
8.4938e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 1.0004e+01 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.1078e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 1.0623e-01
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.1875, Period(s): 5.33333
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.01817, Parameter c: 6.02062
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.1875(Hz)
Response functions:
( 4.3333e-01, 6.8758e-02), ( 5.4982e-01, 9.6089e-01)
( -1.1808e+00, -1.0910e+00), ( -3.1559e-02, -2.2284e-01)
( 1.2338e-01, -8.7698e-03), ( 1.4252e-03, 1.2247e-02)
( -1.1720e-02, -1.0667e-03), ( 9.3049e-02, 5.2977e-04)
Scale: 0.0670486
Covariance matrix without scale:
9.0341e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 1.0842e+01 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.0415e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 9.8028e-02
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.25, Period(s): 4
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.01817, Parameter c: 6.02062
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.25(Hz)
Response functions:
( 2.9440e-01, 5.2417e-02), ( 3.5283e-01, 8.1291e-01)
( -8.9501e-01, -8.5269e-01), ( -4.3739e-02, -1.2720e-01)
( 8.3164e-02, 2.4325e-03), ( -4.4410e-05, 3.7468e-03)
( -2.1733e-02, -6.1390e-03), ( 5.5416e-02, 3.8864e-03)
Scale: 0.0647303
Covariance matrix without scale:
9.3697e+00 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 1.0611e+01 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 1.0222e-01 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 9.8399e-02
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.375, Period(s): 2.66667
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.01772, Parameter c: 6.01905
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.375(Hz)
Response functions:
( 1.6094e-01, 2.8796e-02), ( 3.0870e-01, 5.2132e-01)
( -4.5150e-01, -5.4099e-01), ( -7.6817e-02, -6.0189e-02)
( 4.0335e-02, 6.1953e-04), ( 2.4940e-03, -6.8454e-03)
( -2.5296e-05, 4.9876e-03), ( 2.5261e-02, 9.7822e-03)
Scale: 0.0834926
Covariance matrix without scale:
1.0375e+01 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 1.1508e+01 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 9.2212e-02 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 9.0830e-02
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.5, Period(s): 2
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.01772, Parameter c: 6.01905
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.5(Hz)
Response functions:
( 1.6565e-01, 7.2379e-02), ( 2.1090e-01, 3.5859e-01)
( -2.6607e-01, -3.7411e-01), ( -9.6821e-02, -7.4930e-02)
( 2.4204e-02, -7.0460e-04), ( -2.4448e-03, -5.5413e-03)
( -5.1778e-04, 3.3146e-03), ( 1.4180e-02, 1.0598e-02)
Scale: 0.0813483
Covariance matrix without scale:
1.0669e+01 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 1.1458e+01 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 9.1509e-02 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 8.9388e-02
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 0.75, Period(s): 1.33333
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.0175, Parameter c: 6.01826
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 0.75(Hz)
Response functions:
( 4.8550e-02, 3.2119e-02), ( 1.6104e-01, 2.4290e-01)
( -1.9514e-01, -2.1037e-01), ( -1.1007e-02, -1.3957e-02)
( 1.4124e-02, 1.4807e-03), ( -4.9226e-03, -2.0914e-03)
( 7.1309e-03, -7.3635e-04), ( 8.8656e-03, 2.7065e-03)
Scale: 0.107675
Covariance matrix without scale:
1.1363e+01 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 1.1904e+01 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 8.6804e-02 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 8.5168e-02
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------
================================================================================
Now Frequency(Hz): 1, Period(s): 1
================================================================================
Number of initial candidates: 100
Number of candidates: 100
--------------------------------------------------------------------------------
Improve all candidates
Parameter b: 3.0175, Parameter c: 6.01826
--------------------------------------------------------------------------------
Perform further improvements to the best 10 candidates
--------------------------------------------------------------------------------
Best estimator of frequency 1(Hz)
Response functions:
( -4.0422e-04, 1.7861e-02), ( 9.1192e-02, 1.5144e-01)
( -1.2143e-01, -1.2261e-01), ( 4.5062e-03, 3.0887e-02)
( 9.4648e-03, 2.4087e-03), ( -6.8454e-03, 3.2356e-03)
( 3.0071e-03, -2.6903e-03), ( -2.1803e-03, 1.3900e-03)
Scale: 0.105384
Covariance matrix without scale:
1.1353e+01 0.0000e+00 0.0000e+00 0.0000e+00
0.0000e+00 1.1880e+01 0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00 8.6785e-02 0.0000e+00
0.0000e+00 0.0000e+00 0.0000e+00 8.5431e-02
--------------------------------------------------------------------------------
Estimate errors by fixed-weights bootstrap
--------------------------------------------------------------------------------

465
Samples/RRMS/TRACMT.log Normal file
View File

@@ -0,0 +1,465 @@
Start TRACMT Version v2.0
Read parameters. ( 0 sec )
================================================================================
Summary of control parameters
================================================================================
Number of threads : 1
Procedure type : multivariate regression (RRMS)
At each frequency, initial candidates are selected by random sampling
Maximum number of initial candidates: 100
Maximum number of iteration of the first imporvements: 3
Convegence criteria of the first imporvements: 0.05
Maximum number of the candidates of the second imporvements: 10
Maximum number of iteration of the second imporvements: 16
Convegence criteria of the second imporvements: 0.01
Time range for selecting intial candidates: 00:00:00 - 24:00:00
Error estimation method : fixed-weights bootstrap
Number or repetitions in bootstrap : 1000
Number of output variables : 2
Number of input variables : 2
Number of remote reference variables : 2
Sampling frequency (Hz) : 32
Number of time-series sections : 1
Ratio of overlapping part to whole segment length : 0.5
Output level : 0
Output apparent resistivity and phase to a seperate csv file
Information about the segment lengths and frequencies :
Segment# Length Index Frequency(Hz) Period(sec)
0 65536 3 1.464843750e-03 6.826666667e+02
0 65536 4 1.953125000e-03 5.120000000e+02
1 32768 3 2.929687500e-03 3.413333333e+02
1 32768 4 3.906250000e-03 2.560000000e+02
2 16384 3 5.859375000e-03 1.706666667e+02
2 16384 4 7.812500000e-03 1.280000000e+02
3 8192 3 1.171875000e-02 8.533333333e+01
3 8192 4 1.562500000e-02 6.400000000e+01
4 4096 3 2.343750000e-02 4.266666667e+01
4 4096 4 3.125000000e-02 3.200000000e+01
5 2048 3 4.687500000e-02 2.133333333e+01
5 2048 4 6.250000000e-02 1.600000000e+01
6 1024 3 9.375000000e-02 1.066666667e+01
6 1024 4 1.250000000e-01 8.000000000e+00
7 512 3 1.875000000e-01 5.333333333e+00
7 512 4 2.500000000e-01 4.000000000e+00
8 256 3 3.750000000e-01 2.666666667e+00
8 256 4 5.000000000e-01 2.000000000e+00
9 128 3 7.500000000e-01 1.333333333e+00
9 128 4 1.000000000e+00 1.000000000e+00
Information about the time-series data :
Section# Channel# Type NSkip NData File
0 0 Out0 0 2764800 ../ex.txt
0 1 Out1 0 2764800 ../ey.txt
0 2 Inp0 0 2764800 ../hx.txt
0 3 Inp1 0 2764800 ../hy.txt
0 4 RR0 0 2764800 ../hrx.txt
0 5 RR1 0 2764800 ../hry.txt
Rotation angle (deg.) : 0
Channel# Type Azimuth(deg.)
0 Out0 0
1 Out1 90
2 Inp0 0
3 Inp1 90
4 RR0 0
5 RR1 90
Parameters for robust prewhitening :
Least square estimator is used
Maximum degree of AR model: 10
================================================================================
Read data from ../ex.txt ( 0 sec )
Read data from ../ey.txt ( 1 sec )
Read data from ../hx.txt ( 2 sec )
Read data from ../hy.txt ( 3 sec )
Read data from ../hrx.txt ( 3 sec )
Read data from ../hry.txt ( 4 sec )
Perform preprocessing ( 5 sec )
Secton 0, Channel 0 ( 5 sec )
Subtract mean (-0.889991) ( 5 sec )
Secton 0, Channel 1 ( 5 sec )
Subtract mean (1.69968) ( 5 sec )
Secton 0, Channel 2 ( 5 sec )
Subtract mean (0.0092652) ( 5 sec )
Secton 0, Channel 3 ( 5 sec )
Subtract mean (1.30261) ( 5 sec )
Secton 0, Channel 4 ( 5 sec )
Subtract mean (0.0346805) ( 5 sec )
Secton 0, Channel 5 ( 5 sec )
Subtract mean (1.2857) ( 5 sec )
Perform prewhitening for channel 0 ( 5 sec )
Degree of AR model: 1, Sigma: 7.6076, AIC: 1.90665e+07 ( 5 sec )
Degree of AR model: 2, Sigma: 7.60293, AIC: 1.90631e+07 ( 5 sec )
Degree of AR model: 3, Sigma: 7.59862, AIC: 1.906e+07 ( 5 sec )
Degree of AR model: 4, Sigma: 7.5946, AIC: 1.90571e+07 ( 5 sec )
Degree of AR model: 5, Sigma: 7.59088, AIC: 1.90544e+07 ( 5 sec )
Degree of AR model: 6, Sigma: 7.58783, AIC: 1.90521e+07 ( 5 sec )
Degree of AR model: 7, Sigma: 7.58446, AIC: 1.90497e+07 ( 5 sec )
Degree of AR model: 8, Sigma: 7.58162, AIC: 1.90476e+07 ( 5 sec )
Degree of AR model: 9, Sigma: 7.57884, AIC: 1.90456e+07 ( 5 sec )
Degree of AR model: 10, Sigma: 7.57665, AIC: 1.9044e+07 ( 6 sec )
The AR model of 10 degress gives the minimum AIC (1.9044e+07) ( 6 sec )
AR coefficients: 0.0320459 0.0276236 0.0274305 0.0273417 0.0271195 0.0250291 0.0274279 0.0257729 0.0263083 0.0240252 ( 6 sec )
Perform prewhitening for channel 1 ( 6 sec )
Degree of AR model: 1, Sigma: 7.54273, AIC: 1.90192e+07 ( 6 sec )
Degree of AR model: 2, Sigma: 7.52209, AIC: 1.9004e+07 ( 6 sec )
Degree of AR model: 3, Sigma: 7.50561, AIC: 1.89919e+07 ( 6 sec )
Degree of AR model: 4, Sigma: 7.49133, AIC: 1.89814e+07 ( 6 sec )
Degree of AR model: 5, Sigma: 7.47891, AIC: 1.89722e+07 ( 6 sec )
Degree of AR model: 6, Sigma: 7.46782, AIC: 1.8964e+07 ( 6 sec )
Degree of AR model: 7, Sigma: 7.45798, AIC: 1.89567e+07 ( 6 sec )
Degree of AR model: 8, Sigma: 7.44899, AIC: 1.895e+07 ( 6 sec )
Degree of AR model: 9, Sigma: 7.44151, AIC: 1.89444e+07 ( 6 sec )
Degree of AR model: 10, Sigma: 7.43417, AIC: 1.8939e+07 ( 6 sec )
The AR model of 10 degress gives the minimum AIC (1.8939e+07) ( 6 sec )
AR coefficients: 0.0497931 0.0484711 0.0453945 0.0449254 0.0443603 0.0443792 0.0440958 0.0444201 0.0425092 0.0444076 ( 6 sec )
Perform prewhitening for channel 2 ( 6 sec )
Degree of AR model: 1, Sigma: 1.15041, AIC: 8.62097e+06 ( 6 sec )
Degree of AR model: 2, Sigma: 0.999605, AIC: 7.84398e+06 ( 6 sec )
Degree of AR model: 3, Sigma: 0.94325, AIC: 7.5231e+06 ( 6 sec )
Degree of AR model: 4, Sigma: 0.913582, AIC: 7.34638e+06 ( 6 sec )
Degree of AR model: 5, Sigma: 0.895124, AIC: 7.23352e+06 ( 6 sec )
Degree of AR model: 6, Sigma: 0.882753, AIC: 7.15657e+06 ( 6 sec )
Degree of AR model: 7, Sigma: 0.873879, AIC: 7.1007e+06 ( 6 sec )
Degree of AR model: 8, Sigma: 0.867031, AIC: 7.0572e+06 ( 6 sec )
Degree of AR model: 9, Sigma: 0.861586, AIC: 7.02236e+06 ( 6 sec )
Degree of AR model: 10, Sigma: 0.857167, AIC: 6.99392e+06 ( 6 sec )
The AR model of 10 degress gives the minimum AIC (6.99392e+06) ( 6 sec )
AR coefficients: 0.100812 0.0994283 0.099345 0.0994338 0.100341 0.0991599 0.0983786 0.0996401 0.100555 0.101158 ( 6 sec )
Perform prewhitening for channel 3 ( 6 sec )
Degree of AR model: 1, Sigma: 1.15933, AIC: 8.66365e+06 ( 6 sec )
Degree of AR model: 2, Sigma: 1.01002, AIC: 7.90131e+06 ( 6 sec )
Degree of AR model: 3, Sigma: 0.95364, AIC: 7.58368e+06 ( 6 sec )
Degree of AR model: 4, Sigma: 0.923737, AIC: 7.40751e+06 ( 6 sec )
Degree of AR model: 5, Sigma: 0.905428, AIC: 7.29681e+06 ( 6 sec )
Degree of AR model: 6, Sigma: 0.892914, AIC: 7.21985e+06 ( 6 sec )
Degree of AR model: 7, Sigma: 0.884029, AIC: 7.16455e+06 ( 6 sec )
Degree of AR model: 8, Sigma: 0.877216, AIC: 7.12177e+06 ( 6 sec )
Degree of AR model: 9, Sigma: 0.871841, AIC: 7.08779e+06 ( 6 sec )
Degree of AR model: 10, Sigma: 0.867445, AIC: 7.05983e+06 ( 7 sec )
The AR model of 10 degress gives the minimum AIC (7.05983e+06) ( 7 sec )
AR coefficients: 0.0992426 0.0997661 0.0999695 0.100685 0.0994892 0.0998831 0.0983119 0.0990847 0.0994668 0.100303 ( 7 sec )
Perform prewhitening for channel 4 ( 7 sec )
Degree of AR model: 1, Sigma: 1.16254, AIC: 8.67898e+06 ( 7 sec )
Degree of AR model: 2, Sigma: 1.00903, AIC: 7.89586e+06 ( 7 sec )
Degree of AR model: 3, Sigma: 0.952405, AIC: 7.57651e+06 ( 7 sec )
Degree of AR model: 4, Sigma: 0.922235, AIC: 7.39851e+06 ( 7 sec )
Degree of AR model: 5, Sigma: 0.90364, AIC: 7.28588e+06 ( 7 sec )
Degree of AR model: 6, Sigma: 0.891244, AIC: 7.2095e+06 ( 7 sec )
Degree of AR model: 7, Sigma: 0.882213, AIC: 7.15318e+06 ( 7 sec )
Degree of AR model: 8, Sigma: 0.875262, AIC: 7.10944e+06 ( 7 sec )
Degree of AR model: 9, Sigma: 0.869864, AIC: 7.07523e+06 ( 7 sec )
Degree of AR model: 10, Sigma: 0.865547, AIC: 7.04772e+06 ( 7 sec )
The AR model of 10 degress gives the minimum AIC (7.04772e+06) ( 7 sec )
AR coefficients: 0.0989261 0.10121 0.0987917 0.100744 0.100552 0.0988028 0.0993482 0.100374 0.0999452 0.0995135 ( 7 sec )
Perform prewhitening for channel 5 ( 7 sec )
Degree of AR model: 1, Sigma: 1.16036, AIC: 8.66857e+06 ( 7 sec )
Degree of AR model: 2, Sigma: 1.01086, AIC: 7.90589e+06 ( 7 sec )
Degree of AR model: 3, Sigma: 0.953982, AIC: 7.58566e+06 ( 7 sec )
Degree of AR model: 4, Sigma: 0.924434, AIC: 7.41168e+06 ( 7 sec )
Degree of AR model: 5, Sigma: 0.906107, AIC: 7.30095e+06 ( 7 sec )
Degree of AR model: 6, Sigma: 0.893431, AIC: 7.22305e+06 ( 7 sec )
Degree of AR model: 7, Sigma: 0.884431, AIC: 7.16707e+06 ( 7 sec )
Degree of AR model: 8, Sigma: 0.877486, AIC: 7.12347e+06 ( 7 sec )
Degree of AR model: 9, Sigma: 0.872098, AIC: 7.08941e+06 ( 7 sec )
Degree of AR model: 10, Sigma: 0.867816, AIC: 7.0622e+06 ( 7 sec )
The AR model of 10 degress gives the minimum AIC (7.0622e+06) ( 7 sec )
AR coefficients: 0.0995885 0.098903 0.101124 0.0988656 0.0991358 0.100713 0.0990429 0.100438 0.0997109 0.0989688 ( 7 sec )
===============================================================================
Perform analysis for segment length : 65536 ( 7 sec )
Convert time-series data to frequency-domain ( 7 sec )
Total number of segments : 83 ( 7 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.00146484, Period(s): 682.667 ( 9 sec )
Perform calibration correction ( 9 sec )
Calculate rotated fields ( 9 sec )
Calculate response functions by multivariate regression ( 9 sec )
Determine candicates ( 9 sec )
Number of initial candidates: 100 ( 9 sec )
Number of candidates: 100 ( 9 sec )
Improve all candidates ( 9 sec )
Detetermine the best improved candidates ( 10 sec )
Perform further improvements to the best 10 candidates ( 10 sec )
Select the response with the smallest scale ( 10 sec )
Estimate errors by fixed-weights bootstrap ( 10 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.00195312, Period(s): 512 ( 10 sec )
Perform calibration correction ( 10 sec )
Calculate rotated fields ( 10 sec )
Calculate response functions by multivariate regression ( 10 sec )
Determine candicates ( 10 sec )
Number of initial candidates: 100 ( 10 sec )
Number of candidates: 100 ( 10 sec )
Improve all candidates ( 10 sec )
Detetermine the best improved candidates ( 10 sec )
Perform further improvements to the best 10 candidates ( 10 sec )
Select the response with the smallest scale ( 10 sec )
Estimate errors by fixed-weights bootstrap ( 10 sec )
===============================================================================
Perform analysis for segment length : 32768 ( 10 sec )
Convert time-series data to frequency-domain ( 10 sec )
Total number of segments : 167 ( 10 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.00292969, Period(s): 341.333 ( 12 sec )
Perform calibration correction ( 12 sec )
Calculate rotated fields ( 12 sec )
Calculate response functions by multivariate regression ( 12 sec )
Determine candicates ( 12 sec )
Number of initial candidates: 100 ( 12 sec )
Number of candidates: 100 ( 12 sec )
Improve all candidates ( 12 sec )
Detetermine the best improved candidates ( 12 sec )
Perform further improvements to the best 10 candidates ( 12 sec )
Select the response with the smallest scale ( 12 sec )
Estimate errors by fixed-weights bootstrap ( 12 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.00390625, Period(s): 256 ( 12 sec )
Perform calibration correction ( 12 sec )
Calculate rotated fields ( 12 sec )
Calculate response functions by multivariate regression ( 12 sec )
Determine candicates ( 12 sec )
Number of initial candidates: 100 ( 12 sec )
Number of candidates: 100 ( 12 sec )
Improve all candidates ( 12 sec )
Detetermine the best improved candidates ( 12 sec )
Perform further improvements to the best 10 candidates ( 12 sec )
Select the response with the smallest scale ( 12 sec )
Estimate errors by fixed-weights bootstrap ( 12 sec )
===============================================================================
Perform analysis for segment length : 16384 ( 12 sec )
Convert time-series data to frequency-domain ( 12 sec )
Total number of segments : 336 ( 12 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.00585938, Period(s): 170.667 ( 14 sec )
Perform calibration correction ( 14 sec )
Calculate rotated fields ( 14 sec )
Calculate response functions by multivariate regression ( 14 sec )
Determine candicates ( 14 sec )
Number of initial candidates: 100 ( 14 sec )
Number of candidates: 100 ( 14 sec )
Improve all candidates ( 14 sec )
Detetermine the best improved candidates ( 14 sec )
Perform further improvements to the best 10 candidates ( 14 sec )
Select the response with the smallest scale ( 14 sec )
Estimate errors by fixed-weights bootstrap ( 14 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.0078125, Period(s): 128 ( 14 sec )
Perform calibration correction ( 14 sec )
Calculate rotated fields ( 14 sec )
Calculate response functions by multivariate regression ( 14 sec )
Determine candicates ( 14 sec )
Number of initial candidates: 100 ( 14 sec )
Number of candidates: 100 ( 14 sec )
Improve all candidates ( 14 sec )
Detetermine the best improved candidates ( 14 sec )
Perform further improvements to the best 10 candidates ( 14 sec )
Select the response with the smallest scale ( 14 sec )
Estimate errors by fixed-weights bootstrap ( 14 sec )
===============================================================================
Perform analysis for segment length : 8192 ( 14 sec )
Convert time-series data to frequency-domain ( 14 sec )
Total number of segments : 674 ( 14 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.0117188, Period(s): 85.3333 ( 16 sec )
Perform calibration correction ( 16 sec )
Calculate rotated fields ( 16 sec )
Calculate response functions by multivariate regression ( 16 sec )
Determine candicates ( 16 sec )
Number of initial candidates: 100 ( 16 sec )
Number of candidates: 100 ( 16 sec )
Improve all candidates ( 16 sec )
Detetermine the best improved candidates ( 16 sec )
Perform further improvements to the best 10 candidates ( 16 sec )
Select the response with the smallest scale ( 16 sec )
Estimate errors by fixed-weights bootstrap ( 16 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.015625, Period(s): 64 ( 16 sec )
Perform calibration correction ( 16 sec )
Calculate rotated fields ( 16 sec )
Calculate response functions by multivariate regression ( 16 sec )
Determine candicates ( 16 sec )
Number of initial candidates: 100 ( 16 sec )
Number of candidates: 100 ( 16 sec )
Improve all candidates ( 16 sec )
Detetermine the best improved candidates ( 16 sec )
Perform further improvements to the best 10 candidates ( 16 sec )
Select the response with the smallest scale ( 16 sec )
Estimate errors by fixed-weights bootstrap ( 16 sec )
===============================================================================
Perform analysis for segment length : 4096 ( 16 sec )
Convert time-series data to frequency-domain ( 16 sec )
Total number of segments : 1349 ( 16 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.0234375, Period(s): 42.6667 ( 18 sec )
Perform calibration correction ( 18 sec )
Calculate rotated fields ( 18 sec )
Calculate response functions by multivariate regression ( 18 sec )
Determine candicates ( 18 sec )
Number of initial candidates: 100 ( 18 sec )
Number of candidates: 100 ( 18 sec )
Improve all candidates ( 18 sec )
Detetermine the best improved candidates ( 18 sec )
Perform further improvements to the best 10 candidates ( 18 sec )
Select the response with the smallest scale ( 19 sec )
Estimate errors by fixed-weights bootstrap ( 19 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.03125, Period(s): 32 ( 19 sec )
Perform calibration correction ( 19 sec )
Calculate rotated fields ( 19 sec )
Calculate response functions by multivariate regression ( 19 sec )
Determine candicates ( 19 sec )
Number of initial candidates: 100 ( 19 sec )
Number of candidates: 100 ( 19 sec )
Improve all candidates ( 19 sec )
Detetermine the best improved candidates ( 19 sec )
Perform further improvements to the best 10 candidates ( 19 sec )
Select the response with the smallest scale ( 19 sec )
Estimate errors by fixed-weights bootstrap ( 19 sec )
===============================================================================
Perform analysis for segment length : 2048 ( 19 sec )
Convert time-series data to frequency-domain ( 19 sec )
Total number of segments : 2699 ( 19 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.046875, Period(s): 21.3333 ( 21 sec )
Perform calibration correction ( 21 sec )
Calculate rotated fields ( 21 sec )
Calculate response functions by multivariate regression ( 21 sec )
Determine candicates ( 21 sec )
Number of initial candidates: 100 ( 21 sec )
Number of candidates: 100 ( 21 sec )
Improve all candidates ( 21 sec )
Detetermine the best improved candidates ( 21 sec )
Perform further improvements to the best 10 candidates ( 21 sec )
Select the response with the smallest scale ( 21 sec )
Estimate errors by fixed-weights bootstrap ( 21 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.0625, Period(s): 16 ( 22 sec )
Perform calibration correction ( 22 sec )
Calculate rotated fields ( 22 sec )
Calculate response functions by multivariate regression ( 22 sec )
Determine candicates ( 22 sec )
Number of initial candidates: 100 ( 22 sec )
Number of candidates: 100 ( 22 sec )
Improve all candidates ( 22 sec )
Detetermine the best improved candidates ( 22 sec )
Perform further improvements to the best 10 candidates ( 22 sec )
Select the response with the smallest scale ( 22 sec )
Estimate errors by fixed-weights bootstrap ( 22 sec )
===============================================================================
Perform analysis for segment length : 1024 ( 23 sec )
Convert time-series data to frequency-domain ( 23 sec )
Total number of segments : 5399 ( 23 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.09375, Period(s): 10.6667 ( 24 sec )
Perform calibration correction ( 24 sec )
Calculate rotated fields ( 24 sec )
Calculate response functions by multivariate regression ( 24 sec )
Determine candicates ( 24 sec )
Number of initial candidates: 100 ( 24 sec )
Number of candidates: 100 ( 24 sec )
Improve all candidates ( 24 sec )
Detetermine the best improved candidates ( 26 sec )
Perform further improvements to the best 10 candidates ( 26 sec )
Select the response with the smallest scale ( 26 sec )
Estimate errors by fixed-weights bootstrap ( 26 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.125, Period(s): 8 ( 26 sec )
Perform calibration correction ( 26 sec )
Calculate rotated fields ( 26 sec )
Calculate response functions by multivariate regression ( 26 sec )
Determine candicates ( 26 sec )
Number of initial candidates: 100 ( 26 sec )
Number of candidates: 100 ( 26 sec )
Improve all candidates ( 26 sec )
Detetermine the best improved candidates ( 28 sec )
Perform further improvements to the best 10 candidates ( 28 sec )
Select the response with the smallest scale ( 28 sec )
Estimate errors by fixed-weights bootstrap ( 28 sec )
===============================================================================
Perform analysis for segment length : 512 ( 28 sec )
Convert time-series data to frequency-domain ( 28 sec )
Total number of segments : 10799 ( 28 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.1875, Period(s): 5.33333 ( 30 sec )
Perform calibration correction ( 30 sec )
Calculate rotated fields ( 30 sec )
Calculate response functions by multivariate regression ( 30 sec )
Determine candicates ( 30 sec )
Number of initial candidates: 100 ( 30 sec )
Number of candidates: 100 ( 30 sec )
Improve all candidates ( 30 sec )
Detetermine the best improved candidates ( 33 sec )
Perform further improvements to the best 10 candidates ( 33 sec )
Select the response with the smallest scale ( 34 sec )
Estimate errors by fixed-weights bootstrap ( 34 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.25, Period(s): 4 ( 34 sec )
Perform calibration correction ( 34 sec )
Calculate rotated fields ( 34 sec )
Calculate response functions by multivariate regression ( 34 sec )
Determine candicates ( 34 sec )
Number of initial candidates: 100 ( 34 sec )
Number of candidates: 100 ( 34 sec )
Improve all candidates ( 34 sec )
Detetermine the best improved candidates ( 37 sec )
Perform further improvements to the best 10 candidates ( 38 sec )
Select the response with the smallest scale ( 38 sec )
Estimate errors by fixed-weights bootstrap ( 38 sec )
===============================================================================
Perform analysis for segment length : 256 ( 38 sec )
Convert time-series data to frequency-domain ( 38 sec )
Total number of segments : 21599 ( 38 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.375, Period(s): 2.66667 ( 40 sec )
Perform calibration correction ( 40 sec )
Calculate rotated fields ( 40 sec )
Calculate response functions by multivariate regression ( 40 sec )
Determine candicates ( 40 sec )
Number of initial candidates: 100 ( 40 sec )
Number of candidates: 100 ( 40 sec )
Improve all candidates ( 40 sec )
Detetermine the best improved candidates ( 47 sec )
Perform further improvements to the best 10 candidates ( 47 sec )
Select the response with the smallest scale ( 48 sec )
Estimate errors by fixed-weights bootstrap ( 48 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.5, Period(s): 2 ( 49 sec )
Perform calibration correction ( 49 sec )
Calculate rotated fields ( 49 sec )
Calculate response functions by multivariate regression ( 49 sec )
Determine candicates ( 49 sec )
Number of initial candidates: 100 ( 49 sec )
Number of candidates: 100 ( 49 sec )
Improve all candidates ( 49 sec )
Detetermine the best improved candidates ( 56 sec )
Perform further improvements to the best 10 candidates ( 56 sec )
Select the response with the smallest scale ( 57 sec )
Estimate errors by fixed-weights bootstrap ( 57 sec )
===============================================================================
Perform analysis for segment length : 128 ( 59 sec )
Convert time-series data to frequency-domain ( 59 sec )
Total number of segments : 43199 ( 59 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 0.75, Period(s): 1.33333 ( 60 sec )
Perform calibration correction ( 60 sec )
Calculate rotated fields ( 60 sec )
Calculate response functions by multivariate regression ( 60 sec )
Determine candicates ( 60 sec )
Number of initial candidates: 100 ( 60 sec )
Number of candidates: 100 ( 60 sec )
Improve all candidates ( 60 sec )
Detetermine the best improved candidates ( 74 sec )
Perform further improvements to the best 10 candidates ( 75 sec )
Select the response with the smallest scale ( 77 sec )
Estimate errors by fixed-weights bootstrap ( 77 sec )
-------------------------------------------------------------------------------
Now Frequency(Hz): 1, Period(s): 1 ( 80 sec )
Perform calibration correction ( 80 sec )
Calculate rotated fields ( 80 sec )
Calculate response functions by multivariate regression ( 80 sec )
Determine candicates ( 80 sec )
Number of initial candidates: 100 ( 80 sec )
Number of candidates: 100 ( 80 sec )
Improve all candidates ( 80 sec )
Detetermine the best improved candidates ( 93 sec )
Perform further improvements to the best 10 candidates ( 95 sec )
Select the response with the smallest scale ( 97 sec )
Estimate errors by fixed-weights bootstrap ( 97 sec )
End TRACMT ( 99 sec )

View File

@@ -0,0 +1,21 @@
frequency,period,app_res_0_2,phase_0_2,app_res_0_3,phase_0_3,coherence_0_2+3,app_res_1_2,phase_1_2,app_res_1_3,phase_1_3,coherence_1_2+3,dapp_res_0_2,dphase_0_2,dapp_res_0_3,dphase_0_3,dapp_res_1_2,dphase_1_2,dapp_res_1_3,dphase_1_3
1.4648437500e-03,6.8266666667e+02,4.2168886420e+01,4.8022056661e+01,4.1340512817e+01,5.3319419010e+01,8.9973917276e-01,1.5794724150e+02,-1.2865818972e+02,6.7403069362e+00,-1.3457562207e+02,9.5233260437e-01,3.1073627735e+00,2.1114984689e+00,3.0281598128e+00,2.0989046392e+00,5.6655525723e+00,1.0276521864e+00,1.1674152903e+00,4.9680123869e+00
1.9531250000e-03,5.1200000000e+02,4.3564597655e+01,4.6390553781e+01,4.4830923973e+01,5.4525018856e+01,9.0762085300e-01,1.7097600483e+02,-1.2868474783e+02,7.6490661368e+00,-1.3018648634e+02,9.6762206017e-01,2.9479943515e+00,1.9389583213e+00,3.3836954645e+00,2.1627651164e+00,4.5403323711e+00,7.6077788522e-01,1.2675251362e+00,4.7526841939e+00
2.9296875000e-03,3.4133333333e+02,4.2733401792e+01,5.0335908713e+01,5.2692186912e+01,5.6754047095e+01,8.7725934040e-01,1.7760075640e+02,-1.2554997667e+02,6.4548704970e+00,-1.2472151967e+02,9.4176032684e-01,2.4448036538e+00,1.6391866265e+00,3.1308984849e+00,1.7024693740e+00,4.4291696053e+00,7.1446571271e-01,1.1663941392e+00,5.1837383710e+00
3.9062500000e-03,2.5600000000e+02,4.5922557831e+01,4.8027962255e+01,5.2154354090e+01,6.1902804894e+01,8.5732632366e-01,1.9550851034e+02,-1.2813428751e+02,6.5365207374e+00,-1.1938995875e+02,9.3463939198e-01,2.9148856176e+00,1.8186997932e+00,3.5792471021e+00,1.9664323534e+00,5.3454839210e+00,7.8329891687e-01,1.1908118666e+00,5.2262665539e+00
5.8593750000e-03,1.7066666667e+02,5.2880914162e+01,4.8563234411e+01,5.8043409512e+01,6.0252520232e+01,7.8685932594e-01,2.1004200837e+02,-1.2887160208e+02,6.7669962064e+00,-1.2986454583e+02,9.0661227178e-01,2.6455403173e+00,1.4333536856e+00,3.3869925812e+00,1.6719204213e+00,4.9908997363e+00,6.8073101359e-01,1.1762289054e+00,4.9858222570e+00
7.8125000000e-03,1.2800000000e+02,5.4031076641e+01,4.8131918926e+01,6.3188640137e+01,5.8486935159e+01,7.6301287094e-01,2.1762526110e+02,-1.2887235377e+02,7.5692482270e+00,-1.3327791478e+02,8.9042963299e-01,2.9555564319e+00,1.5672649881e+00,4.0009495261e+00,1.8142171754e+00,6.0655335313e+00,7.9848432966e-01,1.2721803920e+00,4.8205998718e+00
1.1718750000e-02,8.5333333333e+01,5.9358145327e+01,4.2743685642e+01,7.4840212945e+01,5.8611890978e+01,7.0568344865e-01,2.4183856944e+02,-1.2992422141e+02,9.6020683702e+00,-1.2670477300e+02,8.3234334691e-01,2.6382117200e+00,1.2733790843e+00,3.9528469430e+00,1.5132758942e+00,5.9927750718e+00,7.0991468737e-01,1.5025599390e+00,4.4874926656e+00
1.5625000000e-02,6.4000000000e+01,5.7394006151e+01,4.1943056890e+01,8.0773573381e+01,5.7045642999e+01,6.3151710006e-01,2.4463749503e+02,-1.3210244199e+02,9.3997023175e+00,-1.3840676112e+02,7.7865956962e-01,3.2202482370e+00,1.6075793941e+00,4.8426116123e+00,1.7177819817e+00,7.2980438250e+00,8.5465765751e-01,1.7871987618e+00,5.4551631057e+00
2.3437500000e-02,4.2666666667e+01,5.1633535806e+01,4.0069471518e+01,8.7611476461e+01,5.6425674438e+01,5.1676899773e-01,2.4596402093e+02,-1.3357402405e+02,1.1734941367e+01,-1.2531057719e+02,6.9813188573e-01,2.5965177182e+00,1.4407805346e+00,4.5851243259e+00,1.4994511738e+00,6.2573253002e+00,7.2882204079e-01,1.8441505613e+00,4.5066724729e+00
3.1250000000e-02,3.2000000000e+01,5.6513262228e+01,3.5732461211e+01,1.0211148188e+02,5.6413030019e+01,4.4535065602e-01,2.5257613567e+02,-1.3561840051e+02,1.1679347670e+01,-1.2912532506e+02,6.2510658343e-01,3.5031029310e+00,1.7760889521e+00,6.3088942012e+00,1.7702736415e+00,8.0248801145e+00,9.1024257302e-01,2.3310671358e+00,5.7273316112e+00
4.6875000000e-02,2.1333333333e+01,6.1065446320e+01,3.2488891062e+01,1.0512598799e+02,5.9524981611e+01,3.1049538562e-01,2.3744477188e+02,-1.3803063881e+02,8.2696066296e+00,-1.2992682674e+02,4.2061086650e-01,3.7918963404e+00,1.7791942094e+00,6.3681228233e+00,1.7356429997e+00,8.1443452845e+00,9.8266953975e-01,1.9557788832e+00,6.7911748646e+00
6.2500000000e-02,1.6000000000e+01,6.0621323721e+01,3.1358260770e+01,1.2632810857e+02,5.7835967317e+01,2.1119255836e-01,2.2105819282e+02,-1.3590011340e+02,9.0950131491e+00,-1.3256296162e+02,2.6854473703e-01,5.3921814093e+00,2.5490302527e+00,1.0350422678e+01,2.3478604428e+00,1.1233845315e+01,1.4559994279e+00,2.9754839773e+00,9.4146243233e+00
9.3750000000e-02,1.0666666667e+01,3.9603097417e+01,3.0438422556e+01,1.5034144676e+02,5.7752536033e+01,1.0806514363e-01,1.9429047294e+02,-1.3489892412e+02,1.5013595513e+01,-1.2269722451e+02,1.1000148190e-01,4.7489007736e+00,3.4372974651e+00,1.2649972609e+01,2.4111914410e+00,1.1416348883e+01,1.6835687701e+00,4.4177549858e+00,8.4603613564e+00
1.2500000000e-01,8.0000000000e+00,3.7463475544e+01,2.0756375865e+01,1.4808960043e+02,5.6355234280e+01,4.7239197846e-02,1.9087428843e+02,-1.3871629002e+02,6.4597303390e+00,-1.2987559360e+02,4.7239197846e-02,7.2376619930e+00,5.5432004023e+00,1.9519439536e+01,3.7787686491e+00,1.6134676445e+01,2.4223386087e+00,4.1668647292e+00,1.8815768544e+01
1.8750000000e-01,5.3333333333e+00,1.9584904684e+01,2.5028522642e+01,1.4172201875e+02,5.7792497193e+01,1.7617568989e-02,1.8499160388e+02,-1.3322297563e+02,3.4867331457e+00,-1.4440260121e+02,1.7617568989e-02,6.1507909811e+00,9.0344831802e+00,2.2587377678e+01,4.5706908467e+00,2.0524084328e+01,3.1800020527e+00,3.7257066954e+00,3.2294348747e+01
2.5000000000e-01,4.0000000000e+00,3.4804617614e+01,4.5085997151e+01,1.9970647211e+02,6.1017427630e+01,7.5452420080e-03,1.9030275297e+02,-1.3754893906e+02,3.6704792101e+00,-1.3840778697e+02,7.5452420080e-03,1.5359698070e+01,1.2747568188e+01,5.1161851510e+01,7.3593861399e+00,3.2935235911e+01,4.9642294331e+00,6.2912088835e+00,5.8981507398e+01
3.7500000000e-01,2.6666666667e+00,1.9811145761e+01,-1.5192713621e+01,3.0006978275e+02,4.0496483285e+01,2.0282928584e-03,1.6939822452e+02,-1.3203074227e+02,9.9913471627e+00,-8.9358360316e+01,2.0282928584e-03,1.6756584952e+01,2.5018319717e+01,9.6805854108e+01,9.2826842340e+00,3.8993666523e+01,6.6090856717e+00,1.4065510381e+01,4.4739501173e+01
5.0000000000e-01,2.0000000000e+00,3.1078209375e+01,9.7750421526e-01,2.8072073624e+02,2.3630845293e+01,9.4692383969e-04,1.4226306311e+02,-1.2803054508e+02,4.1720991574e+01,-1.4050409799e+02,9.4692383969e-04,3.5150092832e+01,3.4437732519e+01,1.5068632777e+02,1.5568596247e+01,5.9895366204e+01,1.2152194119e+01,4.4339110949e+01,3.2098508259e+01
7.5000000000e-01,1.3333333333e+00,2.2202358119e+01,-1.5105060212e+02,1.8297081679e+02,4.0381278587e+01,4.8556897195e-04,5.9609382797e+01,-1.3661518416e+02,2.9360847370e+01,-1.3322492493e+02,4.8556897195e-04,2.6756826605e+01,3.7053983647e+01,1.0306264369e+02,1.6357920486e+01,2.9732060571e+01,1.4441464439e+01,2.6328428830e+01,2.6638478853e+01
1.0000000000e+00,1.0000000000e+00,2.0141313837e+02,-3.9642468829e+01,1.2450119453e+03,-1.6642143834e+02,8.3444887217e-05,4.1321240276e+01,1.2388481787e+02,5.7793087565e+02,-5.2634102076e+01,8.3444887217e-05,4.2392885822e+02,3.6000000000e+02,2.2428379410e+03,6.4254121306e+01,1.5342552971e+02,3.6000000000e+02,1.1618730174e+03,3.6000000000e+02
1 frequency period app_res_0_2 phase_0_2 app_res_0_3 phase_0_3 coherence_0_2+3 app_res_1_2 phase_1_2 app_res_1_3 phase_1_3 coherence_1_2+3 dapp_res_0_2 dphase_0_2 dapp_res_0_3 dphase_0_3 dapp_res_1_2 dphase_1_2 dapp_res_1_3 dphase_1_3
2 1.4648437500e-03 6.8266666667e+02 4.2168886420e+01 4.8022056661e+01 4.1340512817e+01 5.3319419010e+01 8.9973917276e-01 1.5794724150e+02 -1.2865818972e+02 6.7403069362e+00 -1.3457562207e+02 9.5233260437e-01 3.1073627735e+00 2.1114984689e+00 3.0281598128e+00 2.0989046392e+00 5.6655525723e+00 1.0276521864e+00 1.1674152903e+00 4.9680123869e+00
3 1.9531250000e-03 5.1200000000e+02 4.3564597655e+01 4.6390553781e+01 4.4830923973e+01 5.4525018856e+01 9.0762085300e-01 1.7097600483e+02 -1.2868474783e+02 7.6490661368e+00 -1.3018648634e+02 9.6762206017e-01 2.9479943515e+00 1.9389583213e+00 3.3836954645e+00 2.1627651164e+00 4.5403323711e+00 7.6077788522e-01 1.2675251362e+00 4.7526841939e+00
4 2.9296875000e-03 3.4133333333e+02 4.2733401792e+01 5.0335908713e+01 5.2692186912e+01 5.6754047095e+01 8.7725934040e-01 1.7760075640e+02 -1.2554997667e+02 6.4548704970e+00 -1.2472151967e+02 9.4176032684e-01 2.4448036538e+00 1.6391866265e+00 3.1308984849e+00 1.7024693740e+00 4.4291696053e+00 7.1446571271e-01 1.1663941392e+00 5.1837383710e+00
5 3.9062500000e-03 2.5600000000e+02 4.5922557831e+01 4.8027962255e+01 5.2154354090e+01 6.1902804894e+01 8.5732632366e-01 1.9550851034e+02 -1.2813428751e+02 6.5365207374e+00 -1.1938995875e+02 9.3463939198e-01 2.9148856176e+00 1.8186997932e+00 3.5792471021e+00 1.9664323534e+00 5.3454839210e+00 7.8329891687e-01 1.1908118666e+00 5.2262665539e+00
6 5.8593750000e-03 1.7066666667e+02 5.2880914162e+01 4.8563234411e+01 5.8043409512e+01 6.0252520232e+01 7.8685932594e-01 2.1004200837e+02 -1.2887160208e+02 6.7669962064e+00 -1.2986454583e+02 9.0661227178e-01 2.6455403173e+00 1.4333536856e+00 3.3869925812e+00 1.6719204213e+00 4.9908997363e+00 6.8073101359e-01 1.1762289054e+00 4.9858222570e+00
7 7.8125000000e-03 1.2800000000e+02 5.4031076641e+01 4.8131918926e+01 6.3188640137e+01 5.8486935159e+01 7.6301287094e-01 2.1762526110e+02 -1.2887235377e+02 7.5692482270e+00 -1.3327791478e+02 8.9042963299e-01 2.9555564319e+00 1.5672649881e+00 4.0009495261e+00 1.8142171754e+00 6.0655335313e+00 7.9848432966e-01 1.2721803920e+00 4.8205998718e+00
8 1.1718750000e-02 8.5333333333e+01 5.9358145327e+01 4.2743685642e+01 7.4840212945e+01 5.8611890978e+01 7.0568344865e-01 2.4183856944e+02 -1.2992422141e+02 9.6020683702e+00 -1.2670477300e+02 8.3234334691e-01 2.6382117200e+00 1.2733790843e+00 3.9528469430e+00 1.5132758942e+00 5.9927750718e+00 7.0991468737e-01 1.5025599390e+00 4.4874926656e+00
9 1.5625000000e-02 6.4000000000e+01 5.7394006151e+01 4.1943056890e+01 8.0773573381e+01 5.7045642999e+01 6.3151710006e-01 2.4463749503e+02 -1.3210244199e+02 9.3997023175e+00 -1.3840676112e+02 7.7865956962e-01 3.2202482370e+00 1.6075793941e+00 4.8426116123e+00 1.7177819817e+00 7.2980438250e+00 8.5465765751e-01 1.7871987618e+00 5.4551631057e+00
10 2.3437500000e-02 4.2666666667e+01 5.1633535806e+01 4.0069471518e+01 8.7611476461e+01 5.6425674438e+01 5.1676899773e-01 2.4596402093e+02 -1.3357402405e+02 1.1734941367e+01 -1.2531057719e+02 6.9813188573e-01 2.5965177182e+00 1.4407805346e+00 4.5851243259e+00 1.4994511738e+00 6.2573253002e+00 7.2882204079e-01 1.8441505613e+00 4.5066724729e+00
11 3.1250000000e-02 3.2000000000e+01 5.6513262228e+01 3.5732461211e+01 1.0211148188e+02 5.6413030019e+01 4.4535065602e-01 2.5257613567e+02 -1.3561840051e+02 1.1679347670e+01 -1.2912532506e+02 6.2510658343e-01 3.5031029310e+00 1.7760889521e+00 6.3088942012e+00 1.7702736415e+00 8.0248801145e+00 9.1024257302e-01 2.3310671358e+00 5.7273316112e+00
12 4.6875000000e-02 2.1333333333e+01 6.1065446320e+01 3.2488891062e+01 1.0512598799e+02 5.9524981611e+01 3.1049538562e-01 2.3744477188e+02 -1.3803063881e+02 8.2696066296e+00 -1.2992682674e+02 4.2061086650e-01 3.7918963404e+00 1.7791942094e+00 6.3681228233e+00 1.7356429997e+00 8.1443452845e+00 9.8266953975e-01 1.9557788832e+00 6.7911748646e+00
13 6.2500000000e-02 1.6000000000e+01 6.0621323721e+01 3.1358260770e+01 1.2632810857e+02 5.7835967317e+01 2.1119255836e-01 2.2105819282e+02 -1.3590011340e+02 9.0950131491e+00 -1.3256296162e+02 2.6854473703e-01 5.3921814093e+00 2.5490302527e+00 1.0350422678e+01 2.3478604428e+00 1.1233845315e+01 1.4559994279e+00 2.9754839773e+00 9.4146243233e+00
14 9.3750000000e-02 1.0666666667e+01 3.9603097417e+01 3.0438422556e+01 1.5034144676e+02 5.7752536033e+01 1.0806514363e-01 1.9429047294e+02 -1.3489892412e+02 1.5013595513e+01 -1.2269722451e+02 1.1000148190e-01 4.7489007736e+00 3.4372974651e+00 1.2649972609e+01 2.4111914410e+00 1.1416348883e+01 1.6835687701e+00 4.4177549858e+00 8.4603613564e+00
15 1.2500000000e-01 8.0000000000e+00 3.7463475544e+01 2.0756375865e+01 1.4808960043e+02 5.6355234280e+01 4.7239197846e-02 1.9087428843e+02 -1.3871629002e+02 6.4597303390e+00 -1.2987559360e+02 4.7239197846e-02 7.2376619930e+00 5.5432004023e+00 1.9519439536e+01 3.7787686491e+00 1.6134676445e+01 2.4223386087e+00 4.1668647292e+00 1.8815768544e+01
16 1.8750000000e-01 5.3333333333e+00 1.9584904684e+01 2.5028522642e+01 1.4172201875e+02 5.7792497193e+01 1.7617568989e-02 1.8499160388e+02 -1.3322297563e+02 3.4867331457e+00 -1.4440260121e+02 1.7617568989e-02 6.1507909811e+00 9.0344831802e+00 2.2587377678e+01 4.5706908467e+00 2.0524084328e+01 3.1800020527e+00 3.7257066954e+00 3.2294348747e+01
17 2.5000000000e-01 4.0000000000e+00 3.4804617614e+01 4.5085997151e+01 1.9970647211e+02 6.1017427630e+01 7.5452420080e-03 1.9030275297e+02 -1.3754893906e+02 3.6704792101e+00 -1.3840778697e+02 7.5452420080e-03 1.5359698070e+01 1.2747568188e+01 5.1161851510e+01 7.3593861399e+00 3.2935235911e+01 4.9642294331e+00 6.2912088835e+00 5.8981507398e+01
18 3.7500000000e-01 2.6666666667e+00 1.9811145761e+01 -1.5192713621e+01 3.0006978275e+02 4.0496483285e+01 2.0282928584e-03 1.6939822452e+02 -1.3203074227e+02 9.9913471627e+00 -8.9358360316e+01 2.0282928584e-03 1.6756584952e+01 2.5018319717e+01 9.6805854108e+01 9.2826842340e+00 3.8993666523e+01 6.6090856717e+00 1.4065510381e+01 4.4739501173e+01
19 5.0000000000e-01 2.0000000000e+00 3.1078209375e+01 9.7750421526e-01 2.8072073624e+02 2.3630845293e+01 9.4692383969e-04 1.4226306311e+02 -1.2803054508e+02 4.1720991574e+01 -1.4050409799e+02 9.4692383969e-04 3.5150092832e+01 3.4437732519e+01 1.5068632777e+02 1.5568596247e+01 5.9895366204e+01 1.2152194119e+01 4.4339110949e+01 3.2098508259e+01
20 7.5000000000e-01 1.3333333333e+00 2.2202358119e+01 -1.5105060212e+02 1.8297081679e+02 4.0381278587e+01 4.8556897195e-04 5.9609382797e+01 -1.3661518416e+02 2.9360847370e+01 -1.3322492493e+02 4.8556897195e-04 2.6756826605e+01 3.7053983647e+01 1.0306264369e+02 1.6357920486e+01 2.9732060571e+01 1.4441464439e+01 2.6328428830e+01 2.6638478853e+01
21 1.0000000000e+00 1.0000000000e+00 2.0141313837e+02 -3.9642468829e+01 1.2450119453e+03 -1.6642143834e+02 8.3444887217e-05 4.1321240276e+01 1.2388481787e+02 5.7793087565e+02 -5.2634102076e+01 8.3444887217e-05 4.2392885822e+02 3.6000000000e+02 2.2428379410e+03 6.4254121306e+01 1.5342552971e+02 3.6000000000e+02 1.1618730174e+03 3.6000000000e+02

48
Samples/RRMS/param.dat Normal file
View File

@@ -0,0 +1,48 @@
NUM_OUT
2
SAMPLING_FREQ
32
NUM_SECTION
1
SEGMENT
10
65536 2 3 4
32768 2 3 4
16384 2 3 4
8192 2 3 4
4096 2 3 4
2048 2 3 4
1024 2 3 4
512 2 3 4
256 2 3 4
128 2 3 4
ROTATION
0.0
AZIMUTH
0.0 90.0
0.0 90.0
0.0 90.0
OUTPUT_RHOA_PHS
PREWHITENING
0
10
5
PROCEDURE
1
ERROR_ESTIMATION
1
DATA_FILES
2764800
../ex.txt
0
../ey.txt
0
../hx.txt
0
../hy.txt
0
../hrx.txt
0
../hry.txt
0
END

View File

@@ -0,0 +1,21 @@
frequency,period,resp_real_0_2,resp_imag_0_2,resp_real_0_3,resp_imag_0_3,coherence_0_2+3,resp_real_1_2,resp_imag_1_2,resp_real_1_3,resp_imag_1_3,coherence_1_2+3,dresp_0_2,dresp_0_3,dresp_1_2,dresp_1_3
1.4648437500e-03,6.8266666667e+02,3.7170796163e-01,4.1314324373e-01,3.2870014945e-01,4.4129714577e-01,8.9973917276e-01,-6.7187642587e-01,-8.3989416958e-01,-1.5594261737e-01,-1.5826996724e-01,9.5233260437e-01,2.0476067380e-02,2.0153084204e-02,1.9290207924e-02,1.9241379181e-02
1.9531250000e-03,5.1200000000e+02,4.4988510272e-01,4.7226996340e-01,3.8399619001e-01,5.3884034554e-01,9.0762085300e-01,-8.0764751289e-01,-1.0086590317e+00,-1.7636027481e-01,-2.0879407310e-01,9.6762206017e-01,2.2068855922e-02,2.4970224693e-02,1.7156950165e-02,2.2645003835e-02
2.9296875000e-03,3.4133333333e+02,5.0500346283e-01,6.0905588236e-01,4.8165364720e-01,7.3475708289e-01,8.7725934040e-01,-9.3778371126e-01,-1.3123015244e+00,-1.7514609390e-01,-2.5274020819e-01,9.4176032684e-01,2.2632154980e-02,2.6101263448e-02,2.0112477022e-02,2.7782237369e-02
3.9062500000e-03,2.5600000000e+02,6.3336409438e-01,7.0411283299e-01,4.7533779502e-01,8.9033348187e-01,8.5732632366e-01,-1.2066727908e+00,-1.5370316746e+00,-1.7534750487e-01,-3.1131924641e-01,9.3463939198e-01,3.0056852933e-02,3.4632306809e-02,2.6714018234e-02,3.2546542262e-02
5.8593750000e-03,1.7066666667e+02,8.2372516745e-01,9.3312506160e-01,6.4703069797e-01,1.1321845207e+00,7.8685932594e-01,-1.5567931963e+00,-1.9313128716e+00,-2.8539710697e-01,-3.4176063746e-01,9.0661227178e-01,3.1134762749e-02,3.8046826777e-02,2.9471783455e-02,3.8696753830e-02
7.8125000000e-03,1.2800000000e+02,9.6961564692e-01,1.0818661787e+00,8.2119478794e-01,1.3393824605e+00,7.6301287094e-01,-1.8298223717e+00,-2.2699640636e+00,-3.7276727742e-01,-3.9587664209e-01,8.9042963299e-01,3.9734473874e-02,4.9738603749e-02,4.0631642345e-02,4.5695385483e-02
1.1718750000e-02,8.5333333333e+01,1.3696099030e+00,1.2657744828e+00,1.0906645861e+00,1.7876295724e+00,7.0568344865e-01,-2.4158528204e+00,-2.8868466929e+00,-4.4831724068e-01,-6.0135916495e-01,8.3234334691e-01,4.1444331150e-02,5.5301656768e-02,4.6640247476e-02,5.8687425702e-02
1.5625000000e-02,6.4000000000e+01,1.5750342011e+00,1.4153352946e+00,1.3664861022e+00,2.1078783535e+00,6.3151710006e-01,-2.9310839653e+00,-3.2436169762e+00,-6.4088766373e-01,-5.6887146705e-01,7.7865956962e-01,5.9404740172e-02,7.5302606759e-02,6.5209365722e-02,8.1466831280e-02
2.3437500000e-02,4.2666666667e+01,1.8824269968e+00,1.5834372672e+00,1.7719873403e+00,2.6696499328e+00,5.1676899773e-01,-3.7006596458e+00,-3.8896049785e+00,-6.7782122777e-01,-9.5694661536e-01,6.9813188573e-01,6.1849473428e-02,8.3845790860e-02,6.8291018558e-02,9.2143894119e-02
3.1250000000e-02,3.2000000000e+01,2.4121759935e+00,1.7353974183e+00,2.2096888999e+00,3.3274906477e+00,4.4535065602e-01,-4.4898138524e+00,-4.3939268051e+00,-8.5243560071e-01,-1.0479750093e+00,6.2510658343e-01,9.2099596351e-02,1.2339454824e-01,9.9798132210e-02,1.3481105444e-01
4.6875000000e-02,2.1333333333e+01,3.1910692923e+00,2.0320656370e+00,2.5174330933e+00,4.2780175380e+00,3.1049538562e-01,-5.5465049161e+00,-4.9887274554e+00,-8.9351882813e-01,-1.0676203246e+00,4.2061086650e-01,1.1745846893e-01,1.5034259177e-01,1.2793828320e-01,1.6462772392e-01
6.2500000000e-02,1.6000000000e+01,3.7167217626e+00,2.2649818988e+00,3.3447846899e+00,5.3188296932e+00,2.1119255836e-01,-5.9687031811e+00,-5.7840528689e+00,-1.1403292528e+00,-1.2417088242e+00,2.6854473703e-01,1.9357390099e-01,2.5739677645e-01,2.1118844238e-01,2.7577250591e-01
9.3750000000e-02,1.0666666667e+01,3.7147552433e+00,2.1827838639e+00,4.4792692664e+00,7.0999084505e+00,1.0806514363e-01,-6.7361833599e+00,-6.7599920806e+00,-1.4330693869e+00,-2.2324728506e+00,1.1000148190e-01,2.5832662080e-01,3.5317574278e-01,2.8037683201e-01,3.9030122539e-01
1.2500000000e-01,8.0000000000e+00,4.5248078117e+00,1.7148721474e+00,5.3302195115e+00,8.0090424041e+00,4.7239197846e-02,-8.2075743408e+00,-7.2063967218e+00,-1.2882151817e+00,-1.5420224083e+00,4.7239197846e-02,4.6741675676e-01,6.3403769126e-01,4.6163269310e-01,6.4805552956e-01
1.8750000000e-01,5.3333333333e+00,3.8825870402e+00,1.8128336980e+00,6.1435724504e+00,9.7529949310e+00,1.7617568989e-02,-9.0188334027e+00,-9.5963676820e+00,-1.4701223363e+00,-1.0524032689e+00,1.7617568989e-02,6.7286181123e-01,9.1854997818e-01,7.3053903070e-01,9.6595067357e-01
2.5000000000e-01,4.0000000000e+00,4.6569933261e+00,4.6709940246e+00,7.6556823753e+00,1.3821129386e+01,7.5452420080e-03,-1.1380151653e+01,-1.0410119575e+01,-1.6019654290e+00,-1.4219021686e+00,7.5452420080e-03,1.4554230752e+00,2.0238354267e+00,1.3346372869e+00,1.8356831929e+00
3.7500000000e-01,2.6666666667e+00,5.8817311740e+00,-1.5972278172e+00,1.8037653855e+01,1.5403697156e+01,2.0282928584e-03,-1.1932312433e+01,-1.3237884687e+01,4.8469904838e-02,-4.3279818159e+00,2.0282928584e-03,2.5775159198e+00,3.8261424007e+00,2.0512107625e+00,3.0465906946e+00
5.0000000000e-01,2.0000000000e+00,8.8132236485e+00,1.5037406383e-01,2.4270149278e+01,1.0618930956e+01,9.4692383969e-04,-1.1618611763e+01,-1.4854814657e+01,-7.8809573017e+00,-6.4956132077e+00,9.4692383969e-04,4.9846938608e+00,7.1101147657e+00,3.9699693656e+00,5.4268732534e+00
7.5000000000e-01,1.3333333333e+00,-7.9844835846e+00,-4.4166576540e+00,1.9953497599e+01,1.6970518452e+01,4.8556897195e-04,-1.0865807590e+01,-1.0269830131e+01,-7.1862838138e+00,-7.6459468076e+00,4.8556897195e-04,5.4982019907e+00,7.3772755176e+00,3.7286647286e+00,4.7046388276e+00
1.0000000000e+00,1.0000000000e+00,2.4436696847e+01,-2.0246321618e+01,-7.6693733746e+01,-1.8523793629e+01,8.3444887217e-05,-8.0137565169e+00,1.1932556636e+01,3.2624372311e+01,-4.2723584934e+01,8.3444887217e-05,3.3396741085e+01,7.1066698734e+01,2.6684923591e+01,5.4035070700e+01
1 frequency period resp_real_0_2 resp_imag_0_2 resp_real_0_3 resp_imag_0_3 coherence_0_2+3 resp_real_1_2 resp_imag_1_2 resp_real_1_3 resp_imag_1_3 coherence_1_2+3 dresp_0_2 dresp_0_3 dresp_1_2 dresp_1_3
2 1.4648437500e-03 6.8266666667e+02 3.7170796163e-01 4.1314324373e-01 3.2870014945e-01 4.4129714577e-01 8.9973917276e-01 -6.7187642587e-01 -8.3989416958e-01 -1.5594261737e-01 -1.5826996724e-01 9.5233260437e-01 2.0476067380e-02 2.0153084204e-02 1.9290207924e-02 1.9241379181e-02
3 1.9531250000e-03 5.1200000000e+02 4.4988510272e-01 4.7226996340e-01 3.8399619001e-01 5.3884034554e-01 9.0762085300e-01 -8.0764751289e-01 -1.0086590317e+00 -1.7636027481e-01 -2.0879407310e-01 9.6762206017e-01 2.2068855922e-02 2.4970224693e-02 1.7156950165e-02 2.2645003835e-02
4 2.9296875000e-03 3.4133333333e+02 5.0500346283e-01 6.0905588236e-01 4.8165364720e-01 7.3475708289e-01 8.7725934040e-01 -9.3778371126e-01 -1.3123015244e+00 -1.7514609390e-01 -2.5274020819e-01 9.4176032684e-01 2.2632154980e-02 2.6101263448e-02 2.0112477022e-02 2.7782237369e-02
5 3.9062500000e-03 2.5600000000e+02 6.3336409438e-01 7.0411283299e-01 4.7533779502e-01 8.9033348187e-01 8.5732632366e-01 -1.2066727908e+00 -1.5370316746e+00 -1.7534750487e-01 -3.1131924641e-01 9.3463939198e-01 3.0056852933e-02 3.4632306809e-02 2.6714018234e-02 3.2546542262e-02
6 5.8593750000e-03 1.7066666667e+02 8.2372516745e-01 9.3312506160e-01 6.4703069797e-01 1.1321845207e+00 7.8685932594e-01 -1.5567931963e+00 -1.9313128716e+00 -2.8539710697e-01 -3.4176063746e-01 9.0661227178e-01 3.1134762749e-02 3.8046826777e-02 2.9471783455e-02 3.8696753830e-02
7 7.8125000000e-03 1.2800000000e+02 9.6961564692e-01 1.0818661787e+00 8.2119478794e-01 1.3393824605e+00 7.6301287094e-01 -1.8298223717e+00 -2.2699640636e+00 -3.7276727742e-01 -3.9587664209e-01 8.9042963299e-01 3.9734473874e-02 4.9738603749e-02 4.0631642345e-02 4.5695385483e-02
8 1.1718750000e-02 8.5333333333e+01 1.3696099030e+00 1.2657744828e+00 1.0906645861e+00 1.7876295724e+00 7.0568344865e-01 -2.4158528204e+00 -2.8868466929e+00 -4.4831724068e-01 -6.0135916495e-01 8.3234334691e-01 4.1444331150e-02 5.5301656768e-02 4.6640247476e-02 5.8687425702e-02
9 1.5625000000e-02 6.4000000000e+01 1.5750342011e+00 1.4153352946e+00 1.3664861022e+00 2.1078783535e+00 6.3151710006e-01 -2.9310839653e+00 -3.2436169762e+00 -6.4088766373e-01 -5.6887146705e-01 7.7865956962e-01 5.9404740172e-02 7.5302606759e-02 6.5209365722e-02 8.1466831280e-02
10 2.3437500000e-02 4.2666666667e+01 1.8824269968e+00 1.5834372672e+00 1.7719873403e+00 2.6696499328e+00 5.1676899773e-01 -3.7006596458e+00 -3.8896049785e+00 -6.7782122777e-01 -9.5694661536e-01 6.9813188573e-01 6.1849473428e-02 8.3845790860e-02 6.8291018558e-02 9.2143894119e-02
11 3.1250000000e-02 3.2000000000e+01 2.4121759935e+00 1.7353974183e+00 2.2096888999e+00 3.3274906477e+00 4.4535065602e-01 -4.4898138524e+00 -4.3939268051e+00 -8.5243560071e-01 -1.0479750093e+00 6.2510658343e-01 9.2099596351e-02 1.2339454824e-01 9.9798132210e-02 1.3481105444e-01
12 4.6875000000e-02 2.1333333333e+01 3.1910692923e+00 2.0320656370e+00 2.5174330933e+00 4.2780175380e+00 3.1049538562e-01 -5.5465049161e+00 -4.9887274554e+00 -8.9351882813e-01 -1.0676203246e+00 4.2061086650e-01 1.1745846893e-01 1.5034259177e-01 1.2793828320e-01 1.6462772392e-01
13 6.2500000000e-02 1.6000000000e+01 3.7167217626e+00 2.2649818988e+00 3.3447846899e+00 5.3188296932e+00 2.1119255836e-01 -5.9687031811e+00 -5.7840528689e+00 -1.1403292528e+00 -1.2417088242e+00 2.6854473703e-01 1.9357390099e-01 2.5739677645e-01 2.1118844238e-01 2.7577250591e-01
14 9.3750000000e-02 1.0666666667e+01 3.7147552433e+00 2.1827838639e+00 4.4792692664e+00 7.0999084505e+00 1.0806514363e-01 -6.7361833599e+00 -6.7599920806e+00 -1.4330693869e+00 -2.2324728506e+00 1.1000148190e-01 2.5832662080e-01 3.5317574278e-01 2.8037683201e-01 3.9030122539e-01
15 1.2500000000e-01 8.0000000000e+00 4.5248078117e+00 1.7148721474e+00 5.3302195115e+00 8.0090424041e+00 4.7239197846e-02 -8.2075743408e+00 -7.2063967218e+00 -1.2882151817e+00 -1.5420224083e+00 4.7239197846e-02 4.6741675676e-01 6.3403769126e-01 4.6163269310e-01 6.4805552956e-01
16 1.8750000000e-01 5.3333333333e+00 3.8825870402e+00 1.8128336980e+00 6.1435724504e+00 9.7529949310e+00 1.7617568989e-02 -9.0188334027e+00 -9.5963676820e+00 -1.4701223363e+00 -1.0524032689e+00 1.7617568989e-02 6.7286181123e-01 9.1854997818e-01 7.3053903070e-01 9.6595067357e-01
17 2.5000000000e-01 4.0000000000e+00 4.6569933261e+00 4.6709940246e+00 7.6556823753e+00 1.3821129386e+01 7.5452420080e-03 -1.1380151653e+01 -1.0410119575e+01 -1.6019654290e+00 -1.4219021686e+00 7.5452420080e-03 1.4554230752e+00 2.0238354267e+00 1.3346372869e+00 1.8356831929e+00
18 3.7500000000e-01 2.6666666667e+00 5.8817311740e+00 -1.5972278172e+00 1.8037653855e+01 1.5403697156e+01 2.0282928584e-03 -1.1932312433e+01 -1.3237884687e+01 4.8469904838e-02 -4.3279818159e+00 2.0282928584e-03 2.5775159198e+00 3.8261424007e+00 2.0512107625e+00 3.0465906946e+00
19 5.0000000000e-01 2.0000000000e+00 8.8132236485e+00 1.5037406383e-01 2.4270149278e+01 1.0618930956e+01 9.4692383969e-04 -1.1618611763e+01 -1.4854814657e+01 -7.8809573017e+00 -6.4956132077e+00 9.4692383969e-04 4.9846938608e+00 7.1101147657e+00 3.9699693656e+00 5.4268732534e+00
20 7.5000000000e-01 1.3333333333e+00 -7.9844835846e+00 -4.4166576540e+00 1.9953497599e+01 1.6970518452e+01 4.8556897195e-04 -1.0865807590e+01 -1.0269830131e+01 -7.1862838138e+00 -7.6459468076e+00 4.8556897195e-04 5.4982019907e+00 7.3772755176e+00 3.7286647286e+00 4.7046388276e+00
21 1.0000000000e+00 1.0000000000e+00 2.4436696847e+01 -2.0246321618e+01 -7.6693733746e+01 -1.8523793629e+01 8.3444887217e-05 -8.0137565169e+00 1.1932556636e+01 3.2624372311e+01 -4.2723584934e+01 8.3444887217e-05 3.3396741085e+01 7.1066698734e+01 2.6684923591e+01 5.4035070700e+01

BIN
Samples/ex.txt.gz Normal file

Binary file not shown.

BIN
Samples/ey.txt.gz Normal file

Binary file not shown.

BIN
Samples/hrx.txt.gz Normal file

Binary file not shown.

BIN
Samples/hry.txt.gz Normal file

Binary file not shown.

BIN
Samples/hx.txt.gz Normal file

Binary file not shown.

BIN
Samples/hy.txt.gz Normal file

Binary file not shown.

103
THIRD_PARTY_NOTICES Normal file
View File

@@ -0,0 +1,103 @@
The source codes of TRACMT use the following third parties.
1. CLAPACK
2. MT19937-64 (2004/9/29 version).
The license terms of those third parties are desribed below.
--------------------------------------------------------------------------------
CLAPACK
https://www.netlib.org/clapack/
Copyright (c) 1992-2008 The University of Tennessee. All rights reserved.
$COPYRIGHT$
Additional copyrights may follow
$HEADER$
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer listed
in this license in the documentation and/or other materials
provided with the distribution.
- Neither the name of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
MT19937-64 (2004/9/29 version).
http://math.sci.hiroshima-u.ac.jp/m-mat/MT/mt64.html
A C-program for MT19937-64 (2004/9/29 version).
Coded by Takuji Nishimura and Makoto Matsumoto.
This is a 64-bit version of Mersenne Twister pseudorandom number
generator.
Before using, initialize the state by using init_genrand64(seed)
or init_by_array64(init_key, key_length).
Copyright (C) 2004, Makoto Matsumoto and Takuji Nishimura,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The names of its contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
References:
T. Nishimura, ``Tables of 64-bit Mersenne Twisters''
ACM Transactions on Modeling and
Computer Simulation 10. (2000) 348--357.
M. Matsumoto and T. Nishimura,
``Mersenne Twister: a 623-dimensionally equidistributed
uniform pseudorandom number generator''
ACM Transactions on Modeling and
Computer Simulation 8. (Jan. 1998) 3--30.
Any feedback is very welcome.
http://www.math.hiroshima-u.ac.jp/~m-mat/MT/emt.html
email: m-mat @ math.sci.hiroshima-u.ac.jp (remove spaces)
--------------------------------------------------------------------------------

BIN
docs/Manual_Of_TRACMT.pdf Normal file

Binary file not shown.

3820
src/Analysis.cpp Normal file

File diff suppressed because it is too large Load Diff

281
src/Analysis.h Normal file
View File

@@ -0,0 +1,281 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_ANALYSIS
#define DBLDEF_ANALYSIS
#include "CommonParameters.h"
#include "CalibrationFunction.h"
#include "RobustWeightHuber.h"
#include "RobustWeightThomson.h"
#include "RobustWeightTukeysBiweights.h"
#include <vector>
// Class of analysis
class Analysis{
public:
// Default constructer
Analysis();
// Destructer
virtual ~Analysis();
// Exexute analysis
void run( std::vector<CommonParameters::DataFileSet>& dataFileSets );
// Set object of M-estimator with Huber weight
void setRobustWeightHuber( const int index, const RobustWeightHuber* const ptrRobustWeight );
// Set object of M-estimator with Thomson weight
void setRobustWeightThomson( const int index, const RobustWeightThomson* const ptrRobustWeight );
// Set object of M-estimator with Tukey's biweights
void setRobustWeightTukeysBiweights( const int index, const RobustWeightTukeysBiweights* const ptrRobustWeight );
// Test function
void test() const;
// Test function 2
void test2( std::vector<CommonParameters::DataFileSet>& dataFileSets );
// Test function 3
void test3() const;
protected:
// Calculate apparent resistivity
double calcApparentResistivity( const double freq, const std::complex<double>& Z ) const;
// Calculate error of apparent resistivity
double calcApparentResistivityError( const double freq, const std::complex<double>& Z, const double dZ ) const;
// Calculate diagonal components of hat matrix
double calculateDiagonalComponentsOfHatMatrix( const int numSegments, const int channelX, const int channelY,
std::complex<double>** data, const double* const weights, double* hatDiagonals ) const;
// Calculate phase
double calcPhase( const std::complex<double>& Z ) const;
// Calculate error of phase
double calcPhaseError( const std::complex<double>& Z, const double dZ ) const;
// Calculate response functions by iteratively reweighted least squares
void calculateResponseFunctionsByIRWLS( const int iRobustWeight, const std::complex<double>* const out, const std::complex<double>* const in0,
const std::complex<double>* const in1, const int numSegments, const bool fixScale, double& scale, const double* const weightsPrior,
double* weights, std::complex<double>* residuals, std::complex<double>& resp0, std::complex<double>& resp1, double& coherence,
std::vector<std::string>& titles, std::vector<double>* outputValues, const bool priorityOnFirst = true ) const;
// Calculate response functions by iteratively reweighted remote reference
void calculateResponseFunctionsByIRWLSRemoteReference(const int iRobustWeight, const std::complex<double>* const out,
const std::complex<double>* const in0, const std::complex<double>* const in1,
const std::complex<double>* const rr1, const std::complex<double>* const rr2,
const int numSegments, const bool fixScale, double& scale, const double* const weightsPrior,
double* weights, std::complex<double>* residuals, std::complex<double>& resp0, std::complex<double>& resp1, double& coherence,
std::vector<std::string>& titles, std::vector<double>* outputValues) const;
// Calculate response function by the orinary remote reference method
double calculateResponseFunctionByOrdinaryRemoteReference( const int numSegments, const std::complex<double>* const out,
const std::complex<double>* const in1, const std::complex<double>* const in2,
const std::complex<double>* const rr1, const std::complex<double>* const rr2,
std::complex<double>& resp1, std::complex<double>& resp2 ) const;
// Calculate response function by the ordinary weighted square method
double calculateResponseFunctionByWLS( const std::complex<double>* const out, const std::complex<double>* const in0,
const std::complex<double>* const in1, const int numSegments, const double* const weights, std::complex<double>* residuals,
std::complex<double>& resp0, std::complex<double>& resp1, double& coherence, const bool priorityOnFirst = true ) const;
// Auxiliary function for calculating response function by the weighted leaset square method
void calculateResponseFunctionByWLSAux( const int numSegments, const std::complex<double>* const out,
const std::complex<double>* const in1, const std::complex<double>* const in2, const double* const weights,
std::complex<double>& resp1, std::complex<double>& resp2, const bool priorityOnFirst = true ) const;
// Calculate response function by the weighted leaset square method for bootstrap
void calculateResponseFunctionByWLSForBootstrap( const int numSegments, const int* const segmentIndexes,
const std::complex<double>* const out, const std::complex<double>* const in1, const std::complex<double>* const in2,
const double* const weights, std::complex<double>& resp1, std::complex<double>& resp2, const bool priorityOnFirst = true ) const;
// Calculate response function by the weighted remote reference method
double calculateResponseFunctionByWLSRemoteReference(const std::complex<double>* const out,
const std::complex<double>* const in1, const std::complex<double>* const in2,
const std::complex<double>* const rr1, const std::complex<double>* const rr2,
const int numSegments, const double* const weights, std::complex<double>* residuals,
std::complex<double>& resp1, std::complex<double>& resp2, double& coherence ) const;
// Auxiliary function for calculating response function by the weighted remote reference method
void calculateResponseFunctionByWLSRemoteReferenceAux(const int numSegments, const std::complex<double>* const out,
const std::complex<double>* const in1, const std::complex<double>* const in2,
const std::complex<double>* const rr1, const std::complex<double>* const rr2,
const double* const weights, std::complex<double>& resp1, std::complex<double>& resp2) const;
// Calculate response function by the weighted remote reference method for bootstrap
void calculateResponseFunctionByWLSRemoteReferenceForBootstrap(const int numSegments, const int* const segmentIndexes,
const std::complex<double>* const out,
const std::complex<double>* const in1, const std::complex<double>* const in2,
const std::complex<double>* const rr1, const std::complex<double>* const rr2,
const double* const weights, std::complex<double>& resp1, std::complex<double>& resp2) const;
// Get pointer to M-estimators
RobustWeight* getPointerToRobustWeight(const int iRobustWeight) const;
// Output spectral density functions to cvg file
void outputSpectralDensityFunctionsToCvgFile( const int numSegments, const double timeLength, const std::complex<double>* const out,
const std::complex<double>* const in1, const std::complex<double>* const in2, const double* const weights ) const;
// Output spectral density functions to cvg file
void outputSpectralDensityFunctionsToCvgFile( const int numSegments, const double timeLength, const std::complex<double>* const out,
const std::complex<double>* const in1, const std::complex<double>* const in2, const std::complex<double>* const rr1, const std::complex<double>* const rr2 ) const;
// Merge sections
void mergeSections( std::vector<CommonParameters::DataFileSet>& dataFileSets ) const;
private:
// Copy constructer
Analysis(const Analysis& rhs);
// Assignment operator
Analysis& operator=(const Analysis& rhs);
// Decimation
void decimation( std::vector<CommonParameters::DataFileSet>& dataFileSets ) const;
// Read time-series data
void readTimeSeriesData( std::vector<CommonParameters::DataFileSet>& dataFileSets );
// Read calibration files
void readCalibrationFiles( const std::vector<double>& freq );
// Read one time-series data
void readOneTimeSeriesData( const std::string& fileName, const int numSkipData, const int numDataPoints, double* data );
// Perform preprocessing
void preprocessing( std::vector<CommonParameters::DataFileSet>& dataFileSets );
// Convert time-series data to frequency-domain data
void convertToFrequencyData( const int segmentLength, const std::vector<CommonParameters::DataFileSet>& dataFileSets,
int& numSegmentsTotal, std::complex<double>*** cdata, std::vector< std::pair<std::string, std::string> >& times, std::vector<double>* meanSquares );
// Perform calibration correction for all channels
void calibrationCorrectionAllChannels( const int numChannels, const int numSegmentsTotal, const double freq, std::complex<double>** ftval ) const;
// Perform calibration correction for main analyss
void calibrationCorrection(const int iChan, const int numSegmentsTotal, const double freq, std::complex<double>* ftval, const bool afterPreprocessing, const bool afterTapering ) const;
// Calculate rotated fields
void calculateRotatedFields( const int numSegmentsTotal, std::complex<double>** ftval ) const;
virtual void calculateResponseFunctions( const int iSegLen, const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs ) = 0;
// Modify time-series data based on the EOF analysis
void modifyTimeSeriesBasedOnEOFAnalysis(std::vector<CommonParameters::DataFileSet>& dataFileSets);
// Output average spectrum
void outputAverageSpectrum( std::complex<double>** cdata, const int numData, const int section,
const bool afterPreprocessing, const bool afterCalibration ) const;
// Output average spectrum for the frequencies where response functions are estimated
void outputAverageSpectrum2( std::complex<double>** cdata, const int numData, const int section,
const bool afterPreprocessing, const bool afterCalibration ) const;
// Output spectrum
void outputSpectrum( std::complex<double>** cdata, const int numData, const int section,
const bool afterPreprocessing, const bool afterCalibration ) const;
// Output frequency-domain data
void outputFrequencyDomainData( const int iSegLen, const int freqDegree, const int numSegmentsTotal, std::complex<double>** ftval ) const;
// Output time-series data
void outputTimeSeriesData( const std::vector<CommonParameters::DataFileSet>& dataFileSets, const bool afterPreprocessing ) const;
// Output calibrated time-series data
void outputCalibratedTimeSeriesData(const std::vector<CommonParameters::DataFileSet>& dataFileSets) const;
// Evaluate characteristics of time-series data prior to the estimation of the response functions
void priorEvaluationOfTimeSeriesData( const int interval, const std::vector<CommonParameters::DataFileSet>& dataFileSets,
const bool afterPreprocessing ) const;
// Evaluate characteristics of frequency data from all data prior to the estimation of the response functions
void priorEvaluationOfFrequencyDataFromAllData( const std::vector<CommonParameters::DataFileSet>& dataFileSets,
const bool afterPreprocessing ) const;
// Evaluate characteristics of data segments
void priorEvaluationOfDataSegments( const int numSegmentsTotal, std::complex<double>** ftval,
const std::vector< std::pair<std::string, std::string> >& times, const double timeLength, const std::string& fileName ) const;
// Auxiliary function for evaluating characteristics of data segments
void priorEvaluationOfDataSegmentsAux( const std::vector<int>& segmentIndexes, std::complex<double>** ftval,
const std::vector< std::pair<std::string, std::string> >& times, const double timeLength, const int numSegments,
std::ofstream& ofs ) const;
// Select segments to be excluded by degree of magnetic polarization criteria
void selectSegmentsToBeExcludedByDegreeOfMagneticPolarizationCriteria( const int numSegmentsTotal, std::complex<double>** ftval, std::vector<bool>& remainingSegments ) const;
// Select segments to be excluded by mean square criteria
void selectSegmentsToBeExcludedByMeanSquareCriteria( const int numSegmentsTotal, const std::vector<double>* const meanSquares,
const std::vector< std::pair<std::string, std::string> >& times, std::vector<bool>& remainingSegments ) const;
// Select segments to be excluded by magnetic polarizatiton direction criteria
void selectSegmentsToBeExcludedByMagneticPolarizatitonDirectionCriteria( const int numSegmentsTotal, std::complex<double>** ftval, std::vector<bool>& remainingSegments ) const;
// Select segments to be excluded by square coherence criteria
void selectSegmentsToBeExcludedBySquareCoherenceCriteria( const int numSegmentsTotal, std::complex<double>** ftval,
std::vector<bool>& remainingSegments ) const;
// Auxiliary function for selecting segments to be excluded by square coherence criteria
double selectSegmentsToBeExcludedBySquareCoherenceCriteriaAux( const int numSegments, std::complex<double>** data ) const;
// Select segments to be excluded by square coherence criteria with random sampling
void selectSegmentsToBeExcludedBySquareCoherenceCriteriaWithRandomSampling( const int numSegmentsTotal, std::complex<double>** ftval,
std::vector<bool>& remainingSegments ) const;
// Auxiliary function for selecting segments to be excluded by square coherence criteria with random sampling
bool selectSegmentsToBeExcludedBySquareCoherenceCriteriaWithRandomSamplingAux( const std::vector<int>& segmentIndexes, std::complex<double>** ftval,
const std::vector< std::pair<std::string, std::string> >& times, const double timeLength ) const;
// Write header to the output file for apparent resistivity and phase
void writeHeaderToOutputFileForApparentResistivityAndPhase( std::ofstream& ofs ) const;
// Write header to the output file of response function
void writeHeaderToOutputFileForResponseFunctions( std::ofstream& ofs ) const;
// Arrays of calibration function
CalibrationFunction* m_calibrationFunctions;
// Coefficients of AR model
std::vector<double>* m_coefficientsOfARModel;
// M-estimators
RobustWeight* m_robustWeight[2];
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,161 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_ANALYSIS_MULTIVARIATE_REGRESSION
#define DBLDEF_ANALYSIS_MULTIVARIATE_REGRESSION
#include "Analysis.h"
#include <vector>
#include <complex>
// Class of analysis using multivariate regression
class AnalysisMultivariateRegression : public Analysis {
public:
// Default constructer
AnalysisMultivariateRegression();
// Destructer
virtual ~AnalysisMultivariateRegression();
private:
// Number of input and output variables
int m_numOfOutputAndInputVariables;
// Response functions between output/input variables and reference variables
std::vector< std::complex<double> >** m_responseFunctions;
// Frequencies
std::vector<double> m_frequencies;
// Calculate complex residuals
void calculateComplexResiduals( const int numSegmentsTotal, std::complex<double>** ftval,
std::complex<double>** resp, std::complex<double>** complexResiduals ) const;
// Calculate partial derivatives of responses for robust bootstrap
void calculatePartialDerivativesOfResponses( const int numSegments, const double paramC,
std::complex<double>** ftval, std::complex<double>** resp, const double* const variancesWithoutScale, const double scale,
std::complex<double>** complexResiduals, const double* const MD, const double* const weights,
double** derivativesRegardingResps, double** derivativesRegardingVariancesWithoutScale, double* derivativesRegardingScale ) const;
// Calculate partial derivatives of scale
void calculatePartialDerivativesOfScale( const int numSegments, const double paramB, const double paramC,
std::complex<double>** ftval, std::complex<double>** resp, const double* const variancesWithoutScale, const double scale,
std::complex<double>** complexResiduals, const double* const MD, const double* const weights,
double* derivativesRegardingResps, double* derivativesRegardingVariancesWithoutScale, double& derivativesRegardingScale ) const;
// Calculate partial derivatives of variances without scale for robust bootstrap
void calculatePartialDerivativesOfVariancesWithoutScale( const int numSegments, const double paramC,
std::complex<double>** ftval, std::complex<double>** resp, const double* const variancesWithoutScale, const double scale, const double determinant,
std::complex<double>** complexResiduals, const double* const MD, const double* const weights,
double** derivativesRegardingResps, double** derivativesRegardingVariancesWithoutScale, double* derivativesRegardingScale ) const;
// Calculate response functions
virtual void calculateResponseFunctions( const int iSegLen, const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs );
// Calculate response functions from two samples
bool calculateResponseFunctionsFromTwoSamples(
const std::complex<double>& out1,const std::complex<double>& x1, const std::complex<double>& y1,
const std::complex<double>& out2, const std::complex<double>& x2, const std::complex<double>& y2,
std::complex<double>& resp1, std::complex<double>& resp2 ) const;
// Calculate a vector for partial derivatives
void calculateVectorForPartialDerivatives( const int iSeg, std::complex<double>** ftval,
const double* const variancesWithoutScale, std::complex<double>** complexResiduals,
std::complex<double>** hSigmaMatrix, double* vector ) const;
// Determine candidates
void determineCandidates( const double freq, const int numSegmentsTotal, std::complex<double>** ftval,
const std::vector< std::pair<std::string, std::string> >& times, std::vector< std::pair<int,int> >& candidatesOfPairs,
std::vector< std::complex<double>** >& resp ) const;
// Determine candidates for later frequencies
void determineCandidatesForLaterFrequencies( const double freq, const int numSegmentsTotal, std::vector< std::complex<double>** >& resp ) const;
// Determine candidates by random sampling
void determineCandidatesByRandomSampling( const double freq, const int numSegmentsTotal, std::complex<double>** ftval,
const std::vector< std::pair<std::string, std::string> >& times, std::vector< std::pair<int,int> >& candidatesOfPairs,
std::vector< std::complex<double>** >& resp ) const;
// Improve candidate by I-steps
void improveCandidate( const int numSegmentsTotal, const int numOfMaxIterations,
const double convergenceCriteria, const bool initialCalculation, const double paramB, const double paramC,
std::complex<double>** ftval, std::complex<double>** resp, double* variancesWithoutScale, double& scale, double& determinant,
double* coherencesMin, double* covariancesLowerTriangleWithoutScale) const;
// Calculate Mahalanobis distances
void calculateMD(const int numSegmentsTotal, const int numOfOutputAndInputVariables, std::complex<double>** complexResiduals,
const double* const variancesWithoutScale, double* MD) const;
// Estimate error by fixed-weights bootstrap
void calculateMD(const int numSegmentsTotal, const int numOfOutputAndInputVariables, std::complex<double>** complexResiduals,
const double* const variancesWithoutScale, const double* const covariancesLowerTriangleWithoutScale, double* MD) const;
// Estimate error by robust bootstrap
void estimateErrorByRobustBootstrap(const int numSegmentsTotal, const double paramB, const double paramC,
std::complex<double>** ftval, std::complex<double>** respOrg, const double* const variancesWithoutScaleOrg,
const double* const covariancesLowerTriangleWithoutScaleOrg, const double scaleOrg, const double determinantOrg,
double** respErr) const;
// Estimate error by strict bootstrap
void estimateErrorByStrictBootstrap(const int numSegmentsTotal, const double paramB, const double paramC,
std::complex<double>** ftvalOrg, std::complex<double>** respOrg, const double* const variancesWithoutScaleOrg,
const double* const covariancesLowerTriangleWithoutScaleOrg, const double scaleOrg, const double determinantOrg, double** respErr) const;
// Estimate error by fixed-weights jackknife
void estimateErrorByFixedWeightsJackknife(const int numSegmentsTotal, const double paramB, const double paramC,
std::complex<double>** ftvalOrg, const std::complex<double>* const respOrg0, const std::complex<double>* const respOrg1,
std::complex<double>** respOrg, const double* const variancesWithoutScaleOrg, const double* const covariancesLowerTriangleWithoutScaleOrg,
const double scaleOrg, double** respErr) const;
// Estimate error by subset deletion jackknife
void estimateErrorBySubsetDeletionJackknife(const int numSegmentsTotal, std::complex<double>** ftvalOrg, std::complex<double>** respOrg,
const double* const variancesWithoutScaleOrg, const double* const covariancesLowerTriangleWithoutScaleOrg, const double scaleOrg,
const double determinantOrg, double** respErr) const;
// Estimate error by a parametric approach
void estimateErrorParametric(const int numSegmentsTotal, const double paramB, const double paramC,
std::complex<double>** ftval, std::complex<double>** respOrg, const double* const variancesWithoutScaleOrg,
const double* const covariancesLowerTriangleWithoutScaleOrg, const double scaleOrg, double** respErr) const;
// Get value of covariance matrix
double getValueOfCovarianceMatrix(const int dimension, const double* const variancesWithoutScaleOrg, const double* const covariancesLowerTriangleWithoutScaleOrg,
const int row, const int col) const;
// Write residuals
void writeResiduals( const std::string& fileName, const int numSegmentsTotal, const int numOfOutputAndInputVariables,
const std::vector< std::pair<std::string, std::string> >& times, std::complex<double>** complexResiduals,
const double* const MD, const double* const weights ) const;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,102 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_ANALYSIS_ORDINARY_REMOTE_REFERENCE
#define DBLDEF_ANALYSIS_ORDINARY_REMOTE_REFERENCE
#include "Analysis.h"
// Class of ordinary remote reference method
class AnalysisOrdinaryRemoteReference : public Analysis {
public:
// Default constructer
AnalysisOrdinaryRemoteReference();
// Destructer
virtual ~AnalysisOrdinaryRemoteReference();
private:
// Calculate partial derivatives of responses for robust bootstrap
void calculatePartialDerivativesOfResponses(const int numSegments, const double threshould, std::complex<double>** ftval,
const std::complex<double> resp0, const std::complex<double> resp1, const double scale, const std::complex<double>* const residuals,
const double* const weights, const int iOut, double** derivativesRegardingResps, double* derivativesRegardingScale) const;
// Calculate partial derivatives of scale
void calculatePartialDerivativesOfScale(const int numSegments, const double threshould, const double paramB, std::complex<double>** ftval,
const std::complex<double> resp0, const std::complex<double> resp1, const double scale, const std::complex<double>* const residuals,
const double* const weights, const int iOut, double* derivativesRegardingResps, double& derivativesRegardingScale) const;
// Calculate response functions
virtual void calculateResponseFunctions( const int iSegLen,const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs );
void calculateResponseFunctionsAux(const int iSegLen, const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs, const bool forJackknife, std::complex<double>* respOut0, std::complex<double>* respOut1,
double** hatDiagsOut) const;
// Calculate a vector for partial derivatives
void calculateVectorForPartialDerivatives(const int iSeg, std::complex<double>** ftval, const std::complex<double>* const residuals,
std::complex<double>* hSigmaMatrix, double* vector) const;
// Perform fixed-weights jackknife
void fixedWeightsJackknife(const double freq, const int numSegmentsTotal, double** weightsOrg, std::complex<double>** ftval,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs, const std::complex<double>* const resp0, const std::complex<double>* const resp1, double** hatDiagonals) const;
// Perform fixed-weights bootstrap
void fixedWeightsBootstrap(const double freq, const int numSegmentsTotal, double** weights, std::complex<double>** ftval,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs, const std::complex<double>* const resp0, const std::complex<double>* const resp1) const;
// Estimate errors by parametric method
void parametricErrorEstimation(const int numSegmentsTotal, const double* const weights, std::complex<double>** ftval,
const std::complex<double>* const residuals, const double scale, const bool noRobust, double& error0, double& error1) const;
// Estimate error by fixed-weights bootstrap
void robustBootstrap(const double freq, const int numSegmentsTotal, double** weightsOrg, double* scalesOrg, std::complex<double>** ftval,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs, const std::complex<double>* const resp0Org, const std::complex<double>* const resp1Org) const;
// Estimate errors by strict bootstrap
void strictBootstrap(const int iSegLen, const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs, const std::complex<double>* const resp0, const std::complex<double>* const resp1 ) const;
// Perform subset deletion jackknife
void subsetDeletionJackknife(const int iSegLen, const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs, const std::complex<double>* const resp0, const std::complex<double>* const resp1, double** hatDiagonals) const;
// Write residuals
void writeResiduals(const std::string& fileName, const int numSegmentsTotal,
const std::vector< std::pair<std::string, std::string> >& times, const std::vector<std::string>& titles, const std::vector<double>* outputValues) const;
};
#endif

View File

@@ -0,0 +1,188 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "AnalysisRepeatedMedian.h"
#include "Control.h"
#include "OutputFiles.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include "Util.h"
// Default constructer
AnalysisRepeatedMedian::AnalysisRepeatedMedian()
{
}
// Destructer
AnalysisRepeatedMedian::~AnalysisRepeatedMedian()
{
}
// Calculate response functions
void AnalysisRepeatedMedian::calculateResponseFunctions(const int iSegLen, const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs) {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeLogMessage("Calculate response functions by repeated median estimator");
ptrOutputFiles->writeCvgMessage("================================================================================");
ptrOutputFiles->writeCvgMessage("Now Frequency(Hz): " + Util::toString(freq) + ", Period(s): " + Util::toString(1.0 / freq));
ptrOutputFiles->writeCvgMessage("================================================================================");
const Control* const ptrControl = Control::getInstance();
const int in0 = ptrControl->getChannelIndex(CommonParameters::INPUT, 0);
const int in1 = ptrControl->getChannelIndex(CommonParameters::INPUT, 1);
const int numRemoteReferenceVariables = ptrControl->getNumRemoteReferenceVariables();
assert(numRemoteReferenceVariables >= 2);
const int rr0 = ptrControl->getChannelIndex(CommonParameters::REMOTE_REFERENCE, 0);
const int rr1 = ptrControl->getChannelIndex(CommonParameters::REMOTE_REFERENCE, 1);
const int numOutputVariables = ptrControl->getNumOutputVariables();
ofsResp << std::setprecision(10) << std::scientific << freq;
ofsResp << "," << std::setprecision(10) << std::scientific << 1.0 / freq;
if (ptrControl->doesOutputApparentResistivityAndPhase()) {
ofsRhoaPhs << std::setprecision(10) << std::scientific << freq;
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << 1.0 / freq;
}
std::complex<double>* respOut0 = new std::complex<double>[numOutputVariables];
std::complex<double>* respOut1 = new std::complex<double>[numOutputVariables];
double* dResp0 = new double[numOutputVariables];
double* dResp1 = new double[numOutputVariables];
for (int iOutVar = 0; iOutVar < numOutputVariables; ++iOutVar) {
ptrOutputFiles->writeCvgMessage("--------------------------------------------------------------------------------");
ptrOutputFiles->writeCvgAndLogMessage("Calculate response functions for output variable " + Util::toString(iOutVar));
ptrOutputFiles->writeCvgMessage("--------------------------------------------------------------------------------");
const double weights[2] = { 1.0, 1.0 };
std::complex<double> ftvalOut[2];
std::complex<double> ftvalIn0[2];
std::complex<double> ftvalIn1[2];
std::complex<double> ftvalRr0[2];
std::complex<double> ftvalRr1[2];
double* resp0RealMedian = new double[numSegmentsTotal];
double* resp0ImagMedian = new double[numSegmentsTotal];
double* resp1RealMedian = new double[numSegmentsTotal];
double* resp1ImagMedian = new double[numSegmentsTotal];
const int out = ptrControl->getChannelIndex(CommonParameters::OUTPUT, iOutVar);
for (int iSeg0 = 0; iSeg0 < numSegmentsTotal; ++iSeg0) {
double* resp0Real = new double[numSegmentsTotal - 1];
double* resp0Imag = new double[numSegmentsTotal - 1];
double* resp1Real = new double[numSegmentsTotal - 1];
double* resp1Imag = new double[numSegmentsTotal - 1];
int icount(0);
ftvalOut[0] = ftval[out][iSeg0];
ftvalIn0[0] = ftval[in0][iSeg0];
ftvalIn1[0] = ftval[in1][iSeg0];
ftvalRr0[0] = ftval[rr0][iSeg0];
ftvalRr1[0] = ftval[rr1][iSeg0];
for (int iSeg1 = 0; iSeg1 < numSegmentsTotal; ++iSeg1) {
if (iSeg0 != iSeg1) {
ftvalOut[1] = ftval[out][iSeg1];
ftvalIn0[1] = ftval[in0][iSeg1];
ftvalIn1[1] = ftval[in1][iSeg1];
ftvalRr0[1] = ftval[rr0][iSeg1];
ftvalRr1[1] = ftval[rr1][iSeg1];
std::complex<double> resp0(0.0, 0.0);
std::complex<double> resp1(0.0, 0.0);
calculateResponseFunctionByWLSRemoteReferenceAux(2, ftvalOut, ftvalIn0, ftvalIn1, ftvalRr0, ftvalRr1,
weights, resp0, resp1);
resp0Real[icount] = resp0.real();
resp0Imag[icount] = resp0.imag();
resp1Real[icount] = resp1.real();
resp1Imag[icount] = resp1.imag();
++icount;
}
}
resp0RealMedian[iSeg0] = Util::calculateMedian(numSegmentsTotal - 1, resp0Real);
resp0ImagMedian[iSeg0] = Util::calculateMedian(numSegmentsTotal - 1, resp0Imag);
resp1RealMedian[iSeg0] = Util::calculateMedian(numSegmentsTotal - 1, resp1Real);
resp1ImagMedian[iSeg0] = Util::calculateMedian(numSegmentsTotal - 1, resp1Imag);
delete[] resp0Real;
delete[] resp0Imag;
delete[] resp1Real;
delete[] resp1Imag;
}
const double respOut0Real = Util::calculateMedian(numSegmentsTotal, resp0RealMedian);
const double respOut0Imag = Util::calculateMedian(numSegmentsTotal, resp0ImagMedian);
const double respOut1Real = Util::calculateMedian(numSegmentsTotal, resp1RealMedian);
const double respOut1Imag = Util::calculateMedian(numSegmentsTotal, resp1ImagMedian);
// Output results
const double coherence = 1.0;
ofsResp << "," << std::setprecision(10) << std::scientific << respOut0Real;
ofsResp << "," << std::setprecision(10) << std::scientific << respOut0Imag;
ofsResp << "," << std::setprecision(10) << std::scientific << respOut1Real;
ofsResp << "," << std::setprecision(10) << std::scientific << respOut1Imag;
ofsResp << "," << std::setprecision(10) << std::scientific << coherence;
respOut0[iOutVar] = std::complex<double>(respOut0Real, respOut0Imag);
respOut1[iOutVar] = std::complex<double>(respOut1Real, respOut1Imag);
if (ptrControl->doesOutputApparentResistivityAndPhase()) {
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcApparentResistivity(freq, respOut0[iOutVar]);
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcPhase(respOut0[iOutVar]);
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcApparentResistivity(freq, respOut1[iOutVar]);
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcPhase(respOut1[iOutVar]);
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << coherence;
}
const double factor = 1.483 / sqrt(numSegmentsTotal);
const double dResp0Real = factor * Util::calculateMAD(numSegmentsTotal, respOut0Real, resp0RealMedian);
const double dResp0Imag = factor * Util::calculateMAD(numSegmentsTotal, respOut0Imag, resp0ImagMedian);
const double dResp1Real = factor * Util::calculateMAD(numSegmentsTotal, respOut1Real, resp1RealMedian);
const double dResp1Imag = factor * Util::calculateMAD(numSegmentsTotal, respOut1Imag, resp1ImagMedian);
dResp0[iOutVar] = sqrt(0.5 * (pow(dResp0Real, 2) + pow(dResp0Imag, 2)));
dResp1[iOutVar] = sqrt(0.5 * (pow(dResp1Real, 2) + pow(dResp1Imag, 2)));
delete[] resp0RealMedian;
delete[] resp0ImagMedian;
delete[] resp1RealMedian;
delete[] resp1ImagMedian;
}
for (int iOutVar = 0; iOutVar < numOutputVariables; ++iOutVar) {
ofsResp << "," << std::setprecision(10) << std::scientific << dResp0[iOutVar];
ofsResp << "," << std::setprecision(10) << std::scientific << dResp1[iOutVar];
if (ptrControl->doesOutputApparentResistivityAndPhase()) {
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcApparentResistivityError(freq, respOut0[iOutVar], dResp0[iOutVar]);
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcPhaseError(respOut0[iOutVar], dResp0[iOutVar]);
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcApparentResistivityError(freq, respOut1[iOutVar], dResp1[iOutVar]);
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcPhaseError(respOut1[iOutVar], dResp1[iOutVar]);
}
}
ofsResp << std::endl;
ofsResp.flush();
if (ptrControl->doesOutputApparentResistivityAndPhase()) {
ofsRhoaPhs << std::endl;
ofsRhoaPhs.flush();
}
delete[] respOut0;
delete[] respOut1;
delete[] dResp0;
delete[] dResp1;
}

View File

@@ -0,0 +1,54 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_REPEATED_MEDIAN
#define DBLDEF_REPEATED_MEDIAN
#include "Analysis.h"
// Class of repeated median estimator
class AnalysisRepeatedMedian : public Analysis {
public:
// Default constructer
AnalysisRepeatedMedian();
// Destructer
virtual ~AnalysisRepeatedMedian();
private:
// Calculate response functions
virtual void calculateResponseFunctions( const int iSegLen,const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs );
};
#endif

447
src/AnalysisTest.cpp Normal file
View File

@@ -0,0 +1,447 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "AnalysisTest.h"
#include "Control.h"
#include "OutputFiles.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <iostream>
#include <iomanip>
#ifdef _MERSENNE_TWISTER_ORIGINAL
#else
#include <random>
#endif
#include "Util.h"
#ifdef _MERSENNE_TWISTER_ORIGINAL
#include "mt64.h"
#endif
// Default constructer
AnalysisTest::AnalysisTest()
{
}
// Destructer
AnalysisTest::~AnalysisTest()
{
}
// Calculate response functions
void AnalysisTest::calculateResponseFunctions(const int iSegLen, const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs) {
// Estimate response functions
const Control* const ptrControl = Control::getInstance();
const int numOutputVariables = ptrControl->getNumOutputVariables();
const int numInputVariables = ptrControl->getNumInputVariables();
assert(numInputVariables == 2);
std::complex<double>* istf0 = new std::complex<double>[numOutputVariables + numInputVariables];
std::complex<double>* istf1 = new std::complex<double>[numOutputVariables + numInputVariables];
double coherenceMin(1.0);
int icount(0);
for (int iOut = 0; iOut < numOutputVariables; ++iOut, ++icount) {
const int index = ptrControl->getChannelIndex(CommonParameters::OUTPUT, iOut);
double coherence(0.0);
calculateResponseFunctionsAux(iSegLen, freqDegree, timeLength, freq, numSegmentsTotal, ftval, times, ofsResp, ofsRhoaPhs, false, index, istf0[icount], istf1[icount], coherence);
if (coherence < coherenceMin) {
coherenceMin = coherence;
}
}
for (int iInp = 0; iInp < numInputVariables; ++iInp, ++icount ) {
const int index = ptrControl->getChannelIndex(CommonParameters::INPUT, iInp);
double coherence(0.0);
calculateResponseFunctionsAux(iSegLen, freqDegree, timeLength, freq, numSegmentsTotal, ftval, times, ofsResp, ofsRhoaPhs, false, index, istf0[icount], istf1[icount], coherence);
if (coherence < coherenceMin) {
coherenceMin = coherence;
}
}
// Output response functions
const std::complex<double> Txx = istf0[numOutputVariables];
const std::complex<double> Txy = istf1[numOutputVariables];
const std::complex<double> Tyx = istf0[numOutputVariables + 1];
const std::complex<double> Tyy = istf1[numOutputVariables + 1];
const std::complex<double> det = Txx * Tyy - Txy * Tyx;
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
if (std::abs(det) < CommonParameters::EPS) {
ptrOutputFiles->writeErrorMessage("Determinant is too small: " + Util::toString(std::abs(det)));
}
ofsResp << std::setprecision(10) << std::scientific << freq;
ofsResp << "," << std::setprecision(10) << std::scientific << 1.0 / freq;
if (ptrControl->doesOutputApparentResistivityAndPhase()) {
ofsRhoaPhs << std::setprecision(10) << std::scientific << freq;
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << 1.0 / freq;
}
std::complex<double>* respOut0 = new std::complex<double>[numOutputVariables];
std::complex<double>* respOut1 = new std::complex<double>[numOutputVariables];
for (int iOut = 0; iOut < numOutputVariables; ++iOut) {
const int index = ptrControl->getChannelIndex(CommonParameters::OUTPUT, iOut);
const std::complex<double> U_x = istf0[index];
const std::complex<double> U_y = istf1[index];
respOut0[iOut] = (U_x * Tyy - U_y * Tyx) / det;
respOut1[iOut] = (U_y * Txx - U_x * Txy) / det;
ofsResp << "," << std::setprecision(10) << std::scientific << respOut0[iOut].real();
ofsResp << "," << std::setprecision(10) << std::scientific << respOut0[iOut].imag();
ofsResp << "," << std::setprecision(10) << std::scientific << respOut1[iOut].real();
ofsResp << "," << std::setprecision(10) << std::scientific << respOut1[iOut].imag();
ofsResp << "," << std::setprecision(10) << std::scientific << coherenceMin;
if (ptrControl->doesOutputApparentResistivityAndPhase()) {
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcApparentResistivity(freq, respOut0[iOut]);
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcPhase(respOut0[iOut]);
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcApparentResistivity(freq, respOut1[iOut]);
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcPhase(respOut1[iOut]);
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << coherenceMin;
}
}
if (ptrControl->getErrorEstimationMethod() == Control::STRICT_BOOTSTRAP) {
strictBootstrap(iSegLen, freqDegree, timeLength, freq, numSegmentsTotal, ftval, times, ofsResp, ofsRhoaPhs, respOut0, respOut1);
}
else {
ptrOutputFiles->writeErrorMessage("Unsupported error estimation method : " + Util::toString(ptrControl->getErrorEstimationMethod()));
}
delete[] istf0;
delete[] istf1;
delete[] respOut0;
delete[] respOut1;
}
void AnalysisTest::calculateResponseFunctionsAux(const int iSegLen, const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs, const bool forJackknife, const int out, std::complex<double>& respOut0, std::complex<double>& respOut1,
double& coherenceOut ) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeLogMessage("Calculate response functions by ordinary remote reference");
ptrOutputFiles->writeCvgMessage("================================================================================");
ptrOutputFiles->writeCvgMessage("Now Frequency(Hz): " + Util::toString(freq) + ", Period(s): " + Util::toString(1.0 / freq));
ptrOutputFiles->writeCvgMessage("================================================================================");
const Control* const ptrControl = Control::getInstance();
const int numRemoteReferenceVariables = ptrControl->getNumRemoteReferenceVariables();
assert(numRemoteReferenceVariables >= 2);
const int rr0 = ptrControl->getChannelIndex(CommonParameters::REMOTE_REFERENCE, 0);
const int rr1 = ptrControl->getChannelIndex(CommonParameters::REMOTE_REFERENCE, 1);
double* unitWeights = new double[numSegmentsTotal];
for (int iSeg = 0; iSeg < numSegmentsTotal; ++iSeg) {
unitWeights[iSeg] = 1.0;
}
ptrOutputFiles->writeCvgMessage("--------------------------------------------------------------------------------");
ptrOutputFiles->writeCvgAndLogMessage("Calculate response functions for output variable " + Util::toString(out));
ptrOutputFiles->writeCvgMessage("--------------------------------------------------------------------------------");
// Calculate response functions by the ordinary least square method
double coherence(0.0);
std::complex<double> resp0(0.0, 0.0);
std::complex<double> resp1(0.0, 0.0);
double* weights = new double[numSegmentsTotal];
double sumOfWeights(0.0);
for (int iSeg = 0; iSeg < numSegmentsTotal; ++iSeg) {
weights[iSeg] = 1.0;
sumOfWeights += weights[iSeg];
}
if (sumOfWeights < CommonParameters::EPS) {
ptrOutputFiles->writeErrorMessage("Sum of weights is too small: " + Util::toString(sumOfWeights));
}
std::complex<double>* residuals = new std::complex<double>[numSegmentsTotal];
ptrOutputFiles->writeCvgAndLogMessage("Calculate response functions by the ordinary least square method");
calculateResponseFunctionByWLSRemoteReference(ftval[out], ftval[rr0], ftval[rr1], ftval[rr0], ftval[rr1],
numSegmentsTotal, weights, residuals, resp0, resp1, coherence);
coherenceOut = coherence;
std::vector<std::string> titles;
std::vector<double>* outputValues = new std::vector<double>[numSegmentsTotal];
const bool outputResidual = !forJackknife && ptrControl->getOutputLevel() >= 2;
if (outputResidual) {
titles.push_back("OLS");
for (int iSeg = 0; iSeg < numSegmentsTotal; ++iSeg) {
outputValues[iSeg].push_back(residuals[iSeg].real());
outputValues[iSeg].push_back(residuals[iSeg].imag());
outputValues[iSeg].push_back(weights[iSeg]);
}
}
double absMaxResidual(0.0);
for (int iSeg = 0; iSeg < numSegmentsTotal; ++iSeg) {
const double absResidual = std::abs(residuals[iSeg]);
if (absResidual > absMaxResidual) {
absMaxResidual = absResidual;
}
}
if (absMaxResidual < CommonParameters::EPS) {
// Such a case where the remote reference field is equivalent to the input field
ptrOutputFiles->writeCvgMessage("Robust method is not performed because residuals is nearly zero");
}else{
double scale = RobustWeight::calculateScaleByMADN(numSegmentsTotal, residuals);
// Calculate response functions by regression using the first M-estimator
calculateResponseFunctionsByIRWLSRemoteReference(0, ftval[out], ftval[rr0], ftval[rr1], ftval[rr0], ftval[rr1],
numSegmentsTotal, false, scale, unitWeights, weights, residuals, resp0, resp1, coherence, titles, outputValues);
// Calculate response functions by regression using the second M-estimator
calculateResponseFunctionsByIRWLSRemoteReference(1, ftval[out], ftval[rr0], ftval[rr1], ftval[rr0], ftval[rr1],
numSegmentsTotal, true, scale, unitWeights, weights, residuals, resp0, resp1, coherence, titles, outputValues);
coherenceOut = coherence;
}
if (!forJackknife && ptrControl->getOutputLevel() > 0) {
// Output spectral density functions to cvg file
outputSpectralDensityFunctionsToCvgFile(numSegmentsTotal, timeLength, ftval[out], ftval[rr0], ftval[rr1], weights);
}
respOut0 = resp0;
respOut1 = resp1;
if (outputResidual) {
std::ostringstream oss;
oss << "segm" << iSegLen << "_index" << freqDegree << "_output" << out << "_residuals.csv";
writeResiduals(oss.str(), numSegmentsTotal, times, titles, outputValues);
}
// Release memory
delete[] residuals;
delete[] outputValues;
delete[] weights;
delete[] unitWeights;
}
// Estimate error by strict bootstrap
void AnalysisTest::strictBootstrap(const int iSegLen, const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs, const std::complex<double>* const resp0, const std::complex<double>* const resp1) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeLogMessage("Strict bootstrap is performed to estimate errors");
const Control* const ptrControl = Control::getInstance();
const int numOutputVariables = ptrControl->getNumOutputVariables();
const int numInputVariables = ptrControl->getNumInputVariables();
assert(numInputVariables == 2);
// Copy Fourier transformed values
const int numChannels = ptrControl->getNumberOfChannels();
std::complex<double>** ftvalForBootstrap = new std::complex<double>*[numChannels];
for (int iChan = 0; iChan < numChannels; ++iChan) {
ftvalForBootstrap[iChan] = new std::complex<double>[numSegmentsTotal];
}
#ifdef _DEBUG_WRITE
for (int iChan = 0; iChan < numChannels; ++iChan) {
for (int iSeg = 0; iSeg < numSegmentsTotal; ++iSeg) {
std::cout << iChan << " " << iSeg << " " << ftval[iChan][iSeg] << std::endl;
}
}
#endif
const int numOfSamples = ptrControl->getNumRepetitionsOfBootstrap();
std::complex<double>** resp0Sample = new std::complex<double>*[numOfSamples];
std::complex<double>** resp1Sample = new std::complex<double>*[numOfSamples];
int* segmentIndexes = new int[numSegmentsTotal];
ptrOutputFiles->stopToWriteCvgMessage();
ptrOutputFiles->stopToWriteLogMessage();
ptrOutputFiles->stopToWriteWarningMessage();
#ifdef _RAND
srand(1234);
#else
#ifdef _MERSENNE_TWISTER_ORIGINAL
init_genrand64(1234);
#else
std::mt19937_64 gen(1234);
std::uniform_int_distribution<int> uniformDistibution(0, numSegmentsTotal - 1);
#endif
#endif
for (int iSample = 0; iSample < numOfSamples; ++iSample) {
// Make bootstrap samples
for (int iSeg = 0; iSeg < numSegmentsTotal; ++iSeg) {
#ifdef _RAND
segmentIndexes[iSeg] = (rand() / RAND_MAX) * (numSegmentsTotal - 1);
#else
#ifdef _MERSENNE_TWISTER_ORIGINAL
segmentIndexes[iSeg] = static_cast<int>(genrand64_real1() * numSegmentsTotal);
#else
segmentIndexes[iSeg] = uniformDistibution(gen);
#endif
#endif
}
#ifdef _DEBUG_WRITE
for (int iSeg = 0; iSeg < numSegmentsTotal; ++iSeg) {
std::cout << iSeg << " " << segmentIndexes[iSeg] << std::endl;
}
#endif
// Copy data
for (int iChan = 0; iChan < numChannels; ++iChan) {
for (int icount = 0; icount < numSegmentsTotal; ++icount) {
const int iSeg = segmentIndexes[icount];
ftvalForBootstrap[iChan][icount] = ftval[iChan][iSeg];
}
}
std::complex<double>* istf0 = new std::complex<double>[numOutputVariables + numInputVariables];
std::complex<double>* istf1 = new std::complex<double>[numOutputVariables + numInputVariables];
int icount(0);
for (int iOut = 0; iOut < numOutputVariables; ++iOut, ++icount) {
const int index = ptrControl->getChannelIndex(CommonParameters::OUTPUT, iOut);
double coherence(0.0);
calculateResponseFunctionsAux(iSegLen, freqDegree, timeLength, freq, numSegmentsTotal, ftvalForBootstrap, times,
ofsResp, ofsRhoaPhs, true, index, istf0[icount], istf1[icount], coherence);
}
for (int iInp = 0; iInp < numInputVariables; ++iInp, ++icount) {
const int index = ptrControl->getChannelIndex(CommonParameters::INPUT, iInp);
double coherence(0.0);
calculateResponseFunctionsAux(iSegLen, freqDegree, timeLength, freq, numSegmentsTotal, ftvalForBootstrap, times,
ofsResp, ofsRhoaPhs, true, index, istf0[icount], istf1[icount], coherence);
}
#ifdef _DEBUG_WRITE
for (int i = 0; i < numOutputVariables + numInputVariables; ++i) {
std::cout << i << " " << iSample << " " << istf0[i] << " " << istf1[i] << std::endl;
}
#endif
resp0Sample[iSample] = new std::complex<double>[numOutputVariables];
resp1Sample[iSample] = new std::complex<double>[numOutputVariables];
const std::complex<double> Txx = istf0[numOutputVariables];
const std::complex<double> Txy = istf1[numOutputVariables];
const std::complex<double> Tyx = istf0[numOutputVariables + 1];
const std::complex<double> Tyy = istf1[numOutputVariables + 1];
const std::complex<double> det = Txx * Tyy - Txy * Tyx;
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
if (std::abs(det) < CommonParameters::EPS) {
ptrOutputFiles->writeErrorMessage("Determinant is too small: " + Util::toString(std::abs(det)));
}
for (int iOut = 0; iOut < numOutputVariables; ++iOut) {
const int index = ptrControl->getChannelIndex(CommonParameters::OUTPUT, iOut);
const std::complex<double> U_x = istf0[index];
const std::complex<double> U_y = istf1[index];
resp0Sample[iSample][iOut] = (U_x * Tyy - U_y * Tyx) / det;
resp1Sample[iSample][iOut] = (U_y * Txx - U_x * Txy) / det;
}
delete [] istf0;
delete [] istf1;
}
ptrOutputFiles->restartToWriteCvgMessage();
ptrOutputFiles->restartToWriteLogMessage();
ptrOutputFiles->restartToWriteWarningMessage();
#ifdef _DEBUG_WRITE
for (int iOut = 0; iOut < numOutputVariables; ++iOut) {
for (int iSample = 0; iSample < numOfSamples; ++iSample) {
std::cout << iOut << " " << iSample << " " << resp0Sample[iSample][iOut] << " " << resp1Sample[iSample][iOut] << std::endl;
}
}
#endif
// Calculate error of response functions
assert(numOfSamples > 2);
for (int iOut = 0; iOut < numOutputVariables; ++iOut) {
// Calculate average
std::complex<double> average0 = std::complex<double>(0.0, 0.0);
std::complex<double> average1 = std::complex<double>(0.0, 0.0);
for (int iSample = 0; iSample < numOfSamples; ++iSample) {
average0 += resp0Sample[iSample][iOut];
average1 += resp1Sample[iSample][iOut];
}
average0 /= static_cast<double>(numOfSamples);
average1 /= static_cast<double>(numOfSamples);
// Calculate variance
double variance0(0.0);
double variance1(0.0);
for (int iSample = 0; iSample < numOfSamples; ++iSample) {
variance0 += std::norm(resp0Sample[iSample][iOut] - average0);
variance1 += std::norm(resp1Sample[iSample][iOut] - average1);
}
variance0 /= static_cast<double>(2 * numOfSamples - 4);
variance1 /= static_cast<double>(2 * numOfSamples - 4);
const double dResp0 = sqrt(variance0);
const double dResp1 = sqrt(variance1);
ofsResp << "," << std::setprecision(10) << std::scientific << dResp0;
ofsResp << "," << std::setprecision(10) << std::scientific << dResp1;
if (ptrControl->doesOutputApparentResistivityAndPhase()) {
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcApparentResistivityError(freq, resp0[iOut], dResp0);
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcPhaseError(resp0[iOut], dResp0);
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcApparentResistivityError(freq, resp1[iOut], dResp1);
ofsRhoaPhs << "," << std::setprecision(10) << std::scientific << calcPhaseError(resp1[iOut], dResp1);
}
}
ofsResp << std::endl;
ofsResp.flush();
if (ptrControl->doesOutputApparentResistivityAndPhase()) {
ofsRhoaPhs << std::endl;
ofsRhoaPhs.flush();
}
// Release memory
for (int iChan = 0; iChan < numChannels; ++iChan) {
delete[] ftvalForBootstrap[iChan];
}
delete[] ftvalForBootstrap;
for (int iSample = 0; iSample < numOfSamples; ++iSample) {
delete[] resp0Sample[iSample];
delete[] resp1Sample[iSample];
}
delete[] resp0Sample;
delete[] resp1Sample;
delete[] segmentIndexes;
}
// Write residuals
void AnalysisTest::writeResiduals(const std::string& fileName, const int numSegmentsTotal,
const std::vector< std::pair<std::string, std::string> >& times, const std::vector<std::string>& titles, const std::vector<double>* outputValues) const {
std::ofstream ofs;
ofs.open(fileName.c_str(), std::ios::out);
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
if (ofs.fail()) {
ptrOutputFiles->writeErrorMessage("File open error : " + fileName);
}
ofs << "index";
ofs << ",start_time,end_time";
for (std::vector<std::string>::const_iterator itr = titles.begin(); itr != titles.end(); ++itr) {
ofs << ",residual_real_" << *itr;
ofs << ",residual_imag_" << *itr;
ofs << ",weight_" << *itr;
}
ofs << std::endl;
int index(0);
for (int iSeg = 0; iSeg < numSegmentsTotal; ++iSeg) {
ofs << index;
const std::string timeStart = times[iSeg].first;
const std::string timeEnd = times[iSeg].second;
ofs << "," << timeStart << "," << timeEnd;
for (std::vector<double>::const_iterator itr = outputValues[index].begin(); itr != outputValues[index].end(); ++itr) {
ofs << "," << std::setprecision(10) << std::scientific << *itr;
}
ofs << std::endl;
++index;
}
ofs.close();
}

70
src/AnalysisTest.h Normal file
View File

@@ -0,0 +1,70 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_ANALYSIS_TEST
#define DBLDEF_ANALYSIS_TEST
#include "Analysis.h"
// Class of test
class AnalysisTest : public Analysis {
public:
// Default constructer
AnalysisTest();
// Destructer
virtual ~AnalysisTest();
private:
// Calculate response functions
virtual void calculateResponseFunctions( const int iSegLen,const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs );
void parametricErrorEstimation() const;
void calculateResponseFunctionsAux(const int iSegLen, const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs, const bool forJackknife, const int out, std::complex<double>& respOut0, std::complex<double>& respOut1,
double& coherenceOut ) const;
// Estimate errors by strict bootstrap
void strictBootstrap(const int iSegLen, const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs, const std::complex<double>* const resp0, const std::complex<double>* const resp1 ) const;
// Write residuals
void writeResiduals(const std::string& fileName, const int numSegmentsTotal,
const std::vector< std::pair<std::string, std::string> >& times, const std::vector<std::string>& titles, const std::vector<double>* outputValues) const;
};
#endif

1153
src/AnalysisTwoStage.cpp Normal file

File diff suppressed because it is too large Load Diff

109
src/AnalysisTwoStage.h Normal file
View File

@@ -0,0 +1,109 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_ANALYSIS_TWO_STAGE
#define DBLDEF_ANALYSIS_TWO_STAGE
#include "Analysis.h"
// Class of analysis for two stage remote reference approach
class AnalysisTwoStage : public Analysis {
public:
// Default constructer
AnalysisTwoStage();
// Destructer
virtual ~AnalysisTwoStage();
private:
// Calculate the maximum value of hat matrix diagonals
double calculateMaximumValueOfHatMatrixDiagonals( ) const;
// Calculate response functions
virtual void calculateResponseFunctions( const int iSegLen,const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs );
void calculateResponseFunctionsAux( const int iSegLen,const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs, const bool forJackknife, std::complex<double>* respOut0, std::complex<double>* respOut1, double** hatDiagsOut ) const;
// Calculate response functions by iteratively reweighted least squares for the first stage
void calculateResponseFunctionsByIRWLSForFirstStage( const int iRobustWeight, const int inputVariableIndex,
const int numSegments, const bool fixScale, double& scale, std::complex<double>** data, const double* const leverageWeights,
double* weights, std::complex<double>* residuals, std::complex<double>& resp0, std::complex<double>& resp1,
double& coherence, std::vector<std::string>& titles, std::vector<double>* outputValues ) const;
// Calculate response functions by iteratively reweighted least squares for the second stage
void calculateResponseFunctionsByIRWLSForSecondStage( const int iRobustWeight, const int outputVariableIndex,
const int numSegments, const bool fixScale, double& scale, std::complex<double>** data, std::complex<double>** dataSyn, const double* const leverageWeights,
double* weights, std::complex<double>* residuals, std::complex<double>& resp0, std::complex<double>& resp1,
double& coherence, std::vector<std::string>& titles, std::vector<double>* outputValues ) const;
// Calculate response function by the weighted least square method for the first stage
void calculateResponseFunctionsByWLSForFirstStage( const int inputVariableIndex, const int numSegments, std::complex<double>** data,
double* weights, std::complex<double>* residuals, std::complex<double>& resp0, std::complex<double>& resp1, double& coherence ) const;
// Calculate response function by the weighted least square method for the second stage
void calculateResponseFunctionsByWLSForSecondStage( const int outputVariableIndex, const int numSegments, std::complex<double>** data,
std::complex<double>** dataSyn, double* weights, std::complex<double>* residuals, std::complex<double>& resp0, std::complex<double>& resp1,
double& coherence ) const;
// Perform fixed-weights jackknife
void fixedWeightsJackknife( const double freq, const int numSegmentsTotal, double** weightsOrg, std::complex<double>** ftval,
std::complex<double>** dataSyn, std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs,
const std::complex<double>* const resp0, const std::complex<double>* const resp1, double** hatDiagonals ) const;
// Perform fixed-weights bootstrap
void fixedWeightsBootstrap( const double freq, const int numSegmentsTotal, double** weightsOrg, std::complex<double>** ftval,
std::complex<double>** dataSyn, std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs,
const std::complex<double>* const resp0, const std::complex<double>* const resp1 ) const;
// Output synthetic input data
void outputSyntheticInputData( const int iSegLen, const int freqDegree, const int numSegmentsTotal, std::complex<double>** dataSyn ) const;
// Estimate error by strict bootstrap
void strictBootstrap( const int iSegLen,const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs, const std::complex<double>* const resp0, const std::complex<double>* const resp1 ) const;
// Perform subset deletion jackknife
void subsetDeletionJackknife( const int iSegLen,const int freqDegree, const double timeLength, const double freq,
const int numSegmentsTotal, std::complex<double>** ftval, const std::vector< std::pair<std::string, std::string> >& times,
std::ofstream& ofsResp, std::ofstream& ofsRhoaPhs, const std::complex<double>* const resp0, const std::complex<double>* const resp1, double** hatDiagonals ) const;
// Write residuals
void writeResiduals( const std::string& fileName, const int numSegmentsTotal,
const std::vector< std::pair<std::string, std::string> >& times, const std::vector<std::string>& titles, const std::vector<double>* outputValues ) const;
};
#endif

456
src/Ats.cpp Normal file
View File

@@ -0,0 +1,456 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include <vector>
#include <fstream>
#include <ctime>
#include <stdio.h>
#include <assert.h>
#include <time.h>
#include <bitset>
#include <iomanip>
#include <iostream>
#define snprintf _snprintf
#include "Ats.h"
#include "Util.h"
#include "OutputFiles.h"
#include "CommonParameters.h"
#include "Control.h"
// Default constructer
Ats::Ats():
m_isCalADUResp(false)
{
}
// Destructer
Ats::~Ats(){
}
// Return the instance of the class
Ats* Ats::getInstance(){
static Ats instance;// The only instance
return &instance;
}
// Read ats file
void Ats::readAtsFile( const std::string& fileName, const int numSkipData, const int numDataPoints, double* data ) const{
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeLogMessage("Read data from "+fileName);
FILE* fp = fopen(fileName.c_str(), "rb");
if (fp == NULL) {
ptrOutputFiles->writeErrorMessage("File open error : " + fileName);
}
unsigned char* buff2bytes = new unsigned char[2];
unsigned char* buff4bytes = new unsigned char[4];
unsigned char* buff8bytes = new unsigned char[8];
fread(buff2bytes, 2, 1, fp);
const int headerLength = bytesToInt16(buff2bytes);
fread(buff2bytes, 2, 1, fp);
const int headerVersion = bytesToInt16(buff2bytes);
fread(buff4bytes, 4, 1, fp);
const int numDataInFile = bytesToInt32(buff4bytes);
fread(buff4bytes, 4, 1, fp);
const float samplingFreq = bytesToFloat(buff4bytes);
fread(buff4bytes, 4, 1, fp);
const int startDate = bytesToInt32(buff4bytes);
fread(buff8bytes, 8, 1, fp);
const double lsbmv = bytesToDouble(buff8bytes);
unsigned char* buffRemaining = new unsigned char[headerLength - 24];
fread(buffRemaining, headerLength - 24, 1, fp);
delete[] buffRemaining;
if (numDataPoints + numSkipData > numDataInFile) {
ptrOutputFiles->writeErrorMessage("The number of data in the ATS file (" + Util::toString(numDataInFile) +
") is lower than NSkip(" + Util::toString(numSkipData) + ") + NData(" + Util::toString(numDataPoints) + ")");
};
for (int i = 0; i < numSkipData; ++i) {
fread(buff4bytes, 4, 1, fp);
}
int icount(0);
for (int i = numSkipData; i < numSkipData + numDataPoints; ++i, ++icount) {
fread(buff4bytes, 4, 1, fp);
int32_t ibuf = bytesToInt32(buff4bytes);
data[icount] = static_cast<double>(ibuf) * lsbmv;
}
fclose(fp);
delete[] buff2bytes;
delete[] buff4bytes;
delete[] buff8bytes;
}
// Get calibration file name
std::string Ats::getCalibrationFileName( const int channelIndex ) const{
std::ostringstream fileName;
fileName << "channel" << channelIndex << ".cal";
return fileName.str();
}
// Make calibration file
void Ats::makeCalibrationFile( const std::string& inputString, const int channelIndex, const std::vector<double>& freq ) const{
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
const std::string outputFileName = getCalibrationFileName(channelIndex);
std::ofstream ofs;
ofs.open( outputFileName.c_str(), std::ios::out );
if( ofs.fail() ){
ptrOutputFiles->writeErrorMessage( "File open error: " + outputFileName );
}
const int numFreq = static_cast<int>(freq.size());
if( numFreq < 1 ){
ptrOutputFiles->writeErrorMessage( "Number of the frequencies for which calibrations are estimated is less than 1 : " + Util::toString(numFreq) );
}
if( inputString.find("MFS06") != std::string::npos ){
std::complex<double>* calibFuncCoil = new std::complex<double>[numFreq];
calculateCalibrationFunctionForCoil( inputString, MFS06, freq, calibFuncCoil );
ofs << std::setw(20) << std::scientific << std::setprecision(9) << 1.0 << std::endl;
ofs << std::setw(10) << numFreq << std::endl;
for( int iFreq = 0; iFreq < numFreq; ++iFreq ){
std::complex<double> invCal = 1.0 / calibFuncCoil[iFreq];
if( isCalADUResp() ){
invCal /= calculateCalibrationFunctionForADULFhannel(freq[iFreq]);
}
ofs << std::setw(20) << std::scientific << std::setprecision(9) << freq[iFreq];
ofs << std::setw(20) << std::scientific << std::setprecision(9) << invCal.real();
ofs << std::setw(20) << std::scientific << std::setprecision(9) << invCal.imag() << std::endl;
}
delete [] calibFuncCoil;
}else if( inputString.find("MFS07") != std::string::npos ){
std::complex<double>* calibFuncCoil = new std::complex<double>[numFreq];
calculateCalibrationFunctionForCoil( inputString, MFS07, freq, calibFuncCoil );
ofs << std::setw(20) << std::scientific << std::setprecision(9) << 1.0 << std::endl;
ofs << std::setw(10) << numFreq << std::endl;
for( int iFreq = 0; iFreq < numFreq; ++iFreq ){
std::complex<double> invCal = 1.0 / calibFuncCoil[iFreq];
if( isCalADUResp() ){
invCal /= calculateCalibrationFunctionForADULFhannel(freq[iFreq]);
}
ofs << std::setw(20) << std::scientific << std::setprecision(9) << freq[iFreq];
ofs << std::setw(20) << std::scientific << std::setprecision(9) << invCal.real();
ofs << std::setw(20) << std::scientific << std::setprecision(9) << invCal.imag() << std::endl;
}
delete [] calibFuncCoil;
}else{
// Channel for the electric field [mV/km]
// The input should be dipole length [m]
std::istringstream iss(inputString);
double dipoleLength(0.0);
iss >> dipoleLength;
dipoleLength /= -1000.0;// [m] -> [km] and invert sign
ofs << std::setw(20) << std::scientific << std::setprecision(9) << 1.0/dipoleLength << std::endl;
if( m_isCalADUResp ){
ofs << std::setw(10) << numFreq << std::endl;
for( int iFreq = 0; iFreq < numFreq; ++iFreq ){
const std::complex<double> invCal = 1.0 / calculateCalibrationFunctionForADULFhannel(freq[iFreq]);
ofs << std::setw(20) << std::scientific << std::setprecision(9) << freq[iFreq];
ofs << std::setw(20) << std::scientific << std::setprecision(9) << invCal.real();
ofs << std::setw(20) << std::scientific << std::setprecision(9) << invCal.imag() << std::endl;
}
}else{
ofs << std::setw(10) << 0 << std::endl;
}
}
ofs.close();
}
// Get flag specifing whether the calibration function for ADU is calculated
bool Ats::isCalADUResp() const{
return m_isCalADUResp;
}
// Set flag specifing whether the calibration function for ADU is calculated
void Ats::setIsCalADUResp( const bool isCalADUResp ){
m_isCalADUResp = isCalADUResp;
}
// Calculate calibration function for coil
void Ats::calculateCalibrationFunctionForCoil( const std::string& calibrationFile, const int coilType,
const std::vector<double>& freq, std::complex<double>* calibrationFunction ) const{
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
std::ifstream ifs( calibrationFile.c_str(), std::ios::in );
if( ifs.fail() ){
ptrOutputFiles->writeErrorMessage("File open error : " + calibrationFile);
}
ptrOutputFiles->writeLogMessage("Read calibration function from " + calibrationFile , false);
#if 0
int numFreqInCoilCalFile(0);
ifs >> numFreqInCoilCalFile;
double* freqInCoilCalFile = new double[numFreqInCoilCalFile];
double* logFreqInCoilCalFile = new double[numFreqInCoilCalFile];
double* amp = new double[numFreqInCoilCalFile];
double* phs = new double[numFreqInCoilCalFile];
for( int iFreq = 0; iFreq < numFreqInCoilCalFile; ++iFreq ){
double dbuf(0.0);
ifs >> dbuf;
freqInCoilCalFile[iFreq] = dbuf;
logFreqInCoilCalFile[iFreq] = log10(dbuf);
ifs >> dbuf;
// [V/nT/Hz] => [mV/nT]
amp[iFreq] = dbuf * freqInCoilCalFile[iFreq] * 1000.0;
ifs >> dbuf;
// [deg] => [rad]
phs[iFreq] = dbuf * CommonParameters::DEG2RAD;
if( ifs.eof() ){
ptrOutputFiles->writeErrorMessage("Number of frequencies in " + calibrationFile + " is less than " + Util::toString(numFreqInCoilCalFile) );
break;
}
}
#else
std::string sbuf;
std::vector<std::string> lines;
while(getline(ifs,sbuf)){
if( sbuf.substr(0,1) == "+" ){
lines.push_back(sbuf);
}else if( !lines.empty() ){
break;
}
if( ifs.eof() ){
break;
}
}
const int numFreqInCoilCalFile = static_cast<int>(lines.size());
double* freqsTemp = new double[numFreqInCoilCalFile];
double* amp = new double[numFreqInCoilCalFile];
double* phs = new double[numFreqInCoilCalFile];
for( int iFreq = 0; iFreq < numFreqInCoilCalFile; ++iFreq ){
std::istringstream iss(lines[iFreq]);
double dbuf(0.0);
iss >> dbuf;
freqsTemp[iFreq] = dbuf;
iss >> dbuf;
// [V/nT/Hz] => [mV/nT]
amp[iFreq] = dbuf * freqsTemp[iFreq] * 1000.0;
iss >> dbuf;
// [deg] => [rad]
phs[iFreq] = dbuf * CommonParameters::DEG2RAD;
}
#endif
ifs.close();
// Arrange the data in ascending order
int* ids = new int[numFreqInCoilCalFile];
for( int iFreq = 0; iFreq < numFreqInCoilCalFile; ++iFreq ){
ids[iFreq] = iFreq;
}
Util::quickSort(numFreqInCoilCalFile, ids, freqsTemp);
double* freqInCoilCalFile = new double[numFreqInCoilCalFile];
double* logFreqInCoilCalFile = new double[numFreqInCoilCalFile];
double* coilCalAmp = new double[numFreqInCoilCalFile];
double* coilCalLogAmp = new double[numFreqInCoilCalFile];
double* coilCalPhs = new double[numFreqInCoilCalFile];
for( int iFreq = 0; iFreq < numFreqInCoilCalFile; ++iFreq ){
const int index = ids[iFreq];
if( iFreq >= 1 ){
const int indexPre = ids[iFreq-1];
assert( freqsTemp[index] > freqsTemp[indexPre] );
}
freqInCoilCalFile[iFreq] = freqsTemp[index];
logFreqInCoilCalFile[iFreq] = log10(freqsTemp[index]);
coilCalAmp[iFreq] = amp[index];
coilCalLogAmp[iFreq] = log10(amp[index]);
coilCalPhs[iFreq] = phs[index];
}
delete [] ids;
delete [] freqsTemp;
delete [] amp;
delete [] phs;
double cutoffFrequency(0.0);
double fc1(0.0);
double fc2(0.0);
double AFactor(0.0);
switch (coilType){
case Ats::MFS06:
cutoffFrequency = 0.5;
fc1 = 4.0;
fc2 = 8192.0;
AFactor = 0.8;
break;
case Ats::MFS07:
cutoffFrequency = 5.0;
fc1 = 32.0;
fc2 = 40000.0;
AFactor = 0.64;
break;
default:
ptrOutputFiles->writeErrorMessage("Unknown coil type : " + Util::toString(coilType) );
break;
}
if( freqInCoilCalFile[0] < cutoffFrequency - CommonParameters::EPS ){
int numFreqLower(0);
double fc1Avg = 0.0;
for( int iFreq = 0; iFreq < numFreqInCoilCalFile; ++iFreq ){
const double freq = freqInCoilCalFile[iFreq];
if( freq > cutoffFrequency ){
continue;
}
const double phaseP2 = atan2( freq, fc2 );
fc1Avg += freq * tan( coilCalPhs[iFreq] + phaseP2 );
++numFreqLower;
}
fc1 = fc1Avg / static_cast<double>(numFreqLower);
double AAvg = 0.0;
for( int iFreq = 0; iFreq < numFreqInCoilCalFile; ++iFreq ){
const double freq = freqInCoilCalFile[iFreq];
if( freq > cutoffFrequency ){
continue;
}
const double term1 = pow(fc1/freq, 2) + 1.0;// (f1/f)^2 + 1
const double term2 = pow(freq/fc2, 2) + 1.0;// 1 + (f/f2)^2
AAvg += coilCalAmp[iFreq] * sqrt(term1 * term2);
}
AFactor = AAvg / static_cast<double>(numFreqLower);
}
int iFreq(0);
for( std::vector<double>::const_iterator itrFreq = freq.begin(); itrFreq != freq.end(); ++itrFreq, ++iFreq ){
const double freq = *itrFreq;
if( freq < freqInCoilCalFile[0] ){
// Calculate by estimated transfer function
const double ffc1 = freq / fc1;
const double ffc2 = freq / fc2;
calibrationFunction[iFreq] =
AFactor * std::complex<double>(0.0, ffc1) / std::complex<double>(1.0, ffc1) / std::complex<double>(1.0, ffc2);
}else{
// Interpolation in logarithmic axes
const double logAmp = Util::interpolationAkima( numFreqInCoilCalFile, logFreqInCoilCalFile, coilCalLogAmp, log10(freq) );
const double phs = Util::interpolationAkima( numFreqInCoilCalFile, logFreqInCoilCalFile, coilCalPhs, log10(freq) );
const double amp = pow(10.0, logAmp);
calibrationFunction[iFreq] = amp * std::complex<double>( cos(phs), sin(phs) );
}
}
delete [] freqInCoilCalFile;
delete [] logFreqInCoilCalFile;
delete [] coilCalAmp;
delete [] coilCalLogAmp;
delete [] coilCalPhs;
#ifdef _DEBUG_WRITE
iFreq = 0;
for( std::vector<double>::const_iterator itrFreq = freq.begin(); itrFreq != freq.end(); ++itrFreq, ++iFreq ){
const double freq = *itrFreq;
std::cout << std::setw(20) << std::setprecision(12) << 1.0/freq;
std::cout << std::setw(20) << calibrationFunction[iFreq] << std::endl;
}
#endif
}
// Calculate calibration function for LF-channel of ADU
std::complex<double> Ats::calculateCalibrationFunctionForADULFhannel( const double freq ) const{
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage(static_cast<std::string>(__FUNCTION__) + "cannot be used in this version");
return std::complex<double>(0.0, 0.0);
}
short int Ats::bytesToInt16(unsigned char* ptr) const {
union {
unsigned char c[2];
short int i;
} tmp;
tmp.c[0] = *ptr++;
tmp.c[1] = *ptr;
return tmp.i;
}
int Ats::bytesToInt32(unsigned char* ptr) const {
union {
unsigned char c[4];
int i;
} tmp;
tmp.c[0] = *ptr++;
tmp.c[1] = *ptr++;
tmp.c[2] = *ptr++;
tmp.c[3] = *ptr;
return tmp.i;
}
float Ats::bytesToFloat(unsigned char* ptr) const {
union {
unsigned char c[4];
float f;
} tmp;
tmp.c[0] = *ptr++;
tmp.c[1] = *ptr++;
tmp.c[2] = *ptr++;
tmp.c[3] = *ptr;
return tmp.f;
}
double Ats::bytesToDouble(unsigned char* ptr) const {
union {
unsigned char c[8];
double d;
} tmp;
tmp.c[0] = *ptr++;
tmp.c[1] = *ptr++;
tmp.c[2] = *ptr++;
tmp.c[3] = *ptr++;
tmp.c[4] = *ptr++;
tmp.c[5] = *ptr++;
tmp.c[6] = *ptr++;
tmp.c[7] = *ptr;
return tmp.d;
}

98
src/Ats.h Normal file
View File

@@ -0,0 +1,98 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_ATS
#define DBLDEF_ATS
#include <complex>
#include <vector>
#include <string>
// Class of ats file
class Ats{
public:
enum CoilType{
MFS06 = 0,
MFS07
};
// Return the the instance of the class
static Ats* getInstance();
// Read ats file
void readAtsFile( const std::string& fileName, const int numSkipData, const int numDataPoints, double* data ) const;
// Get calibration file name
std::string getCalibrationFileName( const int channelIndex ) const;
// Make calibration file
void makeCalibrationFile( const std::string& inputString, const int channelIndex, const std::vector<double>& freq ) const;
// Get flag specifing whether the calibration function for ADU is calculated
bool isCalADUResp() const;
// Set flag specifing whether the calibration function for ADU is calculated
void setIsCalADUResp( const bool isCalADUResp );
private:
short int bytesToInt16(unsigned char* ptr) const;
int bytesToInt32(unsigned char* ptr) const;
float bytesToFloat(unsigned char* ptr) const;
double bytesToDouble(unsigned char* ptr) const;
// Constructer
Ats();
// Destructer
~Ats();
// Copy constructer
Ats(const Ats& rhs);
// Assignment operator
Ats& operator=(const Ats& rhs);
// Calculate calibration function for coil
void calculateCalibrationFunctionForCoil( const std::string& calibrationFile, const int coilType,
const std::vector<double>& freq, std::complex<double>* calibrationFunction ) const;
// Calculate calibration function for ADU
std::complex<double> calculateCalibrationFunctionForADULFhannel( const double freq ) const;
// Flag specifing whether the calibration function for ADU is calculated
bool m_isCalADUResp;
};
#endif

175
src/CalibrationFunction.cpp Normal file
View File

@@ -0,0 +1,175 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "CalibrationFunction.h"
#include "Util.h"
#include "OutputFiles.h"
#include "CommonParameters.h"
#include <assert.h>
#include <iostream>
// Constructer
CalibrationFunction::CalibrationFunction( const std::string& calibrationFile ):
m_factor(1.0),
m_numFreqs(0),
m_logFreqs(NULL),
m_logAmps(NULL),
m_phases(NULL)
{
readCalibrationFunction(calibrationFile);
}
// Default constructer
CalibrationFunction::CalibrationFunction():
m_factor(1.0),
m_numFreqs(0),
m_logFreqs(NULL),
m_logAmps(NULL),
m_phases(NULL)
{
}
// Destructer
CalibrationFunction::~CalibrationFunction(){
if( m_logFreqs != NULL ){
delete [] m_logFreqs;
};
if( m_logAmps != NULL ){
delete [] m_logAmps;
};
if( m_phases != NULL ){
delete [] m_phases;
};
}
// Read calibration function
void CalibrationFunction::readCalibrationFunction( const std::string& calibrationFile ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
std::ifstream ifs( calibrationFile.c_str(), std::ios::in );
if( ifs.fail() ){
ptrOutputFiles->writeErrorMessage("File open error : " + calibrationFile);
}
ptrOutputFiles->writeLogMessage("Read calibration function from " + calibrationFile , false);
ifs >> m_factor;
ifs >> m_numFreqs;
#ifdef _DEBUG_WRITE
std::cout << calibrationFile.c_str() << std::endl;
std::cout << "m_factor, m_numFreqs: " << m_factor << " " << m_numFreqs << std::endl;
#endif
if( m_numFreqs < 1 ){
return;
}
double* freqs = new double[m_numFreqs];
double* calReal = new double[m_numFreqs];
double* calImag = new double[m_numFreqs];
for( int iFreq = 0; iFreq < m_numFreqs; ++iFreq ){
double dbuf(0.0);
ifs >> dbuf;
freqs[iFreq] = dbuf;
ifs >> dbuf;
calReal[iFreq] = dbuf;
ifs >> dbuf;
calImag[iFreq] = dbuf;
if( ifs.eof() ){
ptrOutputFiles->writeErrorMessage("Number of frequencies in " + calibrationFile + " is less than " + Util::toString(m_numFreqs) );
break;
}
}
ifs.close();
// Arrange the data in ascending order
int* ids = new int[m_numFreqs];
for( int iFreq = 0; iFreq < m_numFreqs; ++iFreq ){
ids[iFreq] = iFreq;
}
Util::quickSort(m_numFreqs, ids, freqs);
if( m_logFreqs != NULL ){
delete [] m_logFreqs;
};
if( m_logAmps != NULL ){
delete [] m_logAmps;
};
if( m_phases != NULL ){
delete [] m_phases;
};
m_logFreqs = new double[m_numFreqs];
m_logAmps = new double[m_numFreqs];
m_phases = new double[m_numFreqs];
for( int iFreq = 0; iFreq < m_numFreqs; ++iFreq ){
const int index = ids[iFreq];
if( iFreq >= 1 ){
const int indexPre = ids[iFreq-1];
assert( freqs[index] > freqs[indexPre] );
}
m_logFreqs[iFreq] = log10( freqs[index] );
const double amplitude = hypot( calReal[index], calImag[index] );
m_logAmps[iFreq] = log10(amplitude);
m_phases[iFreq] = atan2( calImag[index], calReal[index] );
#ifdef _DEBUG_WRITE
std::cout << "m_logFreqs, amplitude, m_logAmps, m_phases: "
<< m_logFreqs[iFreq] << " " << amplitude << " " << m_logAmps[iFreq] << " " << m_phases[iFreq] << std::endl;
#endif
}
delete [] freqs;
delete [] calReal;
delete [] calImag;
delete [] ids;
}
// Calculate calibration function for a input log frequency
std::complex<double> CalibrationFunction::calculateCalibrationFunction( const double freq ) const{
if( m_numFreqs < 1 ){
return std::complex<double>(m_factor, 0.0);
}
const double log10Freq = log10(freq);
const double logAmp = Util::interpolationAkima( m_numFreqs, m_logFreqs, m_logAmps, log10Freq );
const double phs = Util::interpolationAkima( m_numFreqs, m_logFreqs, m_phases, log10Freq );
const double amp = m_factor * pow(10.0, logAmp);
return amp * std::complex<double>( cos(phs), sin(phs) );
}
// Get constant factor
double CalibrationFunction::getFactor() const{
return m_factor;
}

82
src/CalibrationFunction.h Normal file
View File

@@ -0,0 +1,82 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_CALIBRATION_FUNCTION
#define DBLDEF_CALIBRATION_FUNCTION
#include <complex>
#include <string>
// Class of calibration function
class CalibrationFunction{
public:
// Constructer
CalibrationFunction( const std::string& calibrationFile );
// Default constructer
CalibrationFunction();
// Destructer
~CalibrationFunction();
// Read calibration function
void readCalibrationFunction( const std::string& calibrationFile );
// Calculate calibration function for a input frequency
std::complex<double> calculateCalibrationFunction( const double freq ) const;
// Get constant factor
double getFactor() const;
private:
// Constant factor
double m_factor;
// Number of frequencies in logarithmic scale
int m_numFreqs;
// Arrays of frequencies in logarithmic scale
double* m_logFreqs;
// Arrays of amplitudes in logarithmic scale
double* m_logAmps;
// Arrays of phase (radian)
double* m_phases;
// Copy constructer
CalibrationFunction(const CalibrationFunction& CalibrationFunction);
// Assignment operator
CalibrationFunction& operator=(const CalibrationFunction& CalibrationFunction);
};
#endif

72
src/CommonParameters.h Normal file
View File

@@ -0,0 +1,72 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_COMMON_PARAMETERS
#define DBLDEF_COMMON_PARAMETERS
#include <string>
#include <vector>
namespace CommonParameters{
enum DataType{
OUTPUT = 0,
INPUT,
REMOTE_REFERENCE
};
struct DataFile{
std::string fileName;
std::string mth5GroupName;
int numSkipData;
double* data;
};
struct DataFileSet{
int numDataPoints;
std::vector<DataFile> dataFile;
};
// Circular constant
const static double PI = 3.14159265358979323846;
// Factor converting values from radians to degrees
const static double RAD2DEG = 180.0 / PI;
// Factor converting values from degrees to radians
const static double DEG2RAD = PI / 180.0;
const static double EPS = 1.0e-20;
static char programName[]="TRACMT";
static char version[] = "v2.3.0";
}
#endif

1987
src/Control.cpp Normal file

File diff suppressed because it is too large Load Diff

710
src/Control.h Normal file
View File

@@ -0,0 +1,710 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_CONTROL
#define DBLDEF_CONTROL
#include <vector>
#include "CommonParameters.h"
#include "Analysis.h"
// Class of the control parameters
class Control{
public:
enum ElogDualType {
ELOG1K = 0,
ELOGDUAL_ADU_MODE,
ELOGDUAL_PHX_MODE,
NUM_TYPE_OF_ELOGDUAL_TYPE,
};
enum ElogMTType {
ELOGMT_ADU_MODE,
ELOGMT_PHX_MODE,
NUM_TYPE_OF_ELOGMT_TYPE,
};
enum ElogMTReadingOption {
NOT_SPECIFIED = -1,
READ_EX_EY_HX_HY_HZ_HRX_HRY_FROM_ELOGMT_DATA = 0,
READ_EX_EY_HX_HY_HRX_HRY_FROM_ELOGMT_DATA,
READ_HZ_HX_HY_HRX_HRY_FROM_ELOGMT_DATA,
READ_EX_EY_HX_HY_HZ_FROM_ELOGMT_DATA,
READ_EX_EY_HX_HY_FROM_ELOGMT_DATA,
READ_HZ_HX_HY_FROM_ELOGMT_DATA,
READ_EX_EY_FROM_ELOGMT_DATA,
READ_HX_HY_HRX_HRY_FROM_ELOGMT_DATA,
READ_HX_HY_FROM_ELOGMT_DATA,
NUM_TYPE_OF_ELOGMT_READING_OPTION,
};
enum ErrorEstimationMethod{
PARAMETRIC = 0,
FIXED_WEIGHTS_BOOTSTRAP,
STRICT_BOOTSTRAP,
ROBUST_BOOTSTRAP,
FIXED_WEIGHTS_JACKKNIFE,
SUBSET_DELETION_JACKKNIFE,
NUM_TYPE_OF_ERROR_ESTIMATION_METHOD,
};
enum ProcedureType{
ORDINARY_REMOTE_REFERENCE = 0,
MULTIVARIATE_REGRESSION,
MODIFIED_MULTIVARIATE_REGRESSION,
TWO_STAGE,
REPEATED_MEDIAN,
TEST,
NUM_TYPE_OF_PROCEDURE_TYPE,
};
enum TypeOfEstimatorForPrewhitening{
MANUAL_INPUTS_AR_COEFFICIENTS_FOR_PREWHITENING = -1,
USE_LEAST_SQUARE_ESTIMATOR_FOR_PREWHITENING = 0,
USE_S_ESTIMATOR_FOR_PREWHITENING,
NUM_TYPE_OF_MESTIMATORS_FOR_PREWHITENING,
};
enum TypeOfRobustWeight {
NOT_USED = -1,
HUBER = 0,
TUKEYS_BIWEIGHTS,
THOMSON,
NUM_TYPE_OF_MESTIMATORS,
};
// Type of the threshold of the difference of response fuctions
enum ThresholdTypeOfDifferenceOfResponseFuctions{
DIFFERENCE_OF_RESPONSES_DIVIDED_BY_SQUARE_ROOT_FREQUENCY,
DIFFERENCE_OF_RAW_RESPONSES,
NUM_OF_THRESHOLD_TYPE_OF_DIFFERENCE_OF_RESPONSE_FUCTIONS
};
// Segment length and the index of the frequency where response functions are estimated
enum TimingEOFBasedDenoising{
BEFORE_DECIMATION = 0 ,
AFTER_DEGITAL_FILTERS,
};
// Segment length and the index of the frequency where response functions are estimated
struct SegmentInfo{
int length;
std::vector<int> degrees;
};
// Parameters for ELOG calibration
struct ParamsForElogCalibration{
std::string fileName;
double unitGroupDelay;
};
// Parameters for the data-segment evaluation prior to the calculation of the response functions
struct ParamsForDataSegmentEvaluation{
bool doEvaluation;
int numDataSegments;
};
// Parameters for decimation
struct ParamsForDecimation{
bool applyDecimation;
int decimationInterval;
int filterLength;
double transitionBandWidthInLogarithmicScale;
};
// Parameters for the frequency-domain evaluation prior to the calculation of the response functions
struct ParamsForFreqDomainEvaluation{
bool doEvaluation;
double startOutputFrequency;
double endOutputFrequency;
int numOfOutputFrequency;
int numOfOutputFrequencyForAverage;
};
// Parameters for the time-domain evaluation prior to the calculation of the response functions
struct ParamsForTimeDomainEvaluation{
bool doEvaluation;
int timeSeriesInterval;
};
// Parameters for Hampel filter
struct ParamsForHampelFilter{
bool applyHampelFilter;
int numNeighborsOnEitherSide;
double nsigma;
};
// Parameters for mean square criteria
struct ParamsForMeanSquareCriteria{
bool applyMeanSquareCriteria;
double nsigma;
};
// Parameters for square coherence criteria
struct ParamsForSquareCoherenceCriteria{
bool applySquareCoherenceCriteria;
int numSegments;
double threshold;
};
// Parameters for square coherence criteria with random sampling
struct ParamsForSquareCoherenceCriteriaWithRandomSampling{
bool applySquareCoherenceCriteria;
int numSegments;
int numRandomSamples;
double threshold;
};
// Parameters for robust calculation of autocovariance matrix
struct ParamsForRobustAutoCovariance{
double percentageOfSmallNumberAddedToDiagonals;
int maxNumOfIterations;
double convergenceCriteria;
};
// Parameters of the threshold of the difference of response fuctions
struct ParamsOfThresholdOfDifferenceResponseFuctions{
int type;
double threshold;
};
// Parameters for prewhitening
struct ParamsForPrewhitening{
bool applyPrewhitening;
int typeOfEstimator;
int maxDegreeOfARModel;
int numCandidatesOfPartialAutocorrelationFunction;
};
// Thresholds for robust filter
struct ThresholdsForRobustFilter{
double firstThresholdFactor;
double secondThresholdFactor;
int maxNumOfConsecutiveReplacements;
};
// Parameters for robust filter
struct ParamsForRobustFilter{
bool applyRobustFilter;
bool replaceTimeSeriesWithFilteredValues;
std::vector<ThresholdsForRobustFilter> thresholds;
};
// Parameters for robust multivariate regression
struct ParamsForRobustMultivariateRegression{
bool selectInitialCandidatesByRandomSamplingAtEachFrequency;
int numOfMaxInitialCandidates;
int numOfMaxIterationsOfFirstIstep;
double convergenceCriteriaOfFirstIstep;
int numOfMaxCandidatesOfSecondIstep;
int numOfMaxIterationsOfSecondIstep;
double convergenceCriteriaOfSecondIstep;
std::string startOfTimeRange;
std::string endOfTimeRange;
};
// Parameters for deciding candicates for subsequent frequencies
struct ParamsForDecidingCandicatesForSubsequentFrequencies{
bool useResponseFunctionsOfPreviousFrequency;
std::vector<ParamsOfThresholdOfDifferenceResponseFuctions> thresholdOfDifferences;
};
// Parameters for degree of polarizatiton direction criteria
struct ParamsForDegreeOfMagneticPolarizationCriteria{
bool applyDegreeOfMagneticPolarizationCriteria;
int numSegments;
double threshold;
};
// Parameters for magnetic polarizatiton direction criteria
struct ParamsForMagneticPolarizatitonDirectionCriteria{
bool applyMagneticPolarizatitonDirectionCriteria;
double threshold;
};
// Parameters for the treatment of hat matrix
struct ParamsForTreatmentOfHatMatrix{
bool applyLeverageWeights;
double threshold;
int maxNumberOfOuterIteration;
};
// Return the the instance of the class
static Control* getInstance();
// Run analysis
void run(const bool outputToConsole);
// Get flag specifing whether IIR high-pass filter is applied
bool doesApplyIIRHighPassFilter() const;
// Get flag specifing whether IIR low-pass filter is applied
bool doesApplyIIRLowPassFilter() const;
// Get flag specifing whether calibration for MFS is performed
bool doesMakeCalibrationFileForMFS() const;
// Get flag specifing whether calibration for ELOG-Dual file is performed
bool doesMakeCalibrationFileForElogDual() const;
// Get flag specifing whether calibration for ELOG-MT file is performed
bool doesMakeCalibrationFileForElogMT() const;
// Get flag specifing whether apparent resistivity and phase are outputed in a seperate file
bool doesOutputApparentResistivityAndPhase() const;
// Get flag specifing wheter output frequency domain data as csv file
bool doesOutputFreqDomainDataToCsv() const;
// Get flag specifing wheter output time series data as csv file
bool doesOutputTimeSeriesToCsv() const;
// Get flag specifing whether input file is ATS binary file
bool doesOutputCalibratedTimeSeriesToCsv() const;
// Get flag specifing whether input file is ATS binary file
bool doesReadAtsBinary() const;
// Get flag specifing whether input file is ELOG-Dual binary file
bool doesReadMTH5() const;
// Get flag specifing whether input file is ELOG-Dual binary file
bool doesReadElogDualBinary() const;
// Get flag specifing whether input file is ELOG-MT binary file
bool doesReadElogMTBinary() const;
// Get azimuth
bool doesPeformEOFBasedDenoising() const;
// Get azimuth
double getAzimuth( const int iChan ) const;
// Get channel index
int getChannelIndex( const int dataType, const int index ) const;
// Get option of ELOG-Dual binary data reading
int getElogDualReadingOption() const;
// Get option of ELOG-MT binary data reading
int getElogMTReadingOption() const;
// Get error estimation method
int getErrorEstimationMethod() const;
// Get number of output variables
int getNumOutputVariables() const;
// Get number of input variables
int getNumInputVariables() const;
// Get number of remote reference variables
int getNumRemoteReferenceVariables() const;
// Get sampling frequency
double getSamplingFrequency() const;
// Get number of threads
double getSamplingFrequencyOrg() const;
// Get number of threads
int getNumThreads() const;
// Get number of time-series sections
int getNumTimeSeriesSections() const;
// Get number of segment lengths
int getNumSegmentLengths() const;
// Get number of target frequency degrees in an input segment
int getNumTargetFrequencyInSegment( const int iSeg ) const;
// Get number of the ranges of sections for merge
int getNumRangeOfSectionsForMerge() const;
// Get number of repetitions of bootstrap method
int getNumRepetitionsOfBootstrap() const;
// Get target frequency degrees in an input segment
int getTargetFrequencyDegreesInSegment( const int iSeg, const int index ) const;
// Get length of each segment
int getSegmentLength( const int iSeg ) const;
// Get ratio of overlapping part to whole segment length
double getOverlappingRatio() const;
// Get rotation angle
double getRotationAngle() const;
// Get numebur of calibration files for MFS
int getNumCalibrationFilesForMFS() const;
// Get name of calibration file for MFS
std::string getCalibrationFileNameForMFS(const int iFile) const;
// Get numebur of calibration files
int getNumCalibrationFiles() const;
// Get name of calibration file
std::string getCalibrationFileName( const int iFile ) const;
// Get cutoff frequency for IIR high-pass filter
double getCutoffFrequencyForIIRHighPassFilter() const;
// Get cutoff frequency for IIR low-pass filter
double getCutoffFrequencyForIIRLowPassFilter() const;
// Get cutoff frequencies for notch filter
std::vector<double> getCutoffFrequenciesForNotchFilter() const;
// Get directory of logger calibration files
std::string getDirectoryOfLoggerCalibrationFiles() const;
// Get number of ichannels
int getNumberOfChannels() const;
// Get number of cutoff frequencies for notch filter
int getNumberOfCutoffFrequenciesForNotchFilter() const;
// Get number of frequencies
int getNumberOfFrequencies() const;
// Get frequency
double getFrequency( const int iFreq ) const;
// Get all frequencies without duplications
std::vector<double> getFrequenciesAllWithoutDuplications() const;
// Get output level
int getOutputLevel() const;
// Get parameter Q for notch filter
double getParameterQForNotchFilter() const;
// Get parameters for ELOG-Dual calibration
ParamsForElogCalibration getParamsForElogDualCalibration() const;
// Get parameters for ELOG-MT calibration
ParamsForElogCalibration getParamsForElogMTCalibration() const;
// Get parameters for the data-segment evaluation prior to the calculation of the response functions
ParamsForDataSegmentEvaluation getParamsForDataSegmentEvaluation() const;
// Get parameters for decimation
ParamsForDecimation getParamsForDecimation() const;
// Get parameters for the frequency-domain evaluation prior to the calculation of the response functions
ParamsForFreqDomainEvaluation getParamsForFreqDomainEvaluation() const;
// Get parameters for the time-domain evaluation prior to the calculation of the response functions
ParamsForTimeDomainEvaluation getParamsForTimeDomainEvaluation() const;
// Get parameters for Hampel filter
ParamsForHampelFilter getParamsForHampelFilter() const;
// Get parameters for mean square criteria
ParamsForMeanSquareCriteria getParamsForMeanSquareCriteria() const;
// Get parameters for degree of polarizatiton direction criteria
ParamsForDegreeOfMagneticPolarizationCriteria getParamsForDegreeOfMagneticPolarizationCriteria() const;
// Get parameters for magnetic polarizatiton direction criteria
ParamsForMagneticPolarizatitonDirectionCriteria getParamsForMagneticPolarizatitonDirectionCriteria() const;
// Get parameters for square coherence criteria
ParamsForSquareCoherenceCriteria getParamsForSquareCoherenceCriteria() const;
// Get parameters for square coherence criteria with random sampling
ParamsForSquareCoherenceCriteriaWithRandomSampling getParamsForSquareCoherenceCriteriaWithRandomSampling() const;
// Get parameters for robust calculation of autocovariance matrix
ParamsForRobustAutoCovariance getParamsForRobustAutoCovariance() const;
// Get parameters for robust prewhitening
ParamsForPrewhitening getParamsForPrewhitening() const;
// Get parameters for robust filter
ParamsForRobustFilter getParamsForRobustFilter() const;
// Get parameters for robust multivariate regression
ParamsForRobustMultivariateRegression getParamsForRobustMultivariateRegression() const;
// Get parameters for deciding candicates for subsequent frequencies
ParamsForDecidingCandicatesForSubsequentFrequencies getParamsForDecidingCandicatesForSubsequentFrequencies() const;
// Get parameters for the treatment of hat matrix
ParamsForTreatmentOfHatMatrix getParamsForTreatmentOfHatMatrix() const;
// Get percentage of ommited data in subset deletion jackknife
double getPercentageOfOmmitedDataSubsetDeletionJackknife() const;
// Get ranges of sections for merge
std::pair<int, int> getRangeOfSectionsForMerge( const int iSectionAfterMerge ) const;
// Get time from start time and elapsed time (seconds)
std::string getTimeFromStartTimeOfEachSection( const int sectionIndex, const double elapsedTime, const bool forAfterMergingSections = true ) const;
// Get number of start times of sections
int getNumStartTimesSections() const;
// Get procedure type
int getProcedureType() const;
// Get timing of denoising based on EOF
int getTimingEOFBasedDenoising() const;
// Get type of ELOG-Dual
int getTypeOfElogDual() const;
// Get type of ELOG-MT
int getTypeOfElogMT() const;
// Set sampling frequency
void setSamplingFrequency( const double samplingFrequency );
// Set original sampling frequency
void setSamplingFrequencyOrg(const double samplingFrequency);
private:
// Constructer
Control();
// Destructer
~Control();
// Copy constructer
Control(const Control& rhs);
// Assignment operator
Control& operator=(const Control& rhs);
// Azimuths
std::vector<double> m_azimuths;
// Cutoff frequency for IIR high-pass filter
double m_cutoffFrequencyForIIRHighPassFilter;
// Cutoff frequency for IIR low-pass filter
double m_cutoffFrequencyForIIRLowPassFilter;
// Cutoff frequencies for notch filter
std::vector<double> m_cutoffFrequenciesForNotchFilter;
// Directory of logger calibration files
std::string m_directoryOfLoggerCalibrationFiles;
// Flag specifing whether IIR high-pass filter is applied
bool m_doesApplyIIRHighPassFilter;
// Flag specifing whether IIR low-pass filter is applied
bool m_doesApplyIIRLowPassFilter;
// Option of ELOG-Dual binary data reading
bool m_doesPeformEOFBasedDenoising;
// Option of ELOG-Dual binary data reading
int m_elogDualReadingOption;
// Option of ELOG-MT binary data reading
int m_elogMTReadingOption;
// Error estimation method
int m_errorEstimationMethod;
// Number of output variables
int m_numOutputVariables;
// Number of input variables
int m_numInputVariables;
// Number of remote reference variables
int m_numRemoteReferenceVariables;
// Sampling frequency
double m_samplingFrequencyOrg;
// Sampling frequency
double m_samplingFrequency;
// Number of threads
int m_numThreads;
// Number of time-series sections
int m_numTimeSeriesSections;
// Number of repetitions of bootstrap method
int m_numRepetitionsOfBootstrap;
// Array for segment length and the index of the frequency where response functions are estimated
std::vector<SegmentInfo> m_segments;
// Ratio of overlapping part to whole segment length
double m_overlappingRatio;
// Frequencies where response functions are estimated
std::vector<double> m_frequencies;
// Flag specifing whether input calibration for MFS is performed
bool m_calibForMFS;
// Flag specifing whether input calibration for ELOG-Dual file is performed
bool m_calibForElogDual;
// Flag specifing whether input calibration for ELOG-MT file is performed
bool m_calibForElogMT;
// Pointer to Analysis class
Analysis* m_analysis;
// Data file sets
std::vector<CommonParameters::DataFileSet> m_dataFileSets;
// Rotation angles
double m_rotationAngle;
// Calibration files
std::vector<std::string> m_calibrationFiles;
// Calibration file for MFS
std::vector<std::string> m_calibrationFilesForMFS;
// Percentage of ommited data in subset deletion jackknife
double m_percentageOfOmmitedDataSubsetDeletionJackknife;
// Start time of each section
std::vector<std::string> m_startTimeOfEachSection;
// Flag specifing whether apparent resistivity and phase are outputed in a seperate file
bool m_outputApparentResistivityAndPhase;
// Output level
int m_outputLevel;
// Flag specifing wheter output frequency domain data as csv file
bool m_outputFreqDomainDataToCsv;
// Flag specifing wheter output time series data as csv file
bool m_outputTimeSeriesToCsv;
// Flag specifing wheter output calibrated time series data as csv file
bool m_outputCalibratedTimeSeriesToCsv;
// Parameter Q for notch filter
double m_parameterQForNotchFilter;
// Parameters for ELOGDual calibration
ParamsForElogCalibration m_paramsForElogDualCalibration;
// Parameters for ELOG-MT calibration
ParamsForElogCalibration m_paramsForElogMTCalibration;
// Parameters for the data-segment evaluation prior to the calculation of the response functions
ParamsForDataSegmentEvaluation m_paramsForDataSegmentEvaluation;
// Parameters for decimation
ParamsForDecimation m_paramsForDecimation;
// Parameters for the frequency-domain evaluation prior to the calculation of the response functions
ParamsForFreqDomainEvaluation m_paramsForFreqDomainEvaluation;
// Parameters for the time-domain evaluation prior to the calculation of the response functions
ParamsForTimeDomainEvaluation m_paramsForTimeDomainEvaluation;
// Parameters for square coherence criteria
ParamsForSquareCoherenceCriteria m_paramsForSquareCoherenceCriteria;
// Parameters for square coherence criteria with random sampling
ParamsForSquareCoherenceCriteriaWithRandomSampling m_paramsForSquareCoherenceCriteriaWithRandomSampling;
// Parameters for Hampel filter
ParamsForHampelFilter m_paramsForParamsForHampelFilter;
// Parameters for mean square criteria
ParamsForMeanSquareCriteria m_paramsForMeanSquareCriteria;
// Parameters for degree of polarizatiton direction criteria
ParamsForDegreeOfMagneticPolarizationCriteria m_paramsForDegreeOfMagneticPolarizationCriteria;
// Parameters for magnetic polarizatiton direction criteria
ParamsForMagneticPolarizatitonDirectionCriteria m_paramsForMagneticPolarizatitonDirectionCriteria;
// Parameters for robust calculation of autocovariance matrix
ParamsForRobustAutoCovariance m_paramsForRobustAutoCovariance;
// Parameters for robust prewhitening
ParamsForPrewhitening m_paramsForPrewhitening;
// Parameters for robust filter
ParamsForRobustFilter m_paramsForRobustFilter;
// Parameters for robust multivariate regression
ParamsForRobustMultivariateRegression m_paramsForRobustMultivariateRegression;
// Parameters for deciding candicates for subsequent frequencies
ParamsForDecidingCandicatesForSubsequentFrequencies m_paramsForDecidingCandicatesForSubsequentFrequencies;
// Parameters for the treatment of hat matrix
ParamsForTreatmentOfHatMatrix m_paramsForTreatmentOfHatMatrix;
// Procedure type
int m_procedureType;
// Ranges of sections for merge
std::vector< std::pair<int, int> > m_rangeOfSectionsForMerge;
// Flag specifing whether input file is ATS binary file
bool m_readAtsBinary;
// Flag specifing whether input file is MTH5 file
bool m_readMTH5;
// Flag specifing whether ELOG-Dual binary is read
bool m_readElogDualBinary;
// Flag specifing whether ELOG-MT binary is read
bool m_readElogMTBinary;
// Timing of denoising based on EOF
int m_timingEOFBasedDenoising;
// Type of ELOG-Dual
int m_typeOfElogDual;
// Type of ELOG-MT
int m_typeOfElogMT;
// Read control parameters from input file
void readParameterFile();
};
#endif

188
src/DoubleDenseMatrix.cpp Normal file
View File

@@ -0,0 +1,188 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "DoubleDenseMatrix.h"
#include "OutputFiles.h"
#include "Util.h"
#include <stddef.h> // For null pointer
#include <stdlib.h> // For exit
#include <iostream>
#include <assert.h>
//Default Constructer
DoubleDenseMatrix::DoubleDenseMatrix():
m_numRows(0),
m_numColumns(0),
m_numComponents(0),
m_matrix(NULL),
m_factorizedMatrix(NULL),
m_ipiv(NULL)
{}
// Destructer
DoubleDenseMatrix::~DoubleDenseMatrix(){
if( m_matrix != NULL ){
delete[] m_matrix;
m_matrix = NULL;
}
if( m_factorizedMatrix != NULL ){
delete[] m_factorizedMatrix;
m_factorizedMatrix = NULL;
}
if( m_ipiv != NULL ){
delete [] m_ipiv;
}
}
// Set number of rows and columns
void DoubleDenseMatrix::setNumRowsAndColumns( const int nrows, const int ncols ){
// Total number of rows
m_numRows = nrows;
// Total number of columns
m_numColumns = ncols;
// Total number of components
m_numComponents = nrows * ncols;
m_matrix = new double [m_numComponents];
// Zero clear
zeroClearMatrix();
}
// Add value to matrix
void DoubleDenseMatrix::addValue( const int row, const int col, const double val ){
assert( row <= m_numRows - 1 );
assert( row >= 0 );
assert( col <= m_numColumns - 1 );
assert( col >= 0 );
// Column major
const int index = col * m_numRows + row;
m_matrix[index] += val;
}
// Multiply a scalar to the matrix
void DoubleDenseMatrix::multiplyScalarToMatrix( const double scalar ){
for( int i = 0; i < m_numComponents; ++i ){
m_matrix[i] *= scalar;
}
}
// Set value to matrix
void DoubleDenseMatrix::setValue( const int row, const int col, const double val ){
assert( row <= m_numRows - 1 );
assert( row >= 0 );
assert( col <= m_numColumns - 1 );
assert( col >= 0 );
// Column major
const int index = col * m_numRows + row;
m_matrix[index] = val;
}
//Zero clear matrix
void DoubleDenseMatrix::zeroClearMatrix(){
for( int i = 0; i < m_numComponents; ++i ){
m_matrix[i] = 0.0; // Zero clear
}
if( m_factorizedMatrix != NULL ){
delete[] m_factorizedMatrix;
m_factorizedMatrix = NULL;
}
if( m_ipiv != NULL ){
delete [] m_ipiv;
m_ipiv = NULL;
}
}
// Get total number of rows
int DoubleDenseMatrix::getNumRows() const{
return m_numRows;
}
// Get total number of columns
int DoubleDenseMatrix::getNumColumns() const{
return m_numColumns;
}
// Get value
double DoubleDenseMatrix::getValue( const int row, const int col ) const{
// Column major
const int index = col * m_numRows + row;
return m_matrix[index];
}
// Debug write the matrix componets
void DoubleDenseMatrix::debugWriteMatrix() const{
std::cout << "[";
for( int row = 0; row < m_numRows; ++row ){
for( int col = 0; col < m_numColumns; ++col ){
std::cout << getValue(row, col) << " ";
}
if( row+1 < m_numRows ){
std::cout << ";";
}
}
std::cout << "]" << std::endl;
}
//Copy constructer
DoubleDenseMatrix::DoubleDenseMatrix(const DoubleDenseMatrix &matrix ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("Copy constructer of the class DoubleDenseMatrix is not implemented");
}
// Assignment operator
DoubleDenseMatrix& DoubleDenseMatrix::operator=(const DoubleDenseMatrix& rhs){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("Assignment operator of the class DoubleDenseMatrix is not implemented");
exit(1);
}

101
src/DoubleDenseMatrix.h Normal file
View File

@@ -0,0 +1,101 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_DOUBLE_DENSE_MATRIX
#define DBLDEF_DOUBLE_DENSE_MATRIX
class DoubleDenseMatrix{
public:
//Default Constructer
explicit DoubleDenseMatrix();
//Constructer
explicit DoubleDenseMatrix( const int nrows, const int ncols );
//Destructer
virtual ~DoubleDenseMatrix();
// Set number of rows and columns
virtual void setNumRowsAndColumns( const int nrows, const int ncols );
// Add value to matrix
virtual void addValue( const int row, const int col, const double val );
// Multiply a scalar to the matrix
void multiplyScalarToMatrix( const double scalar );
// Set value to matrix
virtual void setValue( const int row, const int col, const double val );
// Zero clear matrix
virtual void zeroClearMatrix();
// Get number of rows
int getNumRows() const;
// Get number of columns
int getNumColumns() const;
// Get value
virtual double getValue( const int row, const int col ) const;
//Debug write the matrix componets
void debugWriteMatrix() const;
protected:
//Total number of rows
int m_numRows;
//Total number of columns
int m_numColumns;
//Total number of components
int m_numComponents;
//Values of non-zero compnents
double* m_matrix;
// Factorized matrix
double* m_factorizedMatrix;
// Array for LAPACK
int* m_ipiv;
private:
//Copy constructer
DoubleDenseMatrix(const DoubleDenseMatrix &matrix );
// Assignment operator
DoubleDenseMatrix& operator=(const DoubleDenseMatrix& rhs);
};
#endif

View File

@@ -0,0 +1,118 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "DoubleDenseSquareMatrix.h"
#include "Util.h"
#include "OutputFiles.h"
#include <stddef.h> // For null pointer
#include <stdlib.h> // For exit
#include <iostream>
#include <assert.h>
// Default Constructer
DoubleDenseSquareMatrix::DoubleDenseSquareMatrix():
DoubleDenseMatrix()
{}
// Destructer
DoubleDenseSquareMatrix::~DoubleDenseSquareMatrix(){
}
// Factorize matrix
void DoubleDenseSquareMatrix::factorizeMatrix(){
if( m_factorizedMatrix == NULL ){
m_factorizedMatrix = new double[m_numRows * m_numColumns];
}
if( m_ipiv == NULL ){
m_ipiv = new int[m_numRows];
}
Util::factorizeRealSquareMatrix(m_numRows, m_matrix, m_factorizedMatrix, m_ipiv);
}
// Calculate determinant
double DoubleDenseSquareMatrix::calculateDeterminant() const{
double* matrix = new double[m_numRows*m_numColumns];
// Copy matrix
for( int col = 0; col < m_numColumns; ++col ){
for( int row = 0; row < m_numRows; ++row ){
// Column major
const int index = col * m_numRows + row;
matrix[index] = getValue(row, col);
}
}
const double determinant = Util::calculateDeterminantOfMatrix( m_numRows, matrix );
delete [] matrix;
return determinant;
}
// Set Degree of equation
void DoubleDenseSquareMatrix::setDegreeOfEquation( const int nEq ){
assert( nEq > 0 );
setNumRowsAndColumns( nEq, nEq );
}
// Get Degree of equation
int DoubleDenseSquareMatrix::getDegreeOfEquation() const{
return m_numRows;
}
// Solve a linear equation with a right-hand-side vector
void DoubleDenseSquareMatrix::solveLinearEquation( const double* const rhsVector, double* result ) const{
if( m_factorizedMatrix == NULL ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("Matrix has not been factorized");
}
Util::solveLinearEquationRealSquareMatrix( m_numRows, 1, m_ipiv, m_factorizedMatrix, rhsVector, result );
}
// Copy constructer
DoubleDenseSquareMatrix::DoubleDenseSquareMatrix(const DoubleDenseSquareMatrix &matrix ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("Copy constructer of the class DoubleDenseSquareMatrix is not implemented");
}
// Assignment operator
DoubleDenseSquareMatrix& DoubleDenseSquareMatrix::operator=(const DoubleDenseSquareMatrix& rhs){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("Assignment operator of the class DoubleDenseSquareMatrix is not implemented");
exit(1);
}

View File

@@ -0,0 +1,70 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_DOUBLE_DENSE_SQUARE_MATRIX
#define DBLDEF_DOUBLE_DENSE_SQUARE_MATRIX
#include "DoubleDenseMatrix.h"
#include <string>
class DoubleDenseSquareMatrix : public DoubleDenseMatrix{
public:
// Default Constructer
explicit DoubleDenseSquareMatrix();
// Destructer
virtual ~DoubleDenseSquareMatrix();
// Factorize matrix
virtual void factorizeMatrix();
// Calculate determinant
double calculateDeterminant() const;
// Set Degree of equation
virtual void setDegreeOfEquation( const int nEq );
// Get Degree of equation
int getDegreeOfEquation() const;
// Solve a linear equation with a right-hand-side vector
virtual void solveLinearEquation( const double* const rhsVector, double* result ) const;
private:
// Copy constructer
DoubleDenseSquareMatrix(const DoubleDenseSquareMatrix &matrix );
// Assignment operator
DoubleDenseSquareMatrix& operator=(const DoubleDenseSquareMatrix& rhs);
};
#endif

View File

@@ -0,0 +1,198 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "DoubleDenseSquareSymmetricMatrix.h"
#include "OutputFiles.h"
#include "Util.h"
#include <stddef.h> // For null pointer
#include <stdlib.h> // For exit
#include <iostream>
#include <assert.h>
// Default Constructer
DoubleDenseSquareSymmetricMatrix::DoubleDenseSquareSymmetricMatrix():
DoubleDenseSquareMatrix()
{}
// Destructer
DoubleDenseSquareSymmetricMatrix::~DoubleDenseSquareSymmetricMatrix(){
}
// Factorize matrix
void DoubleDenseSquareSymmetricMatrix::factorizeMatrix(){
if( m_factorizedMatrix == NULL ){
m_factorizedMatrix = new double[m_numRows * m_numColumns];
}
if( m_ipiv == NULL ){
m_ipiv = new int[m_numRows];
}
Util::factorizeRealSymmetricMatrix(m_numRows, m_matrix, m_factorizedMatrix, m_ipiv);
//#ifdef _DEBUG_WRITE
// for( int row = 0; row < m_numRows; ++row ){
// for( int col = 0; col < m_numColumns; ++col ){
// // Column major
// const int index = col * m_numRows + row;
// std::cout << "row col val: " << row << " " << col << " " << m_factorizedMatrix[index] << std::endl;
// }
// }
//#endif
}
// Factorize and solve a linear equation with a right-hand-side vector
double DoubleDenseSquareSymmetricMatrix::determinant() {
if (m_factorizedMatrix == NULL) {
m_factorizedMatrix = new double[m_numRows * m_numColumns];
}
if (m_ipiv == NULL) {
m_ipiv = new int[m_numRows];
}
Util::factorizeRealSymmetricMatrix(m_numRows, m_matrix, m_factorizedMatrix, m_ipiv);
double determinant(1.0);
for( int row = 0; row < m_numRows; ++row ){
const int index = row * m_numRows + row;
determinant *= m_factorizedMatrix[index];
}
return determinant;
}
// Factorize and solve a linear equation with a right-hand-side vector
void DoubleDenseSquareSymmetricMatrix::factorizeAndSolveLinearEquation( const double* const rhsVector, double* result ) const{
Util::factorizeAndSolveLinearEquationRealSymmetricMatrix(m_numRows, 1, m_matrix, rhsVector, result);
}
// Set Degree of equation
void DoubleDenseSquareSymmetricMatrix::setDegreeOfEquation( const int nEq ){
assert( nEq > 0 );
//Total number of rows
m_numRows = nEq;
//Total number of columns
m_numColumns = nEq;
// Total number of components
m_numComponents = ( nEq * nEq + nEq ) / 2;
m_matrix = new double [m_numComponents];
// Zero clear
zeroClearMatrix();
}
// Set number of rows and columns
void DoubleDenseSquareSymmetricMatrix::setNumRowsAndColumns( const int nrows, const int ncols ){
assert( nrows == ncols );
setDegreeOfEquation(nrows);
}
// Add value to matrix
void DoubleDenseSquareSymmetricMatrix::addValue( const int row, const int col, const double val ){
// Allow lower triangle part only
assert( row >= col );
// Column major
const int index = m_numColumns * col + ( col - col * col ) / 2 + ( row - col );
m_matrix[index] += val;
}
// Get value
double DoubleDenseSquareSymmetricMatrix::getValue( const int row, const int col ) const{
if( row >= col ){
// Lower triangle part
// Column major
const int index = m_numColumns * col + ( col - col * col ) / 2 + ( row - col );
return m_matrix[index];
}else{
// Upper triangle part
return getValue( col, row );
}
}
// Set value to matrix
void DoubleDenseSquareSymmetricMatrix::setValue( const int row, const int col, const double val ){
// Allow lower triangle part only
assert( row >= col );
// Column major
const int index = m_numColumns * col + ( col - col * col ) / 2 + ( row - col );
m_matrix[index] = val;
}
// Solve a linear equation with a right-hand-side vector
void DoubleDenseSquareSymmetricMatrix::solveLinearEquation( const double* const rhsVector, double* result ) const{
if( m_factorizedMatrix == NULL ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("Matrix has not been factorized");
}
Util::solveLinearEquationRealSymmetricMatrix( m_numRows, 1, m_ipiv, m_factorizedMatrix, rhsVector, result );
}
// Zero clear matrix
void DoubleDenseSquareSymmetricMatrix::zeroClearMatrix(){
DoubleDenseMatrix::zeroClearMatrix();
}
//Copy constructer
DoubleDenseSquareSymmetricMatrix::DoubleDenseSquareSymmetricMatrix(const DoubleDenseSquareSymmetricMatrix &matrix ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("Copy constructer of the class DoubleDenseSquareSymmetricMatrix is not implemented");
}
// Assignment operator
DoubleDenseSquareSymmetricMatrix& DoubleDenseSquareSymmetricMatrix::operator=(const DoubleDenseSquareSymmetricMatrix& rhs){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("Assignment operator of the class DoubleDenseSquareSymmetricMatrix is not implemented");
exit(1);
}

View File

@@ -0,0 +1,86 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_DOUBLE_DENSE_SQUARE_SYMMETRIC_MATRIX
#define DBLDEF_DOUBLE_DENSE_SQUARE_SYMMETRIC_MATRIX
#include "DoubleDenseSquareMatrix.h"
#include <set>
class DoubleDenseSquareSymmetricMatrix : public DoubleDenseSquareMatrix {
public:
// Default Constructer
explicit DoubleDenseSquareSymmetricMatrix();
// Destructer
virtual ~DoubleDenseSquareSymmetricMatrix();
// Factorize matrix
virtual void factorizeMatrix();
// Factorize and solve a linear equation with a right-hand-side vector
double determinant();
// Factorize and solve a linear equation with a right-hand-side vector
virtual void factorizeAndSolveLinearEquation( const double* const rhsVector, double* result ) const;
// Set Degree of equation
virtual void setDegreeOfEquation( const int nEq );
// Set number of rows and columns
virtual void setNumRowsAndColumns( const int nrows, const int ncols );
// Add value to matrix
virtual void addValue( const int row, const int col, const double val );
// Get value
virtual double getValue( const int row, const int col ) const;
// Set value to matrix
virtual void setValue( const int row, const int col, const double val );
// Solve a linear equation with a right-hand-side vector
virtual void solveLinearEquation( const double* const rhsVector, double* result ) const;
// Zero clear matrix
virtual void zeroClearMatrix();
private:
// Copy constructer
DoubleDenseSquareSymmetricMatrix(const DoubleDenseSquareSymmetricMatrix &matrix );
// Assignment operator
DoubleDenseSquareSymmetricMatrix& operator=(const DoubleDenseSquareSymmetricMatrix& rhs);
};
#endif

View File

@@ -0,0 +1,98 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "DoubleDenseSquareSymmetricPositiveDefiniteMatrix.h"
#include "OutputFiles.h"
#include "Util.h"
#include <stddef.h> // For null pointer
#include <stdlib.h> // For exit
#include <iostream>
#include <assert.h>
// Default Constructer
DoubleDenseSquareSymmetricPositiveDefiniteMatrix::DoubleDenseSquareSymmetricPositiveDefiniteMatrix()
{}
// Destructer
DoubleDenseSquareSymmetricPositiveDefiniteMatrix::~DoubleDenseSquareSymmetricPositiveDefiniteMatrix()
{}
// Factorize matrix
void DoubleDenseSquareSymmetricPositiveDefiniteMatrix::factorizeMatrix(){
if( m_factorizedMatrix == NULL ){
m_factorizedMatrix = new double[m_numRows * m_numColumns];
}
Util::factorizeRealSymmetricPositiveDefiniteMatrix(m_numRows, m_matrix, m_factorizedMatrix);
#ifdef _DEBUG_WRITE
for( int row = 0; row < m_numRows; ++row ){
for( int col = 0; col < m_numColumns; ++col ){
// Column major
const int index = col * m_numRows + row;
std::cout << "row col val: " << row << " " << col << " " << m_factorizedMatrix[index] << std::endl;
}
}
#endif
}
// Factorize and solve a linear equation with a right-hand-side vector
void DoubleDenseSquareSymmetricPositiveDefiniteMatrix::factorizeAndSolveLinearEquation( const double* const rhsVector, double* result ) const{
Util::factorizeAndSolveLinearEquationRealSymmetricPositiveDefiniteMatrix(m_numRows, 1, m_matrix, rhsVector, result);
}
// Solve a linear equation with a right-hand-side vector
void DoubleDenseSquareSymmetricPositiveDefiniteMatrix::solveLinearEquation( const double* const rhsVector, double* result ) const{
if( m_factorizedMatrix == NULL ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("Matrix has not been factorized");
}
Util::solveLinearEquationRealSymmetricPositiveDefiniteMatrix( m_numRows, 1, m_factorizedMatrix, rhsVector, result );
}
//Copy constructer
DoubleDenseSquareSymmetricPositiveDefiniteMatrix::DoubleDenseSquareSymmetricPositiveDefiniteMatrix(const DoubleDenseSquareSymmetricPositiveDefiniteMatrix &matrix ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("Copy constructer of the class DoubleDenseSquareSymmetricPositiveDefiniteMatrix is not implemented");
}
// Assignment operator
DoubleDenseSquareSymmetricPositiveDefiniteMatrix& DoubleDenseSquareSymmetricPositiveDefiniteMatrix::operator=(const DoubleDenseSquareSymmetricPositiveDefiniteMatrix& rhs){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("Assignment operator of the class DoubleDenseSquareSymmetricPositiveDefiniteMatrix is not implemented");
exit(1);
}

View File

@@ -0,0 +1,65 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_DOUBLE_DENSE_SQUARE_SYMMETRIC_POSITIVE_DEFINITE_MATRIX
#define DBLDEF_DOUBLE_DENSE_SQUARE_SYMMETRIC_POSITIVE_DEFINITE_MATRIX
#include "DoubleDenseSquareSymmetricMatrix.h"
#include <set>
class DoubleDenseSquareSymmetricPositiveDefiniteMatrix : public DoubleDenseSquareSymmetricMatrix {
public:
// Default Constructer
explicit DoubleDenseSquareSymmetricPositiveDefiniteMatrix();
// Destructer
virtual ~DoubleDenseSquareSymmetricPositiveDefiniteMatrix();
// Factorize matrix
virtual void factorizeMatrix();
// Factorize and solve a linear equation with a right-hand-side vector
virtual void factorizeAndSolveLinearEquation( const double* const rhsVector, double* result ) const;
// Solve a linear equation with a right-hand-side vector
virtual void solveLinearEquation( const double* const rhsVector, double* result ) const;
private:
// Copy constructer
DoubleDenseSquareSymmetricPositiveDefiniteMatrix(const DoubleDenseSquareSymmetricPositiveDefiniteMatrix &matrix );
// Assignment operator
DoubleDenseSquareSymmetricPositiveDefiniteMatrix& operator=(const DoubleDenseSquareSymmetricPositiveDefiniteMatrix& rhs);
};
#endif

488
src/ElogDual.cpp Normal file
View File

@@ -0,0 +1,488 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "ElogDual.h"
#include "Util.h"
#include "OutputFiles.h"
#include "CommonParameters.h"
#include "Control.h"
#include <iomanip>
#include <iostream>
#include <assert.h>
#include <complex>
#ifdef _USE_FILESYSTEM
#include <filesystem>
#endif
// Return the instance of the class
ElogDual* ElogDual::getInstance() {
static ElogDual instance;// The only instance
return &instance;
}
// Read ELOG-Dual binary file
void ElogDual::readElogBinaryFile(const std::string& fileName, const int numSkipData, const int numDataPoints, int& counter, double* ex, double* ey) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeLogMessage("Read Ex and Ey data from " + fileName);
FILE * fp = fopen(fileName.c_str(), "rb");
if(fp == NULL) {
ptrOutputFiles->writeErrorMessage("File open error : " + fileName);
}
// Determine file type
const Control* const ptrControl = Control::getInstance();
const int freq = static_cast<int>(ptrControl->getSamplingFrequency());
const int data_size = AD_CH * freq * AD_BYTES;
unsigned char* data = new unsigned char[data_size];
const double factor = 2500.0 / static_cast<double>(pow(2,23));// Dynamic range +/- 2500 mV
while(1) {
// Read header of each block
recdata_head d;
if(fread(&d, 1, REC_DATALEN_HEAD, fp) < 1){
break;
}
// Read AD data of each block
if(fread(data, 1, data_size, fp) < 1){
break;
}
if( counter + freq <= numSkipData ){
counter += freq;
// Go to next block
continue;
}
// Determine end position prior to the start position because counter can be modified in determing start position
int endPos(freq);
if( numSkipData + numDataPoints > counter && numSkipData + numDataPoints <= counter + freq ){
// End position locates in this block
endPos = numSkipData + numDataPoints - counter;
}
int startPos(0);
if( numSkipData > counter && numSkipData <= counter + freq ){
// Start position locates in this block
startPos = numSkipData - counter;
counter = numSkipData;
}
for( int j = startPos; j < endPos; ++j, ++counter ){
// Ex
const int lbufx = bytesToInt32(&data[j * AD_BYTES * AD_CH]);
ex[counter - numSkipData] = static_cast<double>(lbufx) * factor;
// Ey
const int lbufy = bytesToInt32(&data[j * AD_BYTES * AD_CH + AD_BYTES]);
ey[counter - numSkipData] = static_cast<double>(lbufy) * factor;
#ifdef _DEBUG_WRITE
std::cout << std::setw(10) << counter - numSkipData << std::endl;
std::cout << std::setw(10) << lbufx << std::endl;
std::cout << std::setw(10) << lbufy << std::endl;
std::cout << std::setw(10) << ex[counter - numSkipData] << std::endl;
std::cout << std::setw(10) << ey[counter - numSkipData] << std::endl;
#endif
}
if( counter - numSkipData >= numDataPoints ){
break;
}
}
delete [] data;
fclose(fp);
}
// Read ELOG-Dual binary file under a directory
void ElogDual::readElogBinaryFilesUnderADirectory(const std::string& directory, const int numSkipData, const int numDataPoints, double* ex, double* ey) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
#ifdef _USE_FILESYSTEM
const Control* const ptrControl = Control::getInstance();
const int freq = static_cast<int>(ptrControl->getSamplingFrequency());
std::ostringstream oss;
oss << "_" << freq << "Hz";
const std::string stringCompared = oss.str();
if (std::filesystem::is_directory(directory)) {
auto dirItr = std::filesystem::directory_iterator(directory);
int counter(0);
for (auto& p : dirItr) {
const std::string fileName = p.path().string();
if (fileName.find(stringCompared) != std::string::npos && Util::extractExtensionOfFileName(fileName).find("dat") != std::string::npos) {
readElogBinaryFile(fileName, numSkipData, numDataPoints, counter, ex, ey);
if (counter >= numSkipData + numDataPoints){
break;
}
}
}
}
else
{
ptrOutputFiles->writeErrorMessage("There is no directory of ELOG data.");
}
#else
ptrOutputFiles->writeErrorMessage("Multiple inputs of ELOG data under a directory is not supported by this version.");
#endif
}
// Get calibration file name
std::string ElogDual::getCalibrationFileName(const int channelIndex) const {
std::ostringstream fileName;
fileName << "channel" << channelIndex << ".cal";
return fileName.str();
}
// Make calibration file
void ElogDual::makeCalibrationFile( const std::string& fileName, const double unitGroupDelay, const int channelIndexX, const int channelIndexY,
const double dipoleLengthX, const double dipoleLengthY, const std::vector<double>& freq) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
const int numFreq = static_cast<int>(freq.size());
if( numFreq < 1 ){
ptrOutputFiles->writeErrorMessage( "Number of the frequencies for which calibrations are estimated is less than 1 : " + Util::toString(numFreq) );
}
const std::string outputFileNameX = getCalibrationFileName(channelIndexX);
std::ofstream ofsX;
ofsX.open( outputFileNameX.c_str(), std::ios::out );
if( ofsX.fail() ){
ptrOutputFiles->writeErrorMessage( "File open error : " + outputFileNameX );
}
const double dipoleLengthXkm = dipoleLengthX / -1000.0;// [m] -> [km] and invert sign
ofsX << std::setw(20) << std::scientific << std::setprecision(9) << 1.0/dipoleLengthXkm << std::endl;
ofsX << std::setw(10) << numFreq << std::endl;
const std::string outputFileNameY = getCalibrationFileName(channelIndexY);
std::ofstream ofsY;
ofsY.open( outputFileNameY.c_str(), std::ios::out );
if( ofsY.fail() ){
ptrOutputFiles->writeErrorMessage( "File open error : " + outputFileNameY );
}
const double dipoleLengthYkm = dipoleLengthY / -1000.0;// [m] -> [km] and invert sign
ofsY << std::setw(20) << std::scientific << std::setprecision(9) << 1.0/dipoleLengthYkm << std::endl;
ofsY << std::setw(10) << numFreq << std::endl;
const Control* const ptrControl = Control::getInstance();
for( int iFreq = 0; iFreq < numFreq; ++iFreq ){
std::complex<double> calElogX(1.0,0.0);
std::complex<double> calElogY(1.0,0.0);
calculateCalibrationFunctionForAnalogFilter(fileName, freq[iFreq], calElogX, calElogY);
#ifdef _DEBUG_WRITE
std::cout << "elog analog filter" << std::endl;
std::cout << std::setw(20) << std::setprecision(12) << 1.0/freq[iFreq];
std::cout << std::setw(20) << std::setprecision(12) << std::abs(calElogX);
std::cout << std::setw(20) << std::setprecision(12) << atan2(calElogX.imag(),calElogX.real()) * CommonParameters::RAD2DEG;
std::cout << std::endl;
std::cout << std::setw(20) << std::setprecision(12) << 1.0/freq[iFreq];
std::cout << std::setw(20) << std::setprecision(12) << std::abs(calElogY);
std::cout << std::setw(20) << std::setprecision(12) << atan2(calElogY.imag(),calElogY.real()) * CommonParameters::RAD2DEG;
std::cout << std::endl;
#endif
{
//------- 1st fir filer from measured calibration table
std::string path = "";
if (!ptrControl->getDirectoryOfLoggerCalibrationFiles().empty()) {
#ifdef _LINUX
path = ptrControl->getDirectoryOfLoggerCalibrationFiles() + "\/";
#else
path = ptrControl->getDirectoryOfLoggerCalibrationFiles() + "\\";
#endif
}
std::string fileName = "firh.txt";
if (ptrControl->getTypeOfElogDual() == Control::ELOGDUAL_ADU_MODE) {
fileName = "firh_adu.txt";
}
else if (ptrControl->getTypeOfElogDual() == Control::ELOGDUAL_PHX_MODE) {
fileName = "firh_phx.txt";
}
const std::complex<double> firh = Util::calculateCalibrationForFIRFilterType1(path + fileName, 9, 14336.0, freq[iFreq], true);
calElogX *= firh;
calElogY *= firh;
#ifdef _DEBUG_WRITE
std::cout << "elog firh" << std::endl;
std::cout << std::setw(20) << std::setprecision(12) << 1.0/freq[iFreq];
std::cout << std::setw(20) << std::setprecision(12) << std::abs(calElogX);
std::cout << std::setw(20) << std::setprecision(12) << atan2(calElogX.imag(),calElogX.real()) * CommonParameters::RAD2DEG;
std::cout << std::endl;
std::cout << std::setw(20) << std::setprecision(12) << 1.0/freq[iFreq];
std::cout << std::setw(20) << std::setprecision(12) << std::abs(calElogY);
std::cout << std::setw(20) << std::setprecision(12) << atan2(calElogY.imag(),calElogY.real()) * CommonParameters::RAD2DEG;
std::cout << std::endl;
#endif
}
{
//------ 2nd fir filter ---
// 4900 is described in elog cal file (4.9 Vpp input)
calElogX /= 4900.0;
calElogY /= 4900.0;
#ifdef _DEBUG_WRITE
std::cout << "elog 2nd fir filter" << std::endl;
std::cout << std::setw(20) << std::setprecision(12) << 1.0/freq[iFreq];
std::cout << std::setw(20) << std::setprecision(12) << std::abs(calElogX);
std::cout << std::setw(20) << std::setprecision(12) << atan2(calElogX.imag(),calElogX.real()) * CommonParameters::RAD2DEG;
std::cout << std::endl;
std::cout << std::setw(20) << std::setprecision(12) << 1.0/freq[iFreq];
std::cout << std::setw(20) << std::setprecision(12) << std::abs(calElogY);
std::cout << std::setw(20) << std::setprecision(12) << atan2(calElogY.imag(),calElogY.real()) * CommonParameters::RAD2DEG;
std::cout << std::endl;
#endif
}
{
//------ Gain correction ---
const double tsGroupDelay = 1.0 / 14336.0 * unitGroupDelay;
const double angle = 2.0 * CommonParameters::PI * freq[iFreq] * tsGroupDelay;
const std::complex<double> groupDelay = std::complex<double>(cos(angle), sin(angle));
calElogX /= groupDelay;
calElogY /= groupDelay;
#ifdef _DEBUG_WRITE
std::cout << "elog gain correction" << std::endl;
std::cout << std::setw(20) << std::setprecision(12) << 1.0/freq[iFreq];
std::cout << std::setw(20) << std::setprecision(12) << std::abs(calElogX);
std::cout << std::setw(20) << std::setprecision(12) << atan2(calElogX.imag(),calElogX.real()) * CommonParameters::RAD2DEG;
std::cout << std::endl;
std::cout << std::setw(20) << std::setprecision(12) << 1.0/freq[iFreq];
std::cout << std::setw(20) << std::setprecision(12) << std::abs(calElogY);
std::cout << std::setw(20) << std::setprecision(12) << atan2(calElogY.imag(),calElogY.real()) * CommonParameters::RAD2DEG;
std::cout << std::endl;
#endif
}
if( fabs(ptrControl->getSamplingFrequencyOrg() - 32.0) < CommonParameters::EPS ) {
//------ Group delay correction ---
std::string path = "";
if (!ptrControl->getDirectoryOfLoggerCalibrationFiles().empty()) {
#ifdef _LINUX
path = ptrControl->getDirectoryOfLoggerCalibrationFiles() + "\/";
#else
path = ptrControl->getDirectoryOfLoggerCalibrationFiles() + "\\";
#endif
}
std::string fileName = "firl.txt";
if (ptrControl->getTypeOfElogDual() == Control::ELOGDUAL_ADU_MODE) {
fileName = "firl_adu.txt";
}
else if (ptrControl->getTypeOfElogDual() == Control::ELOGDUAL_PHX_MODE) {
fileName = "firl_phx.txt";
}
const std::complex<double> firl = Util::calculateCalibrationForFIRFilterType2(path + fileName, 9, 1024.0, freq[iFreq], -361, 0);
calElogX *= firl;
calElogY *= firl;
#ifdef _DEBUG_WRITE
std::cout << "elog roup delay correction" << std::endl;
std::cout << std::setw(20) << std::setprecision(12) << 1.0/freq[iFreq];
std::cout << std::setw(20) << std::setprecision(12) << std::abs(calElogX);
std::cout << std::setw(20) << std::setprecision(12) << atan2(calElogX.imag(),calElogX.real()) * CommonParameters::RAD2DEG;
std::cout << std::endl;
std::cout << std::setw(20) << std::setprecision(12) << 1.0/freq[iFreq];
std::cout << std::setw(20) << std::setprecision(12) << std::abs(calElogY);
std::cout << std::setw(20) << std::setprecision(12) << atan2(calElogY.imag(),calElogY.real()) * CommonParameters::RAD2DEG;
std::cout << std::endl;
#endif
}
const std::complex<double> invCalX = 1.0 / calElogX;
ofsX << std::setw(20) << std::scientific << std::setprecision(9) << freq[iFreq];
ofsX << std::setw(20) << std::scientific << std::setprecision(9) << invCalX.real();
ofsX << std::setw(20) << std::scientific << std::setprecision(9) << invCalX.imag() << std::endl;
const std::complex<double> invCalY = 1.0 / calElogY;
ofsY << std::setw(20) << std::scientific << std::setprecision(9) << freq[iFreq];
ofsY << std::setw(20) << std::scientific << std::setprecision(9) << invCalY.real();
ofsY << std::setw(20) << std::scientific << std::setprecision(9) << invCalY.imag() << std::endl;
}
ofsX.close();
ofsY.close();
}
// Calculate calibration function for analog filter
void ElogDual::calculateCalibrationFunctionForAnalogFilter(const std::string& fileName, const double freq,
std::complex<double>& calElogX, std::complex<double>& calElogY) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
std::ifstream ifs( fileName.c_str(), std::ios::in );
if( ifs.fail() ){
ptrOutputFiles->writeErrorMessage( "File open error: " + fileName );
}
std::string line;
std::getline(ifs, line);
std::vector<std::string> dataLines;
while(std::getline(ifs, line)){
dataLines.push_back(line);
}
ifs.close();
const int numFreqsInCalFile = static_cast<int>(dataLines.size());
//ptrOutputFiles->writeLogMessage("Number of frequencies in the ELOG cal-file: " + Util::toString(numFreqsInCalFile));
double* freqsTemp = new double[numFreqsInCalFile];
double* ampX = new double[numFreqsInCalFile];
double* ampY = new double[numFreqsInCalFile];
double* phsX = new double[numFreqsInCalFile];
double* phsY = new double[numFreqsInCalFile];
int iFreq(0);
for( std::vector<std::string>::const_iterator itr = dataLines.begin(); itr != dataLines.end(); ++itr, ++iFreq ){
std::istringstream iss(*itr);
std::string sbuf;
double dbuf(0.0);
{// Freq(Hz)
std::getline(iss, sbuf, ',');
std::istringstream iss(sbuf);
iss >> dbuf;
freqsTemp[iFreq] = dbuf;
}
{// CH1 Amp(Vpp)
std::getline(iss, sbuf, ',');
std::istringstream iss(sbuf);
iss >> dbuf;
ampX[iFreq] = dbuf;
}
{// CH2 Amp(Vpp)
std::getline(iss, sbuf, ',');
std::istringstream iss(sbuf);
iss >> dbuf;
ampY[iFreq] = dbuf;
}
{// CH1 Phase(deg)
std::getline(iss, sbuf, ',');
std::istringstream iss(sbuf);
iss >> dbuf;
phsX[iFreq] = dbuf * CommonParameters::DEG2RAD;
}
{// CH2 Phase(deg)
std::getline(iss, sbuf, ',');
std::istringstream iss(sbuf);
iss >> dbuf;
phsY[iFreq] = dbuf * CommonParameters::DEG2RAD;
}
}
// Arrange the data in ascending order
int* ids = new int[numFreqsInCalFile];
for( int iFreq = 0; iFreq < numFreqsInCalFile; ++iFreq ){
ids[iFreq] = iFreq;
}
Util::quickSort(numFreqsInCalFile, ids, freqsTemp);
double* freqsInCalFile = new double[numFreqsInCalFile];
std::complex<double>* calX = new std::complex<double>[numFreqsInCalFile];
std::complex<double>* calY = new std::complex<double>[numFreqsInCalFile];
for( int iFreq = 0; iFreq < numFreqsInCalFile; ++iFreq ){
const int index = ids[iFreq];
if( iFreq >= 1 ){
const int indexPre = ids[iFreq-1];
assert( freqsTemp[index] > freqsTemp[indexPre] );
}
freqsInCalFile[iFreq] = freqsTemp[index];
calX[iFreq] = ampX[index] * std::complex<double>(cos(phsX[index]), sin(phsX[index]));
calY[iFreq] = ampY[index] * std::complex<double>(cos(phsY[index]), sin(phsY[index]));
#ifdef _DEBUG_WRITE
std::cout << std::setw(20) << std::setprecision(12) << 1.0/freqsInCalFile[iFreq];
std::cout << std::setw(20) << std::setprecision(12) << std::abs(calX[iFreq]);
std::cout << std::setw(20) << std::setprecision(12) << atan2(calX[iFreq].imag(),calX[iFreq].real()) * CommonParameters::RAD2DEG;
std::cout << std::endl;
std::cout << std::setw(20) << std::setprecision(12) << 1.0/freqsInCalFile[iFreq];
std::cout << std::setw(20) << std::setprecision(12) << std::abs(calY[iFreq]);
std::cout << std::setw(20) << std::setprecision(12) << atan2(calY[iFreq].imag(),calY[iFreq].real()) * CommonParameters::RAD2DEG;
std::cout << std::endl;
#endif
}
delete [] ids;
delete [] freqsTemp;
delete [] ampX;
delete [] ampY;
delete [] phsX;
delete [] phsY;
if( freq < freqsInCalFile[0] ){
#ifdef _DEBUG_WRITE
std::cout << "cho-shuuki" << std::endl;
std::cout << freq << " " << freqsInCalFile[0] << " " << freqsInCalFile[numFreqsInCalFile-1] << std::endl;
#endif
const double rdDelay = -156.7 * 1.e-6 * freq;
calElogX = std::abs(calX[0]) * std::complex<double>(cos(rdDelay),sin(rdDelay));
calElogY = std::abs(calY[0]) * std::complex<double>(cos(rdDelay),sin(rdDelay));
}
else if( freq > freqsInCalFile[numFreqsInCalFile-1] ){
#ifdef _DEBUG_WRITE
std::cout << "tan-shuuki" << std::endl;
std::cout << freq << " " << freqsInCalFile[0] << " " << freqsInCalFile[numFreqsInCalFile-1] << std::endl;
#endif
calElogX = calX[numFreqsInCalFile-1];
calElogY = calY[numFreqsInCalFile-1];
}
else{
#ifdef _DEBUG_WRITE
std::cout << "aida" << std::endl;
std::cout << freq << " " << freqsInCalFile[0] << " " << freqsInCalFile[numFreqsInCalFile-1] << std::endl;
#endif
for( int iFreq = 0; iFreq < numFreqsInCalFile - 1; ++iFreq ){
if( freq >= freqsInCalFile[iFreq] && freq <= freqsInCalFile[iFreq+1] ){
#ifdef _DEBUG_WRITE
std::cout << "haitta" << std::endl;
std::cout << freq << " " << freqsInCalFile[iFreq] << " " << freqsInCalFile[iFreq+1] << std::endl;
std::cout << calX[iFreq] << " " << calY[iFreq] << std::endl;
std::cout << calX[iFreq+1] << " " << calY[iFreq+1] << std::endl;
#endif
const double factor = (freq - freqsInCalFile[iFreq]) / (freqsInCalFile[iFreq+1] - freqsInCalFile[iFreq]);
calElogX = calX[iFreq] + (calX[iFreq+1] - calX[iFreq]) * factor;
calElogY = calY[iFreq] + (calY[iFreq+1] - calY[iFreq]) * factor;
}
}
}
delete [] freqsInCalFile;
delete [] calX;
delete [] calY;
}
int ElogDual::bytesToInt32(unsigned char* ptr) const {
union {
unsigned char c[4];
int i;
} tmp;
tmp.c[0] = *ptr++;
tmp.c[1] = *ptr++;
tmp.c[2] = *ptr;
if (*ptr & 0x80) {// 0x80 <-> 1000 0000
// Sign bit is 1 => negative value
tmp.c[3] = 0xFF;// 0xFF <-> 1111 1111
}
else {
// Sign bit is 0 => positive value
tmp.c[3] = 0x00;
}
return tmp.i;
}

78
src/ElogDual.h Normal file
View File

@@ -0,0 +1,78 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_ELOGDual
#define DBLDEF_ELOGDual
#include <stdio.h>
#include <stdint.h>
#include <string>
#include <vector>
#include <complex>
// Class of ELOG-Dual
class ElogDual {
public:
struct recdata_head{
uint8_t hour;
uint8_t min;
uint8_t sec;
};
const static int AD_CH = 2;
const static int AD_BYTES = 3;
const static int REC_DATALEN_HEAD = sizeof(recdata_head);
// Return the the instance of the class
static ElogDual* getInstance();
// Read elog binary file
void readElogBinaryFile( const std::string& fileName, const int numSkipData, const int numDataPoints, int& counter, double* ex, double* ey) const;
// Read elog binary file under a directory
void readElogBinaryFilesUnderADirectory(const std::string& directoryName, const int numSkipData, const int numDataPoints, double* ex, double* ey) const;
// Get calibration file name
std::string getCalibrationFileName( const int channelIndex ) const;
// Make calibration file
void makeCalibrationFile( const std::string& fileName, const double unitGroupDelay, const int channelIndexX, const int channelIndexY,
const double dipoleLengthX, const double dipoleLengthY, const std::vector<double>& freq ) const;
private:
// Calculate calibration function for analog filter
void calculateCalibrationFunctionForAnalogFilter( const std::string& fileName, const double freq,
std::complex<double>& calElogX, std::complex<double>& calElogY ) const;
int bytesToInt32(unsigned char* ptr) const;
};
#endif

821
src/ElogMT.cpp Normal file
View File

@@ -0,0 +1,821 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "ElogMT.h"
#include "Util.h"
#include "OutputFiles.h"
#include "CommonParameters.h"
#include "Control.h"
#include <iomanip>
#include <iostream>
#include <assert.h>
#include <complex>
#ifdef _USE_FILESYSTEM
#include <filesystem>
#endif
const static double MV_LSB_E = 2500. / 8388608.;
const static double MV_LSB_H = 10000. / 8388608.;
// Return the instance of the class
ElogMT* ElogMT::getInstance(){
static ElogMT instance;// The only instance
return &instance;
}
// Read ELOG-MT binary file
void ElogMT::readElogBinaryFile(const std::string& fileName, const int numSkipData, const int numDataPoints, int& counter, double* ex, double* ey, double* hz, double* hx, double* hy) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeLogMessage("Read Ex, Ey, Hz, Hx, and Hy data from " + fileName);
FILE* fp = fopen(fileName.c_str(), "rb");
if (fp == NULL) {
ptrOutputFiles->writeErrorMessage("File open error : " + fileName);
}
// Determine file type
const Control* const ptrControl = Control::getInstance();
const int freq = static_cast<int>(ptrControl->getSamplingFrequency());
const int data_size = AD_CH * freq * AD_BYTES;
unsigned char* data = new unsigned char[data_size];
while (1) {
// Read header of each block
recdata_head d;
if (fread(&d, 1, REC_DATALEN_HEAD, fp) < 1) {
break;
}
// Read AD data of each block
if (fread(data, 1, data_size, fp) < 1) {
break;
}
if (counter + freq <= numSkipData) {
counter += freq;
// Go to next block
continue;
}
// Determine end position prior to the start position because counter can be modified in determing start position
int endPos(freq);
if (numSkipData + numDataPoints > counter && numSkipData + numDataPoints <= counter + freq) {
// End position locates in this block
endPos = numSkipData + numDataPoints - counter;
}
int startPos(0);
if (numSkipData > counter && numSkipData <= counter + freq) {
// Start position locates in this block
startPos = numSkipData - counter;
counter = numSkipData;
}
for (int j = startPos; j < endPos; ++j, ++counter) {
long lbuf(0);
// Ex
lbuf = b3_to_long32(&data[j * AD_BYTES * AD_CH]);
ex[counter - numSkipData] = lbuf * MV_LSB_E;
// Ey
lbuf = b3_to_long32(&data[j * AD_BYTES * AD_CH + AD_BYTES]);
ey[counter - numSkipData] = lbuf * MV_LSB_E;
// Hx
lbuf = b3_to_long32(&data[j * AD_BYTES * AD_CH + AD_BYTES * 2]);
hx[counter - numSkipData] = lbuf * MV_LSB_H;
// Hy
lbuf = b3_to_long32(&data[j * AD_BYTES * AD_CH + AD_BYTES * 3]);
hy[counter - numSkipData] = lbuf * MV_LSB_H;
// Hz
lbuf = b3_to_long32(&data[j * AD_BYTES * AD_CH + AD_BYTES * 4]);
hz[counter - numSkipData] = lbuf * MV_LSB_H;
}
if (counter - numSkipData >= numDataPoints) {
break;
}
}
delete[] data;
fclose(fp);
}
// Read ELOG-MT binary file under a directory
void ElogMT::readElogBinaryFilesUnderADirectory(const std::string& directoryName, const int numSkipData, const int numDataPoints, double* ex, double* ey, double* hz, double* hx, double* hy) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
#ifdef _USE_FILESYSTEM
const Control* const ptrControl = Control::getInstance();
const int freq = static_cast<int>(ptrControl->getSamplingFrequency());
std::ostringstream oss;
oss << "_" << freq << "Hz";
const std::string stringCompared = oss.str();
if (std::filesystem::is_directory(directoryName)) {
auto dirItr = std::filesystem::directory_iterator(directoryName);
int counter(0);
for (auto& p : dirItr) {
const std::string fileName = p.path().string();
if (fileName.find(stringCompared) != std::string::npos && Util::extractExtensionOfFileName(fileName).find("dat") != std::string::npos ) {
readElogBinaryFile(fileName, numSkipData, numDataPoints, counter, ex, ey, hz, hx, hy);
if (counter >= numSkipData + numDataPoints) {
break;
}
}
}
}else{
ptrOutputFiles->writeErrorMessage("There is no directory of ELOG-MT data.");
}
#else
ptrOutputFiles->writeErrorMessage("Multiple inputs of ELOG data under a directory is not supported by this version.");
#endif
}
// Read ELOG-MT binary file (Ex and Ey)
void ElogMT::readElogBinaryFileExEyOnly(const std::string& fileName, const int numSkipData, const int numDataPoints, int& counter, double* ex, double* ey) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeLogMessage("Read Ex and Ey data from "+fileName);
FILE * fp = fopen(fileName.c_str(), "rb");
if(fp == NULL) {
ptrOutputFiles->writeErrorMessage("File open error : " + fileName);
}
// Determine file type
const Control* const ptrControl = Control::getInstance();
const int freq = static_cast<int>(ptrControl->getSamplingFrequency());
const int data_size = AD_CH * freq * AD_BYTES;
unsigned char* data = new unsigned char[data_size];
while(1) {
// Read header of each block
recdata_head d;
if(fread(&d, 1, REC_DATALEN_HEAD, fp) < 1){
break;
}
// Read AD data of each block
if(fread(data, 1, data_size, fp) < 1){
break;
}
if( counter + freq <= numSkipData ){
counter += freq;
// Go to next block
continue;
}
// Determine end position prior to the start position because counter can be modified in determing start position
int endPos(freq);
if( numSkipData + numDataPoints > counter && numSkipData + numDataPoints <= counter + freq ){
// End position locates in this block
endPos = numSkipData + numDataPoints - counter;
}
int startPos(0);
if( numSkipData > counter && numSkipData <= counter + freq ){
// Start position locates in this block
startPos = numSkipData - counter;
counter = numSkipData;
}
for( int j = startPos; j < endPos; ++j, ++counter ){
// Ex
long lbufx = b3_to_long32( &data[j*AD_BYTES*AD_CH] );
ex[counter - numSkipData] = lbufx * MV_LSB_E;
// Ey
long lbufy = b3_to_long32( &data[j*AD_BYTES*AD_CH + AD_BYTES] );
ey[counter - numSkipData] = lbufy * MV_LSB_E;
}
if( counter - numSkipData >= numDataPoints ){
break;
}
}
delete [] data;
fclose(fp);
}
// Read ELOG-MT binary file under a directory (two electric field data only)
void ElogMT::readElogBinaryFilesUnderADirectoryExEyOnly(const std::string& directoryName, const int numSkipData, const int numDataPoints, double* ex, double* ey) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
#ifdef _USE_FILESYSTEM
const Control* const ptrControl = Control::getInstance();
const int freq = static_cast<int>(ptrControl->getSamplingFrequency());
std::ostringstream oss;
oss << "_" << freq << "Hz";
const std::string stringCompared = oss.str();
if (std::filesystem::is_directory(directoryName)) {
auto dirItr = std::filesystem::directory_iterator(directoryName);
int counter(0);
for (auto& p : dirItr) {
const std::string fileName = p.path().string();
if (fileName.find(stringCompared) != std::string::npos && Util::extractExtensionOfFileName(fileName).find("dat") != std::string::npos) {
readElogBinaryFileExEyOnly(fileName, numSkipData, numDataPoints, counter, ex, ey);
if (counter >= numSkipData + numDataPoints) {
break;
}
}
}
} else {
ptrOutputFiles->writeErrorMessage("There is no directory of ELOG-MT data.");
}
#else
ptrOutputFiles->writeErrorMessage("Multiple inputs of ELOG data under a directory is not supported by this version.");
#endif
}
// Read ELOG-MT binary file (Hx and Hy)
void ElogMT::readElogBinaryFileHxHyOnly(const std::string& fileName, const int numSkipData, const int numDataPoints, int& counter, double* hx, double* hy) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeLogMessage("Read Hx and Hy data from " + fileName);
FILE* fp = fopen(fileName.c_str(), "rb");
if (fp == NULL) {
ptrOutputFiles->writeErrorMessage("File open error : " + fileName);
}
// Determine file type
const Control* const ptrControl = Control::getInstance();
const int freq = static_cast<int>(ptrControl->getSamplingFrequency());
const int data_size = AD_CH * freq * AD_BYTES;
unsigned char* data = new unsigned char[data_size];
while (1) {
// Read header of each block
recdata_head d;
if (fread(&d, 1, REC_DATALEN_HEAD, fp) < 1) {
break;
}
// Read AD data of each block
if (fread(data, 1, data_size, fp) < 1) {
break;
}
if (counter + freq <= numSkipData) {
counter += freq;
// Go to next block
continue;
}
// Determine end position prior to the start position because counter can be modified in determing start position
int endPos(freq);
if (numSkipData + numDataPoints > counter && numSkipData + numDataPoints <= counter + freq) {
// End position locates in this block
endPos = numSkipData + numDataPoints - counter;
}
int startPos(0);
if (numSkipData > counter && numSkipData <= counter + freq) {
// Start position locates in this block
startPos = numSkipData - counter;
counter = numSkipData;
}
for (int j = startPos; j < endPos; ++j, ++counter) {
long lbuf(0);
// Hx
lbuf = b3_to_long32(&data[j * AD_BYTES * AD_CH + AD_BYTES * 2]);
hx[counter - numSkipData] = lbuf * MV_LSB_H;
// Hy
lbuf = b3_to_long32(&data[j * AD_BYTES * AD_CH + AD_BYTES * 3]);
hy[counter - numSkipData] = lbuf * MV_LSB_H;
}
if (counter - numSkipData >= numDataPoints) {
break;
}
}
delete[] data;
fclose(fp);
}
// Read ELOG-MT binary file under a directory(two horizontal magnetic field data only)
void ElogMT::readElogBinaryFilesUnderADirectoryHxHyOnly(const std::string& directoryName, const int numSkipData, const int numDataPoints, double* hx, double* hy) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
#ifdef _USE_FILESYSTEM
const Control* const ptrControl = Control::getInstance();
const int freq = static_cast<int>(ptrControl->getSamplingFrequency());
std::ostringstream oss;
oss << "_" << freq << "Hz";
const std::string stringCompared = oss.str();
if (std::filesystem::is_directory(directoryName)) {
auto dirItr = std::filesystem::directory_iterator(directoryName);
int counter(0);
for (auto& p : dirItr) {
const std::string fileName = p.path().string();
if (fileName.find(stringCompared) != std::string::npos && Util::extractExtensionOfFileName(fileName).find("dat") != std::string::npos) {
readElogBinaryFileHxHyOnly(fileName, numSkipData, numDataPoints, counter, hx, hy);
if (counter >= numSkipData + numDataPoints) {
break;
}
}
}
} else {
ptrOutputFiles->writeErrorMessage("There is no directory of ELOG-MT data.");
}
#else
ptrOutputFiles->writeErrorMessage("Multiple inputs of ELOG data under a directory is not supported by this version.");
#endif
}
// Read ELOG-MT binary file (Ex, Ey, Hx, and Hy only)
void ElogMT::readElogBinaryFileExEyHxHyOnly(const std::string& fileName, const int numSkipData, const int numDataPoints, int& counter, double* ex, double* ey, double* hx, double* hy) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeLogMessage("Read Ex, Ey, Hx, and Hy data from " + fileName);
FILE* fp = fopen(fileName.c_str(), "rb");
if (fp == NULL) {
ptrOutputFiles->writeErrorMessage("File open error : " + fileName);
}
// Determine file type
const Control* const ptrControl = Control::getInstance();
const int freq = static_cast<int>(ptrControl->getSamplingFrequency());
const int data_size = AD_CH * freq * AD_BYTES;
unsigned char* data = new unsigned char[data_size];
while (1) {
// Read header of each block
recdata_head d;
if (fread(&d, 1, REC_DATALEN_HEAD, fp) < 1) {
break;
}
// Read AD data of each block
if (fread(data, 1, data_size, fp) < 1) {
break;
}
if (counter + freq <= numSkipData) {
counter += freq;
// Go to next block
continue;
}
// Determine end position prior to the start position because counter can be modified in determing start position
int endPos(freq);
if (numSkipData + numDataPoints > counter && numSkipData + numDataPoints <= counter + freq) {
// End position locates in this block
endPos = numSkipData + numDataPoints - counter;
}
int startPos(0);
if (numSkipData > counter && numSkipData <= counter + freq) {
// Start position locates in this block
startPos = numSkipData - counter;
counter = numSkipData;
}
for (int j = startPos; j < endPos; ++j, ++counter) {
long lbuf(0);
// Ex
lbuf = b3_to_long32(&data[j * AD_BYTES * AD_CH]);
ex[counter - numSkipData] = lbuf * MV_LSB_E;
// Ey
lbuf = b3_to_long32(&data[j * AD_BYTES * AD_CH + AD_BYTES]);
ey[counter - numSkipData] = lbuf * MV_LSB_E;
// Hx
lbuf = b3_to_long32(&data[j * AD_BYTES * AD_CH + AD_BYTES * 2]);
hx[counter - numSkipData] = lbuf * MV_LSB_H;
// Hy
lbuf = b3_to_long32(&data[j * AD_BYTES * AD_CH + AD_BYTES * 3]);
hy[counter - numSkipData] = lbuf * MV_LSB_H;
}
if (counter - numSkipData >= numDataPoints) {
break;
}
}
delete[] data;
fclose(fp);
}
// Read ELOG-MT binary file under a directory (Ex, Ey, Hx, and Hy only)
void ElogMT::readElogBinaryFilesUnderADirectoryExEyHxHyOnly(const std::string& directoryName, const int numSkipData, const int numDataPoints, double* ex, double* ey, double* hx, double* hy) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
#ifdef _USE_FILESYSTEM
const Control* const ptrControl = Control::getInstance();
const int freq = static_cast<int>(ptrControl->getSamplingFrequency());
std::ostringstream oss;
oss << "_" << freq << "Hz";
const std::string stringCompared = oss.str();
if (std::filesystem::is_directory(directoryName)) {
auto dirItr = std::filesystem::directory_iterator(directoryName);
int counter(0);
for (auto& p : dirItr) {
const std::string fileName = p.path().string();
if (fileName.find(stringCompared) != std::string::npos && Util::extractExtensionOfFileName(fileName).find("dat") != std::string::npos) {
readElogBinaryFileExEyHxHyOnly(fileName, numSkipData, numDataPoints, counter, ex, ey, hx, hy);
if (counter >= numSkipData + numDataPoints) {
break;
}
}
}
} else {
ptrOutputFiles->writeErrorMessage("There is no directory of ELOG-MT data.");
}
#else
ptrOutputFiles->writeErrorMessage("Multiple inputs of ELOG data under a directory is not supported by this version.");
#endif
}
// Read ELOG-MT binary file (Hz, Hx, and Hy only)
void ElogMT::readElogBinaryFileHzHxHyOnly(const std::string& fileName, const int numSkipData, const int numDataPoints, int& counter, double* hz, double* hx, double* hy) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeLogMessage("Read Hz, Hx, and Hy data from " + fileName);
FILE* fp = fopen(fileName.c_str(), "rb");
if (fp == NULL) {
ptrOutputFiles->writeErrorMessage("File open error : " + fileName);
}
// Determine file type
const Control* const ptrControl = Control::getInstance();
const int freq = static_cast<int>(ptrControl->getSamplingFrequency());
const int data_size = AD_CH * freq * AD_BYTES;
unsigned char* data = new unsigned char[data_size];
while (1) {
// Read header of each block
recdata_head d;
if (fread(&d, 1, REC_DATALEN_HEAD, fp) < 1) {
break;
}
// Read AD data of each block
if (fread(data, 1, data_size, fp) < 1) {
break;
}
if (counter + freq <= numSkipData) {
counter += freq;
// Go to next block
continue;
}
// Determine end position prior to the start position because counter can be modified in determing start position
int endPos(freq);
if (numSkipData + numDataPoints > counter && numSkipData + numDataPoints <= counter + freq) {
// End position locates in this block
endPos = numSkipData + numDataPoints - counter;
}
int startPos(0);
if (numSkipData > counter && numSkipData <= counter + freq) {
// Start position locates in this block
startPos = numSkipData - counter;
counter = numSkipData;
}
for (int j = startPos; j < endPos; ++j, ++counter) {
long lbuf(0);
// Hx
lbuf = b3_to_long32(&data[j * AD_BYTES * AD_CH + AD_BYTES * 2]);
hx[counter - numSkipData] = lbuf * MV_LSB_H;
// Hy
lbuf = b3_to_long32(&data[j * AD_BYTES * AD_CH + AD_BYTES * 3]);
hy[counter - numSkipData] = lbuf * MV_LSB_H;
// Hz
lbuf = b3_to_long32(&data[j * AD_BYTES * AD_CH + AD_BYTES * 4]);
hz[counter - numSkipData] = lbuf * MV_LSB_H;
}
if (counter - numSkipData >= numDataPoints) {
break;
}
}
delete[] data;
fclose(fp);
}
// Read ELOG-MT binary file under a directory (Hz, Hx, and Hy only)
void ElogMT::readElogBinaryFilesUnderADirectoryHzHxHyOnly(const std::string& directoryName, const int numSkipData, const int numDataPoints, double* hz, double* hx, double* hy) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
#ifdef _USE_FILESYSTEM
const Control* const ptrControl = Control::getInstance();
const int freq = static_cast<int>(ptrControl->getSamplingFrequency());
std::ostringstream oss;
oss << "_" << freq << "Hz";
const std::string stringCompared = oss.str();
if (std::filesystem::is_directory(directoryName)) {
auto dirItr = std::filesystem::directory_iterator(directoryName);
int counter(0);
for (auto& p : dirItr) {
const std::string fileName = p.path().string();
if (fileName.find(stringCompared) != std::string::npos && Util::extractExtensionOfFileName(fileName).find("dat") != std::string::npos) {
readElogBinaryFileHzHxHyOnly(fileName, numSkipData, numDataPoints, counter, hz, hx, hy);
if (counter >= numSkipData + numDataPoints) {
break;
}
}
}
}
else {
ptrOutputFiles->writeErrorMessage("There is no directory of ELOG-MT data.");
}
#else
ptrOutputFiles->writeErrorMessage("Multiple inputs of ELOG data under a directory is not supported by this version.");
#endif
}
// Get calibration file name
std::string ElogMT::getCalibrationFileName( const int channelIndex ) const{
std::ostringstream fileName;
fileName << "channel" << channelIndex << ".cal";
return fileName.str();
}
// Make calibration file
void ElogMT::makeCalibrationFile( const std::string& fileName, const double unitGroupDelay, const std::vector<int>& channelIndexes,
const double dipoleLengthX, const double dipoleLengthY, const std::vector<double>& freq ) const{
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
const int numFreq = static_cast<int>(freq.size());
if( numFreq < 1 ){
ptrOutputFiles->writeErrorMessage( "Number of the frequencies for which calibrations are estimated is less than 1 : " + Util::toString(numFreq) );
}
std::ofstream ofs[AD_CH];
for( std::vector<int>::const_iterator itr = channelIndexes.begin(); itr != channelIndexes.end(); ++itr ){
const int iCh = *itr;
const std::string outputFileName = getCalibrationFileName(iCh);
ofs[iCh].open( outputFileName.c_str(), std::ios::out );
if( ofs[iCh].fail() ){
ptrOutputFiles->writeErrorMessage( "File open error : " + outputFileName );
}
if( iCh == 0 ){
const double dipoleLength = dipoleLengthX / -1000.0;// [m] -> [km] and invert sign
ofs[iCh] << std::setw(20) << std::scientific << std::setprecision(9) << 1.0/dipoleLength << std::endl;
}else if( iCh == 1 ){
const double dipoleLength = dipoleLengthY / -1000.0;// [m] -> [km] and invert sign
ofs[iCh] << std::setw(20) << std::scientific << std::setprecision(9) << 1.0/dipoleLength << std::endl;
}else{
ofs[iCh] << std::setw(20) << std::scientific << std::setprecision(9) << 1.0 << std::endl;
}
ofs[iCh] << std::setw(10) << numFreq << std::endl;
}
const Control* const ptrControl = Control::getInstance();
for( int iFreq = 0; iFreq < numFreq; ++iFreq ){
std::complex<double> calElog[AD_CH];
for( int iCh = 0; iCh < AD_CH; ++iCh ){
calElog[iCh] = std::complex<double>(1.0, 0.0);
}
calculateCalibrationFunctionForAnalogFilter(fileName, freq[iFreq], calElog);
{
//------- 1st fir filer from measured calibration table
std::string path = "";
if (!ptrControl->getDirectoryOfLoggerCalibrationFiles().empty()) {
#ifdef _LINUX
path = ptrControl->getDirectoryOfLoggerCalibrationFiles() + "\/";
#else
path = ptrControl->getDirectoryOfLoggerCalibrationFiles() + "\\";
#endif
}
std::string fileName = "firh.txt";
if (ptrControl->getTypeOfElogMT() == Control::ELOGMT_ADU_MODE) {
fileName = "firh_adu.txt";
}
else if (ptrControl->getTypeOfElogMT() == Control::ELOGMT_PHX_MODE) {
fileName = "firh_phx.txt";
}
const std::complex<double> firh = Util::calculateCalibrationForFIRFilterType1(path + fileName, 9, 14336.0, freq[iFreq], true);
for( int iCh = 0; iCh < AD_CH; ++iCh ){
calElog[iCh] *= firh;
}
}
{
//------ 2nd fir filter ---
// 4900 is described in elog cal file (4.9 Vpp input)
for( int iCh = 0; iCh < AD_CH; ++iCh ){
calElog[iCh] /= 4900.0;
}
}
{
//------ Gain correction ---
const double tsGroupDelay = 1.0 / 14336.0 * unitGroupDelay;
const double angle = 2.0 * CommonParameters::PI * freq[iFreq] * tsGroupDelay;
const std::complex<double> groupDelay = std::complex<double>(cos(angle), sin(angle));
for( int iCh = 0; iCh < AD_CH; ++iCh ){
calElog[iCh] /= groupDelay;
}
}
if( fabs(ptrControl->getSamplingFrequencyOrg() - 32.0) < CommonParameters::EPS ) {
//------ Group delay correction ---
std::string path = "";
if (!ptrControl->getDirectoryOfLoggerCalibrationFiles().empty()) {
#ifdef _LINUX
path = ptrControl->getDirectoryOfLoggerCalibrationFiles() + "\/";
#else
path = ptrControl->getDirectoryOfLoggerCalibrationFiles() + "\\";
#endif
}
std::string fileName = "firl.txt";
if (ptrControl->getTypeOfElogMT() == Control::ELOGMT_ADU_MODE) {
fileName = "firl_adu.txt";
}
else if (ptrControl->getTypeOfElogMT() == Control::ELOGMT_PHX_MODE) {
fileName = "firl_phx.txt";
}
const std::complex<double> firl = Util::calculateCalibrationForFIRFilterType2(path + fileName, 9, 1024.0, freq[iFreq], -396, 0);
for( int iCh = 0; iCh < AD_CH; ++iCh ){
calElog[iCh] *= firl;
}
}
for( std::vector<int>::const_iterator itr = channelIndexes.begin(); itr != channelIndexes.end(); ++itr ){
const int iCh = *itr;
const std::complex<double> invCal = 1.0 / calElog[iCh];
ofs[iCh] << std::setw(20) << std::scientific << std::setprecision(9) << freq[iFreq];
ofs[iCh] << std::setw(20) << std::scientific << std::setprecision(9) << invCal.real();
ofs[iCh] << std::setw(20) << std::scientific << std::setprecision(9) << invCal.imag() << std::endl;
}
}
for( std::vector<int>::const_iterator itr = channelIndexes.begin(); itr != channelIndexes.end(); ++itr ){
const int iCh = * itr;
ofs[iCh].close();
}
}
// Calculate calibration function for analog filter
void ElogMT::calculateCalibrationFunctionForAnalogFilter( const std::string& fileName, const double freq, std::complex<double>* calElog ) const{
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
std::ifstream ifs( fileName.c_str(), std::ios::in );
if( ifs.fail() ){
ptrOutputFiles->writeErrorMessage( "File open error: " + fileName );
}
std::string line;
std::getline(ifs, line);
std::vector<std::string> dataLines;
while(std::getline(ifs, line)){
dataLines.push_back(line);
}
ifs.close();
const int numFreqsInCalFile = static_cast<int>(dataLines.size());
double* freqsTemp = new double[numFreqsInCalFile];
double** amp = new double*[AD_CH];
double** phs = new double*[AD_CH];
for( int iCh = 0; iCh < AD_CH; ++iCh ){
amp[iCh] = new double[numFreqsInCalFile];
phs[iCh] = new double[numFreqsInCalFile];
for( int i = 0; i < numFreqsInCalFile; ++i ){
amp[iCh][i] = 0.0;
phs[iCh][i] = 0.0;
}
}
int iFreq(0);
for( std::vector<std::string>::const_iterator itr = dataLines.begin(); itr != dataLines.end(); ++itr, ++iFreq ){
std::istringstream iss(*itr);
std::string sbuf;
double dbuf(0.0);
{// Freq(Hz)
std::getline(iss, sbuf, ',');
std::istringstream iss(sbuf);
iss >> dbuf;
freqsTemp[iFreq] = dbuf;
}
for( int iCh = 0; iCh < AD_CH; ++iCh ){
{// Amp(Vpp)
std::getline(iss, sbuf, ',');
std::istringstream iss(sbuf);
iss >> dbuf;
amp[iCh][iFreq] = dbuf;
}
{// Phase(deg)
std::getline(iss, sbuf, ',');
std::istringstream iss(sbuf);
iss >> dbuf;
phs[iCh][iFreq] = dbuf * CommonParameters::DEG2RAD;
}
}
}
// Arrange the data in ascending order
int* ids = new int[numFreqsInCalFile];
for( int iFreq = 0; iFreq < numFreqsInCalFile; ++iFreq ){
ids[iFreq] = iFreq;
}
Util::quickSort(numFreqsInCalFile, ids, freqsTemp);
double* freqsInCalFile = new double[numFreqsInCalFile];
std::complex<double>** cal = new std::complex<double>*[AD_CH];
for( int iCh = 0; iCh < AD_CH; ++iCh ){
cal[iCh] = new std::complex<double>[numFreqsInCalFile];
}
for( int iFreq = 0; iFreq < numFreqsInCalFile; ++iFreq ){
const int index = ids[iFreq];
if( iFreq >= 1 ){
const int indexPre = ids[iFreq-1];
assert( freqsTemp[index] > freqsTemp[indexPre] );
}
freqsInCalFile[iFreq] = freqsTemp[index];
for( int iCh = 0; iCh < AD_CH; ++iCh ){
cal[iCh][iFreq] = amp[iCh][index] * std::complex<double>(cos(phs[iCh][index]), sin(phs[iCh][index]));
}
}
delete [] ids;
delete [] freqsTemp;
for( int i = 0; i < AD_CH; ++i ){
delete [] amp[i];
delete [] phs[i];
}
delete [] amp ;
delete [] phs;
if( freq < freqsInCalFile[0] ){
const double rdDelay = -156.7 * 1.e-6 * freq;
for( int iCh = 0; iCh < AD_CH; ++iCh ){
calElog[iCh] = std::abs(cal[iCh][0]) * std::complex<double>(cos(rdDelay),sin(rdDelay));
}
}
else if( freq > freqsInCalFile[numFreqsInCalFile-1] ){
for( int iCh = 0; iCh < AD_CH; ++iCh ){
calElog[iCh] = cal[iCh][numFreqsInCalFile-1];
}
}
else{
for( int iFreq = 0; iFreq < numFreqsInCalFile - 1; ++iFreq ){
if( freq >= freqsInCalFile[iFreq] && freq <= freqsInCalFile[iFreq+1] ){
const double factor = (freq - freqsInCalFile[iFreq]) / (freqsInCalFile[iFreq+1] - freqsInCalFile[iFreq]);
for( int iCh = 0; iCh < AD_CH; ++iCh ){
calElog[iCh] = cal[iCh][iFreq] + (cal[iCh][iFreq+1] - cal[iCh][iFreq]) * factor;
}
}
}
}
delete [] freqsInCalFile;
for( int iCh = 0; iCh < AD_CH; ++iCh ){
delete [] cal[iCh];
}
delete [] cal;
}
int32_t ElogMT::b3_to_long32( unsigned char *ptr ) const{
union {
unsigned char c[4];
int32_t i;
} tmp;
tmp.c[0] = *ptr++;
tmp.c[1] = *ptr++;
tmp.c[2] = *ptr;
if(*ptr & 0x80){// 0x80 <-> 1000 0000
// Sign bit is 1 => negative value
tmp.c[3] = 0xFF;// 0xFF <-> 1111 1111
}else {
// Sign bit is 0 => positive value
tmp.c[3] = 0;
}
#ifdef _DEBUG_WRITE
printf("tmp.i : 0x%08X\n", tmp.i);
for( int i = 0; i < 4; i++){
printf("tmp.c[%d] : 0x%02X\n", i, tmp.c[i]);
}
std::cout << tmp.i << std::endl;
#endif
return tmp.i;
}

102
src/ElogMT.h Normal file
View File

@@ -0,0 +1,102 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_ElogMT
#define DBLDEF_ElogMT
#include <stdio.h>
#include <stdint.h>
#include <string>
#include <vector>
#include <complex>
// Class of ELOG-MT mode
class ElogMT{
public:
struct recdata_head{
uint8_t hour;
uint8_t min;
uint8_t sec;
};
// Return the the instance of the class
static ElogMT* getInstance();
static const int AD_CH = 5;
static const int AD_BYTES = 3;
static const int REC_DATALEN_HEAD = sizeof(recdata_head);
// Read ELOG-MT binary file
void readElogBinaryFile(const std::string& fileName, const int numSkipData, const int numDataPoints, int& counter, double* ex, double* ey, double* hz, double* hx, double* hy) const;
// Read ELOG-MT binary file under a directory
void readElogBinaryFilesUnderADirectory(const std::string& directoryName, const int numSkipData, const int numDataPoints, double* ex, double* ey, double* hz, double* hx, double* hy) const;
// Read ELOG-MT binary file (Ex and Ey only)
void readElogBinaryFileExEyOnly(const std::string& fileName, const int numSkipData, const int numDataPoints, int& counter, double* ex, double* ey) const;
// Read ELOG-MT binary file under a directory (Ex and Ey only)
void readElogBinaryFilesUnderADirectoryExEyOnly(const std::string& directoryName, const int numSkipData, const int numDataPoints, double* ex, double* ey) const;
// Read ELOG-MT binary file (Hx and Hy only)
void readElogBinaryFileHxHyOnly(const std::string& fileName, const int numSkipData, const int numDataPoints, int& counter, double* hx, double* hy) const;
// Read ELOG-MT binary file under a directory (Hx and Hy only)
void readElogBinaryFilesUnderADirectoryHxHyOnly(const std::string& directoryName, const int numSkipData, const int numDataPoints, double* hx, double* hy) const;
// Read ELOG-MT binary file (Ex, Ey, Hx, and Hy only)
void readElogBinaryFileExEyHxHyOnly(const std::string& fileName, const int numSkipData, const int numDataPoints, int& counter, double* ex, double* ey, double* hx, double* hy) const;
// Read ELOG-MT binary file under a directory (Ex, Ey, Hx, and Hy only)
void readElogBinaryFilesUnderADirectoryExEyHxHyOnly(const std::string& directoryName, const int numSkipData, const int numDataPoints, double* ex, double* ey, double* hx, double* hy) const;
// Read ELOG-MT binary file (Hz, Hx, and Hy only)
void readElogBinaryFileHzHxHyOnly(const std::string& fileName, const int numSkipData, const int numDataPoints, int& counter, double* hz, double* hx, double* hy) const;
// Read ELOG-MT binary file under a directory (Hz, Hx, and Hy only)
void readElogBinaryFilesUnderADirectoryHzHxHyOnly(const std::string& directoryName, const int numSkipData, const int numDataPoints, double* hz, double* hx, double* hy) const;
// Get calibration file name
std::string getCalibrationFileName( const int channelIndex ) const;
// Make calibration file
void makeCalibrationFile( const std::string& fileName, const double unitGroupDelay, const std::vector<int>& channelIndexes,
const double dipoleLengthX, const double dipoleLengthY, const std::vector<double>& freq ) const;
private:
// Calculate calibration function for analog filter
void calculateCalibrationFunctionForAnalogFilter( const std::string& fileName, const double freq, std::complex<double>* calElog ) const;
int32_t b3_to_long32( unsigned char *ptr ) const;
};
#endif

278
src/LapackInterface.cpp Normal file
View File

@@ -0,0 +1,278 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "LapackInterface.h"
#include "OutputFiles.h"
#include "Util.h"
extern "C"
{
#include "f2c.h"
#include "clapack.h"
}
// Calcualte all eigenvalues and eigenvectors of a real symmetric matrix
// @note Matrix and vectors are overwritten
void LapackInterface::calculateEigenValuesAndVectorsOfRealSymmetricMatrix( const int dimension, double* matrix, double* vectors ){
integer n = static_cast<integer>(dimension);
integer lda = n;
integer dum1 = 1;
integer dum2 = -1;
integer nb = ilaenv_(&dum1, "DSYTRD", "L", &n, &dum2, &dum2, &dum2);
integer lwork = (nb + 2) * n;
double* work = new double[lwork];
integer info = 0;
dsyev_("V", "L", &n, matrix, &lda, vectors, work, &lwork, &info);
delete[] work;
if (info < 0) {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("An argument had an illegal value : info=" + Util::toString(info));
}
else if (info > 0) {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("Eigenvalue calculation is not converged : info=" + Util::toString(info));
}
}
// Factrize and solve linear equation with real coefficents matrix
// @note Matrix and vectors are overwritten
void LapackInterface::factorizeAndSolveLinearEquationRealMatrix( const int dimension, const int nRhs, double* matrix, double* vectors ){
integer n = static_cast<integer>( dimension );
integer nb = static_cast<integer>( nRhs );
integer lda = n;
integer* ipiv = new integer[dimension];
integer ldb = n;
integer info(0);
dgesv_(&n, &nb, matrix, &lda, ipiv, vectors, &ldb, &info);
delete [] ipiv;
if( info < 0 ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("An argument had an illegal value : info="+Util::toString(info) );
}else if( info > 0 ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("Singular matrix : info="+Util::toString(info) );
}
}
// Factrize and solve linear equation with real symmetric matrix
// @note Matrix and vectors are overwritten
void LapackInterface::factorizeAndSolveLinearEquationRealSymmetricMatrix( const int dimension, const int nRhs, double* matrix, double* vectors ){
integer n = static_cast<integer>( dimension );
integer nb = static_cast<integer>( nRhs );
integer lda = n;
integer* ipiv = new integer[dimension];
integer ldb = n;
integer lwork = n * nb;
double* work = new double[lwork];
integer info(0);
dsysv_("L", &n, &nb, matrix, &lda, ipiv, vectors, &ldb, work, &lwork, &info);
delete [] ipiv;
delete [] work;
if( info < 0 ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("An argument had an illegal value : info="+Util::toString(info) );
}else if( info > 0 ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("D(i,i) is exactly zero : info="+Util::toString(info) );
}
}
// Factrize and solve linear equation with real symmetric positive definite matrix
// @note Matrix and vectors are overwritten
void LapackInterface::factorizeAndSolveLinearEquationRealSymmetricPositiveDefiniteMatrix( const int dimension, const int nRhs, double* matrix, double* vectors ){
integer n = static_cast<integer>( dimension );
integer nb = static_cast<integer>( nRhs );
integer lda = n;
integer ldb = n;
integer info(0);
dposv_("L", &n, &nb, matrix, &lda, vectors, &ldb, &info);
if( info < 0 ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("An argument had an illegal value : info="+Util::toString(info) );
}else if( info > 0 ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("D(i,i) is exactly zero : info="+Util::toString(info) );
}
}
// Factorize a real square matrix
// @note Matrix and vectors are overwritten
void LapackInterface::factorizeRealSquareMatrix( const int dimension, double* matrix, int* ipivInt ){
integer n = static_cast<integer>(dimension);
integer m = n;
integer lda = m;
integer info(0);
integer* ipiv = new integer[dimension];
dgetrf_( &m, &n, matrix, &lda, ipiv, &info );
for( int i = 0; i < dimension; ++i ){
ipivInt[i] = ipiv[i];
}
delete [] ipiv;
if( info < 0 ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("An argument had an illegal value : info="+Util::toString(info) );
}else if( info > 0 ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage(" D(i,i) is exactly zero : info="+Util::toString(info) );
}
}
// Factorize a real symmetric matrix
// @note Matrix and vectors are overwritten
void LapackInterface::factorizeRealSymmetricMatrix( const int dimension, double* matrix, int* ipivInt ){
integer n = static_cast<integer>(dimension);
integer dum1 = 1;
integer dum2 = -1;
integer nb = ilaenv_( &dum1, "DSYTRF", "L", &n, &dum2, &dum2, &dum2 );
integer lda = n;
integer* ipiv = new integer[dimension];
integer lwork = n * nb;
double* work = new double[lwork];
integer info(0);
dsytrf_("L", &n, matrix, &lda, ipiv, work, &lwork, &info);
for( int i = 0; i < dimension; ++i ){
ipivInt[i] = ipiv[i];
}
delete [] ipiv;
delete [] work;
if( info < 0 ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("An argument had an illegal value : info="+Util::toString(info) );
}else if( info > 0 ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage(" D(i,i) is exactly zero : info="+Util::toString(info) );
}
}
// Factorize a real symmetric positive definite matrix
// @note Matrix and vectors are overwritten
void LapackInterface::factorizeRealSymmetricPositiveDefiniteMatrix( const int dimension, double* matrix ){
integer n = static_cast<integer>(dimension);
integer lda = n;
integer info(0);
dpotrf_("L", &n, matrix, &lda, &info);
if( info < 0 ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("An argument had an illegal value : info="+Util::toString(info) );
}else if( info > 0 ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage(" D(i,i) is exactly zero : info="+Util::toString(info) );
}
}
// Solve a linear equation with real square matrix
void LapackInterface::solveLinearEquationRealSquareMatrix( const int dimension, const int nRhs, const int* const ipivInt, double* factorizedMatrix, double* vectors ){
integer n = static_cast<integer>(dimension);
integer nb = static_cast<integer>(nRhs);
integer lda = n;
integer* ipiv = new integer[dimension];
for( int i = 0; i < dimension; ++i ){
ipiv[i] = ipivInt[i];
}
integer ldb = n;
integer info(0);
dgetrs_("N", &n, &nb, factorizedMatrix, &lda, ipiv, vectors, &ldb, &info);
delete [] ipiv;
if( info < 0 ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("An argument had an illegal value : info="+Util::toString(info) );
}
}
// Solve a linear equation with real symmetric matrix
void LapackInterface::solveLinearEquationRealSymmetricMatrix( const int dimension, const int nRhs, const int* const ipivInt, double* factorizedMatrix, double* vectors ){
integer n = static_cast<integer>(dimension);
integer nb = static_cast<integer>(nRhs);
integer lda = n;
integer* ipiv = new integer[dimension];
for( int i = 0; i < dimension; ++i ){
ipiv[i] = ipivInt[i];
}
integer ldb = n;
integer info(0);
dsytrs_("L", &n, &nb, factorizedMatrix, &lda, ipiv, vectors, &ldb, &info);
delete [] ipiv;
if( info < 0 ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("An argument had an illegal value : info="+Util::toString(info) );
}
}
// Solve a linear equation with real symmetric positive definite matrix
void LapackInterface::solveLinearEquationRealSymmetricPositiveDefiniteMatrix( const int dimension, const int nRhs, double* factorizedMatrix, double* vectors ){
integer n = static_cast<integer>(dimension);
integer nb = static_cast<integer>(nRhs);
integer lda = n;
integer* ipiv = new integer[dimension];
integer ldb = n;
integer info(0);
dpotrs_("L", &n, &nb, factorizedMatrix, &lda, vectors, &ldb, &info);
if( info < 0 ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("An argument had an illegal value : info="+Util::toString(info) );
}
}

74
src/LapackInterface.h Normal file
View File

@@ -0,0 +1,74 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_LAPACK_INTERFACE
#define DBLDEF_LAPACK_INTERFACE
namespace LapackInterface
{
// Calcualte all eigenvalues and eigenvectors of a real symmetric matrix
// @note Matrix and vectors are overwritten
void calculateEigenValuesAndVectorsOfRealSymmetricMatrix( const int dimension, double* matrix, double* vectors );
// Factorize and solve a linear equation with real coefficents matrix
// @note Matrix and vectors are overwritten
void factorizeAndSolveLinearEquationRealMatrix( const int dimension, const int nRhs, double* matrix, double* vectors );
// Factorize and solve a linear equation with real symmetric matrix
// @note Matrix and vectors are overwritten
void factorizeAndSolveLinearEquationRealSymmetricMatrix( const int dimension, const int nRhs, double* matrix, double* vectors );
// Factorize and solve a linear equation with real symmetric positive definite matrix
// @note Matrix and vectors are overwritten
void factorizeAndSolveLinearEquationRealSymmetricPositiveDefiniteMatrix( const int dimension, const int nRhs, double* matrix, double* vectors );
// Factorize a real square matrix
// @note Matrix and vectors are overwritten
void factorizeRealSquareMatrix( const int dimension, double* matrix, int* ipivInt );
// Factorize a real symmetric matrix
// @note Matrix and vectors are overwritten
void factorizeRealSymmetricMatrix( const int dimension, double* matrix, int* ipivInt );
// Factorize a real symmetric positive definite matrix
// @note Matrix and vectors are overwritten
void factorizeRealSymmetricPositiveDefiniteMatrix( const int dimension, double* matrix );
// Solve a linear equation with real square matrix
void solveLinearEquationRealSquareMatrix( const int dimension, const int nRhs, const int* const ipivInt, double* factorizedMatrix, double* vectors );
// Solve a linear equation with real symmetric matrix
void solveLinearEquationRealSymmetricMatrix( const int dimension, const int nRhs, const int* const ipivInt, double* factorizedMatrix, double* vectors );
// Solve a linear equation with real symmetric positive definite matrix
void solveLinearEquationRealSymmetricPositiveDefiniteMatrix( const int dimension, const int nRhs, double* factorizedMatrix, double* vectors );
}
#endif

79
src/MTH5.cpp Normal file
View File

@@ -0,0 +1,79 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "MTH5.h"
#include "Util.h"
#include "OutputFiles.h"
#include <H5Cpp.h>
// Default constructer
MTH5::MTH5()
{
}
// Destructer
MTH5::~MTH5(){
}
// Return the instance of the class
MTH5* MTH5::getInstance(){
static MTH5 instance;// The only instance
return &instance;
}
// Read MTH5 file
void MTH5::readMTH5File(const std::string& fileName, const std::string groupName, const int numSkipData, const int numDataPoints, double* data) const{
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeLogMessage("Read data from " + groupName + " of " + fileName);
hid_t file_id = H5Fopen(fileName.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
hid_t dataset_id = H5Dopen(file_id, groupName.c_str(), H5P_DEFAULT);
hid_t filespace_id = H5Dget_space(dataset_id);
int ndims = H5Sget_simple_extent_ndims(filespace_id);
if (ndims < 1) {
ptrOutputFiles->writeErrorMessage("Number of dimensions is less than one (" + Util::toString(ndims) + ")");
}
hsize_t* dims = new hsize_t[ndims];
H5Sget_simple_extent_dims(filespace_id, dims, NULL);
const int numDataInGroup = dims[0];
delete[] dims;
if (numDataInGroup < numDataPoints)
{
ptrOutputFiles->writeErrorMessage("Number of data in this group (" + Util::toString(numDataInGroup) + ") is smaller than " + Util::toString(numDataPoints));
}
hid_t type = H5Dget_type(dataset_id);
hsize_t dimsmr[1] = { numDataPoints };
hid_t memspace_id = H5Screate_simple(1, dimsmr, NULL);
hsize_t roffset[1] = { numSkipData };
hsize_t rcount[1] = { numDataPoints };
H5Sselect_hyperslab(filespace_id, H5S_SELECT_SET, roffset, NULL, rcount, NULL);
H5Dread(dataset_id, H5T_NATIVE_DOUBLE, memspace_id, filespace_id, H5P_DEFAULT, data);
}

61
src/MTH5.h Normal file
View File

@@ -0,0 +1,61 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_MTH5
#define DBLDEF_MTH5
#include <string>
// Class of MTH5 file
class MTH5{
public:
// Return the the instance of the class
static MTH5* getInstance();
// Read MTH5 file
void readMTH5File( const std::string& fileName, const std::string groupName, const int numSkipData, const int numDataPoints, double* data ) const;
private:
// Constructer
MTH5();
// Destructer
~MTH5();
// Copy constructer
MTH5(const MTH5& rhs);
// Assignment operator
MTH5& operator=(const MTH5& rhs);
};
#endif

47
src/Makefile Normal file
View File

@@ -0,0 +1,47 @@
CXX = icpc
CC = icpc
CXXFLAGS = -O3 \
-qopenmp \
-DNDEBUG \
-D_USE_OMP \
-D_LINUX \
-D_MERSENNE_TWISTER_ORIGINAL \
-I./include
DEST = ./
LIB_DIR = ./lib
LDFLAGS = -L${LIB_DIR}
LIBS = ${LIB_DIR}/lapack_LINUX.a ${LIB_DIR}/blas_LINUX.a ${LIB_DIR}/libf2c.a
OBJS = Analysis.cpp \
AnalysisMultivariateRegression.cpp \
AnalysisTwoStage.cpp \
AnalysisOrdinaryRemoteReference.cpp \
AnalysisTest.cpp \
AnalysisRepeatedMedian.cpp \
Ats.cpp \
CalibrationFunction.cpp \
Control.cpp \
DoubleDenseMatrix.cpp \
DoubleDenseSquareMatrix.cpp \
DoubleDenseSquareSymmetricMatrix.cpp \
DoubleDenseSquareSymmetricPositiveDefiniteMatrix.cpp \
ElogDual.cpp \
ElogMT.cpp \
LapackInterface.cpp \
OutputFiles.cpp \
RobustPrewhitening.cpp \
RobustWeight.cpp \
RobustWeightHuber.cpp \
RobustWeightThomson.cpp \
RobustWeightTukeysBiweights.cpp \
Util.cpp \
UtilRobust.cpp \
main.cpp \
mt19937-64.cpp
PROGRAM = TRACMT
all: $(PROGRAM)
$(PROGRAM): $(OBJS)
$(CXX) $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LIBS) -o $(PROGRAM)
clean:; rm -f *.o *~ $(PROGRAM)

45
src/Makefile_C++11 Normal file
View File

@@ -0,0 +1,45 @@
CXX = icpc
CC = icpc
CXXFLAGS = -O3 \
-qopenmp \
-DNDEBUG \
-D_USE_OMP \
-D_LINUX \
-I./include
DEST = ./
LIB_DIR = ./lib
LDFLAGS = -L${LIB_DIR}
LIBS = ${LIB_DIR}/lapack_LINUX.a ${LIB_DIR}/blas_LINUX.a ${LIB_DIR}/libf2c.a
OBJS = Analysis.cpp \
AnalysisMultivariateRegression.cpp \
AnalysisTwoStage.cpp \
AnalysisOrdinaryRemoteReference.cpp \
AnalysisTest.cpp \
AnalysisRepeatedMedian.cpp \
Ats.cpp \
CalibrationFunction.cpp \
Control.cpp \
DoubleDenseMatrix.cpp \
DoubleDenseSquareMatrix.cpp \
DoubleDenseSquareSymmetricMatrix.cpp \
DoubleDenseSquareSymmetricPositiveDefiniteMatrix.cpp \
ElogDual.cpp \
ElogMT.cpp \
LapackInterface.cpp \
OutputFiles.cpp \
RobustPrewhitening.cpp \
RobustWeight.cpp \
RobustWeightHuber.cpp \
RobustWeightThomson.cpp \
RobustWeightTukeysBiweights.cpp \
Util.cpp \
UtilRobust.cpp \
main.cpp
PROGRAM = TRACMT
all: $(PROGRAM)
$(PROGRAM): $(OBJS)
$(CXX) $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LIBS) -o $(PROGRAM)
clean:; rm -f *.o *~ $(PROGRAM)

49
src/Makefile_C++11_MTH5 Normal file
View File

@@ -0,0 +1,49 @@
CXX = icpc
CC = icpc
CXXFLAGS = -O3 \
-qopenmp \
-DNDEBUG \
-D_USE_OMP \
-D_LINUX \
-D_MTH5 \
-I./include \
-I/usr/local/hdf5-1.10.5/include
DEST = ./
LIB_DIR = ./lib
LIB_MTH5_DIR = /usr/local/hdf5-1.10.5/lib
LDFLAGS = -L${LIB_DIR} -L${LIB_MTH5_DIR}
LIBS = ${LIB_DIR}/lapack_LINUX.a ${LIB_DIR}/blas_LINUX.a ${LIB_DIR}/libf2c.a -lhdf5
OBJS = Analysis.cpp \
AnalysisMultivariateRegression.cpp \
AnalysisTwoStage.cpp \
AnalysisOrdinaryRemoteReference.cpp \
AnalysisTest.cpp \
AnalysisRepeatedMedian.cpp \
Ats.cpp \
CalibrationFunction.cpp \
Control.cpp \
DoubleDenseMatrix.cpp \
DoubleDenseSquareMatrix.cpp \
DoubleDenseSquareSymmetricMatrix.cpp \
DoubleDenseSquareSymmetricPositiveDefiniteMatrix.cpp \
ElogDual.cpp \
ElogMT.cpp \
LapackInterface.cpp \
OutputFiles.cpp \
RobustPrewhitening.cpp \
RobustWeight.cpp \
RobustWeightHuber.cpp \
RobustWeightThomson.cpp \
RobustWeightTukeysBiweights.cpp \
Util.cpp \
UtilRobust.cpp \
MTH5.cpp \
main.cpp
PROGRAM = TRACMT
all: $(PROGRAM)
$(PROGRAM): $(OBJS)
$(CXX) $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LIBS) -o $(PROGRAM)
clean:; rm -f *.o *~ $(PROGRAM)

50
src/Makefile_MTH5 Normal file
View File

@@ -0,0 +1,50 @@
CXX = icpc
CC = icpc
CXXFLAGS = -O3 \
-qopenmp \
-DNDEBUG \
-D_USE_OMP \
-D_LINUX \
-D_MERSENNE_TWISTER_ORIGINAL \
-D_MTH5 \
-I./include \
-I/usr/local/hdf5-1.10.5/include
DEST = ./
LIB_DIR = ./lib
LIB_MTH5_DIR = /usr/local/hdf5-1.10.5/lib
LDFLAGS = -L${LIB_DIR} -L${LIB_MTH5_DIR}
LIBS = ${LIB_DIR}/lapack_LINUX.a ${LIB_DIR}/blas_LINUX.a ${LIB_DIR}/libf2c.a -lhdf5
OBJS = Analysis.cpp \
AnalysisMultivariateRegression.cpp \
AnalysisTwoStage.cpp \
AnalysisOrdinaryRemoteReference.cpp \
AnalysisTest.cpp \
AnalysisRepeatedMedian.cpp \
Ats.cpp \
CalibrationFunction.cpp \
Control.cpp \
DoubleDenseMatrix.cpp \
DoubleDenseSquareMatrix.cpp \
DoubleDenseSquareSymmetricMatrix.cpp \
DoubleDenseSquareSymmetricPositiveDefiniteMatrix.cpp \
ElogDual.cpp \
ElogMT.cpp \
LapackInterface.cpp \
OutputFiles.cpp \
RobustPrewhitening.cpp \
RobustWeight.cpp \
RobustWeightHuber.cpp \
RobustWeightThomson.cpp \
RobustWeightTukeysBiweights.cpp \
Util.cpp \
UtilRobust.cpp \
main.cpp \
mt19937-64.cpp
PROGRAM = TRACMT
all: $(PROGRAM)
$(PROGRAM): $(OBJS)
$(CXX) $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LIBS) -o $(PROGRAM)
clean:; rm -f *.o *~ $(PROGRAM)

201
src/OutputFiles.cpp Normal file
View File

@@ -0,0 +1,201 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include <iostream>
#include <sstream>
#include <iomanip>
#include "CommonParameters.h"
#include "OutputFiles.h"
// Return the the instance of the class
OutputFiles* OutputFiles::getInstance(){
static OutputFiles instance;// The only instance
return &instance;
}
// Restart to write cvg message
void OutputFiles::restartToWriteCvgMessage(){
m_isWritingCvgMessageStopped = false;
}
// Restart to write log message
void OutputFiles::restartToWriteLogMessage(){
m_isWritingLogMessageStopped = false;
}
// Restart to write warning essage
void OutputFiles::restartToWriteWarningMessage(){
m_isWritingWarningMessageStopped = false;
}
// Set flag specifing whether messages are shown to console
void OutputFiles::setOutputToConsole(const bool outputToConsole) {
m_outputToConsole = outputToConsole;
}
// Stop to write cvg message
void OutputFiles::stopToWriteCvgMessage(){
m_isWritingCvgMessageStopped = true;
}
// Stop to write log message
void OutputFiles::stopToWriteLogMessage(){
m_isWritingLogMessageStopped = true;
}
// Stop to write warning essage
void OutputFiles::stopToWriteWarningMessage(){
m_isWritingWarningMessageStopped = true;
}
// Write to cvg message
void OutputFiles::writeCvgMessage( const std::string& msg ){
if(m_isWritingCvgMessageStopped){
return;
}
m_cvgFile << msg << std::endl;
}
// Write to cvg message
void OutputFiles::writeCvgAndLogMessage( const std::string& msg, const bool withElapsedTime ){
writeLogMessage(msg, withElapsedTime);
writeCvgMessage(msg);
}
// Write log message
void OutputFiles::writeLogMessage( const std::string& msg, const bool withElapsedTime ){
if(m_isWritingLogMessageStopped){
return;
}
if( withElapsedTime ){
m_logFile << msg << " " << outputElapsedTime() << std::endl;
}else{
m_logFile << msg << std::endl;
}
if (m_outputToConsole) {
if (withElapsedTime) {
std::cout << msg << " " << outputElapsedTime() << std::endl;
}
else {
std::cout << msg << std::endl;
}
}
}
// Write error message
void OutputFiles::writeErrorMessage( const std::string& msg ){
m_logFile << "[Error] " << msg << std::endl;
if (m_outputToConsole) {
std::cout << "[Error] " << msg << std::endl;
}
exit(1);
}
// Write warning message
void OutputFiles::writeWarningMessage( const std::string& msg ){
if(m_isWritingWarningMessageStopped){
return;
}
m_logFile << "[Warning] " << msg << std::endl;
if (m_outputToConsole) {
std::cout << "[Warning] " << msg << std::endl;
}
}
// Constructer
OutputFiles::OutputFiles():
m_isWritingCvgMessageStopped(false),
m_isWritingLogMessageStopped(false),
m_isWritingWarningMessageStopped(false),
m_outputToConsole(false),
m_startTime(NULL)
{
// Open cvg file
std::ostringstream cvgFileName;
cvgFileName << CommonParameters::programName <<".cvg";
m_cvgFile.open( cvgFileName.str().c_str(), std::ios::out );
if( m_cvgFile.fail() ){
std::cerr << "File open error !! : " << cvgFileName.str() << std::endl;
exit(1);
}
// Open log file
std::ostringstream logFileName;
logFileName << CommonParameters::programName <<".log";
m_logFile.open( logFileName.str().c_str(), std::ios::out );
if( m_logFile.fail() ){
std::cerr << "File open error !! : " << logFileName.str() << std::endl;
exit(1);
}
// Measure the start time
time(&m_startTime);
OutputFiles::m_logFile << "Start " << CommonParameters::programName << " Version " << CommonParameters::version << std::endl;
}
// Destructer
OutputFiles::~OutputFiles(){
if( m_cvgFile.is_open() ){
m_cvgFile.close();
}
if( m_logFile.is_open() ){
m_logFile.close();
}
}
// Copy constructer
OutputFiles::OutputFiles(const OutputFiles& rhs){
std::cerr << "Error : Copy constructer of the class LogFile is not implemented." << std::endl;
exit(1);
}
// Copy assignment operator
OutputFiles& OutputFiles::operator=(const OutputFiles& rhs){
std::cerr << "Error : Copy assignment operator of the class LogFile is not implemented." << std::endl;
exit(1);
}
// Calculate elapsed time
std::string OutputFiles::outputElapsedTime() const{
time_t curTime(NULL);
time(&curTime);
std::ostringstream output;
output << "( " << difftime(curTime, m_startTime) << " sec )";
return output.str();
}

120
src/OutputFiles.h Normal file
View File

@@ -0,0 +1,120 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_OUTPUT_FILES
#define DBLDEF_OUTPUT_FILES
#include <fstream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <ctime>
// Class of output files
class OutputFiles{
public:
// Return the the instance of the class
static OutputFiles* getInstance();
// Restart to write cvg message
void restartToWriteCvgMessage();
// Restart to write log message
void restartToWriteLogMessage();
// Restart to write warning essage
void restartToWriteWarningMessage();
// Set flag specifing whether messages are shown to console
void setOutputToConsole(const bool outputToConsole);
// Stop to write cvg message
void stopToWriteCvgMessage();
// Stop to write log message
void stopToWriteLogMessage();
// Stop to write warning essage
void stopToWriteWarningMessage();
// Write to cvg message
void writeCvgMessage( const std::string& msg );
// Write to cvg message
void writeCvgAndLogMessage( const std::string& msg, const bool withElapsedTime = true );
// Write log message
void writeLogMessage( const std::string& msg, const bool withElapsedTime = true );
// Write error message
void writeErrorMessage( const std::string& msg );
// Write warning message
void writeWarningMessage( const std::string& msg );
private:
// Conrvergence file
std::ofstream m_cvgFile;
// Log file
std::ofstream m_logFile;
// Flag specifing whether writing cvg message is stopped
bool m_isWritingCvgMessageStopped;
// Flag specifing whether writing log message is stopped
bool m_isWritingLogMessageStopped;
// Flag specifing whether writing warning message is stopped
bool m_isWritingWarningMessageStopped;
// Flag specifing whether messages are shown to console
bool m_outputToConsole;
// The time the class instanced
time_t m_startTime;
// Constructer
OutputFiles();
// Destructer
~OutputFiles();
// Copy constructer
OutputFiles(const OutputFiles& rhs);
// Assignment operator
OutputFiles& operator=(const OutputFiles& rhs);
// Calculate and output elapsed time
std::string outputElapsedTime() const;
};
#endif

840
src/RobustPrewhitening.cpp Normal file
View File

@@ -0,0 +1,840 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "RobustPrewhitening.h"
#include "OutputFiles.h"
#include "Control.h"
#include "Util.h"
#include "UtilRobust.h"
#include "DoubleDenseSquareSymmetricPositiveDefiniteMatrix.h"
#include <assert.h>
#include <iostream>
#include <iomanip>
// Default constructer
RobustPrewhitening::RobustPrewhitening()
{
}
// Destructer
RobustPrewhitening::~RobustPrewhitening()
{
}
// Return the instance of the class
RobustPrewhitening* RobustPrewhitening::getInstance(){
static RobustPrewhitening instance;// The only instance
return &instance;
}
// Perform robust prewhitening
void RobustPrewhitening::robustPrewhitening( std::vector<CommonParameters::DataFileSet>& dataFileSets, std::vector<double>* coeffsAROutput ) const{
const Control* const ptrControl = Control::getInstance();
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
const Control::ParamsForPrewhitening params = ptrControl->getParamsForPrewhitening();
const int maxDegreesOfAR = params.maxDegreeOfARModel;
const Control::ParamsForRobustFilter paramsForFilter = ptrControl->getParamsForRobustFilter();
int numDataPointsAll(0);
int iSection(0);
for( std::vector<CommonParameters::DataFileSet>::const_iterator itr = dataFileSets.begin(); itr != dataFileSets.end(); ++itr, ++iSection ){
numDataPointsAll += itr->numDataPoints;
}
const int numSections = iSection;
// Calculate candidates
const int numCandidates = params.numCandidatesOfPartialAutocorrelationFunction;
if( numCandidates % 2 == 0 ){
ptrOutputFiles->writeErrorMessage("Numbef of candidates of partial autocorrelation function should be an odd number");
}
double* candidates = new double[numCandidates];
for( int iCan = 0; iCan < numCandidates; ++iCan ){
const int index = iCan % 2 == 1 ? iCan / 2 + 1 : -(iCan / 2);
candidates[iCan] = static_cast<double>(index) / static_cast<double>(numCandidates - 1) * 2.0;
#ifdef _DEBUG_WRITE
std::cout << candidates[iCan] << std::endl;
#endif
}
const int numChannels = ptrControl->getNumberOfChannels();
for( int iChan = 0; iChan < numChannels; ++iChan ){
ptrOutputFiles->writeLogMessage("Perform prewhitening for channel " + Util::toString(iChan));
double* coeffsAR= new double[maxDegreesOfAR];
for( int iDeg = 0; iDeg < maxDegreesOfAR; ++iDeg ){
coeffsAR[iDeg] = 0.0;
}
// Copy data to temporal arrays
const int numOfDataSets = static_cast<int>(dataFileSets.size());
int* numOfData = new int[numOfDataSets];;
double** dataOrg = new double*[numOfDataSets];
double** dataMod = new double*[numOfDataSets];
int iSet(0);
for( std::vector<CommonParameters::DataFileSet>::const_iterator itr = dataFileSets.begin(); itr != dataFileSets.end(); ++itr, ++iSet ){
const int numData = itr->numDataPoints;
numOfData[iSet] = numData;
dataOrg[iSet] = new double[numData];
dataMod[iSet] = new double[numData];
for( int iData = 0; iData < numData; ++iData ){
dataOrg[iSet][iData] = itr->dataFile[iChan].data[iData];
dataMod[iSet][iData] = dataOrg[iSet][iData];
}
}
DoubleDenseSquareSymmetricMatrix autoCovarianceMatrixMaxDegreesOfAR;
if(paramsForFilter.applyRobustFilter){
// Calculate auto-covariance matrix
ptrOutputFiles->writeCvgAndLogMessage("Calculate auto-covariance matrix of channel " + Util::toString(iChan));
calculateRobustAutoCovarianceMatrix( maxDegreesOfAR, numOfDataSets, numOfData, dataOrg, autoCovarianceMatrixMaxDegreesOfAR );
}
assert( iSet == numOfDataSets );
double squredSigma(0.0);
if (params.typeOfEstimator == Control::USE_LEAST_SQUARE_ESTIMATOR_FOR_PREWHITENING) {
int numOfDataAll(0);
for (int iSet = 0; iSet < numOfDataSets; ++iSet) {
const int numData = numOfData[iSet];
numOfDataAll += numData;
for (int iData = 0; iData < numData; ++iData) {
squredSigma += dataMod[iSet][iData] * dataMod[iSet][iData];
}
}
squredSigma /= static_cast<double>(numOfDataAll);
}
double minAIC(1.0e20);
int iDegAROfMinAIC(-1);
double scaleOfMinAIC(-1.0);
double* coeffsAROfMinAIC = new double[maxDegreesOfAR];
for( int iDegAR = 1; iDegAR <= maxDegreesOfAR; ++iDegAR ){
const int numDataForSEstimator = numDataPointsAll - iDegAR * numSections;
// Calculate forward MMSE prediction residual and backward MMSE prediction residual
double* forwardMMSEResidual = new double[numDataForSEstimator];
double* backwardMMSEResidual = new double[numDataForSEstimator];
int icount(0);
for( int iSet = 0; iSet < numOfDataSets; ++iSet ){
const int numData = numOfData[iSet];
for( int iData = iDegAR; iData < numData; ++iData ){
forwardMMSEResidual[icount] = dataMod[iSet][iData];
for( int i = 0; i < iDegAR - 1; ++i ){
const int index = iData - 1 - i;
forwardMMSEResidual[icount] -= coeffsAR[i] * dataMod[iSet][index];
}
backwardMMSEResidual[icount] = dataMod[iSet][iData - iDegAR];
for( int i = 0; i < iDegAR - 1; ++i ){
const int index = iData - iDegAR + 1 + i;
backwardMMSEResidual[icount] -= coeffsAR[i] * dataMod[iSet][index];
}
++icount;
}
}
assert(icount == numDataForSEstimator);
// Calculate AR coefficients
double scale(0.0);
double partialAutocorrelationFunction(0.0);
double AIC(0.0);
if( params.typeOfEstimator == Control::USE_S_ESTIMATOR_FOR_PREWHITENING ){
UtilRobust::computeSEstimatorForUnivariateLinearRegression( numDataForSEstimator, numCandidates,
forwardMMSEResidual, backwardMMSEResidual, candidates, -1.0, 1.0, scale, partialAutocorrelationFunction, AIC );
ptrOutputFiles->writeLogMessage("Degree of AR model: " + Util::toString(iDegAR) + ", Sigma: " + Util::toString(scale)
+ ", AICS: " + Util::toString(AIC));
}else if( params.typeOfEstimator == Control::USE_LEAST_SQUARE_ESTIMATOR_FOR_PREWHITENING ){
UtilRobust::computeLSEstimatorForUnivariateLinearRegression( numDataForSEstimator, forwardMMSEResidual, backwardMMSEResidual,
-1.0, 1.0, scale, partialAutocorrelationFunction );
squredSigma *= (1.0 - partialAutocorrelationFunction * partialAutocorrelationFunction);
double sigma = sqrt(squredSigma);
if (sigma < CommonParameters::EPS)
{
sigma = CommonParameters::EPS;
}
AIC = 2.0 * static_cast<double>(numDataForSEstimator) * log(sigma) + 2.0 * (static_cast<double>(iDegAR) + 1.0)
+ static_cast<double>(numDataForSEstimator) + static_cast<double>(numDataForSEstimator) * log(2.0 * CommonParameters::PI);
ptrOutputFiles->writeLogMessage("Degree of AR model: " + Util::toString(iDegAR) + ", Sigma: " + Util::toString(sigma)
+ ", AIC: " + Util::toString(AIC));
}else{
ptrOutputFiles->writeErrorMessage("Wrong type of estimator for prewhitening: " + Util::toString(params.typeOfEstimator));
}
delete [] forwardMMSEResidual;
delete [] backwardMMSEResidual;
coeffsAR[iDegAR - 1] = partialAutocorrelationFunction;
if( iDegAR > 1 ){
double* coeffsARPre = new double[iDegAR - 1];
for( int i = 0; i < iDegAR - 1; ++i ){
coeffsARPre[i] = coeffsAR[i];
}
for( int i = 0; i < iDegAR - 1; ++i ){
const int index = iDegAR - 2 - i;
coeffsAR[i] -= partialAutocorrelationFunction * coeffsARPre[index];
}
#ifdef _DEBUG_WRITE
for( int i = 0; i < iDegAR - 1; ++i ){
std::cout << "AR old new: " << coeffsARPre[i] << " " << coeffsAR[i] << std::endl;
}
#endif
delete [] coeffsARPre;
}
#ifdef _DEBUG_WRITE
for( int i = 0; i < iDegAR; ++i ){
std::cout << "AR coeffs: " << coeffsAR[i] << std::endl;
}
#endif
if( AIC < minAIC ){
minAIC = AIC;
iDegAROfMinAIC = iDegAR;
scaleOfMinAIC = scale;
for( int i = 0; i < iDegAR; ++i ){
coeffsAROfMinAIC[i] = coeffsAR[i];
}
for( int i = iDegAR; i < maxDegreesOfAR; ++i ){
coeffsAROfMinAIC[i] = 0.0;
}
}
if(paramsForFilter.applyRobustFilter){
// Calculate robust-filtered value
double* autoCovariance = new double[iDegAR * iDegAR];
// Copy matrix
icount = 0;
for( int col = 0; col < iDegAR; ++col ){
for( int row = 0; row < iDegAR; ++row ){
// Column major
autoCovariance[icount] = autoCovarianceMatrixMaxDegreesOfAR.getValue(row, col);
++icount;
}
}
#ifdef _DEBUG_WRITE
Util::debugWriteRealMatrix(iDegAR, iDegAR, autoCovariance);
#endif
int iSet(0);
for( std::vector<CommonParameters::DataFileSet>::const_iterator itr = dataFileSets.begin(); itr != dataFileSets.end(); ++itr, ++iSet ){
const int numData = itr->numDataPoints;
calculateRobustFilteredValue( iChan, numData, iDegAR, coeffsAR, scale, dataOrg[iSet], autoCovariance, dataMod[iSet] );
}
delete [] autoCovariance;
}else{
int iSet = 0;
for( std::vector<CommonParameters::DataFileSet>::const_iterator itr = dataFileSets.begin(); itr != dataFileSets.end(); ++itr, ++iSet ){
const int numData = itr->numDataPoints;
for( int iData = 0; iData < numData; ++iData ){
dataMod[iSet][iData] = dataOrg[iSet][iData];
}
}
}
}
delete [] coeffsAR;
if( params.typeOfEstimator == Control::USE_S_ESTIMATOR_FOR_PREWHITENING ){
ptrOutputFiles->writeLogMessage("The AR model of " + Util::toString(iDegAROfMinAIC) + " degress gives the minimum AICS (" + Util::toString(minAIC) + ")");
}else if( params.typeOfEstimator == Control::USE_LEAST_SQUARE_ESTIMATOR_FOR_PREWHITENING ){
ptrOutputFiles->writeLogMessage("The AR model of " + Util::toString(iDegAROfMinAIC) + " degress gives the minimum AIC (" + Util::toString(minAIC) + ")");
}
for( int i = 0; i < iDegAROfMinAIC; ++i ){
coeffsAROutput[iChan].push_back(coeffsAROfMinAIC[i]);
}
std::ostringstream msg;
msg << "AR coefficients: ";
for( int i = 0; i < iDegAROfMinAIC; ++i ){
msg << coeffsAROfMinAIC[i] << " ";
}
ptrOutputFiles->writeLogMessage(msg.str());
if( paramsForFilter.applyRobustFilter && paramsForFilter.replaceTimeSeriesWithFilteredValues ){
ptrOutputFiles->writeLogMessage("Replace observed time-series with filtered values");
double* autoCovariance = new double[iDegAROfMinAIC * iDegAROfMinAIC];
// Copy matrix
int icount = 0;
for( int col = 0; col < iDegAROfMinAIC; ++col ){
for( int row = 0; row < iDegAROfMinAIC; ++row ){
// Column major
autoCovariance[icount] = autoCovarianceMatrixMaxDegreesOfAR.getValue(row, col);
++icount;
}
}
#ifdef _DEBUG_WRITE
Util::debugWriteRealMatrix(iDegAROfMinAIC, iDegAROfMinAIC, autoCovariance);
#endif
// Calculate robust-filtered value
int iSet = 0;
for( std::vector<CommonParameters::DataFileSet>::const_iterator itr = dataFileSets.begin(); itr != dataFileSets.end(); ++itr, ++iSet ){
const int numData = itr->numDataPoints;
// Calculate robust-filtered value
calculateRobustFilteredValue( iChan, numData, iDegAROfMinAIC, coeffsAROfMinAIC, scaleOfMinAIC, dataOrg[iSet], autoCovariance, dataMod[iSet] );
// Output robust-filtered time serieas
if( ptrControl->doesOutputTimeSeriesToCsv() ){
std::ostringstream oss;
oss << "time_series_robust_filtered_sect_" << iSet << "_chan_" << iChan << ".csv";
std::ofstream ofs;
ofs.open( oss.str().c_str(), std::ios::out );
if( ofs.fail() ){
ptrOutputFiles->writeLogMessage("File open error !! : " + oss.str());
}
for( int iData = 0; iData < numData; ++iData ){
ofs << std::setprecision(12) << std::scientific << dataMod[iSet][iData] << std::endl;
}
ofs.close();
}
}
delete [] autoCovariance;
}else{
int iSet = 0;
for( std::vector<CommonParameters::DataFileSet>::const_iterator itr = dataFileSets.begin(); itr != dataFileSets.end(); ++itr, ++iSet ){
const int numData = itr->numDataPoints;
for( int iData = 0; iData < numData; ++iData ){
dataMod[iSet][iData] = dataOrg[iSet][iData];
}
}
}
// Prewhitening
iSet = 0;
for( std::vector<CommonParameters::DataFileSet>::iterator itr = dataFileSets.begin(); itr != dataFileSets.end(); ++itr, ++iSet ){
const int numData = itr->numDataPoints;
// Replace observed time-series with filtered values
for( int iData = 0; iData < iDegAROfMinAIC; ++iData ){
itr->dataFile[iChan].data[iData] = 0.0;
}
for( int iData = iDegAROfMinAIC; iData < numData; ++iData ){
double work = dataMod[iSet][iData];
for( int iAR = 0; iAR < iDegAROfMinAIC; ++iAR ){
const int index = iData - iAR - 1;
work -= coeffsAROfMinAIC[iAR] * dataMod[iSet][index];
}
itr->dataFile[iChan].data[iData] = work;
}
}
// Release memory
delete [] coeffsAROfMinAIC;
delete [] numOfData;
for( int iSet = 0; iSet < numOfDataSets; ++iSet ){
delete [] dataOrg[iSet];
delete [] dataMod[iSet];
}
delete [] dataOrg;
delete [] dataMod;
}
delete [] candidates;
}
// Perform prewhitening using user-defined AR coefficients
void RobustPrewhitening::prewhiteningUsingUserDefinedARCoeffs( std::vector<CommonParameters::DataFileSet>& dataFileSets, std::vector<double>* coeffsAROutput ) const{
const Control* const ptrControl = Control::getInstance();
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
const std::string fileName = "AR_coefficients.dat";
std::ifstream ifs( fileName.c_str(), std::ios::in );
if( ifs.fail() ){
ptrOutputFiles->writeErrorMessage("File open error : " + fileName);
}
const int numChannels = ptrControl->getNumberOfChannels();
for( int iChan = 0; iChan < numChannels; ++iChan ){
ptrOutputFiles->writeLogMessage("Perform prewhitening for channel " + Util::toString(iChan));
// Copy data to temporal arrays
const int numOfDataSets = static_cast<int>(dataFileSets.size());
double** dataOrg = new double*[numOfDataSets];
int iSet(0);
for( std::vector<CommonParameters::DataFileSet>::const_iterator itr = dataFileSets.begin(); itr != dataFileSets.end(); ++itr, ++iSet ){
const int numData = itr->numDataPoints;
dataOrg[iSet] = new double[numData];
for( int iData = 0; iData < numData; ++iData ){
dataOrg[iSet][iData] = itr->dataFile[iChan].data[iData];
}
}
int numCoeffs(0);
ifs >> numCoeffs;
for( int i = 0; i < numCoeffs; ++i ){
double dbuf(0.0);
ifs >> dbuf;
coeffsAROutput[iChan].push_back(dbuf);
}
std::ostringstream msg;
msg << "AR coefficients: ";
for( int i = 0; i < numCoeffs; ++i ){
msg << coeffsAROutput[iChan][i] << " ";
}
ptrOutputFiles->writeLogMessage(msg.str());
// Prewhitening
iSet = 0;
for( std::vector<CommonParameters::DataFileSet>::iterator itr = dataFileSets.begin(); itr != dataFileSets.end(); ++itr, ++iSet ){
const int numData = itr->numDataPoints;
// Replace observed time-series with filtered values
for( int iData = 0; iData < numCoeffs; ++iData ){
itr->dataFile[iChan].data[iData] = 0.0;
}
for( int iData = numCoeffs; iData < numData; ++iData ){
double work = dataOrg[iSet][iData];
for( int iAR = 0; iAR < numCoeffs; ++iAR ){
const int index = iData - iAR - 1;
work -= coeffsAROutput[iChan][iAR] * dataOrg[iSet][index];
}
itr->dataFile[iChan].data[iData] = work;
}
}
// Release memory
for( int iSet = 0; iSet < numOfDataSets; ++iSet ){
delete [] dataOrg[iSet];
}
delete [] dataOrg;
}
ifs.close();
}
// Calculate robust-filtered value
void RobustPrewhitening::calculateRobustFilteredValue( const int iChan, const int numOfData, const int degreesOfAR, const double* const coeffsOfAR,
double sigma, const double* const yOrg, const double* const autoCovariance, double* yMod ) const{
const Control* const ptrControl = Control::getInstance();
const Control::ParamsForRobustFilter params = ptrControl->getParamsForRobustFilter();
const int maxNumOfConsecutiveReplacements = params.thresholds[iChan].maxNumOfConsecutiveReplacements;
const double paramA = params.thresholds[iChan].firstThresholdFactor;
const double paramB = params.thresholds[iChan].secondThresholdFactor;
const bool doesGackToPreviousData = maxNumOfConsecutiveReplacements > 0;
// Initial values of state vector and covariance matrix
const double median = Util::calculateMedian( degreesOfAR, yOrg );
double* xHat = new double[degreesOfAR];
double* xHatPre = new double[degreesOfAR];
for( int iDeg = 0; iDeg < degreesOfAR; ++iDeg ){
xHat[iDeg] = median;
xHatPre[iDeg] = xHat[iDeg];
}
double* covP = new double[degreesOfAR * degreesOfAR];
double* covPPre = new double[degreesOfAR * degreesOfAR];
for( int i = 0; i < degreesOfAR * degreesOfAR; ++i ){
covP[i] = autoCovariance[i];
covPPre[i] = covP[i];
}
for( int iDeg = 0; iDeg < degreesOfAR; ++iDeg ){
yMod[iDeg] = yOrg[iDeg];
}
double* xTilde = new double[degreesOfAR];
double* covM = new double[degreesOfAR*degreesOfAR];
double* workVector = new double[degreesOfAR];
int numOfConsecutiveReplacements(0);
int iDataPre = degreesOfAR - 1;
bool residualAssumedToBeZero(false);
for( int iData = degreesOfAR; iData < numOfData; ++iData ){
// x_tilde = phi * x_hat
xTilde[0] = 0.0;
for( int iDeg = 0; iDeg < degreesOfAR; ++iDeg ){
xTilde[0] += coeffsOfAR[iDeg] * xHat[iDeg];
}
for( int iDeg = 1; iDeg < degreesOfAR; ++iDeg ){
xTilde[iDeg] = xHat[iDeg-1];
}
#ifdef _DEBUG_WRITE
std::cout << "[";
for( int iDeg = 0; iDeg < degreesOfAR; ++iDeg ){
std::cout << coeffsOfAR[iDeg] << " ";
}
std::cout << "; ";
for( int row = 1; row < degreesOfAR; ++row ){
for( int col = 0; col < degreesOfAR; ++col ){
const double value = row - 1 == col ? 1.0 : 0.0;
std::cout << value << " ";
}
std::cout << "; ";
}
std::cout << "]" << std::endl;
for( int iDeg = 0; iDeg < degreesOfAR; ++iDeg ){
std::cout << "iDeg xHat: " << iDeg << " " << xHat[iDeg] << std::endl;
}
for( int iDeg = 0; iDeg < degreesOfAR; ++iDeg ){
std::cout << "iDeg xTilde: " << iDeg << " " << xTilde[iDeg] << std::endl;
}
Util::debugWriteRealMatrix(degreesOfAR, degreesOfAR, covP);
#endif
for( int col = 0; col < degreesOfAR; ++col ){
double work(0.0);
for( int row = 0; row < degreesOfAR; ++row ){
// P matrix is column major
const int index = col * degreesOfAR + row;
work += coeffsOfAR[row] * covP[index];
}
workVector[col] = work;
}
#ifdef _DEBUG_WRITE
for( int iDeg = 0; iDeg < degreesOfAR; ++iDeg ){
std::cout << "iDeg workVector: " << iDeg << " " << workVector[iDeg] << std::endl;
}
#endif
// Zero clear
for( int col = 0; col < degreesOfAR; ++col ){
for( int row = 0; row < degreesOfAR; ++row ){
const int index = col * degreesOfAR + row;
covM[index] = 0.0;// Zero clear
}
}
#ifdef _DEBUG_WRITE
Util::debugWriteRealMatrix(degreesOfAR, degreesOfAR, covM);
#endif
// The (1.1) component of M_t+1 matrix
covM[0] = 0.0;// Zero clear
for( int i = 0; i < degreesOfAR; ++i ){
covM[0] += workVector[i] * coeffsOfAR[i];
}
if( covM[0] < 0.0 ){
covM[0] = 0.0; // Zero clear
// Add (1.1) component of Q matrix
covM[0] += pow(sigma, 2);
}else{
// Add (1.1) component of Q matrix
covM[0] += pow(sigma, 2);
#ifdef _DEBUG_WRITE
Util::debugWriteRealMatrix(degreesOfAR, degreesOfAR, covM);
#endif
// The first column of M_t+1 matrix except (1.1) component
for( int row = 1; row < degreesOfAR; ++row ){
covM[row] = workVector[row - 1];
}
#ifdef _DEBUG_WRITE
Util::debugWriteRealMatrix(degreesOfAR, degreesOfAR, covM);
#endif
// The first row of M_t+1 matrix except (1.1) component
for( int col = 1; col < degreesOfAR; ++col ){
const int index = col * degreesOfAR;
covM[index] = workVector[col - 1];
}
#ifdef _DEBUG_WRITE
Util::debugWriteRealMatrix(degreesOfAR, degreesOfAR, covM);
#endif
// The remaing components of M_t+1 matrix
for( int col = 1; col < degreesOfAR; ++col ){
for( int row = 1; row < degreesOfAR; ++row ){
const int indexM = col * degreesOfAR + row;
const int indexP = (col - 1) * degreesOfAR + (row - 1);
covM[indexM] = covP[indexP];
}
}
}
#ifdef _DEBUG_WRITE
Util::debugWriteRealMatrix(degreesOfAR, degreesOfAR, covM);
#endif
const double mt = std::max( covM[0], 1.0e-20 );
const double normalizedResidual = ( yOrg[iData] - xTilde[0] ) / sqrt(mt);
const double weightForStateVector = calculateWeightForStateVectorOfRobustFilter( normalizedResidual, paramA, paramB, residualAssumedToBeZero );
for( int i = 0; i < degreesOfAR; ++i ){
// M_t matrix is column major
xHat[i] = xTilde[i] + covM[i] / sqrt(mt) * weightForStateVector;
}
yMod[iData] = xHat[0];
const double weightForCovariance = calculateWeightForCovarianceMatrixOfRobustFilter( normalizedResidual, paramA, paramB, false );
// P_t = M_t - chi * m_t * m_t^T / m_t
// First, copy M_t matrx to P_t matrx
for( int col = 0; col < degreesOfAR; ++col ){
for( int row = 0; row < degreesOfAR; ++row ){
// Column major
const int index = col * degreesOfAR + row;
covP[index] = covM[index];
}
}
#ifdef _DEBUG_WRITE
Util::debugWriteRealMatrix(degreesOfAR, degreesOfAR, covP);
#endif
for( int col = 0; col < degreesOfAR; ++col ){
for( int row = 0; row < degreesOfAR; ++row ){
// Column major
const double work = covM[col] * covM[row] / mt * weightForCovariance;
const int index = col * degreesOfAR + row;
covP[index] -= work;
}
}
#ifdef _DEBUG_WRITE
Util::debugWriteRealMatrix(degreesOfAR, degreesOfAR, covP);
#endif
if( Util::calculateDeterminantOfMatrix( degreesOfAR, covP ) <= 0.0 ){
for( int col = 0; col < degreesOfAR; ++col ){
for( int row = 0; row < degreesOfAR; ++row ){
// Column major
const int index = col * degreesOfAR + row;
covP[index] = 0.0;
}
}
}
// Check the number of consecutive replacements
if( !residualAssumedToBeZero && fabs(yMod[iData] - yOrg[iData]) / std::max(fabs(yOrg[iData]), CommonParameters::EPS) > 1.0e-3 ){
#ifdef _DEBUG_WRITE
std::cout << "org mod: " << yOrg[iData] << " " << yMod[iData] << std::endl;
#endif
++numOfConsecutiveReplacements;
}else{
numOfConsecutiveReplacements = 0;
iDataPre = iData;
for( int iDeg = 0; iDeg < degreesOfAR; ++iDeg ){
xHatPre[iDeg] = xHat[iDeg];
}
for( int i = 0; i < degreesOfAR * degreesOfAR; ++i ){
covPPre[i] = covP[i];
}
}
residualAssumedToBeZero = false;
if( doesGackToPreviousData && numOfConsecutiveReplacements >= maxNumOfConsecutiveReplacements ){
// Restore state vector and covariance matrix
for( int iDeg = 0; iDeg < degreesOfAR; ++iDeg ){
xHat[iDeg] = xHatPre[iDeg];
}
for( int i = 0; i < degreesOfAR * degreesOfAR; ++i ){
covP[i] = covPPre[i];
}
numOfConsecutiveReplacements = 0;
residualAssumedToBeZero = true;
iData = iDataPre;
// Go back to previous data
}
}
delete [] xHat;
delete [] xHatPre;
delete [] xTilde;
delete [] covP;
delete [] covPPre;
delete [] covM;
delete [] workVector;
}
// Calculate robust auto-covariance matrix
void RobustPrewhitening::calculateRobustAutoCovarianceMatrix( const int degreesOfAR, const int numOfDataSets,
const int* const numOfData, double** data, DoubleDenseSquareSymmetricMatrix& covarianceMatrix ) const{
const Control* const ptrControl = Control::getInstance();
const Control::ParamsForRobustAutoCovariance params = ptrControl->getParamsForRobustAutoCovariance();
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
int numOfDataAll = 0;
for( int iSet = 0; iSet < numOfDataSets; ++iSet ){
numOfDataAll += numOfData[iSet];
}
const int numOfSamples = numOfDataAll - degreesOfAR * numOfDataSets;
covarianceMatrix.setDegreeOfEquation(degreesOfAR + 1);
// Add to matrix
for( int iSet = 0; iSet < numOfDataSets; ++iSet ){
const int numData = numOfData[iSet];
for( int iData = degreesOfAR; iData < numData; ++iData ){
for( int iDiff = 0; iDiff < degreesOfAR + 1; ++iDiff ){
const double value = data[iSet][iData] * data[iSet][iData - iDiff];
for( int iCol = 0; iCol < degreesOfAR + 1; ++iCol ){
const int iRow = iCol + iDiff;
if( iRow < degreesOfAR + 1 ){
covarianceMatrix.addValue(iRow, iCol, value);
}
}
}
}
}
#ifdef _DEBUG_WRITE
covarianceMatrix.debugWriteMatrix();
#endif
// Add small number to the diagonals for making the matrix positive-definite
for( int iCol = 0; iCol < degreesOfAR + 1; ++iCol ){
const double value = covarianceMatrix.getValue(iCol, iCol) * params.percentageOfSmallNumberAddedToDiagonals / 100.0;
covarianceMatrix.addValue(iCol, iCol, value);
}
covarianceMatrix.multiplyScalarToMatrix( 1.0/static_cast<double>(numOfSamples) );
#ifdef _DEBUG_WRITE
covarianceMatrix.debugWriteMatrix();
#endif
const double determinant = covarianceMatrix.calculateDeterminant();
// Force det(C) to 1
covarianceMatrix.multiplyScalarToMatrix( pow(1.0/fabs(determinant), 1.0/static_cast<double>(degreesOfAR+1)) );
#ifdef _DEBUG_WRITE
std::cout << "det: " << covarianceMatrix.calculateDeterminant() << std::endl;
covarianceMatrix.debugWriteMatrix();
#endif
double paramB(0.0);
double paramC(0.0);
RobustWeightTukeysBiweights::calculateParams(degreesOfAR + 1, numOfSamples, paramB, paramC);
double* MD = new double[numOfSamples];
calculateMD(degreesOfAR, numOfDataSets, numOfData, data, covarianceMatrix, MD);
// Initial estimation of scale
double scale = Util::calculateMedian(numOfSamples, MD);
scale = RobustWeightTukeysBiweights::calculateRobustScale(numOfSamples, MD, scale, paramB, paramC);
#ifdef _DEBUG_WRITE
std::cout << "scale: " << scale << std::endl;
#endif
ptrOutputFiles->writeCvgMessage("Number of data = " + Util::toString(numOfSamples) +
", Initial scale = " + Util::toString(scale) + ", Determinant = " + Util::toString(determinant));
double scalePre = scale;
for( int iter = 0; iter < params.maxNumOfIterations; ++iter ){
covarianceMatrix.zeroClearMatrix();
#ifdef _DEBUG_WRITE
covarianceMatrix.debugWriteMatrix();
#endif
// Add to matrix
double sumOfWeights(0.0);
double denominator(0.0);
int icount(0);
for( int iSet = 0; iSet < numOfDataSets; ++iSet ){
const int numData = numOfData[iSet];
for( int iData = degreesOfAR; iData < numData; ++iData ){
const double weight = RobustWeightTukeysBiweights::calculateWeights(MD[icount] / scale, paramC);
for( int iDiff = 0; iDiff < degreesOfAR + 1; ++iDiff ){
const double value = data[iSet][iData] * data[iSet][iData - iDiff] * weight;
for( int iCol = 0; iCol < degreesOfAR + 1; ++iCol ){
const int iRow = iCol + iDiff;
if( iRow < degreesOfAR + 1 ){
covarianceMatrix.addValue(iRow, iCol, value);
}
}
}
sumOfWeights += weight;
denominator += RobustWeightTukeysBiweights::calculateTermInDenominatorOfRobustCovariance(MD[icount] / scale, paramC);
++icount;
}
}
// Add small number to the diagonals for making the matrix positive-definite
for( int iCol = 0; iCol < degreesOfAR + 1; ++iCol ){
const double value = covarianceMatrix.getValue(iCol, iCol) * params.percentageOfSmallNumberAddedToDiagonals / 100.0;
covarianceMatrix.addValue(iCol, iCol, value);
}
if( denominator < CommonParameters::EPS ){
ptrOutputFiles->writeWarningMessage("Denominator of robust covariance is too small (" + Util::toString(denominator) + ")");
}
const double factor = static_cast<double>(degreesOfAR + 1) / std::max(denominator, CommonParameters::EPS);
//covarianceMatrix.multiplyScalarToMatrix( 1.0/sumOfWeights );
covarianceMatrix.multiplyScalarToMatrix(factor);
#ifdef _DEBUG_WRITE
covarianceMatrix.debugWriteMatrix();
#endif
const double determinant = covarianceMatrix.calculateDeterminant();
// Force det(C) to 1
covarianceMatrix.multiplyScalarToMatrix( pow(1.0/fabs(determinant), 1.0/static_cast<double>(degreesOfAR+1)) );
#ifdef _DEBUG_WRITE
std::cout << "det: " << covarianceMatrix.calculateDeterminant() << std::endl;
covarianceMatrix.debugWriteMatrix();
#endif
calculateMD(degreesOfAR, numOfDataSets, numOfData, data, covarianceMatrix, MD);
scale = RobustWeightTukeysBiweights::calculateRobustScale(numOfSamples, MD, scale, paramB, paramC);
ptrOutputFiles->writeCvgMessage("Iteration number = " + Util::toString(iter) + ", Sum of weights = " + Util::toString(sumOfWeights) +
", Scale = " + Util::toString(scale) + ", Determinant = " + Util::toString(determinant));
if( fabs(scale-scalePre)/fabs(scalePre) < params.convergenceCriteria ){
break;
}
scalePre = scale;
}
covarianceMatrix.multiplyScalarToMatrix( pow(scale,2) );
#ifdef _DEBUG_WRITE
covarianceMatrix.debugWriteMatrix();
#endif
delete [] MD;
}
// Calculate Mahalanobis distances
// @note covariance matrix is factorized in this function
void RobustPrewhitening::calculateMD( const int degreesOfAR, const int numOfDataSets, const int* const numOfData, double** data,
DoubleDenseSquareSymmetricMatrix& covarianceMatrix, double* MD ) const{
double* residualVector = new double[degreesOfAR + 1];
double* workVector = new double[degreesOfAR + 1];
covarianceMatrix.factorizeMatrix();
#ifdef _DEBUG_WRITE
covarianceMatrix.debugWriteMatrix();
#endif
int icount(0);
for( int iSet = 0; iSet < numOfDataSets; ++iSet ){
const int numData = numOfData[iSet];
for( int iData = degreesOfAR; iData < numData; ++iData ){
for( int iDiff = 0; iDiff < degreesOfAR + 1; ++iDiff ){
residualVector[iDiff] = data[iSet][iData - iDiff];
}
covarianceMatrix.solveLinearEquation(residualVector, workVector);
double mahalanobisDistances(0.0);
for( int iDiff = 0; iDiff < degreesOfAR + 1; ++iDiff ){
mahalanobisDistances += residualVector[iDiff] * workVector[iDiff];
}
MD[icount] = sqrt(fabs(mahalanobisDistances));
//#ifdef _DEBUG_WRITE
// for( int iDiff = 0; iDiff < degreesOfAR + 1; ++iDiff ){
// std::cout << "residualVector:" << residualVector[iDiff] << std::endl;
// }
// for( int iDiff = 0; iDiff < degreesOfAR + 1; ++iDiff ){
// std::cout << "workVector:" << workVector[iDiff] << std::endl;
// }
// std::cout << "mahalanobisDistances:" << mahalanobisDistances << std::endl;
//#endif
++icount;
}
}
delete [] residualVector;
delete [] workVector;
}
// Calculate weight for state vector in robust filter
double RobustPrewhitening::calculateWeightForStateVectorOfRobustFilter( const double val, const double paramA, const double paramB, const bool residualAssumedToBeZero ) const{
assert( paramA < paramB );
if( residualAssumedToBeZero || fabs(val) <= paramA ){
return val;
}
else if( val > paramA && val <= paramB ){
return paramA * (paramB - val) / (paramB - paramA);
}
else if( val >= -paramB && val < -paramA ){
return - paramA * (paramB + val) / (paramB - paramA);
}
else{
return 0.0;
}
}
// Calculate weight for covariance matrix in robust filter
double RobustPrewhitening::calculateWeightForCovarianceMatrixOfRobustFilter( const double val, const double paramA, const double paramB, const bool residualAssumedToBeZero ) const{
assert( paramA < paramB );
if( residualAssumedToBeZero || fabs(val) <= paramA ){
return 1.0;
}
else if( val > paramA && val <= paramB ){
return paramA * (paramB / val - 1.0) / (paramB - paramA);
}
else if( val >= -paramB && val < -paramA ){
return - paramA * (paramB / val + 1.0) / (paramB - paramA);
}
else{
return 0.0;
}
}

88
src/RobustPrewhitening.h Normal file
View File

@@ -0,0 +1,88 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_ROBUST_PREWHITENING
#define DBLDEF_ROBUST_PREWHITENING
#include "CommonParameters.h"
#include "DoubleDenseSquareSymmetricPositiveDefiniteMatrix.h"
#include <vector>
// Class of robust prewhitening
class RobustPrewhitening{
public:
// Default constructer
RobustPrewhitening();
// Destructer
~RobustPrewhitening();
// Return the the instance of the class
static RobustPrewhitening* getInstance();
// Perform robust prewhitening
void robustPrewhitening( std::vector<CommonParameters::DataFileSet>& dataFileSets, std::vector<double>* coeffsAROutput ) const;
// Perform prewhitening using user-defined AR coefficients
void prewhiteningUsingUserDefinedARCoeffs( std::vector<CommonParameters::DataFileSet>& dataFileSets, std::vector<double>* coeffsAROutput ) const;
private:
// Copy constructer
RobustPrewhitening(const RobustPrewhitening& rhs);
// Assignment operator
RobustPrewhitening& operator=(const RobustPrewhitening& rhs);
// Calculate robust-filtered value
void calculateRobustFilteredValue( const int iChan, const int numOfData, const int degreesOfAR, const double* const coeffsOfAR,
const double sigma, const double* const yOrg, const double* const autoCovariance, double* yMod ) const;
// Calculate robust auto-covariance matrix
void calculateRobustAutoCovarianceMatrix( const int degreesOfAR, const int numOfDataSets, const int* const numOfData,
double** data, DoubleDenseSquareSymmetricMatrix& covarianceMatrix ) const;
// Calculate Mahalanobis distances
// @note covariance matrix is factorized in this function
//void calculateMD( const int degreesOfAR, const int numOfDataAll, const double* const dataAll,
// DoubleDenseSquareSymmetricMatrix& covarianceMatrix, double* residualVector, double* MD ) const;
void calculateMD( const int degreesOfAR, const int numOfDataSets, const int* const numOfData, double** data,
DoubleDenseSquareSymmetricMatrix& covarianceMatrix, double* MD ) const;
// Calculate weight for state vector in robust filter
double calculateWeightForStateVectorOfRobustFilter( const double val, const double paramA, const double paramB, const bool residualAssumedToBeZero ) const;
// Calculate weight for covariance matrix in robust filter
double calculateWeightForCovarianceMatrixOfRobustFilter( const double val, const double paramA, const double paramB, const bool residualAssumedToBeZero ) const;
};
#endif

93
src/RobustWeight.cpp Normal file
View File

@@ -0,0 +1,93 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "RobustWeight.h"
#include "OutputFiles.h"
#include "Util.h"
// Default constructer
RobustWeight::RobustWeight():
m_convergenceCriteria(0.01),
m_name("no name"),
m_numIterationMax(10)
{
}
// Destructer
RobustWeight::~RobustWeight()
{
}
// Get convergence criteria
double RobustWeight::getConvergenceCriteria() const{
return m_convergenceCriteria;
}
// Get name of M-estimator
std::string RobustWeight::getNameOfRobustWeight() const{
return m_name;
}
// Get maximum number of iteration
int RobustWeight::getNumIterationMax() const{
return m_numIterationMax;
}
// Set convergence criteria
void RobustWeight::setConvergenceCriteria( const double criteria ){
m_convergenceCriteria = criteria;
}
// Set name of M-estimator
void RobustWeight::setNameOfRobustWeight( const std::string& name ){
m_name = name;
}
// Set maximum number of iteration
void RobustWeight::setNumIterationMax( const int numIterMax ){
m_numIterationMax = numIterMax;
}
// Calculate scale of absolute values of complex residuals by MADN
double RobustWeight::calculateScaleByMADN(const int numSegments, const std::complex<double>* const residuals) {
std::vector<double> absoluteResiduals;
for( int iSeg = 0; iSeg < numSegments; ++iSeg ){
absoluteResiduals.push_back(std::abs(residuals[iSeg]));
}
const double sigmaMAD = Util::calculateMAD(absoluteResiduals);
return sigmaMAD / 0.448453;
}
// Calculate scale of absolute values of complex residuals
double RobustWeight::calculateScale(const int numSegments, const std::complex<double>* const residuals, const double scalePre) const{
return calculateScaleByMADN(numSegments, residuals);
}

91
src/RobustWeight.h Normal file
View File

@@ -0,0 +1,91 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_ROBUST_WEIGHT
#define DBLDEF_ROBUST_WEIGHT
#include "CommonParameters.h"
#include <complex>
// Class of Robust estimator
class RobustWeight{
public:
// Default constructer
RobustWeight();
// Destructer
virtual ~RobustWeight();
// Calculate sum of the second order derivative of loss function
virtual double calculateSumOf2ndOrderDerivativeOfLossFunction(const int numSegments, const std::complex<double>* const residuals, const double scale) const = 0;
// Calculate scale of absolute values of complex residuals by MADN
static double calculateScaleByMADN(const int numSegments, const std::complex<double>* const residuals);
// Calculate scale of absolute values of complex residuals
virtual double calculateScale(const int numSegments, const std::complex<double>* const residuals, const double scalePre) const;
// Calculate weights
virtual double calculateWeights(const int numSegments, const std::complex<double>* const residuals, const double scale, const double* const weightsPrior,
double* weights) const = 0;
// Get convergence criteria
double getConvergenceCriteria() const;
// Get name of M-estimator
std::string getNameOfRobustWeight() const;
// Get maximum number of iteration
int getNumIterationMax() const;
// Set convergence criteria
void setConvergenceCriteria( const double criteria );
// Set name of M-estimator
void setNameOfRobustWeight( const std::string& name );
// Set maximum number of iteration
void setNumIterationMax( const int numIterMax );
protected:
private:
// Convergence criteria
double m_convergenceCriteria;
// Name of M-estimator
std::string m_name;
// Maximum number of iteration
int m_numIterationMax;
};
#endif

106
src/RobustWeightHuber.cpp Normal file
View File

@@ -0,0 +1,106 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "RobustWeightHuber.h"
#include "OutputFiles.h"
#include "Util.h"
#include <iostream>
// Default constructer
RobustWeightHuber::RobustWeightHuber():
m_threshould(3.0)
{
setNameOfRobustWeight("Huber");
}
//// Copy constructer
//RobustWeightHuber::RobustWeightHuber(const RobustWeightHuber& obj){
// m_threshould = obj.m_threshould;
//}
// Destructer
RobustWeightHuber::~RobustWeightHuber()
{
}
// Calculate sum of the second order derivative of loss function
double RobustWeightHuber::calculateSumOf2ndOrderDerivativeOfLossFunction(const int numSegments, const std::complex<double>* const residuals, const double scale) const {
const double threshould = getThreshould();
double sumOfDerivatives(0.0);
for (int iSeg = 0; iSeg < numSegments; ++iSeg) {
const double x = std::abs(residuals[iSeg]) / scale;
if (x <= threshould) {
sumOfDerivatives += 1.0;
}
}
return sumOfDerivatives;
}
// Calculate weights
double RobustWeightHuber::calculateWeights(const int numSegments, const std::complex<double>* const residuals, const double scale,
const double* const weightsPrior, double* weights) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeCvgMessage(" Scale factor: " + Util::toString(scale));
#ifdef _DEBUG_WRITE
std::cout << "scaleFactor: " << scale << std::endl;
#endif
const double threshould = getThreshould();
double sumOfWeights(0.0);
for (int iSeg = 0; iSeg < numSegments; ++iSeg) {
weights[iSeg] = weightsPrior[iSeg];
const double x = std::abs(residuals[iSeg]) / scale;
if (x <= threshould) {
// Huber weight is unity
}
else {
weights[iSeg] *= threshould / x;
}
sumOfWeights += weights[iSeg];
#ifdef _DEBUG_WRITE
std::cout << "iSeg absres x weightsPrior weights: "
<< iSeg << " " << std::abs(residuals[iSeg]) << " " << x << " " << weightsPrior[iSeg] << " " << weights[iSeg] << std::endl;
#endif
}
return sumOfWeights;
}
// Get threshould value for downweighting
double RobustWeightHuber::getThreshould() const{
return m_threshould;
}
// Set threshould value for downweighting
void RobustWeightHuber::setThreshould( const double threshould ){
m_threshould = threshould;
}

69
src/RobustWeightHuber.h Normal file
View File

@@ -0,0 +1,69 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_ROBUST_WEIGHT_HUBER
#define DBLDEF_ROBUST_WEIGHT_HUBER
#include "RobustWeight.h"
#include "CommonParameters.h"
#include <complex>
// Class of M-estimator using Huber weights
class RobustWeightHuber : public RobustWeight{
public:
// Default constructer
RobustWeightHuber();
// Destructer
virtual ~RobustWeightHuber();
// Calculate sum of the second order derivative of loss function
virtual double calculateSumOf2ndOrderDerivativeOfLossFunction(const int numSegments, const std::complex<double>* const residuals, const double scale) const;
// Calculate weights
virtual double calculateWeights(const int numSegments, const std::complex<double>* const residuals, const double scale, const double* const weightsPrior,
double* weights) const;
// Get threshould value for downweighting
double getThreshould() const;
// Set threshould value for downweighting
void setThreshould( const double threshould );
protected:
private:
// Threshould value for downweighting
double m_threshould;
};
#endif

View File

@@ -0,0 +1,98 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "RobustWeightThomson.h"
#include "OutputFiles.h"
#include "Util.h"
#include <iostream>
// Default constructer
RobustWeightThomson::RobustWeightThomson():
m_parameterForDetermingProbability(0.0)
{
setNameOfRobustWeight("Thomson");
}
// Destructer
RobustWeightThomson::~RobustWeightThomson()
{
}
// Calculate sum of the second order derivative of loss function
double RobustWeightThomson::calculateSumOf2ndOrderDerivativeOfLossFunction(const int numSegments, const std::complex<double>* const residuals, const double scale) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeErrorMessage("Parametric error estimation cannot be used for Thomson weight");
return -1;
}
// Calculate weights
double RobustWeightThomson::calculateWeights(const int numSegments, const std::complex<double>* const residuals, const double scale,
const double* const weightsPrior, double* weights) const {
const double param = getParameterForDetermingProbability();
double probability = (static_cast<double>(numSegments) - param - 0.5) / static_cast<double>(numSegments);
if (param < 0.0 - CommonParameters::EPS) {
probability = -param;
}
const double Q = sqrt(-2.0 * log(1.0 - probability));
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeCvgMessage(" Probability for determining the point at which downweighting starts: " + Util::toString(probability));
ptrOutputFiles->writeCvgMessage(" Scale factor: " + Util::toString(scale));
#ifdef _DEBUG_WRITE
std::cout << "probability: " << probability << std::endl;
std::cout << "Q: " << Q << std::endl;
std::cout << "scaleFactor: " << scale << std::endl;
#endif
double sumOfWeights(0.0);
for (int iSeg = 0; iSeg < numSegments; ++iSeg) {
weights[iSeg] = weightsPrior[iSeg];
const double x = std::abs(residuals[iSeg]) / scale;
weights[iSeg] *= exp(exp(-Q * Q)) * exp(-exp(Q * (fabs(x) - Q)));
sumOfWeights += weights[iSeg];
#ifdef _DEBUG_WRITE
std::cout << "iSeg absres x weightsPrior weights: "
<< iSeg << " " << std::abs(residuals[iSeg]) << " " << x << " " << weightsPrior[iSeg] << " " << weights[iSeg] << std::endl;
#endif
}
return sumOfWeights;
}
// Get parameter for determing the probability used for outlier rejection
double RobustWeightThomson::getParameterForDetermingProbability() const{
return m_parameterForDetermingProbability;
}
// Set parameter for determing the probability used for outlier rejection
void RobustWeightThomson::setParameterForDetermingProbability( const double prob ){
m_parameterForDetermingProbability = prob;
}

69
src/RobustWeightThomson.h Normal file
View File

@@ -0,0 +1,69 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_ROBUST_WEIGHT_THOMSON
#define DBLDEF_ROBUST_WEIGHT_THOMSON
#include "RobustWeight.h"
#include "CommonParameters.h"
#include <complex>
// Class of M-estimator using Thomson weights
class RobustWeightThomson : public RobustWeight{
public:
// Default constructer
RobustWeightThomson();
// Destructer
virtual ~RobustWeightThomson();
// Calculate sum of the second order derivative of loss function
virtual double calculateSumOf2ndOrderDerivativeOfLossFunction(const int numSegments, const std::complex<double>* const residuals, const double scale) const;
// Calculate weights
virtual double calculateWeights(const int numSegments, const std::complex<double>* const residuals, const double scale, const double* const weightsPrior,
double* weights) const;
// Get parameter for determing the probability used for outlier rejection
double getParameterForDetermingProbability() const;
// Set parameter for determing the probability used for outlier rejection
void setParameterForDetermingProbability( const double prob );
protected:
private:
// Parameter for determing the probability used for outlier rejection
double m_parameterForDetermingProbability;
};
#endif

View File

@@ -0,0 +1,282 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "RobustWeightTukeysBiweights.h"
#include "OutputFiles.h"
#include "Util.h"
#include "TableOfTukeysBiweightParameters.h"
#include <assert.h>
// Default constructer
RobustWeightTukeysBiweights::RobustWeightTukeysBiweights():
m_degreesOfFreedom(2)
{
setNameOfRobustWeight("Tukey's biweights");
}
// Calculate sum of the second order derivative of loss function
double RobustWeightTukeysBiweights::calculateSumOf2ndOrderDerivativeOfLossFunction(const int numSegments, const std::complex<double>* const residuals, const double scale) const {
double paramB(0.0);
double paramC(0.0);
calculateParams(getDegreesOfFreedom(), numSegments, paramB, paramC);
double sumOfDerivatives(0.0);
for (int iSeg = 0; iSeg < numSegments; ++iSeg){
const double x = std::abs(residuals[iSeg]) / scale;
sumOfDerivatives += calculateSecondDerivativeOfLossFunction(x, paramC);
}
return sumOfDerivatives;
}
// Calculate weights
double RobustWeightTukeysBiweights::calculateWeights(const int numSegments, const std::complex<double>* const residuals, const double scale,
const double* const weightsPrior, double* weights) const {
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeCvgMessage(" Scale factor: " + Util::toString(scale));
double paramB(0.0);
double paramC(0.0);
calculateParams(getDegreesOfFreedom(), numSegments, paramB, paramC);
ptrOutputFiles->writeCvgMessage(" Parameter c: " + Util::toString(paramC));
double sumOfWeights(0.0);
for (int iSeg = 0; iSeg < numSegments; ++iSeg) {
weights[iSeg] = weightsPrior[iSeg];
const double x = std::abs(residuals[iSeg]) / scale;
weights[iSeg] *= calculateWeights(x, paramC);
sumOfWeights += weights[iSeg];
}
return sumOfWeights;
}
// Destructer
RobustWeightTukeysBiweights::~RobustWeightTukeysBiweights()
{
}
// Calculate scale of absolute values of complex residuals
double RobustWeightTukeysBiweights::calculateScale(const int numSegments, const std::complex<double>* const residuals, const double scalePre) const {
double paramB(0.0);
double paramC(0.0);
calculateParams(getDegreesOfFreedom(), numSegments, paramB, paramC);
double* realResiduals = new double[numSegments];
for (int iSeg = 0; iSeg < numSegments; ++iSeg) {
realResiduals[iSeg] = std::abs(residuals[iSeg]);
}
const double scaleNew = calculateRobustScale(numSegments, realResiduals, scalePre, paramB, paramC);
delete[] realResiduals;
return scaleNew;
}
// Get degrees of freedom
int RobustWeightTukeysBiweights::getDegreesOfFreedom() const{
return m_degreesOfFreedom;
}
// Set degrees of freedom
void RobustWeightTukeysBiweights::setDegreesOfFreedom( const int dof ){
m_degreesOfFreedom = dof;
}
// Calculate derivative of the loss function of Tukey's biweights
double RobustWeightTukeysBiweights::calculateDerivativeOfLossFunction(const double val, const double c) {
assert(c > 0.0);
if (fabs(val) > c) {
return 0.0;
}
else {
const double temp = 1.0 - pow(val / c, 2);
return val * pow(temp, 2);
}
}
// Calculate loss function of Tukey's biweight function
double RobustWeightTukeysBiweights::calculateLossFunction(const double val, const double c) {
assert(c > 0.0);
if (fabs(val) > c) {
// c^2 / 6
return pow(c, 2) / 6;
}
else {
// x^2 / 2 - x^4 / c^2 / 2 + x^6 / c^4 / 6
return pow(val, 2) / 2.0 - pow(val, 4) / pow(c, 2) / 2.0 + pow(val, 6) / pow(c, 4) / 6.0;
}
}
// Calculate expectation of Tukey's biweight function
double RobustWeightTukeysBiweights::calculateExpectation(const int dimension, const double c) {
assert(dimension > 0);
double* arguments = new double[dimension];
double* factors = new double[dimension];
double sum(0.0);
calculateExpectationAux(dimension, c, 0, arguments, factors, sum);
delete[] arguments;
delete[] factors;
return sum / pow(sqrt(2.0 * CommonParameters::PI), dimension);
}
// Auxiliary function for calculating the expectation of Tukey's biweight function
void RobustWeightTukeysBiweights::calculateExpectationAux(const int dimension, const double c, const int idim,
double* arguments, double* factors, double& sum) {
const double lowerLimit = -5.0;
const double upperLimit = 5.0;
const int numInterval = 20;
const double interval = (upperLimit - lowerLimit) / static_cast<double>(numInterval);
for (int iInterval = 0; iInterval < numInterval + 1; ++iInterval) {
arguments[idim] = lowerLimit + static_cast<int>(iInterval) * interval;
if (iInterval == 0 || iInterval == numInterval) {
factors[idim] = 0.5 * interval;
}
else {
factors[idim] = interval;
}
if (idim == dimension - 1) {
double squareSumOfArguments(0.0);
for (int i = 0; i < dimension; ++i) {
squareSumOfArguments += pow(arguments[i], 2);
}
double temp = calculateLossFunction(sqrt(squareSumOfArguments), c) * exp(-0.5 * squareSumOfArguments);
for (int i = 0; i < dimension; ++i) {
temp *= factors[i];
}
sum += temp;
}
else {
// Go to next inner loop
calculateExpectationAux(dimension, c, idim + 1, arguments, factors, sum);
}
}
}
// Calculate parameters of Tukey's biweight function
void RobustWeightTukeysBiweights::calculateParams(const int dimension, const int numOfData, double& paramB, double& paramC) {
assert(dimension > 0);
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
if (dimension > TableOfTukeysBiweightParameters::numDimensions) {
ptrOutputFiles->writeErrorMessage("Number of dimensions for Tukey's biweight function exceeds the upper limit ("
+ Util::toString(TableOfTukeysBiweightParameters::numDimensions) + ")");
}
const int idim = dimension - 1;
const double rhs = 0.5 * (1.0 - static_cast<double>(dimension) / static_cast<double>(numOfData));// (n-p)/2n
for (int ic = 1; ic < TableOfTukeysBiweightParameters::numOfParamCs; ++ic) {
const double c0 = TableOfTukeysBiweightParameters::paramCsOfTukeyBiweight[ic - 1];
const double b0 = TableOfTukeysBiweightParameters::paramBsOfTukeyBiweight[idim][ic - 1];
const double lhs0 = ic == 1 ? 1.0 : 6.0 * b0 / pow(c0, 2);// b / (c^2/6)
const double diff0 = lhs0 - rhs;
const double c1 = TableOfTukeysBiweightParameters::paramCsOfTukeyBiweight[ic];
const double b1 = TableOfTukeysBiweightParameters::paramBsOfTukeyBiweight[idim][ic];
const double lhs1 = 6.0 * b1 / pow(c1, 2);// b / (c^2/6)
const double diff1 = lhs1 - rhs;
// lhs monotonically decreases
if (diff0 >= 0.0 && diff1 <= 0.0) {
const double weight = fabs(diff0) / fabs(lhs1 - lhs0);
paramC = (1.0 - weight) * c0 + weight * c1;
paramB = (1.0 - weight) * b0 + weight * b1;
return;
}
}
ptrOutputFiles->writeErrorMessage("Parameters of Tukey's biweight function was not able to be determined");
}
// Calculate robust scale with Tukey's biweights
double RobustWeightTukeysBiweights::calculateRobustScale(const int numOfData, const double* residuals, const double scalePre,
const double paramb, const double paramc) {
double squareScale(0.0);
for (int iData = 0; iData < numOfData; ++iData) {
const double val = residuals[iData] / scalePre;
if (fabs(val) < CommonParameters::EPS) {
// rho''(0) / 2 = 1 / 2
squareScale += 0.5 * pow(residuals[iData], 2);
}
else {
squareScale += calculateLossFunction(val, paramc) * pow(scalePre, 2);
}
}
squareScale /= static_cast<double>(numOfData);
squareScale /= paramb;
return sqrt(squareScale);
}
// Calculate second order derivative of the loss function of Tukey's biweights
double RobustWeightTukeysBiweights::calculateSecondDerivativeOfLossFunction(const double val, const double c) {
assert(c > 0.0);
if (fabs(val) > c) {
return 0.0;
}
else {
// 1 - 6 * x^2 / c^2 + 5 * x^4 / c^4
return 1.0 - 6.0 * pow(val / c, 2) + 5.0 * pow(val / c, 4);
}
}
// Calculate the term in the denominator of robust covariance matrix using Tukey's biweights
double RobustWeightTukeysBiweights::calculateTermInDenominatorOfRobustCovariance(const double val, const double c) {
return calculateWeights(val, c) * pow(val, 2);
}
// Calculate Tukey's biweights
double RobustWeightTukeysBiweights::calculateWeights(const double val, const double c) {
assert(c > 0.0);
if (fabs(val) > c) {
return 0.0;
}
else {
// 1 - 2 * x^2 / c^2 + x^4 / c^4
return 1.0 - 2.0 * pow(val / c, 2) + pow(val / c, 4);
}
}

View File

@@ -0,0 +1,101 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_ROBUST_TUKEYS_BIWEIGHTS
#define DBLDEF_ROBUST_TUKEYS_BIWEIGHTS
#include "RobustWeight.h"
#include "CommonParameters.h"
#include <complex>
// Class of M-estimator using Tukey's biweights
class RobustWeightTukeysBiweights : public RobustWeight{
public:
// Default constructer
RobustWeightTukeysBiweights();
// Destructer
virtual ~RobustWeightTukeysBiweights();
// Calculate sum of the second order derivative of loss function
virtual double calculateSumOf2ndOrderDerivativeOfLossFunction(const int numSegments, const std::complex<double>* const residuals, const double scale) const;
// Calculate weights
virtual double calculateWeights(const int numSegments, const std::complex<double>* const residuals, const double scale, const double* const weightsPrior,
double* weights) const;
// Calculate scale of absolute values of complex residuals
virtual double calculateScale(const int numSegments, const std::complex<double>* const residuals, const double scalePre) const;
// Get degrees of freedom
int getDegreesOfFreedom() const;
// Set degrees of freedom
void setDegreesOfFreedom( const int dof );
// Calculate derivative of the loss function of Tukey's biweights
static double calculateDerivativeOfLossFunction(const double val, const double c);
// Calculate the expectation of Tukey's biweight function
static double calculateExpectation(const int dimension, const double c);
// Auxiliary function for calculating the expectation of Tukey's biweight function
static void calculateExpectationAux(const int dimension, const double c, const int idim,
double* arguments, double* factors, double& sum);
// Calculate loss function of Tukey's biweight function
static double calculateLossFunction(const double val, const double c);
// Calculate parameters of Tukey's biweight function
static void calculateParams(const int dimension, const int numOfData, double& paramB, double& paramC);
// Calculate robust scale with Tukey's biweights
static double calculateRobustScale(const int numOfData, const double* residuals, const double scalePre,
const double paramb, const double paramc);
// Calculate second order derivative of the loss function of Tukey's biweights
static double calculateSecondDerivativeOfLossFunction(const double val, const double c);
// Calculate the term in the denominator of robust covariance matrix using Tukey's biweights
static double calculateTermInDenominatorOfRobustCovariance(const double val, const double c);
// Calculate Tukey's biweights
static double calculateWeights(const double val, const double c);
protected:
private:
// Degrees of freedom
int m_degreesOfFreedom;
};
#endif

File diff suppressed because it is too large Load Diff

1570
src/Util.cpp Normal file

File diff suppressed because it is too large Load Diff

229
src/Util.h Normal file
View File

@@ -0,0 +1,229 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_UTIL
#define DBLDEF_UTIL
#include <complex>
#include <vector>
#include <sstream>
namespace Util
{
// Apply IIR high-pass filter
void applyIIRHighPassFilter( const double samplingFreq, const double cutoffFreq, const int numData, double* data );
// Apply IIR low-pass filter
void applyIIRLowPassFilter( const double samplingFreq, const double cutoffFreq, const int numData, double* data );
// Apply notch filter
void applyNotchFilter( const double Q, const double samplingFreq, const double cutoffFreq, const int numData, double* data );
// Convert string "HH:MM:SS" to seconds
int convertHHMMSSToSeconds( const std::string& hhmmss );
// Debug write real matrix
// Matrix must be stored by column major order
void debugWriteRealMatrix( const int numRows, const int numColumns, const double* const matrix );
// Sort elements by its key value with quick sort
void quickSort( const int numOfIDs, int* ids, const double* const values );
// Sort elements by its key value with quick sort and replace original arrays
void quickSort( const int numOfIDs, double* values );
// Calculate Absolute value fo a complex value
double calculateAbsoluteValue( const std::complex<double> value );
// Calculate calibration function for FIR filter (Type1)
std::complex<double> calculateCalibrationForFIRFilterType1( const std::string& fileName, const int nskip,
const double samplingFreq, const double freq, const bool groupDelay );
// Calculate calibration function for FIR filter (Type2)
std::complex<double> calculateCalibrationForFIRFilterType2( const std::string& fileName, const int nskip,
const double samplingFreq, const double freq, const int nfstart, const int nfend );
// Calculate determinant of real square matrix
double calculateDeterminantOfMatrix( const int dimension, const double* const matrix );
// Calcualte all eigenvalues and eigenvectors of a real symmetric
void calculateEigenValuesAndVectorsOfRealSymmetricMatrix( const int dimension, const double* const matrix,
double* eigenValues, double* eigenVectors );
// Calculate IQR
double calculateIQR( const int num, const double* const data );
// Calculate MADN
double calculateMADN( const int num, const double* const data );
// Calculate MADN
double calculateMADN( const std::vector<double>& data );
// calculate mean value
double calculateMeanValue( const int num, const double* const data );
// calculate mean square value
double calculateMeanSquareValue( const int num, const double* const data );
// Calculate median
double calculateMedian( const int num, const double* const data );
// Calculate median
double calculateMedian( const std::vector<double>& data );
// Calculate median absolute deviation
double calculateMAD(const int num, const double median, const double* const data);
// Calculate median absolute deviation
double calculateMAD( const int num, const double* const data );
// Calculate median absolute deviation
double calculateMAD( const std::vector<double>& data );
// Calculate regression coefficients by weighted least square method
double calculateRegressionCoefficientsByWLS( const int numOfData, const double* const y, const double* const x,
const double* const weights );
// Calculate regression coefficients by weighted least square method with intercept
void calculateRegressionCoefficientsByWLSWithIntercept(const int numOfData, const double* const y, const double* const x,
const double* const weights, double& slope, double& intercept);
// calculate variance
double calculateVariance( const int num, const double mean, const double* const data );
// calculate linear trend factor by Hino (1985)
double calculateLinearTrendFactorByHino1985( const int num, const double* const data );
// calculate linear trend factor by the least square
void calculateLinearTrendFactorByLeastSquare( const int num, const double* const data, double& b0, double& b1 );
// Apply Hampel filter
int hampelFilter( const int num, const int numNeighborsOnEitherSide, const double nsigma, double* data );
// Apply Hanning window
void hanningWindow( const int num, double* data );
// Perform FFT
void fft( const int num, std::complex<double>* data, const int isign );
// Fourier transform
void fourierTransform( const int num, std::complex<double>* data );
// Inverse fourier transform
void inverseFourierTransform( const int num, std::complex<double>* data );
// Calculate field at an angle from those of two different directions
std::complex<double> calculateRotatedField( const double d1, const double d2, const double rot, const std::complex<double>& v1, const std::complex<double>& v2 );
// Check wether the input value is power of two
bool isPow2( const int val );
// Interpolation by the algorithm of Akima (1970)
double interpolationAkima( const int num, const double* const dataX, const double* const dataY, const double x );
// Calculate slope t for the interpolation by the algorithm of Akima (1970)
double calculateSlopeForInterpolationAkima( const double* const dataX, const double* const dataY );
// Linear interpolation
double interpolationLinear( const double x1, const double x2, const double y1, const double y2, const double x );
// Calculate FIR filter coefficients by the least square method
void calculateFIRFilterCoeffsByLeastSquare( const int dimension, const bool isLowPass, const double samplingFreq,
const double freq1, const double freq2, const double weight1, const double weight2, double* coeff );
// Calculate frequency characteristics of FIR filter
std::complex<double> calculateFrequencyCharacteristicsOfFIRFilter( const int dimension, const double samplingFreq, const double freq, const double* coeff );
// Calculate frequency characteristics of IIR high-pass filter
std::complex<double> calculateFrequencyCharacteristicsOfIIRHighPassFilter( const double freq, const double samplingFrequency, const double cutoffFreq );
// Calculate frequency characteristics of IIR low-pass filter
std::complex<double> calculateFrequencyCharacteristicsOfIIRLowPassFilter( const double freq, const double samplingFrequency, const double cutoffFreq );
// Calculate frequency characteristics of notch filter
std::complex<double> calculateFrequencyCharacteristicsOfNotchFilter( const double freq, const double Q, const double samplingFrequency, const double cutoffFreq );
// Factrize and solve a linear equation with real coefficents matrix
void factorizeAndSolveLinearEquationRealMatrix( const int dimension, const int nRhs, const double* const matrix, const double* const rhsVectors, double* result );
// Factrize and solve a linear equation with real symmetric matrix
void factorizeAndSolveLinearEquationRealSymmetricMatrix( const int dimension, const int nRhs, const double* const matrix, const double* const rhsVectors, double* result );
// Factrize and solve a linear equation with real symmetric positive definite matrix
void factorizeAndSolveLinearEquationRealSymmetricPositiveDefiniteMatrix( const int dimension, const int nRhs, const double* const matrix, const double* const rhsVectors, double* result );
// Factorize a real square matrix
void factorizeRealSquareMatrix( const int dimension, const double* const matrix, double* factorizedMatrix, int* ipiv );
// Factorize a real symmetric matrix
void factorizeRealSymmetricMatrix( const int dimension, const double* const matrix, double* factorizedMatrix, int* ipiv );
// Factorize a real symmetric positive definite matrix
void factorizeRealSymmetricPositiveDefiniteMatrix( const int dimension, const double* const matrix, double* factorizedMatrix );
// Solve a linear equation with real square matrix
void solveLinearEquationRealSquareMatrix( const int dimension, const int nRhs, const int* const ipivInt, double* factorizedMatrix, const double* const rhsVectors, double* result );
// Solve a linear equation with real symmetric matrix
void solveLinearEquationRealSymmetricMatrix( const int dimension, const int nRhs, const int* const ipivInt, double* factorizedMatrix, const double* const rhsVectors, double* result );
// Solve a linear equation with real symmetric positive definite matrix
void solveLinearEquationRealSymmetricPositiveDefiniteMatrix( const int dimension, const int nRhs, double* factorizedMatrix, const double* const rhsVectors, double* result );
// Extract filename without extension
std::string extractFileNameWithoutExtension( const std::string& fileNameFull );
// Extract extension of filename
std::string extractExtensionOfFileName(const std::string& fileNameFull);
// The second degree Lagrange interpolation
double interpolation2ndOrderLagrange( const double x1, const double x2, const double x3, const double y1, const double y2, const double y3, const double x );
// Convert a decimal number to a binary-coded form
int decimalToBinary(int dec );
// Convert to string
template < typename T >
std::string toString( const T x ){
std::ostringstream oss;
oss << x;
return oss.str();
}
// Convert string to integer
int stringToInt( const std::string& sbuf );
// Convert string to double
double stringToDouble( const std::string& sbuf );
}
#endif

319
src/UtilRobust.cpp Normal file
View File

@@ -0,0 +1,319 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include "UtilRobust.h"
#include "Util.h"
#include "OutputFiles.h"
#include "CommonParameters.h"
#include <algorithm>
#include <assert.h>
#include <iomanip>
#include <iostream>
// Calculate bisquare weights
double UtilRobust::calculateBisquareWeights( const double val, const double c ){
assert( c > 0.0 );
if( fabs(val) > c ){
return 0.0;
}else{
const double temp = 1.0 - pow(val/c, 2);
return pow(temp, 2);
}
}
// Calculate loss function of bisquare weights
double UtilRobust::calculateLossFunctionOfBisquareWeights( const double val, const double c ){
assert( c > 0.0 );
if( fabs(val) > c ){
return 1.0;
}else{
const double temp = 1.0 - pow(val/c, 2);
return 1.0 - pow(temp, 3);
}
}
// Calculate derivative of the loss function of bisquare weights
double UtilRobust::calculateDerivativeOfLossFunctionOfBisquareWeights( const double val, const double c ){
assert( c > 0.0 );
if( fabs(val) > c ){
return 0.0;
}else{
const double temp = 1.0 - pow(val/c, 2);
return 6.0 * val / pow(c, 2) * (temp, 2);
}
}
// Calculate M-estimator of scale
double UtilRobust::calculateMEstimatorOfScale( const int numOfData, const double* const residuals ){
double scale = Util::calculateMADN(numOfData, residuals);
const double paramb = 0.5;
const double paramc = 1.56;
const int numOfISteps = 20;
const double convergenceCriteria = 0.05;
for( int iter = 0; iter < numOfISteps; ++iter ){
const double scaleNew = calculateRobustScaleWithBisquareWeights(numOfData, residuals, scale, paramb, paramc);
if( fabs(scale - scaleNew)/fabs(scale) < convergenceCriteria ){
// Converged
return scaleNew;
}
scale = scaleNew;
}
return scale;
}
// Calculate robust scale with bisquare weights
double UtilRobust::calculateRobustScaleWithBisquareWeights( const int numOfData, const double* residuals, const double scale,
const double paramb, const double paramc ){
double squareScale(0.0);
for( int iData = 0; iData < numOfData; ++iData ){
const double u = residuals[iData] / scale;
if( fabs(u) < CommonParameters::EPS ){
// rho''(0) / 2 = 6 / c^2 / 2 = 3 / c^2
squareScale += 3.0 / pow(paramc, 2) * pow(residuals[iData], 2);
}else{
squareScale += calculateLossFunctionOfBisquareWeights(residuals[iData]/scale, paramc) * pow(scale, 2);
}
}
squareScale /= static_cast<double>(numOfData);
squareScale /= paramb;
return sqrt(squareScale);
}
// Calculate second derivative of the loss function of bisquare weights
double UtilRobust::calculateSecondDerivativeOfLossFunctionOfBisquareWeights( const double val, const double c ){
assert( c > 0.0 );
if( fabs(val) > c ){
return 0.0;
}else{
const double temp = 1.0 - pow(val/c, 2);
const double term1 = 6.0 / pow(c, 2) * pow(temp, 2);
const double term2 = 24.0 * pow(val, 2) / pow(c, 4) * temp;
return term1 - term2;
}
}
// Compute least square estimator for univariate linear regression
void UtilRobust::computeLSEstimatorForUnivariateLinearRegression( const int numOfData, const double* const y, const double* const x,
const double coeffMin, const double coeffMax, double& scaleOut, double& coeffOut ){
double xx = 0.0;
double xy = 0.0;
for( int iData = 0; iData < numOfData; ++iData ){
xx += x[iData] * x[iData];
xy += x[iData] * y[iData];
}
if( fabs(xx) < CommonParameters::EPS ){
OutputFiles* ptrOutputFiles = OutputFiles::getInstance();
ptrOutputFiles->writeWarningMessage("Denominator is too small ("+ Util::toString(xx) + ") in the weighted least square method");
coeffOut = xy / CommonParameters::EPS;
}else{
coeffOut = xy / xx;
}
if( coeffOut < coeffMin ){
coeffOut = coeffMin;
}
if( coeffOut > coeffMax ){
coeffOut = coeffMax;
}
double* residuals = new double[numOfData];
for( int iData = 0; iData < numOfData; ++iData ){
residuals[iData] = y[iData] - coeffOut * x[iData];
}
const double variance = Util::calculateVariance(numOfData, 0.0, residuals);
scaleOut= sqrt(variance);
delete [] residuals;
}
// Compute S-estimator for univariate linear regression
// This function is based on the algorithm of Salibian-Barrera & Yohai (2006)
void UtilRobust::computeSEstimatorForUnivariateLinearRegression( const int numOfData, const int numOfCandidates,
const double* const y, const double* const x, const double* const coeffCandidates, const double coeffMin, const double coeffMax,
double& scaleOut, double& coeffOut, double& AICS ){
const double paramb = 0.5;
const double paramc = 1.56;
const int numOfISteps = 20;
// Initialize
scaleOut = 1.0e20;
coeffOut = 0.0;
double* residuals = new double[numOfData];
for( int iCan = 0; iCan < numOfCandidates; ++iCan ){
double coeff = coeffCandidates[iCan];
for( int iData = 0; iData < numOfData; ++iData ){
residuals[iData] = y[iData] - coeff * x[iData];
}
double scale = Util::calculateMADN(numOfData, residuals);
performISteps( numOfData, y, x, paramb, paramc, numOfISteps, coeffMin, coeffMax, coeff, scale, residuals );
if( scale < scaleOut ){
scaleOut = scale;
coeffOut = coeff;
}
}
double Jsn(0.0);
double Ksn(0.0);
for( int iData = 0; iData < numOfData; ++iData ){
const double normalizedResidual = residuals[iData] / scaleOut;
Jsn += calculateSecondDerivativeOfLossFunctionOfBisquareWeights(normalizedResidual, paramc) * pow(x[iData]/scaleOut,2);
Ksn += pow(calculateDerivativeOfLossFunctionOfBisquareWeights(normalizedResidual, paramc), 2) * pow(x[iData]/scaleOut,2);
}
// 1/n is omiteed because it is canceled out
const double term1 = 2.0 * static_cast<double>(numOfData) * log(scaleOut);
double term2(0.0);
if( fabs(Jsn) > CommonParameters::EPS ){
const double term2 = 2.0 * Ksn / Jsn;
}
AICS = term1 + term2;
delete [] residuals;
}
// Compute S-estimator for univariate linear regression with intercept
void UtilRobust::computeSEstimatorForUnivariateLinearRegressionWithIntercept(const int numOfData, const int numOfCandidates,
const double* const y, const double* const x, const double* const slopeCandidates, const double* const interceptCandidates,
double& scaleOut, double& slopeOut, double& interceptOut) {
const double paramb = 0.5;
const double paramc = 1.56;
const int numOfISteps = 20;
// Initialize
scaleOut = 1.0e20;
slopeOut = 0.0;
interceptOut = 0.0;
double* residuals = new double[numOfData];
for (int iCan = 0; iCan < numOfCandidates; ++iCan) {
double slope = slopeCandidates[iCan];
double intercept = interceptCandidates[iCan];
for (int iData = 0; iData < numOfData; ++iData) {
residuals[iData] = y[iData] - slope * x[iData] - intercept;
}
double scale = Util::calculateMADN(numOfData, residuals);
performIStepsWithIntercept(numOfData, y, x, paramb, paramc, numOfISteps, slope, intercept, scale, residuals);
#ifdef _DEBUG_WRITE
std::cout << "iCan " << iCan << " " << slope << " " << intercept << " " << scale << std::endl;
#endif
if (scale < scaleOut) {
slopeOut = slope;
interceptOut = intercept;
scaleOut = scale;
}
}
delete[] residuals;
}
// Perform I-steps for calculating S-estimator for univariate linear regression
void UtilRobust::performISteps( const int numOfData, const double* const y, const double* const x,
const double paramb, const double paramc, const int numOfISteps, const double coeffMin, const double coeffMax,
double& coeff, double& scale, double* residuals ){
double* weights = new double[numOfData];
const double convergenceCriteriaCoeff = 0.01;
const double convergenceCriteriaScale = 0.05;
double coeffPre = coeff;
double scalePre = scale;
for( int iter = 0; iter < numOfISteps; ++iter ){
scale = calculateRobustScaleWithBisquareWeights(numOfData, residuals, scale, paramb, paramc);
for( int iData = 0; iData < numOfData; ++iData ){
weights[iData] = calculateBisquareWeights( residuals[iData]/scale, paramc );
}
coeff = Util::calculateRegressionCoefficientsByWLS( numOfData, y, x, weights );
if( coeff < coeffMin ){
coeff = coeffMin;
}
if( coeff > coeffMax ){
coeff = coeffMax;
}
for( int iData = 0; iData < numOfData; ++iData ){
residuals[iData] = y[iData] - coeff * x[iData];
}
if( fabs(coeff - coeffPre)/fabs(coeffPre) < convergenceCriteriaCoeff &&
fabs(scale - scalePre)/fabs(scalePre) < convergenceCriteriaScale ){
// Converged
break;
}
coeffPre = coeff;
scalePre = scale;
}
delete [] weights;
}
// Perform I-steps for calculating S-estimator for univariate linear regression with intercept
void UtilRobust::performIStepsWithIntercept(const int numOfData, const double* const y, const double* const x,
const double paramb, const double paramc, const int numOfISteps, double& slope, double& intercept, double& scale, double* residuals) {
double* weights = new double[numOfData];
const double convergenceCriteria = 0.01;
const double convergenceCriteriaScale = 0.05;
double slopePre = slope;
double interceptPre = intercept;
double scalePre = scale;
for (int iter = 0; iter < numOfISteps; ++iter) {
scale = calculateRobustScaleWithBisquareWeights(numOfData, residuals, scale, paramb, paramc);
for (int iData = 0; iData < numOfData; ++iData) {
weights[iData] = calculateBisquareWeights(residuals[iData] / scale, paramc);
}
Util::calculateRegressionCoefficientsByWLSWithIntercept(numOfData, y, x, weights, slope, intercept);
for (int iData = 0; iData < numOfData; ++iData) {
residuals[iData] = y[iData] - slope * x[iData] - intercept;
}
if (fabs(slope - slopePre) / fabs(slopePre) < convergenceCriteria &&
fabs(intercept - interceptPre) / fabs(interceptPre) < convergenceCriteria &&
fabs(scale - scalePre) / fabs(scalePre) < convergenceCriteriaScale) {
// Converged
break;
}
slopePre = slope;
interceptPre = intercept;
scalePre = scale;
}
delete[] weights;
}

78
src/UtilRobust.h Normal file
View File

@@ -0,0 +1,78 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#ifndef DBLDEF_UTIL_ROBUST
#define DBLDEF_UTIL_ROBUST
namespace UtilRobust
{
// Calculate bisquare weights
double calculateBisquareWeights( const double val, const double c );
// Calculate loss function of bisquare weights
double calculateLossFunctionOfBisquareWeights( const double val, const double c );
// Calculate derivative of the loss function of bisquare weights
double calculateDerivativeOfLossFunctionOfBisquareWeights(const double val, const double c);
// Calculate M-estimator of scale
double calculateMEstimatorOfScale( const int numOfData, const double* const residuals );
// Calculate robust scale with bisquare weights
double calculateRobustScaleWithBisquareWeights( const int numOfData, const double* residuals, const double scale,
const double paramb, const double paramc );
// Calculate second order derivative of the loss function of bisquare weights
double calculateSecondDerivativeOfLossFunctionOfBisquareWeights( const double val, const double c );
// Compute least square estimator for univariate linear regression
void computeLSEstimatorForUnivariateLinearRegression( const int numOfData, const double* const y, const double* const x,
const double coeffMin, const double coeffMax, double& scaleOut, double& coeffOut );
// Compute S-estimator for univariate linear regression
void computeSEstimatorForUnivariateLinearRegression( const int numOfData, const int numOfCandidates,
const double* const y, const double* const x, const double* const coeffCandidates, const double coeffMin, const double coeffMax,
double& scaleOut, double& coeffOut, double& AICS );
// Compute S-estimator for univariate linear regression
void computeSEstimatorForUnivariateLinearRegressionWithIntercept(const int numOfData, const int numOfCandidates,
const double* const y, const double* const x, const double* const slopeCandidates, const double* const interceptCandidates,
double& scaleOut, double& slopeOut, double& interceptOut);
// Perform I-steps for calculating S-estimator for univariate linear regression
void performISteps( const int numOfData, const double* const y, const double* const x,
const double paramb, const double paramc, const int numOfISteps, const double coeffMin, const double coeffMax,
double& coeff, double& scale, double* residuals );
// Perform I-steps for calculating S-estimator for univariate linear regression with intercept
void performIStepsWithIntercept(const int numOfData, const double* const y, const double* const x,
const double paramb, const double paramc, const int numOfISteps, double& slope, double& intercept, double& scale, double* residuals);
}
#endif

48
src/main.cpp Normal file
View File

@@ -0,0 +1,48 @@
//--------------------------------------------------------------------------
// Copyright(c) 2024, Yoshiya Usui
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met :
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and /or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//--------------------------------------------------------------------------
#include <stdio.h>
#include <string.h>
#include "Control.h"
int main( int argc, char* argv[] ){
bool outputToConsole(false);
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "-cout") == 0) {
outputToConsole = true;
}
}
Control::getInstance()->run(outputToConsole);
return 0;
}