Files
simpeg/tests/mt/forward/test_Problem1D_VsAnalyticHalfspace.py
T
2016-06-01 20:53:12 -07:00

103 lines
3.0 KiB
Python

import unittest
import SimPEG as simpeg
from SimPEG import NSEM
from SimPEG.Utils import meshTensor
import numpy as np
# Define the tolerances
TOLr = 5e-1
TOLp = 5e-1
def appRes_TotalFieldNorm(sigmaHalf):
# Make the survey
survey, sigma, mesh = NSEM.Utils.testUtils.setup1DSurvey(sigmaHalf)
problem = NSEM.Problem1D_eTotal(mesh)
problem.pair(survey)
# Get the fields
fields = problem.fields(sigma)
# Project the data
data = survey.eval(fields)
# Calculate the app res and phs
app_r = np.array(NSEM.Utils.testUtils.getAppResPhs(data))[:,0]
return np.linalg.norm(np.abs(np.log(app_r) - np.log(np.ones(survey.nFreq)/sigmaHalf))*np.log(sigmaHalf))
def appPhs_TotalFieldNorm(sigmaHalf):
# Make the survey
survey, sigma, mesh = NSEM.Utils.testUtils.setup1DSurvey(sigmaHalf)
problem = NSEM.Problem1D_eTotal(mesh)
problem.pair(survey)
# Get the fields
fields = problem.fields(sigma)
# Project the data
data = survey.eval(fields)
# Calculate the app phs
app_p = np.array(NSEM.Utils.testUtils.getAppResPhs(data))[:,1]
return np.linalg.norm(np.abs(app_p - np.ones(survey.nFreq)*45)/ 45)
def appRes_psFieldNorm(sigmaHalf):
# Make the survey
survey, sigma, mesh = NSEM.Utils.testUtils.setup1DSurvey(sigmaHalf,False)
problem = NSEM.Problem1D_ePrimSec(mesh, sigmaPrimary = sigma)
problem.pair(survey)
# Get the fields
fields = problem.fields(sigma)
# Project the data
data = survey.eval(fields)
# Calculate the app res and phs
app_r = np.array(NSEM.Utils.testUtils.getAppResPhs(data))[:,0]
return np.linalg.norm(np.abs(np.log(app_r) - np.log(np.ones(survey.nFreq)/sigmaHalf))*np.log(sigmaHalf))
def appPhs_psFieldNorm(sigmaHalf):
# Make the survey
survey, sigma, mesh = NSEM.Utils.testUtils.setup1DSurvey(sigmaHalf,False)
problem = NSEM.Problem1D_ePrimSec(mesh, sigmaPrimary = sigma)
problem.pair(survey)
# Get the fields
fields = problem.fields(sigma)
# Project the data
data = survey.eval(fields)
# Calculate the app phs
app_p = np.array(NSEM.Utils.testUtils.getAppResPhs(data))[:,1]
return np.linalg.norm(np.abs(app_p - np.ones(survey.nFreq)*45)/ 45)
class TestAnalytics(unittest.TestCase):
def setUp(self):
pass
# Total Fields
# def test_appRes2en1(self):self.assertLess(appRes_TotalFieldNorm(2e-1), TOLr)
# def test_appPhs2en1(self):self.assertLess(appPhs_TotalFieldNorm(2e-1), TOLp)
# Primary/secondary
def test_appRes1en0_ps(self):self.assertLess(appRes_psFieldNorm(1e-0), TOLr)
def test_appPhs1en0_ps(self):self.assertLess(appPhs_psFieldNorm(1e-0), TOLp)
def test_appRes2en1_ps(self):self.assertLess(appRes_psFieldNorm(2e-1), TOLr)
def test_appPhs2en1_ps(self):self.assertLess(appPhs_psFieldNorm(2e-1), TOLp)
def test_appRes2en3_ps(self):self.assertLess(appRes_psFieldNorm(2e-3), TOLr)
def test_appPhs2en3_ps(self):self.assertLess(appPhs_psFieldNorm(2e-3), TOLp)
if __name__ == '__main__':
unittest.main()