Skip to content
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

Segmented r_power_n #62

Merged
merged 6 commits into from
Jan 8, 2025

Conversation

krisvanneste
Copy link
Collaborator

Hello Claudio,

My best wishes for the new year!

I have created a new branch adding support for a segmented powerlaw spreading model, similar to Boore (2003), and implemented in simulation codes like EXSIM and SMSIM. I also think that we could move all the geometrical spreading related functions in ssp_util.py to a dedicated ssp_geom_spreading.py file. In principle, the original r_spread_n model can also be implemented with the r_spread_n_segmented model, but for now I left it, which may result in some overlap. This is a design decision that I prefer to leave to you.

I based this branch on v1.8 (because I want to apply it to my data and v2 is still experimental), but if you prefer, I could also base it on v2. I thought development of the v2 branch had stalled, but I now notice that you have continued developing. I will try to catch up as soon as possible.

krisvanneste and others added 6 commits January 8, 2025 09:34
…on parameter.

Added new 'geom_spread_n_exponents' and 'geom_spread_n_distances configuration parameters.
Also, explain in config file that the number of exponents must be one more than the number of distances.
@claudiodsf claudiodsf force-pushed the segmented_r_power_n branch from 55f5c4b to b45ec4d Compare January 8, 2025 08:45
@claudiodsf
Copy link
Member

Dear Kris, happy new year to you too! 🌟

Thanks for the pull request, which looks nice. 👍

I rebased it on the latest main branch and added a few commits (including a Changelog entry 😉).
Let me know if that still works for you.

Concerning moving the geometrical spreading code to ssp_geom_spreading.py, I agree with that.

However, I prefer to proceed in this order:

  1. merge this PR
  2. rebase v2 over the current main (which will be already quite some work)
  3. in the main branch, move the code to ssp_geom_spreading.py
  4. rebase again v2 over main

@krisvanneste
Copy link
Collaborator Author

Claudio,

Thank you!

I force-pulled and ran it again on my example. The results are the same as before.

Here is a plot comparing a simple 1/R spreading model and the segmented Boore (2003) model, obtained by calling the r_power_n and r_power_n_segmented functions directly:
geom_spread

Of course I agree to proceed in the order you propose. Let me know if I can help.

@claudiodsf
Copy link
Member

Great, I also wrote some code to compare the different spreading models. Once we create the ssp_geom_spreading.py module, we could add a utility function to plot the different models.

@claudiodsf claudiodsf merged commit 0e5197f into SeismicSource:main Jan 8, 2025
2 checks passed
@krisvanneste
Copy link
Collaborator Author

Claudio, please wait before merging with the main branch.
I'm running into a problem with another example.

@claudiodsf
Copy link
Member

Did it already! Just make another PR 😉

@krisvanneste
Copy link
Collaborator Author

OK, I first need to find the problem.

@claudiodsf
Copy link
Member

However, I prefer to proceed in this order:

  1. merge this PR
  2. rebase v2 over the current main (which will be already quite some work)
  3. in the main branch, move the code to ssp_geom_spreading.py
  4. rebase again v2 over main

Points 3. and 4. are done! @krisvanneste, could you please double-check? Thanks!

@krisvanneste
Copy link
Collaborator Author

Points 3. and 4. are done! @krisvanneste, could you please double-check? Thanks!

I ran the example in my notebook with a segmented spreading model and it seems to work as expected!

@claudiodsf
Copy link
Member

Great, thanks!

I'm currently working on adding to the module a plot_geom_spread_models() which should be useful for debug.
I'll let you know when it's done.

@claudiodsf
Copy link
Member

Plotting function added to the mainbranch! (still have to do for v2).

Here's an example code and resulting plots:

import numpy as np
from sourcespec.ssp_geom_spreading import plot_geom_spread_models

source_depth = 10
epi_dists = np.arange(10, 1000, 10)
models = [
    ('r_power_n', {'exponent': 1}),
    ('boatwright', {'cutoff_dist_in_km': 100}),
    ('boatwright', {'cutoff_dist_in_km': 200, 'freqs': 0}),
    ('boatwright', {'cutoff_dist_in_km': 200, 'freqs': 10}),
    ('teleseismic', {'phase': 'P'}),
    ('teleseismic', {'phase': 'S'}),
]
plot_geom_spread_models(
    source_depth, epi_dists, models=models,
    plottype='linlog', xaxis='epi_dist')

source_depth = 0
epi_dists = np.arange(1, 1000, 1)
models = [
    ('r_power_n', {'exponent': 1}),
    ('r_power_n_segmented', None),
]
plot_geom_spread_models(
    source_depth, epi_dists, models=models,
    plottype='loglog', xaxis='hypo_dist')

geom_spread_plot1
geom_spread_plot2

@krisvanneste
Copy link
Collaborator Author

Nice!

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