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

Causality discussion and typos in Filtering Basics notebook #45

Open
liamtoney opened this issue Mar 29, 2023 · 1 comment
Open

Causality discussion and typos in Filtering Basics notebook #45

liamtoney opened this issue Mar 29, 2023 · 1 comment
Labels

Comments

@liamtoney
Copy link

Thanks for these great resources.

I was trying to understand causal / acausal filtering today in the context of ObsPy's functions and came across the Basics in filtering notebook.

In the Causal versus acausal section of the notebook, there looks to be a typo where the "causal" filters have zerophase=True while the "acausal" filter has zerophase=False.

tr_filt = tr.copy()            # causal filter / not zero phase. Order = 2
tr_filt.filter('lowpass', freq=f, zerophase=True, corners=2)
tr_filt2 = tr.copy()           # causal filter / not zero phase. Order = set by ncorners
tr_filt2.filter('lowpass', freq=f, zerophase=True, corners=ncorners)
tr_filt3 = tr.copy()           # acausal filter / zero phase. Order = set by ncorners
tr_filt3.filter('lowpass', freq=f, zerophase=False, corners=ncorners)

Presumably, these should be switched?

On a related note, in the solutions the following discussion:

  1. The difference between the two causal filters (red and blue) are minor, even when the order of the filter is increased. But the acausal filter (green) shows a phase shift relative to the original data. This phase shift increases drastically when increasing the order of the filter.

"causal" and "acausal" would need to be swapped here — the trace in green has a phase shift due to its causal nature, not the opposite.

  1. Zooming into a time window from 4.5 s to 5 s and setting the maximum amplitude to 400, we see that the phase shift is also shifting the first onset. We would pick it incorrectly. Therefore, whenever the scientific task involves the correct time picking of phases, we have to work with causal filters. When only the frequency content is important, we can also work with acausal filters.

It is my understanding that the final two sentences here are correct, but in this case for the wrong reason. The causal filter does introduce a phase shift but it is typically used in phase picking applications to avoid pre-onset artifacts arising from acausal filtering of impulsive arrivals, correct? It might be good to clarify here.

I would be happy to draft a quick PR to address these comments, if they make sense to the notebook creators.

@megies
Copy link
Member

megies commented Mar 30, 2023

In the Causal versus acausal section of the notebook, there looks to be a typo where the "causal" filters have zerophase=True while the "acausal" filter has zerophase=False.

I agree, that looks like an error in there. The wording is also weird: "The output of a causal filter depends only on past and present input, while the output also depends on future input." The second half of the sentence is about acausal filter only mentioned in the following sentence. It probably should be ..., while the output [of an acausal filter] also depends on future input.

"causal" and "acausal" would need to be swapped here — the trace in green has a phase shift due to its causal nature, not the opposite.

Agreed.

It is my understanding that the final two sentences here are correct, but in this case for the wrong reason.

I guess the wording could be improved but in general it seems OK like you said.


It would be good to have these things fixed. Sadly, currently we don't have a set workflow for making updates to seismo live, so it means quite some work, so not sure how/when an update would make it to the live webpage.

CC @heinerigel

@megies megies changed the title Casuality discussion and typos in Filtering Basics notebook Causality discussion and typos in Filtering Basics notebook Mar 30, 2023
@megies megies added the bug label Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants