<jupyter_start><jupyter_text>Seting up a 2D mesh and model<jupyter_code>from simpegem1d import skytem_HM_2015
wave = skytem_HM_2015()
time = np.logspace(-6, -3, 21)
hz = get_vertical_discretization_time(time, facter_tmax=0.5, factor_tmin=10.)
time_input_currents = wave.current_times[-7:]
input_currents = wave.currents[-7:]

from scipy.spatial import Delaunay
def PolygonInd(mesh, pts):
    hull = Delaunay(pts)
    inds = hull.find_simplex(mesh.gridCC)>=0
    return inds
n_sounding = 20
dx = 20.
hx = np.ones(n_sounding) * dx
mesh = Mesh.TensorMesh([hx, hz], x0='00')
inds =  mesh.gridCC[:,1]<25
inds_1 =  mesh.gridCC[:,1]<50
sigma = np.ones(mesh.nC) * 1./100.
sigma[inds_1] = 1./10.
sigma[inds] = 1./50.
x0 = np.r_[0., 75.]
x1 = np.r_[400., 75.]
x2 = np.r_[400., 90.]
x3 = np.r_[0., 125.]
pts = np.vstack((x0, x1, x2, x3, x0))
# poly_inds = PolygonInd(mesh, pts)
# sigma[poly_inds] = 0.1
cb = plt.colorbar(
    mesh.plotImage(sigma, grid=True, pcolorOpts={"norm":LogNorm()})[0],
    fraction=0.025, pad=0.04    
)

plt.ylim(mesh.vectorNy.max(), mesh.vectorNy.min())
plt.gca().set_aspect('equal')
x = mesh.vectorCCx
y = np.zeros_like(x)
z = np.ones_like(x) * 30.
rx_locations = np.c_[x, y, z]
src_locations = np.c_[x, y, z]
topo = np.c_[x, y, z-30.].astype(float)
mapping = Maps.ExpMap(mesh)
%%time
field_type = 'secondary'
rx_type = 'dBzdt'
src_type = 'CircularLoop'
offset = np.r_[8.]
a = 13.
n_pulse = 1
base_frequency = 20.
jacSwitch = True
wave_type = 'stepoff'
i=0
sigma_i = np.ones(19) * 1e-2
args = rx_locations[i,:], src_locations[i,:], topo[i,:], hz, time, field_type, rx_type, src_type, wave_type, offset, a, time_input_currents, input_currents, n_pulse, base_frequency, sigma_i, jacSwitch
resp_sim = run_simulation_TD(args)
survey = GlobalEM1DSurveyTD(
    rx_locations = rx_locations,
    src_locations = src_locations,    
    topo = topo,
    time = time,
    src_type = "VMD",
    rx_type = "dBzdt",    
    field_type = 'secondary',
    wave_type = 'stepoff',    
    offset = np.r_[8.],    
    a = 13.,
    input_currents=input_currents,
    time_input_currents=time_input_currents,
    n_pulse = 1,
    base_frequency = 20.,
)
prob = GlobalEM1DProblemTD(mesh, sigmaMap=mapping, hz=hz, parallel=True, n_cpu=2)
prob.pair(survey)
m = np.log(sigma)
pred = survey.dpred(m)
%%time 
prob.Jtvec(m, pred)
from simpegem1d import EM1DSurveyTD, EM1D
mesh_1d = Mesh.TensorMesh([mesh.hy], x0=[0.])
depth = -mesh_1d.gridN[:-1]
m_1d = np.log(prob.Sigma[0,:])
FDsurvey = EM1DSurveyTD(
    rx_location = np.array([0., 0., 30.]),
    src_location = np.array([0., 0., 30.]),
    topo= np.array([0., 0., 0.]),
    time = time,
    depth=depth,
    src_type = "VMD",
    rx_type = "dBzdt",    
    field_type = 'secondary',
    wave_type = 'stepoff',    
    offset = np.r_[8.],    
    a = 13.,
    input_currents=input_currents,
    time_input_currents=time_input_currents,
    n_pulse = 1,
    base_frequency = 20.
)
prob_1d = EM1D(
    mesh_1d, sigmaMap=Maps.ExpMap(mesh_1d), jacSwitch=False,
    chi=np.zeros(FDsurvey.n_layer)
)
if prob_1d.ispaired:
    prob_1d.unpair()
if FDsurvey.ispaired:
    FDsurvey.unpair()
prob_1d.pair(FDsurvey)
resp = FDsurvey.dpred(m_1d)
pred.shape
PRED = pred.reshape(( prob.n_sounding, survey.n_time))
plt.loglog(time, -PRED[0,:])
plt.loglog(time, -resp, 'k.')
# plt.loglog(time, -resp_sim, 'rx')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.165377751338489, 'fraction_numerical': 0.04253420582986318, 'mean_word_length': 4.004464285714286, 'pattern_counts': {'":': 1, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '159692', 'license': 'MIT', 'n_tokens_mistral': 1573, 'n_tokens_neox': 1471, 'n_words': 273, 'path': 'notebooks/develop/Test_global_em1d_fwd_td.ipynb', 'repo_name': 'igotchalk/simpegEM1D', 'size': '3362'}