-
Notifications
You must be signed in to change notification settings - Fork 2
Implementing the coherence and amplitude spectra and fixing bugs in the cross spectra. #5
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
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d64fcc1
modify get_cross_spectrum, remove related other
sortega87 5de8896
adding coherence example
sortega87 0ee73d5
rename example
sortega87 8c13cdc
adding tests
sortega87 c8a0288
update version
sortega87 6768e55
update spectrum
sortega87 23dadb2
rename spectra file
sortega87 7850d7a
unfreezing window
sortega87 df464be
separating coherence calculation
sortega87 54aa801
Change get_cross_spectrum output type
sortega87 6efff13
changing spectra definition in cross spectra
sortega87 860f599
Update spectrum.py
sortega87 a823e26
Update __init__.py
sortega87 bc4682d
coherence inside get_cross_spectra
sortega87 53e8602
fixing get_co_spectrum and get_quadrture_spectrum
sortega87 f00972f
updating changelog
sortega87 1cc8929
Updating cross spectra example
sortega87 deb12e5
Fixing typo in test_spectrum_coh2.py
sortega87 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| """Test power spectrum for time-lon-lat fields.""" | ||
|
|
||
| import numpy as np | ||
| import pytest | ||
| import xarray as xr | ||
|
|
||
| from pywk99.spectrum.spectrum import get_cross_spectrum | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def variables(): | ||
| olr1 = xr.open_dataarray("tests/olr.test.nc").transpose( | ||
| "time", "lon", "lat" | ||
| ) | ||
| olr2 = olr1.copy() | ||
| variables = xr.Dataset({"olr1": olr1, "olr2": olr2}) | ||
| variables = variables.sortby(["lat"]) | ||
| return variables | ||
|
|
||
|
|
||
| @pytest.fixture(params=["symmetric", "asymmetric"]) | ||
| def cross_spectrum(variables, request): | ||
| component_type = request.param | ||
| cross_spectrum = get_cross_spectrum( | ||
| variables, component_type, window_length="30D", overlap_length="10D" | ||
| ) | ||
| return cross_spectrum | ||
|
|
||
|
|
||
| def test_coherence_squared_is_one_for_the_same_field(cross_spectrum) -> None: | ||
| coh2 = cross_spectrum.coherence_squared | ||
| assert np.all(np.ravel(coh2.values) == pytest.approx(1.0)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.