-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add basic tests for fft noise gen * Fix example * Aesthetics
- Loading branch information
Showing
2 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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,53 @@ | ||
import numpy as np | ||
|
||
from pysteps.noise import fftgenerators | ||
from pysteps.tests.helpers import get_precipitation_fields | ||
|
||
|
||
PRECIP = get_precipitation_fields( | ||
num_prev_files=0, | ||
num_next_files=0, | ||
return_raw=False, | ||
metadata=False, | ||
upscale=2000, | ||
) | ||
PRECIP = PRECIP.filled() | ||
|
||
|
||
def test_noise_param_2d_fft_filter(): | ||
|
||
fft_filter = fftgenerators.initialize_param_2d_fft_filter(PRECIP) | ||
|
||
assert isinstance(fft_filter, dict) | ||
assert all([key in fft_filter for key in ["field", "input_shape", "model", "pars"]]) | ||
|
||
out = fftgenerators.generate_noise_2d_fft_filter(fft_filter) | ||
|
||
assert isinstance(out, np.ndarray) | ||
assert out.shape == PRECIP.shape | ||
|
||
|
||
def test_noise_nonparam_2d_fft_filter(): | ||
|
||
fft_filter = fftgenerators.initialize_nonparam_2d_fft_filter(PRECIP) | ||
|
||
assert isinstance(fft_filter, dict) | ||
assert all([key in fft_filter for key in ["field", "input_shape"]]) | ||
|
||
out = fftgenerators.generate_noise_2d_fft_filter(fft_filter) | ||
|
||
assert isinstance(out, np.ndarray) | ||
assert out.shape == PRECIP.shape | ||
|
||
|
||
def test_noise_nonparam_2d_ssft_filter(): | ||
|
||
fft_filter = fftgenerators.initialize_nonparam_2d_ssft_filter(PRECIP) | ||
|
||
assert isinstance(fft_filter, dict) | ||
assert all([key in fft_filter for key in ["field", "input_shape"]]) | ||
|
||
out = fftgenerators.generate_noise_2d_ssft_filter(fft_filter) | ||
|
||
assert isinstance(out, np.ndarray) | ||
assert out.shape == PRECIP.shape |