Skip to content

Add taup_model as an optional parameter (not kewyword) to plot_beachball and plot_polarities #308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SeismoFelix
Copy link
Member

The subroutines plot_beachball and plot_polarities in their current form does not contain taup_model as a required parameter, or at least as an optional one with a default value. Therefore, if the user wants to specify the velocity model to use for calculating the piercing points on the beachball, this parameter has to be passed as a keyword argument by the user. Otherwise, the ak135 model will be used when these functions invoke _plot_beachball_matplotlib, _plot_beachball_pygmt, and _plot_beachball_gmt.

I think that this approach makes the MTUQ user prone to errors by having discrepancies in the polarity calculation - since this information is retrieved independently and in that case, the velocity model is a required parameter prior calling _takeoff_angle_taup-and the piercing points calculation when _takeoff_angle_taup is called again for plotting the stations and the polarities in the beachball, but in this case the velocity model is a keyword argument.

For example, MTUQ in its current form, when running Waveforms+Polarities.py, as is, the result is:

Screenshot 2025-04-04 at 11 50 01 PM

which is correct, since the model used is AK135.

However, the same code after changing the model to PREM, but leaving plot_beachball and plot_polarities as is yields an inconsistency between the piercing points (calculated by default with ak135) and the predicted polarities (calculated with PREM):

Screenshot 2025-04-05 at 12 09 14 AM

However, if taup_model model is passed by the user as a keyword argument , the polarity calculation and the beachball plots are consistent:

Screenshot 2025-04-05 at 12 20 07 AM

I propose to define taup_model directly in the public subroutines plot_beachball and plot_polarities, rather than being a keyword argument. I think this may help the users not having discrepancies between the predicted polarities and the piercing points by using different models in both processes. In my case, it took me some time realizing that taup_model could be passed as a keyword argument into plot_polarities, since this is not explicity mentioned in the docstring unlike plot_beachball. In the way I am proposing the modifications, mantains AK135 as the default model if is not specified in plot_beachball and plot_polarities, with the aim of not affecting the current examples, where this parameter is not passed to those subroutines.

Sorry for the long explanation. If you consider, that this modification is unncessary, I understand if you want to keep the taup_model parameter as a keyword argument in plot_beachball and plot_polarities. However, I would kindly ask, at least, to include this parameter in the docstring of plot_polarities for avoiding any confusion to current and future users.

Thanks.

The subroutines plot_beachball and plot_polarities were hard-coded for using ak135 models when invoking _plot_beachball_matplotlib, _plot_beachball_pygmt, and _plot_beachball_gmt. Now plot_beachball and plot_polarities includes explicitly taup_model parameter, but if this parameter is not defined by the user, then the ak135 model is used by defautl.
It is better to leave taup_model as a parameter with default value of ak135, rather than being a required parameter in the private subroutines _plot_beachball_gmt, _plot_beachball_pygmt, and plot_beachball_matplotlib.
@SeismoFelix SeismoFelix changed the title Add taup_model as an as an optional parameter (not kewyword) to plot_beachball and plot_polarities Add taup_model as an optional parameter (not kewyword) to plot_beachball and plot_polarities Apr 5, 2025
@SeismoFelix
Copy link
Member Author

Before deciding merging or not, I believe is more relevant to address this instalation issue: #307

@rmodrak
Copy link
Member

rmodrak commented Apr 5, 2025

Agreed, the polarity routines have not received as much attention as the others. Now is a good opportunity to improve them.

@rmodrak
Copy link
Member

rmodrak commented Apr 5, 2025

Agreed, better documenting taup_model and similar options could be helpful. While we're looking at it, larger changes such as moving certain calculations between the frontends and backends might also be useful?

@rmodrak
Copy link
Member

rmodrak commented Apr 5, 2025

Possibly relevant: #309

@rmodrak
Copy link
Member

rmodrak commented Apr 10, 2025

If there's no further discussion, perhaps we could merge today. Then perhaps we could iterate further in another PR

@SeismoFelix
Copy link
Member Author

Hi Ryan,
Thanks. Yes. Sorry I have not discussed further this. I am preparing for SSA and probably the other contributors too, so I have not worked on this subject after submitting this PR. Cheers.

@rmodrak
Copy link
Member

rmodrak commented Apr 10, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants