Skip to content

Commit

Permalink
Update inversion_2d.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kujaku11 committed Oct 23, 2024
1 parent eeb745e commit cae0dc1
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions mtpy/modeling/simpeg/recipes/inversion_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,3 +548,64 @@ def plot_tikhonov_curve(self):
ax.set_xlim(xlim)
plt.tight_layout()
plt.show()

def plot_responses(self, iteration_number, **kwargs):
"""
Plot responses all together
:param iteration: DESCRIPTION
:type iteration: TYPE
:param **kwargs: DESCRIPTION
:type **kwargs: TYPE
:return: DESCRIPTION
:rtype: TYPE
"""
shape = (self.data.n_frequencies, 2, self.data.n_stations)

Check warning on line 564 in mtpy/modeling/simpeg/recipes/inversion_2d.py

View check run for this annotation

Codecov / codecov/patch

mtpy/modeling/simpeg/recipes/inversion_2d.py#L564

Added line #L564 was not covered by tests

dpred = self.iterations[iteration_number]["dpred"]
te_pred = dpred.reshape(

Check warning on line 567 in mtpy/modeling/simpeg/recipes/inversion_2d.py

View check run for this annotation

Codecov / codecov/patch

mtpy/modeling/simpeg/recipes/inversion_2d.py#L566-L567

Added lines #L566 - L567 were not covered by tests
(2, self.data.n_frequencies, 2, self.data.n_stations)
)[0, :, :, :]
tm_pred = dpred.reshape(

Check warning on line 570 in mtpy/modeling/simpeg/recipes/inversion_2d.py

View check run for this annotation

Codecov / codecov/patch

mtpy/modeling/simpeg/recipes/inversion_2d.py#L570

Added line #L570 was not covered by tests
(2, self.data.n_frequencies, 2, self.data.n_stations)
)[1, :, :, :]

te_obs = self.data.te_data.dobs.copy().reshape(shape)
tm_obs = self.data.tm_data.dobs.copy().reshape(shape)

Check warning on line 575 in mtpy/modeling/simpeg/recipes/inversion_2d.py

View check run for this annotation

Codecov / codecov/patch

mtpy/modeling/simpeg/recipes/inversion_2d.py#L574-L575

Added lines #L574 - L575 were not covered by tests

## With these plot frequency goes from high on the left to low on the right.
## Moving shallow to deep from left to right.

fig = plt.figure(figsize=(10, 3))
ax1 = fig.add_subplot(2, 2, 1)
ax2 = fig.add_subplot(2, 2, 2, sharex=ax1)
ax3 = fig.add_subplot(2, 2, 3, sharex=ax1)
ax4 = fig.add_subplot(2, 2, 4, sharex=ax1)

Check warning on line 584 in mtpy/modeling/simpeg/recipes/inversion_2d.py

View check run for this annotation

Codecov / codecov/patch

mtpy/modeling/simpeg/recipes/inversion_2d.py#L580-L584

Added lines #L580 - L584 were not covered by tests

# plot TE Resistivity
ax1.semilogy(te_obs[:, 0, :].flatten(), "b.", label="observed")
ax1.semilogy(te_pred[:, 0, :].flatten(), "r.", label="predicted")
ax1.set_title("TE")
ax1.set_ylabel("Apparent Resistivity")
ax1.set_xlim((self.data.n_stations * self.data.n_frequencies, 0))
ax1.legend()

Check warning on line 592 in mtpy/modeling/simpeg/recipes/inversion_2d.py

View check run for this annotation

Codecov / codecov/patch

mtpy/modeling/simpeg/recipes/inversion_2d.py#L587-L592

Added lines #L587 - L592 were not covered by tests

# plot TM Resistivity
ax2.semilogy(tm_obs[:, 0, :].flatten(), "b.", label="observed")
ax2.semilogy(tm_pred[:, 0, :].flatten(), "r.", label="predicted")
ax2.set_title("TM")
ax2.legend()

Check warning on line 598 in mtpy/modeling/simpeg/recipes/inversion_2d.py

View check run for this annotation

Codecov / codecov/patch

mtpy/modeling/simpeg/recipes/inversion_2d.py#L595-L598

Added lines #L595 - L598 were not covered by tests

# plot TE Phase
ax3.plot(te_obs[:, 1, :].flatten(), "b.", label="observed")
ax3.plot(te_pred[:, 1, :].flatten(), "r.", label="predicted")
ax3.set_xlabel("data point")
ax3.legend()

Check warning on line 604 in mtpy/modeling/simpeg/recipes/inversion_2d.py

View check run for this annotation

Codecov / codecov/patch

mtpy/modeling/simpeg/recipes/inversion_2d.py#L601-L604

Added lines #L601 - L604 were not covered by tests

# plot TM Phase
ax4.plot(tm_obs[:, 1, :].flatten(), "b.", label="observed")
ax4.plot(tm_pred[:, 1, :].flatten(), "r.", label="predicted")
ax3.legend()

Check warning on line 609 in mtpy/modeling/simpeg/recipes/inversion_2d.py

View check run for this annotation

Codecov / codecov/patch

mtpy/modeling/simpeg/recipes/inversion_2d.py#L607-L609

Added lines #L607 - L609 were not covered by tests

# plt.ylim(10, 1000)

0 comments on commit cae0dc1

Please sign in to comment.