Skip to content

Commit 87df5a3

Browse files
committed
updating plots
1 parent cae0dc1 commit 87df5a3

File tree

1 file changed

+155
-35
lines changed

1 file changed

+155
-35
lines changed

mtpy/modeling/simpeg/recipes/inversion_2d.py

Lines changed: 155 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,7 @@ def plot_tikhonov_curve(self):
539539
xlim = ax.get_xlim()
540540
ax.plot(
541541
xlim,
542-
np.ones(2)
543-
* (
544-
self.data.te_observations.size + self.data.tm_observations.size
545-
),
542+
np.ones(2) * (self.data.te_survey.nD + self.data.tm_survey.nD),
546543
"--",
547544
)
548545
ax.set_xlim(xlim)
@@ -574,38 +571,161 @@ def plot_responses(self, iteration_number, **kwargs):
574571
te_obs = self.data.te_data.dobs.copy().reshape(shape)
575572
tm_obs = self.data.tm_data.dobs.copy().reshape(shape)
576573

574+
obs_color = kwargs.get("obs_color", (0, 178 / 255, 1))
575+
pred_color = kwargs.get("pred_color", (1, 110 / 255, 0))
576+
obs_marker = "."
577+
pred_maker = "o"
578+
577579
## With these plot frequency goes from high on the left to low on the right.
578580
## Moving shallow to deep from left to right.
579581

