Comments (12)
Hi @Fangyh09, can you provide the error message (the complete traceback) and the OS that you are using?
from pysteps.
from matplotlib import cm, pyplot
import numpy as np
import os
from pprint import pprint
from pysteps import io, rcparams
from pysteps.noise.fftgenerators import initialize_param_2d_fft_filter
from pysteps.noise.fftgenerators import initialize_nonparam_2d_fft_filter
from pysteps.noise.fftgenerators import generate_noise_2d_fft_filter
from pysteps.utils import conversion, rapsd, transformation
from pysteps.visualization import plot_precip_field, plot_spectrum1d
# Import the example radar composite
root_path = rcparams.data_sources["mch"]["root_path"]
filename = os.path.join(root_path, "20160711", "AQC161932100V_00005.801.gif")
R, _, metadata = io.import_mch_gif(filename, product="AQC", unit="mm", accutime=5.0)
# Convert to mm/h
R, metadata = conversion.to_rainrate(R, metadata)
# Nicely print the metadata
pprint(metadata)
# Plot the rainfall field
plot_precip_field(R, geodata=metadata)
# Log-transform the data
R, metadata = transformation.dB_transform(R, metadata, threshold=0.1, zerovalue=-15.0)
# Assign the fill value to all the Nans
R[~np.isfinite(R)] = metadata["zerovalue"]
# Fit the parametric PSD to the observation
Fp = initialize_param_2d_fft_filter(R)
# Compute the observed and fitted 1D PSD
L = np.max(Fp["input_shape"])
if L % 2 == 0:
wn = np.arange(0, int(L / 2) + 1)
else:
wn = np.arange(0, int(L / 2))
R_, freq = rapsd(R, fft_method=np.fft, return_freq=True)
f = np.exp(Fp["model"](np.log(wn), *Fp["pars"]))
# Extract the scaling break in km, beta1 and beta2
w0 = L / np.exp(Fp["pars"][0])
b1 = Fp["pars"][2]
b2 = Fp["pars"][3]
# Plot the observed power spectrum and the model
fig, ax = pyplot.subplots()
plot_scales = [512, 256, 128, 64, 32, 16, 8, 4]
plot_spectrum1d(
freq,
R_,
x_units="km",
y_units="dBR",
color="k",
ax=ax,
label="Observed",
wavelength_ticks=plot_scales,
)
plot_spectrum1d(
freq,
f,
x_units="km",
y_units="dBR",
color="r",
ax=ax,
label="Fit",
wavelength_ticks=plot_scales,
)
pyplot.legend()
ax.set_title(
"Radially averaged log-power spectrum of R\n"
r"$\omega_0=%.0f km, \beta_1=%.1f, \beta_2=%.1f$" % (w0, b1, b2)
)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-10-b4008649c42f> in <module>()
1 # Fit the parametric PSD to the observation
----> 2 Fp = initialize_param_2d_fft_filter(R)
3
4 # Compute the observed and fitted 1D PSD
5 L = np.max(Fp["input_shape"])
~/miniconda2/envs/maskrcnn_benchmark/lib/python3.6/site-packages/pysteps-1.0.0-py3.6-linux-x86_64.egg/pysteps/noise/fftgenerators.py in initialize_param_2d_fft_filter(X, **kwargs)
98 raise ValueError("the input is not two- or three-dimensional array")
99 if np.any(~np.isfinite(X)):
--> 100 raise ValueError("X contains non-finite values")
101
102 # defaults
ValueError: X contains non-finite values
uname -a
Linux nonews 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
from pysteps.
@aperezhortal
I found the reason, R is all nan after io.import_mch_gif
.
What are the possible reasons?
from pysteps.
I can't reproduce the error in my enviroment.
One possibility is that the file is corrupt. To discard that possibility, try using a different file, like:
filename = os.path.join(root_path, "20150515", "AQC151351605F_00005.801.gif")
Also, you can try to sync the pysteps-data dir using git pull
.
from pysteps.
If that does not work, another thing to try is reinstalling the PIL package used to read the GIFs:
conda install PIL --force-reinstall
from pysteps.
I installed using this way:
git clone https://github.com/pySTEPS/pysteps.git
python setup.py install
from pysteps.
python setup.py install
will try to install only missing dependencies, it won't update any package.
From your error log , it seems that you installed Pystepst in an anaconda environment (maskrcnn_benchmark). Hence, I think that you can update PIL using:
source activate maskrcnn_benchmark
conda install PIL --force-reinstall
from pysteps.
To discard any issues with the pysteps-data files, try cloning that repo again.
from pysteps.
When fix old errors, I met with new error
"ImportError: cannot import name 'create_prompt_application".
Reproduce
conda create -n pysteps
conda install pysteps
jupyter notebook
I tried "sudo pip3 install 'prompt-toolkit<2.1.0,>=2.0.0' --force-reinstall", but failed.
from pysteps.
@aperezhortal Could you reproduce the error?
Any other way to install the enviroment?
from pysteps.
@Fangyh09, that error is related to the jupyter package, and not pysteps.
I tryied the following steps to install both packages in the new environment and everything worked fine.
conda create -n pysteps
source activate pysteps ( activate the environment, otherwise pysteps will be installed in the base env)
conda install pysteps jupyter
jupyter notebook
from pysteps.
@aperezhortal You are right.
Thanks for your quick reply. It works after
conda create -n pysteps # <--- important
source activate pysteps
conda config --env --set channel_priority strict
conda config --env --prepend channels conda-forge
conda install pysteps jupyter
jupyter notebook
from pysteps.
Related Issues (20)
- How to handle no rain in pysteps? HOT 8
- Error: aggregate_fields_space HOT 2
- Power spectral density (PSD) with "rapsd" function HOT 2
- Unable to run any of the example scripts HOT 4
- Input for pysteps HOT 3
- how to import my own dataset (.tiff) HOT 2
- location parameter L2 in the SAL verification HOT 6
- Insert Nowcasting Model PhaSt in the pySTEPS package HOT 11
- STEPS-blending: Losing small scale features in the first time steps and other issues HOT 4
- STEPS-blending: deterministic mode not working
- Install pysteps on Mac with Apple silicon processors HOT 4
- fft_method pyfftw causes unexpected noise additions when using multi-threading HOT 5
- missing module HOT 3
- Satellite data as input for pysteps HOT 3
- Structure parameter in SAL verification metric
- No reproducibility of steps blended nowcast when using noise_stddev_adj='auto' HOT 4
- Possibility of generating intermediate values between data points? HOT 2
- Add Kalman-filter based post-processing to blending scheme HOT 1
- Cannot update coverage reports to codecov
- CI fails to install pysteps on macos-latest
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysteps.