import numpy as np

"""The forecast methods in the nowcasts module implement the following interface:

    forecast(R, V, num_timesteps, non-keyworded arguments, keyword arguments)

where R (m,n) is the input precipitation field to be extrapolated and V (2,m,n) is
an array containing  the x- and y-components of the m*n advection field. num_timesteps
is an integer specifying the number of time steps to forecast. Non-keyword
arguments specific to each method can be included. The interface accepts optional
keyword arguments that are specific to a given forecast method.

The output of each method is a three-dimensional array of shape (num_timesteps,m,n)
containing a time series of nowcast precipitation fields.

"""

def get_method(name):
    """Return one callable function to produce deterministic or ensemble
    precipitation nowcasts.\n\

    Methods for precipitation nowcasting:

    +-------------------+-----------------------------------------------------+
    |     Name          |              Description                            |
    +===================+=====================================================+
    |  eulerian         | this approach simply keeps the last observation     |
    |                   | frozen (Eulerian persistence)                       |
    +-------------------+-----------------------------------------------------+
    |  lagrangian or    | this approach extrapolates the last observation     |
    |  extrapolation    | following the motion field (Lagrangian persistence) |
    +-------------------+-----------------------------------------------------+
    |  steps            | implementation of the STEPS stochastic nowcasting   |
    |                   | method as described in :cite:`Seed2003`,            |
    |                   | :cite:`BPS2006` and :cite:`SPN2013`                 |
    +-------------------+-----------------------------------------------------+

    """
    if name.lower() in ["eulerian"]:
        def eulerian(R, V, num_timesteps, *args, **kwargs):
            return np.repeat(R[None, :, :,], num_timesteps, axis=0)
        return eulerian
    elif name.lower() in ["extrapolation", "lagrangian"]:
        from . import extrapolation
        return extrapolation.forecast
    elif name.lower() in ["steps"]:
        from . import steps
        return steps.forecast
    else:
        raise ValueError("unknown nowcasting method %s" % name)

@@ -133,33 +133,8 @@
 eps,
- non-keyworded arguments,
  key
@@ -201,27 +201,8 @@
 eld 
-to be extrapolated 
 and 
@@ -217,17 +217,17 @@
 ) is
-%0A
+ 
 an array
  con
@@ -222,17 +222,17 @@
 an array
- 
+%0A
 containi
@@ -367,71 +367,8 @@
 ast.
- Non-keyword%0Aarguments specific to each method can be included.
  The
@@ -377,17 +377,17 @@
 nterface
- 
+%0A
 accepts 
@@ -394,17 +394,17 @@
 optional
-%0A
+ 
 keyword 
@@ -417,17 +417,8 @@
 nts 
-that are 
 spec
@@ -429,25 +429,18 @@
  to 
-a
+the
  given 
-forecast 
 meth
@@ -459,22 +459,81 @@
 put 
-of each method
+depends on the type of the method. For deterministic methods, the %0Aoutput
  is 
@@ -586,17 +586,17 @@
 eps,m,n)
-%0A
+ 
 containi
@@ -600,16 +600,17 @@
 ining a 
+%0A
 time ser
@@ -645,16 +645,131 @@
  fields.
+ For stochastic methods, the %0Aoutput is a four-dimensional array of shape (num_ensemble_members,num_timesteps,m,n).
 %0A%0A%22%22%22%0A%0Ad
@@ -803,19 +803,17 @@
 %22Return 
-one
+a
  callabl
@@ -827,18 +827,21 @@
 ion 
-to produce
+for computing
  det
@@ -903,44 +903,27 @@
     
-Methods for precipitation nowcasting
+Implemented methods
 :%0A%0A 
@@ -1962,16 +1962,98 @@
 -----+%0A%0A
+    steps produces stochastic nowcasts, and the other methods are deterministic.%0A%0A
     %22%22%22%0A

Revise docstring