Giter Site home page Giter Site logo

rainymotion's People

Contributors

elmerjeanpierrelopez avatar hydrogo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rainymotion's Issues

Questions on RYScaler()

Hi Georgy,
I have 2 questions about the function utils.RYScaler():

  1. For input data of cv2.calcOpticalFlowPyrLK() or cv2.optflow.createOptFlow_DIS(),
    why don't you directly use rain rate (mm/h) scaled to [0,256]? If use dbz, I suspect the intensity conservation assumption will be less obeyed than linear rain rate.

  2. inv_RYScaler() has converted data back to mm/5 min. But when doing metrics such as CSI, the threshold is set using the unit of mm/h. I guess there is an issue here.

Thanks.
Yuchao

Wrong shape numpy array in new coordinates of Dense and DenseRotation

Hi all,

Thanks for the great RainyMotion initiative, it's great to have a nowcasting 'benchmark' as open-source code.
I have tried the code on the Dutch KNMI radar data (similar to Radolan, but with 765 rows and 700 cols - hence, not a nice square). The Sparse and SparseSD codes work smoothly, but with both Dense algorithms, I get the following error:
ValueError: operands could not be broadcast together with shapes (700,765) (765,700)

Looking a bit further into the code, I found the following (example of Dense @ line 527, but similar in DenseRotation):
` # no need in rounding deltas
delta_x = delta[::, ::, 0]
delta_y = delta[::, ::, 1]

    # make a source meshgrid
    coord_source_i, coord_source_j = np.meshgrid(range(last_frame.shape[0]), range(last_frame.shape[1]))
    
    # propagate our image through time based on dense flow
    # container for our nowcasts
    nowcst_frames = []
    
    for lead_step in range(self.lead_steps):       
        
        # calculate new coordinates of radar pixels
        coord_target_i = coord_source_i + delta_x * (lead_step + 1)
        coord_target_j = coord_source_j + delta_y * (lead_step + 1)`

coord_source_i is a 2D-array with 700 rows and 765 columns, but delta_x is a 2D-array with 765 rows and 700 columns. Hence, that raises the error.
The same problem seems to occur with coord_source_j.

Since I was not totally sure what the array should look like, I can't come up with a solution yet. Though, it seems like something goes wrong with the constructing of the meshgrid?

Thanks for your help!

Kind regards,

Ruben Imhoff

cv2 optflow attributes part of main module in newest version

Hi Georgy,

I found out that in the latest version(s) of cv2, the creatOptFlow attributes are no longer part of cv2.optflow, but of the main branch of cv2, so:

    # calculate dense flow
    if method == "Farneback":
        of_instance = cv2.optflow.createOptFlow_Farneback()
    elif method == "DIS":
        of_instance = cv2.optflow.createOptFlow_DIS()
    elif method == "DeepFlow":
        of_instance = cv2.optflow.createOptFlow_DeepFlow()
    elif method == "PCAFlow":
        of_instance = cv2.optflow.createOptFlow_PCAFlow()
    elif method == "SimpleFlow":
        of_instance = cv2.optflow.createOptFlow_SimpleFlow()
    elif method == "SparseToDense":
        of_instance = cv2.optflow.createOptFlow_SparseToDense()

will become (e.g.):

    # calculate dense flow
    elif method == "DIS":
        of_instance = cv2.DISOpticalFlow_create()

For robustness, perhaps an idea to check for the cv2-version and adjust this part of the code to that?

How to view data on python

Hi Georgy,
I have 3 questions
I want to see the values in file "data.h5", but how can I view data on python? I can't see all the data:

import h5py
f = h5py.File("./rainymotion-master/rainymotion-master/data/data.h5", mode="r")
print(f['201605291650'][:])

and I see:
[[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]
...
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]]

  1. what is the file "eval_dict.npy"?

3)With this script:

from rainymotion.models import Dense
model = Dense()
model.input_data = open("./rainymotion-master/rainymotion-master/data/data.h5")
nowcasts = model.run()