580582
fig = plt.figure(figsize=(10, 3))
581-
ax1 = fig.add_subplot(2, 2, 1)
582-
ax2 = fig.add_subplot(2, 2, 2, sharex=ax1)
583-
ax3 = fig.add_subplot(2, 2, 3, sharex=ax1)
584-
ax4 = fig.add_subplot(2, 2, 4, sharex=ax1)
585-
586-
# plot TE Resistivity
587-
ax1.semilogy(te_obs[:, 0, :].flatten(), "b.", label="observed")
588-
ax1.semilogy(te_pred[:, 0, :].flatten(), "r.", label="predicted")
589-
ax1.set_title("TE")
590-
ax1.set_ylabel("Apparent Resistivity")
591-
ax1.set_xlim((self.data.n_stations * self.data.n_frequencies, 0))
592-
ax1.legend()
593-
594-
# plot TM Resistivity
595-
ax2.semilogy(tm_obs[:, 0, :].flatten(), "b.", label="observed")
596-
ax2.semilogy(tm_pred[:, 0, :].flatten(), "r.", label="predicted")
597-
ax2.set_title("TM")
598-
ax2.legend()
599-
600-
# plot TE Phase
601-
ax3.plot(te_obs[:, 1, :].flatten(), "b.", label="observed")
602-
ax3.plot(te_pred[:, 1, :].flatten(), "r.", label="predicted")
603-
ax3.set_xlabel("data point")
604-
ax3.legend()
605-
606-
# plot TM Phase
607-
ax4.plot(tm_obs[:, 1, :].flatten(), "b.", label="observed")
608-
ax4.plot(tm_pred[:, 1, :].flatten(), "r.", label="predicted")
609-
ax3.legend()
610-
611-
# plt.ylim(10, 1000)
583+
584+
if not self.data.invert_impedance:
585+
ax1 = fig.add_subplot(2, 2, 1)
586+
ax2 = fig.add_subplot(2, 2, 2, sharex=ax1)
587+
ax3 = fig.add_subplot(2, 2, 3, sharex=ax1)
588+
ax4 = fig.add_subplot(2, 2, 4, sharex=ax1)
589+
590+
# plot TE Resistivity
591+
ax1.semilogy(
592+
te_obs[:, 0, :].flatten(),
593+
".",
594+
color=obs_color,
595+
label="observed",
596+
)
597+
ax1.semilogy(
598+
te_pred[:, 0, :].flatten(),
599+
".",
600+
color=pred_color,
601+
label="predicted",
602+
)
603+
ax1.set_title("TE")
604+
ax1.set_ylabel("Apparent Resistivity")
605+
ax1.set_xlim((self.data.n_stations * self.data.n_frequencies, 0))
606+
ax1.legend()
607+
608+
# plot TM Resistivity
609+
ax2.semilogy(
610+
tm_obs[:, 0, :].flatten(),
611+
obs_marker,
612+
color=obs_color,
613+
label="observed",
614+
)
615+
ax2.semilogy(
616+
tm_pred[:, 0, :].flatten(),
617+
pred_maker,
618+
color=pred_color,
619+
label="predicted",
620+
)
621+
ax2.set_title("TM")
622+
ax2.legend()
623+
624+
# plot TE Phase
625+
ax3.plot(
626+
te_obs[:, 1, :].flatten(),
627+
obs_marker,
628+
color=obs_color,
629+
label="observed",
630+
)
631+
ax3.plot(
632+
te_pred[:, 1, :].flatten(),
633+
pred_maker,
634+
color=pred_color,
635+
label="predicted",
636+
)
637+
ax3.set_xlabel("data point")
638+
ax3.set_ylabel("Phase")
639+
ax3.legend()
640+
641+
# plot TM Phase
642+
ax4.plot(
643+
tm_obs[:, 1, :].flatten(),
644+
obs_marker,
645+
color=obs_color,
646+
label="observed",
647+
)
648+
ax4.plot(
649+
tm_pred[:, 1, :].flatten(),
650+
pred_maker,
651+
color=pred_color,
652+
label="predicted",
653+
)
654+
ax3.legend()
655+
656+
if self.data.invert_impedance:
657+
te_pred = np.abs(te_pred)
658+
tm_pred = np.abs(tm_pred)
659+
te_obs = np.abs(te_obs)
660+
tm_obs = np.abs(tm_obs)
661+
662+
ax1 = fig.add_subplot(2, 2, 1)
663+
ax2 = fig.add_subplot(2, 2, 2, sharex=ax1, sharey=ax1)
664+
ax3 = fig.add_subplot(2, 2, 3, sharex=ax1)
665+
ax4 = fig.add_subplot(2, 2, 4, sharex=ax1, sharey=ax3)
666+
667+
# plot TE Resistivity
668+
ax1.semilogy(
669+
np.abs(te_obs[:, 0, :].flatten()),
670+
".",
671+
color=obs_color,
672+
label="observed",
673+
)
674+
ax1.semilogy(
675+
np.abs(te_pred[:, 0, :].flatten()),
676+
".",
677+
color=pred_color,
678+
label="predicted",
679+
)
680+
ax1.set_title("TE")
681+
ax1.set_ylabel("Real Impedance [Ohms]")
682+
ax1.set_xlim((self.data.n_stations * self.data.n_frequencies, 0))
683+
ax1.legend()
684+
685+
# plot TM Resistivity
686+
ax2.semilogy(
687+
np.abs(tm_obs[:, 0, :].flatten()),
688+
obs_marker,
689+
color=obs_color,
690+
label="observed",
691+
)
692+
ax2.semilogy(
693+
np.abs(tm_pred[:, 0, :].flatten()),
694+
pred_maker,
695+
color=pred_color,
696+
label="predicted",
697+
)
698+
ax2.set_title("TM")
699+
ax2.legend()
700+
701+
# plot TE Phase
702+
ax3.plot(
703+
np.abs(te_obs[:, 1, :].flatten()),
704+
obs_marker,
705+
color=obs_color,
706+
label="observed",
707+
)
708+
ax3.plot(
709+
np.abs(te_pred[:, 1, :].flatten()),
710+
pred_maker,
711+
color=pred_color,
712+
label="predicted",
713+
)
714+
ax3.set_xlabel("data point")
715+
ax1.set_ylabel("Imag Impedance [Ohms]")
716+
ax3.legend()
717+
718+
# plot TM Phase
719+
ax4.plot(
720+
np.abs(tm_obs[:, 1, :].flatten()),
721+
obs_marker,
722+
color=obs_color,
723+
label="observed",
724+
)
725+
ax4.plot(
726+
np.abs(tm_pred[:, 1, :].flatten()),
727+
pred_maker,
728+
color=pred_color,
729+
label="predicted",
730+
)
731+
ax3.legend()

0 commit comments

Comments
 (0)