# Path: wradlib/trafo.py
# class SBandToKu:
# class KuBandToS:
# def rvp_to_dbz(x):
# def decibel(x):
# def idecibel(x):
# def r_to_depth(x, interval):
# def kdp_to_r(kdp, f, a=129.0, b=0.85):
# def si_to_kmh(vals):
# def si_to_mph(vals):
# def si_2_kts(vals):
# def kmh_to_si(vals):
# def mph_to_si(vals):
# def kts_to_si(vals):
# 
# Path: wradlib/zr.py
# def z_to_r(z, a=200.0, b=1.6):
# def r_to_z(r, a=200.0, b=1.6):
# def z_to_r_enhanced(z, polar=True, shower=True):


import numpy as np
from wradlib import trafo, zr
#!/usr/bin/env python
# Copyright (c) 2011-2020, wradlib developers.
# Distributed under the MIT License. See LICENSE.txt for more info.




class TestZRConversion:
    img = np.zeros((5, 11), dtype=np.float32)
    img[0:1, 1:3] = 11.0  # precip field
    img[0:1, 6:9] = 45.0
    img[2:3, 1:3] = 38.0
    img[2:3, 6:9] = 2.0
    img[3:4, 1:7] = 5.0

    img = np.stack([img, img * 1.1, img * 1.2], axis=0)

    def test_z_to_r(self):
        assert zr.z_to_r(trafo.idecibel(10.0)) == 0.1537645610180688

    def test_r_to_z(self):
        assert zr.r_to_z(0.15) == 9.611164492610417

    def test_z_to_r_enhanced(self):
        res_rr, res_si = zr.z_to_r_enhanced(trafo.idecibel(self.img), polar=True)

# Path: wradlib/trafo.py
# class SBandToKu:
# class KuBandToS:
# def rvp_to_dbz(x):
# def decibel(x):
# def idecibel(x):
# def r_to_depth(x, interval):
# def kdp_to_r(kdp, f, a=129.0, b=0.85):
# def si_to_kmh(vals):
# def si_to_mph(vals):
# def si_2_kts(vals):
# def kmh_to_si(vals):
# def mph_to_si(vals):
# def kts_to_si(vals):
# 
# Path: wradlib/zr.py
# def z_to_r(z, a=200.0, b=1.6):
# def r_to_z(r, a=200.0, b=1.6):
# def z_to_r_enhanced(z, polar=True, shower=True):


# Path: wradlib/tests/test_zr.py
import numpy as np
from wradlib import trafo, zr

#!/usr/bin/env python
# Copyright (c) 2011-2020, wradlib developers.
# Distributed under the MIT License. See LICENSE.txt for more info.




class TestZRConversion:
    img = np.zeros((5, 11), dtype=np.float32)
    img[0:1, 1:3] = 11.0  # precip field
    img[0:1, 6:9] = 45.0
    img[2:3, 1:3] = 38.0
    img[2:3, 6:9] = 2.0
    img[3:4, 1:7] = 5.0

    img = np.stack([img, img * 1.1, img * 1.2], axis=0)

    def test_z_to_r(self):
        assert zr.z_to_r(trafo.idecibel(10.0)) == 0.1537645610180688

    def test_r_to_z(self):
        assert zr.r_to_z(0.15) == 9.611164492610417

    def test_z_to_r_enhanced(self):
        res_rr, res_si = zr.z_to_r_enhanced(trafo.idecibel(self.img), polar=True)

        res_rr2, res_si2 = zr.z_to_r_enhanced(trafo.idecibel(self.img[0]), polar=True)