-
Notifications
You must be signed in to change notification settings - Fork 13
Fix ssp correction #69
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
base: main
Are you sure you want to change the base?
Conversation
Note that I won't be in the office tomorrow. We can continue on Thursday or Friday. |
…quency range before correcting in station_correction function. Note that the logspaced version of the corrected spectrum is not truncated, but filled with NaN values outside the common frequency range.
…ight before fitting in _spec_inversion function.
146d642
to
8d6f0e6
Compare
Dear Kris, thanks for the PR. There were indeed many conflicts (my suggestion to start from the previous branch was bad). I can now check the PR contents... 😉 |
I added a couple of commits to move common interpolation code to a function and to remove the unnecessary |
I force-pulled the branch. |
There is still a problem in my tests when computing spectral weights from S/N: signal spectrum and noise spectrum sometimes do not have the same length. Today's is holiday in France and tomorrow I'll take the day off. |
On my side it still works. |
I think the problem is here:
This assumption is no longer valid if the frequency range A possible solution would be to pass the frequency range as an extra optional argument when calling So something like: specnoise = _build_spectrum(config, trace_noise, interpolate_freqs=spec.freqs) |
OK, I will have a look as well. Enjoy your long weekend! |
I understand the problem now. I think it would be better not to change the frequency range of the signal spectrum, and set NaN values outside the frequency range of the residual for the linear-spaced spectrum as well, thus also keeping linear-spaced and log-spaced versions in sync. We then need to check if the NaN values do not give any problem when calculating spectral SNR. I will improve the |
…ncy range of the original spectrum, neither in linear space nor in logarithmic space.
Claudio, I changed the station correction function in a way that the original frequency range is not modified. Can you check if this solves your problem with noise weighting? |
Hi Kris, thanks for this additional work. I had to make some further modifications:
Now it seems to work, but I need to test it more extensively. Could you also check on your side? |
OK |
One more commit related to NaN data 😉 |
My results look identical. |
Great!
Ok, so maybe I can use a similar approach for weight computation, instead of replacing NaN with 1e-9... |
I did it like this:
This is possible because we know the NaN values only occur at the start and/or end. The interpolated spectrum will also be NaN where the original one is NaN, because we don't allow extrapolation. |
Claudio,
Here is my pull request to fix the interpolation issue when residual correction is applied. As you suggested, I created the branch from the
fix_source_residuals
branch, but now it says that it can't automatically merge... Let me know if I need to do it differently.I ran the fix with my test case and it appears to work, but you should be aware that in the spectrum returned by the
station_correction
function, the linear-spaced and log-spaced versions may not have the same length and frequency range. The linear one is truncated to the common frequency range with the station residual, while the logarithmic one keeps the original length, with values outside the common frequency range set to NaN. I'm not sure if this could cause any problems further in the code, but I did not notice anything.