I get a file without values. Where is my error?

Thanks you
Giovanni

Is this project available for GPU acceleration?

Hi,
I have successfully used this module to predict my radar map, but I found that it runs really slow, how can I accelerate it? Is this module available for the GPU acceleration?
Any suggestion would be appreciated
Thanks,
Zhang

trf.estimate gives error due to empty pts_target array

Hi Georgy,

With a small test for a local event, I got the following error when running the Sparse model:

<C:\Anaconda\lib\site-packages\numpy\core\fromnumeric.py:2909: RuntimeWarning: Mean of empty slice.
out=out, **kwargs)
C:\Anaconda\lib\site-packages\numpy\core_methods.py:73: RuntimeWarning: invalid value encountered in true_divide
ret, rcount, out=ret, casting='unsafe', subok=False)
C:\Anaconda\lib\site-packages\skimage\transform_geometric.py:53: RuntimeWarning: invalid value encountered in double_scalars
rms = math.sqrt(np.sum((points - centroid) ** 2) / points.shape[0])
Traceback (most recent call last):

File "", line 1, in
runfile('C:/Users/imhof_rn/Documents/Scripts/RainyMotion_Catchment.py', wdir='C:/Users/imhof_rn/Documents/Scripts')

File "C:\Anaconda\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)

File "C:\Anaconda\lib\site-packages\spyder\utils\site\sitecustomize.py", line 87, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)

File "C:/Users/imhof_rn/Documents/Scripts/RainyMotion_Catchment.py", line 276, in
optical_flow(data, eval_idx, results, "Sparse")

File "C:/Users/imhof_rn/Documents/Scripts/RainyMotion_Catchment.py", line 191, in optical_flow
nowcast = model.run()

File "build\bdist.win-amd64\egg\rainymotion\models.py", line 215, in run
trf.estimate(pts_source, pts_target)

File "C:\Anaconda\lib\site-packages\skimage\transform_geometric.py", line 679, in estimate
_, _, V = np.linalg.svd(A)

File "C:\Anaconda\lib\site-packages\numpy\linalg\linalg.py", line 1368, in svd
_assertNoEmpty2d(a)

File "C:\Anaconda\lib\site-packages\numpy\linalg\linalg.py", line 226, in _assertNoEmpty2d
raise LinAlgError("Arrays cannot be empty")

LinAlgError: Arrays cannot be empty>

It seems that pts_target is an empty array for that time step, even though all data files seems okay and contain data.
Are you familiar with this error?

To make it reproducible, I have added the data in a zip-file. It's a case with data from the Dutch KNMI (rows = 765, cols = 700, temp interval = 5 min.) and I use a lead time of 6 hours (72 steps).

If you need any more information, let me know!

Thanks!

Ruben

preprocessing BOM radar images

Hello, rainymotion looks like a great and powerful tool and I was looking to use it on BOM (Australia Bureau of Meteorology) radar images, but I'm having trouble understanding how to preprocess the data correctly.

I currently have combined and processed two GIFs from the BOM website:

radar

radar-masked

I converted the 7 steps of this GIF into a numpy array that was formatted into the required 3D numpy array (frames, dim_x, dim_y) for input, however, I'm unsure what exactly to put for the x and y coordinates. I currently just have a 512x512 array with zeros where there is no rain and ones in the corresponding coordinates where there is rain.
I assumed maybe I have to convert the rainfall intensity into a scalar and put them into the corresponding indexes in the 512x512 array based on their x and y coordinates?

Any help would be appreciated, thanks.

terminate called after throwing an instance of 'std::length_error'

I tried to run the four models, but shows some error.
I used the following code,

import numpy as np
import matplotlib.pyplot as plt
from rainymotion.models import DenseRotation

initialize the model

model = DenseRotation()

upload data to the model instance

model.input_data = np.load("/home/binoy/binoy/data.npy",allow_pickle=True)

