pysteps.postprocessing.probmatching.shift_scale
pysteps.postprocessing.probmatching.shift_scale¶
- pysteps.postprocessing.probmatching.shift_scale(R, f, rain_fraction_trg, second_moment_trg, **kwargs)¶
Find shift and scale that is needed to return the required second_moment and rain area. The optimization is performed with the Nelder-Mead algorithm available in scipy. It assumes a forward transformation ln_rain = ln(rain)-ln(min_rain) if rain > min_rain, else 0.
- Parameters
- R: array_like
The initial array to be shift and scaled.
- f: function
The inverse transformation that is applied after the shift and scale.
- rain_fraction_trg: float
The required rain fraction to be matched by shifting.
- second_moment_trg: float
The required second moment to be matched by scaling. The second_moment is defined as second_moment = var + mean^2.
- Returns
- shift: float
The shift value that produces the required rain fraction.
- scale: float
The scale value that produces the required second_moment.
- R: array_like
The shifted, scaled and back-transformed array.
- Other Parameters
- scale: float
Optional initial value of the scale parameter for the Nelder-Mead optimisation. Typically, this would be the scale parameter estimated the previous time step. Default: 1.
- max_iterations: int
Maximum allowed number of iterations and function evaluations. More details: https://docs.scipy.org/doc/scipy/reference/optimize.minimize-neldermead.html Deafult: 100.
- tol: float
Tolerance for termination. More details: https://docs.scipy.org/doc/scipy/reference/optimize.minimize-neldermead.html Default: 0.05*second_moment_trg, i.e. terminate the search if the error is less than 5% since the second moment is a bit unstable.