run the model with default parameters

nowcast = model.run()
print (nowcast)

While running Dense and DenseRotation it shows that,
dense and denserotation

in Sparse it seen that,
Sparse

for SparseSD,
sparseSD

I don't have a strong base in python. So got stuck in running process, please help me to resolve the same.
Thanks in advance!!!!!!

Sparse model crashing at certain input

Hey Gerogy,

Awesome and clean project! I am using rainymotion in my MSc thesis about weather nowcasting for intraday electricity trading. It works pretty neat for benchmarking optical flow methods.
My issue is that the Sparse model crashes on certain input.

Minimum example code:

import glob

import numpy
from PIL import Image
from rainymotion.models import Sparse

imageFolderPath = f'/PATH/TO/failing_data'
imagePath = sorted(glob.glob(imageFolderPath + '/*.png'))

im_array = numpy.array([numpy.array(Image.open(img).convert('L'), 'f') for img in imagePath])
model = Sparse()

model.input_data = im_array
nowcasts = model.run()

failing_data.zip

My investigations went until _sparse_linear in models.py,

new_corners, st, err = cv2.calcOpticalFlowPyrLK(prevImg=data_instance[i - 1],
                                                nextImg=data_instance[i],
                                                prevPts=old_corners,
                                                nextPts=None,
                                                **of_params['lk_pars'])

This method call returned all None-s and causing crashing 1 line after.
All output:

/home/user/anaconda3/envs/rainymotion/lib/python3.7/site-packages/wradlib/io/xarray.py:951: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  class XRadVol(collections.MutableMapping):
Traceback (most recent call last):
  File "/home/user/Workspace/Dexter/task-pod-ml/nowcasting/src/optical_flow_sparse_error_minimal.py", line 15, in <module>
    nowcasts = model.run()
  File "/home/user/anaconda3/envs/rainymotion/lib/python3.7/site-packages/rainymotion-0.1-py3.7.egg/rainymotion/models.py", line 256, in run
  File "/home/user/anaconda3/envs/rainymotion/lib/python3.7/site-packages/rainymotion-0.1-py3.7.egg/rainymotion/models.py", line 60, in _sparse_linear
AttributeError: 'NoneType' object has no attribute 'ravel'

I have similar inputs like this, but they do not crash all the time just with certain sets. All other models work fine with the same data.

How to run the model?

I have this error each time i tried running the model
I followed all the instructions

model.input_data = np.load("C:/Users/Administrator/hydrogo/data/data.h5")
Traceback (most recent call last):
File "", line 1, in
NameError: name 'np' is not defined

What will be the number of input and output images??

Hi Georgy,
I have some doubts regarding rainymotion package.
How many images must be provided as input?
What number of images will be the final result?
Should the interval between the input and output images be the same?

Relevance of files along with data.h5.

rainymotion

Sir, could you please explain the relevance of files along with data.h5.The screenshot of the same is attached herewith. For my study I have only single file in NetCDF format. Can I proceed with this single file?

more api / examples plz !

hi Georgy:
I feel so excited on your Rainymotion project. I believe that it will give me great help in the field of nowcasting.
However, I find it a little bit difficult in preparing suitable input data (as I am a raw hand of python and hdf5 format). Also, I have no idea in choosing the proper functions (i.e. SparseSD or Sparse?) in different conditions.
Could you give a little bit more introduction in the following update of the upcoming tutorial(if there is a upcoming one)?

Possible error in _interpolator()

I think there is an error in the _interpolator() function of models.py:

at line 606:

def _interpolator(points, coord_source, coord_target, method="idw"):
coord_source_i, coord_source_j = coord_source
coord_target_i, coord_target_j = coord_target
# reshape
trg = np.vstack((coord_source_i.ravel(), coord_source_j.ravel())).T
src = np.vstack((coord_target_i.ravel(), coord_target_j.ravel())).T
I think trg and src should exchange their positions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.