Beispiel #1
0
 def test_plot_ppi(self):
     ax, pm = vis.plot_ppi(self.img, re=6371000., ke=(4. / 3.))
     ax, pm = vis.plot_ppi(self.img, self.r, self.az,
                           re=6371000., ke=(4. / 3.))
     ax, pm = vis.plot_ppi(self.img, self.r, self.az, refrac=True,
                           re=6371000., ke=(4. / 3.))
     ax, pm = vis.plot_ppi(self.img, self.r, self.az, refrac=True,
                           re=6371000., ke=(4. / 3.), ax=ax)
     ax, pm = vis.plot_ppi(self.img, self.r, self.az, refrac=True,
                           re=6371000., ke=(4. / 3.), ax=212)
     ax, pm = vis.plot_ppi(self.img, autoext=False)
     vis.plot_ppi_crosshair(site=(0, 0), ranges=[2, 4, 8])
     vis.plot_ppi_crosshair(site=(0, 0),
                            ranges=[2, 4, 8],
                            angles=[0, 45, 90, 180, 270],
                            line=dict(color='white',
                                      linestyle='solid'))
     ax, pm = vis.plot_ppi(self.img, site=(10., 45.), autoext=False,
                           proj=self.proj)
     vis.plot_ppi_crosshair(site=(0, 0),
                            ranges=[2, 4, 8],
                            angles=[0, 45, 90, 180, 270],
                            proj=self.proj,
                            line=dict(color='white',
                                      linestyle='solid'))
     ax, pm = vis.plot_ppi(self.img, func='contour')
     ax, pm = vis.plot_ppi(self.img, func='contourf')
Beispiel #2
0
 def test_plot_cg_ppi(self):
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=cgax)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=111)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=121)
     cgax, pm = vis.plot_ppi(self.img, autoext=False, cg=True)
     cgax, pm = vis.plot_ppi(self.img, refrac=False, cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contour', cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contourf', cg=True)
Beispiel #3
0
 def test_plot_cg_ppi(self):
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=cgax)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=111)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=121)
     cgax, pm = vis.plot_ppi(self.img, autoext=False, cg=True)
     cgax, pm = vis.plot_ppi(self.img, refrac=False, cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contour', cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contourf', cg=True)
Beispiel #4
0
 def test_plot_cg_ppi(self):
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=cgax)
     fig, ax = pl.subplots(2, 2)
     self.assertRaises(TypeError,
                       lambda: vis.plot_ppi(self.img, elev=2.0,
                                            cg=True, ax=ax[0, 0]))
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=111)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=121)
     cgax, pm = vis.plot_ppi(self.img, autoext=False, cg=True)
     cgax, pm = vis.plot_ppi(self.img, refrac=False, cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contour', cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contourf', cg=True)
Beispiel #5
0
 def test_plot_cg_ppi(self):
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=cgax)
     fig, ax = pl.subplots(2, 2)
     self.assertRaises(
         TypeError,
         lambda: vis.plot_ppi(self.img, elev=2.0, cg=True, ax=ax[0, 0]))
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=111)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=121)
     cgax, pm = vis.plot_ppi(self.img, autoext=False, cg=True)
     cgax, pm = vis.plot_ppi(self.img, refrac=False, cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contour', cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contourf', cg=True)
Beispiel #6
0
 def test_plot_ppi(self):
     pl.figure()
     proj = georef.create_osr("dwd-radolan")
     ax, pm = vis.plot_ppi(self.img, re=6371000., ke=4./3.)
     ax, pm = vis.plot_ppi(self.img, autoext=False)
     vis.plot_ppi_crosshair(site=(0, 0),
                            ranges=[2, 4, 8],
                            angles=[0, 45, 90, 180, 270],
                            line=dict(color='white',
                                      linestyle='solid'))
     pl.figure()
     ax, pm = vis.plot_ppi(self.img, site=(10., 45.), autoext=False, proj=proj)
     vis.plot_ppi_crosshair(site=(0, 0),
                            ranges=[2, 4, 8],
                            angles=[0, 45, 90, 180, 270],
                            proj=proj,
                            line=dict(color='white',
                                      linestyle='solid'))
Beispiel #7
0
 def test_plot_ppi(self):
     ax, pm = vis.plot_ppi(self.img, re=6371000., ke=(4. / 3.))
     ax, pm = vis.plot_ppi(self.img, autoext=False)
     vis.plot_ppi_crosshair(site=(0, 0),
                            ranges=[2, 4, 8],
                            angles=[0, 45, 90, 180, 270],
                            line=dict(color='white', linestyle='solid'))
     ax, pm = vis.plot_ppi(self.img,
                           site=(10., 45.),
                           autoext=False,
                           proj=self.proj)
     vis.plot_ppi_crosshair(site=(0, 0),
                            ranges=[2, 4, 8],
                            angles=[0, 45, 90, 180, 270],
                            proj=self.proj,
                            line=dict(color='white', linestyle='solid'))
     ax, pm = vis.plot_ppi(self.img, func='contour')
     ax, pm = vis.plot_ppi(self.img, func='contourf')
Beispiel #8
0
 def test_plot_ppi_cartopy(self):
     if cartopy:
         site = (7, 45, 0.)
         map_proj = cartopy.crs.Mercator(central_longitude=site[1])
         ax, pm = vis.plot_ppi(self.img, self.r, self.az, proj=map_proj)
         self.assertIsInstance(ax, cartopy.mpl.geoaxes.GeoAxes)
         fig = pl.figure(figsize=(10, 10))
         ax = fig.add_subplot(111, projection=map_proj)
         self.da_ppi.wradlib.plot_ppi(ax=ax)
         ax.gridlines(draw_labels=True)
Beispiel #9
0
 def test_plot_ppi_cartopy(self):
     if cartopy:
         site = (7, 45, 0.)
         map_proj = cartopy.crs.Mercator(central_longitude=site[1])
         ax, pm = vis.plot_ppi(self.img, self.r, self.az, proj=map_proj)
         self.assertIsInstance(ax, cartopy.mpl.geoaxes.GeoAxes)
         fig = pl.figure(figsize=(10, 10))
         ax = fig.add_subplot(111, projection=map_proj)
         self.da_ppi.wradlib.plot_ppi(ax=ax)
         ax.gridlines(draw_labels=True)
Beispiel #10
0
 def test_plot_ppi(self):
     pl.figure()
     proj = georef.create_osr("dwd-radolan")
     ax, pm = vis.plot_ppi(self.img, re=6371000., ke=4. / 3.)
     ax, pm = vis.plot_ppi(self.img, autoext=False)
     vis.plot_ppi_crosshair(site=(0, 0),
                            ranges=[2, 4, 8],
                            angles=[0, 45, 90, 180, 270],
                            line=dict(color='white', linestyle='solid'))
     pl.figure()
     ax, pm = vis.plot_ppi(self.img,
                           site=(10., 45.),
                           autoext=False,
                           proj=proj)
     vis.plot_ppi_crosshair(site=(0, 0),
                            ranges=[2, 4, 8],
                            angles=[0, 45, 90, 180, 270],
                            proj=proj,
                            line=dict(color='white', linestyle='solid'))
Beispiel #11
0
 def test_plot_ppi_cartopy(self):
     if cartopy:
         if (LooseVersion(cartopy.__version__) < LooseVersion("0.18.0")) and (
             LooseVersion(mpl.__version__) >= LooseVersion("3.3.0")
         ):
             pytest.skip("fails for cartopy < 0.18.0 and matplotlib >= 3.3.0")
         site = (7, 45, 0.0)
         map_proj = cartopy.crs.Mercator(central_longitude=site[1])
         ax, pm = vis.plot_ppi(self.img, self.r, self.az, proj=map_proj)
         assert isinstance(ax, cartopy.mpl.geoaxes.GeoAxes)
         fig = pl.figure(figsize=(10, 10))
         ax = fig.add_subplot(111, projection=map_proj)
         self.da_ppi.wradlib.plot_ppi(ax=ax)
         ax.gridlines(draw_labels=True)
Beispiel #12
0
 def test_plot_cg_ppi(self):
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True)
     cgax, pm = vis.plot_ppi(self.img, autoext=False, cg=True)
     cgax, pm = vis.plot_ppi(self.img, refrac=False, cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contour', cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contourf', cg=True)
     with self.assertWarns(UserWarning):
         cgax, pm = vis.plot_ppi(self.img, func='contourf',
                                 proj=self.proj, cg=True)
Beispiel #13
0
 def test_plot_cg_ppi(self):
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True)
     cgax, pm = vis.plot_ppi(self.img, autoext=False, cg=True)
     cgax, pm = vis.plot_ppi(self.img, refrac=False, cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contour', cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contourf', cg=True)
     with self.assertWarns(UserWarning):
         cgax, pm = vis.plot_ppi(self.img,
                                 func='contourf',
                                 proj=self.proj,
                                 cg=True)
def ex_clutter_gabella():
    # load the example data
    import numpy as np
    # Todo: link right data set
    testdata = np.loadtxt(os.path.dirname(__file__) + '/' + 'data/polar_dBZ_fbg.gz')

    # calculate the clutter map
    clmap = clutter.filter_gabella(testdata,
                                   wsize=5,
                                   thrsnorain=0.,
                                   tr1=6.,
                                   n_p=8,
                                   tr2=1.3)

    # visualize the result
    ax, pm = vis.plot_ppi(clmap)
    ax.set_title('cluttermap')
    pl.show()
Beispiel #15
0
def ex_clutter_gabella():
    # load the example data
    import numpy as np
    # Todo: link right data set
    testdata = np.loadtxt(
        os.path.dirname(__file__) + '/' + 'data/polar_dBZ_fbg.gz')

    # calculate the clutter map
    clmap = clutter.filter_gabella(testdata,
                                   wsize=5,
                                   thrsnorain=0.,
                                   tr1=6.,
                                   n_p=8,
                                   tr2=1.3)

    # visualize the result
    ax, pm = vis.plot_ppi(clmap)
    ax.set_title('cluttermap')
    pl.show()
def ex_clutter_cloud():
    # read the radar volume scan
    path = os.path.dirname(__file__) + '/'
    pvol = io.read_OPERA_hdf5(path + 'data/20130429043000.rad.bewid.pvol.dbzh.scan1.hdf')

    # Count the number of dataset

    ntilt = 1
    for i in range(100):
        try:
            pvol["dataset%d/what" % ntilt]
            ntilt += 1
        except Exception:
            ntilt -= 1
            break

    # Construct radar values

    nrays = int(pvol["dataset1/where"]["nrays"])
    nbins = int(pvol["dataset1/where"]["nbins"])
    val = np.empty((ntilt, nrays, nbins))
    for t in range(ntilt):
        val[t, ...] = pvol["dataset%d/data1/data" % (t + 1)]
    gain = float(pvol["dataset1/data1/what"]["gain"])
    offset = float(pvol["dataset1/data1/what"]["offset"])
    val = val * gain + offset

    # Construct radar coordinates

    rscale = int(pvol["dataset1/where"]["rscale"])
    coord = np.empty((ntilt, nrays, nbins, 3))
    for t in range(ntilt):
        elangle = pvol["dataset%d/where" % (t + 1)]["elangle"]
        coord[t, ...] = georef.sweep_centroids(nrays, rscale, nbins, elangle)
    ascale = math.pi / nrays
    sitecoords = (pvol["where"]["lon"], pvol["where"]["lat"], pvol["where"]["height"])
    proj_radar = georef.create_osr("aeqd", lat_0=pvol["where"]["lat"], lon_0=pvol["where"]["lon"])
    coord[..., 0], coord[..., 1], coord[..., 2] = georef.polar2lonlatalt_n(coord[..., 0], np.degrees(coord[..., 1]),
                                                                           coord[..., 2], sitecoords, re=6370040.,
                                                                           ke=4. / 3.)
    coord = georef.reproject(coord, projection_target=proj_radar)

    # Construct collocated satellite data

    sat_gdal = io.read_safnwc(path + 'data/SAFNWC_MSG3_CT___201304290415_BEL_________.h5')
    val_sat = georef.read_gdal_values(sat_gdal)
    coord_sat = georef.read_gdal_coordinates(sat_gdal)
    proj_sat = georef.read_gdal_projection(sat_gdal)
    coord_sat = georef.reproject(coord_sat, projection_source=proj_sat, projection_target=proj_radar)
    coord_radar = coord
    interp = ipol.Nearest(coord_sat[..., 0:2].reshape(-1, 2), coord_radar[..., 0:2].reshape(-1, 2))
    val_sat = interp(val_sat.ravel()).reshape(val.shape)

    # Estimate localisation errors

    timelag = 9 * 60
    wind = 10
    error = np.absolute(timelag) * wind

    # Identify clutter based on collocated cloudtype
    clutter = cl.filter_cloudtype(val[0, ...], val_sat[0, ...], scale=rscale, smoothing=error)
    # visualize the result
    plt.figure()
    vis.plot_ppi(clutter)
    plt.suptitle('clutter')
    plt.savefig('clutter_cloud_example_1.png')
    plt.figure()
    vis.plot_ppi(val_sat[0, ...])
    plt.suptitle('satellite')
    plt.savefig('clutter_cloud_example_2.png')
    plt.show()
Beispiel #17
0
 def test_plot_ppi(self):
     ax, pm = vis.plot_ppi(self.img, re=6371000.0, ke=(4.0 / 3.0))
     ax, pm = vis.plot_ppi(self.img, self.r, self.az, re=6371000.0, ke=(4.0 / 3.0))
     ax, pm = vis.plot_ppi(
         self.img, self.r, self.az, re=6371000.0, ke=(4.0 / 3.0), ax=ax
     )
     ax, pm = vis.plot_ppi(
         self.img, self.r, self.az, re=6371000.0, ke=(4.0 / 3.0), ax=212
     )
     ax, pm = vis.plot_ppi(self.img)
     vis.plot_ppi_crosshair(site=(0, 0, 0), ranges=[2, 4, 8])
     vis.plot_ppi_crosshair(
         site=(0, 0, 0),
         ranges=[2, 4, 8],
         angles=[0, 45, 90, 180, 270],
         line=dict(color="white", linestyle="solid"),
     )
     ax, pm = vis.plot_ppi(self.img, self.r, site=(10.0, 45.0, 0.0), proj=self.proj)
     vis.plot_ppi_crosshair(
         site=(10.0, 45.0, 0.0),
         ranges=[2, 4, 8],
         angles=[0, 45, 90, 180, 270],
         proj=self.proj,
         line=dict(color="white", linestyle="solid"),
     )
     ax, pm = vis.plot_ppi(self.img, func="contour")
     ax, pm = vis.plot_ppi(self.img, func="contourf")
     ax, pm = vis.plot_ppi(self.img, self.r, self.az, proj=self.proj, site=(0, 0, 0))
     with pytest.warns(UserWarning):
         ax, pm = vis.plot_ppi(self.img, site=(10.0, 45.0, 0.0), proj=self.proj)
     with pytest.warns(UserWarning):
         ax, pm = vis.plot_ppi(self.img, proj=None, site=(0, 0, 0))
     with pytest.raises(TypeError):
         ax, pm = vis.plot_ppi(self.img, proj=self.proj)
     with pytest.raises(ValueError):
         ax, pm = vis.plot_ppi(self.img, site=(0, 0), proj=self.proj)
     with pytest.raises(ValueError):
         vis.plot_ppi_crosshair(site=(0, 0), ranges=[2, 4, 8])
Beispiel #18
0
 def test_plot_cg_ppi(self):
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, proj="cg")
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, proj="cg", site=(0, 0, 0))
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, proj="cg", ax=cgax)
     fig, ax = pl.subplots(2, 2)
     with pytest.raises(TypeError):
         vis.plot_ppi(self.img, elev=2.0, proj="cg", ax=ax[0, 0])
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, proj="cg", ax=111)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, proj="cg", ax=121)
     cgax, pm = vis.plot_ppi(self.img, proj="cg")
     cgax, pm = vis.plot_ppi(self.img, func="contour", proj="cg")
     cgax, pm = vis.plot_ppi(self.img, func="contourf", proj="cg")
     cgax, pm = vis.plot_ppi(self.img, func="contourf", proj="cg")
Beispiel #19
0
 def test_plot_cg_ppi_py3k(self):
     with self.assertWarns(UserWarning):
         cgax, pm = vis.plot_ppi(self.img,
                                 func='contourf',
                                 proj=self.proj,
                                 cg=True)
Beispiel #20
0
 def test_plot_cg_ppi(self):
     # DeprecationTests
     with self.assertWarns(DeprecationWarning):
         cgax, pm = vis.plot_ppi(self.img, autoext=True, cg=True)
     with self.assertWarns(DeprecationWarning):
         cgax, pm = vis.plot_ppi(self.img, autoext=False, cg=True)
     with self.assertWarns(DeprecationWarning):
         cgax, pm = vis.plot_ppi(self.img, refrac=True, cg=True)
     with self.assertWarns(DeprecationWarning):
         cgax, pm = vis.plot_ppi(self.img, refrac=False, cg=True)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True)
     cgax, pm = vis.plot_ppi(self.img,
                             elev=2.0,
                             cg=True,
                             proj=self.proj,
                             site=(0, 0, 0))
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, proj='cg')
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=cgax)
     fig, ax = pl.subplots(2, 2)
     self.assertRaises(
         TypeError,
         lambda: vis.plot_ppi(self.img, elev=2.0, cg=True, ax=ax[0, 0]))
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=111)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=121)
     cgax, pm = vis.plot_ppi(self.img, cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contour', cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contourf', cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contourf', cg=True)
     with self.assertWarns(DeprecationWarning):
         cgax, pm = vis.plot_ppi(self.img,
                                 func='contourf',
                                 proj=self.proj,
                                 site=(0, 0, 0),
                                 cg=True)
Beispiel #21
0
    def test_plot_ppi(self):
        # DeprecationTests
        with self.assertWarns(DeprecationWarning):
            ax, pm = vis.plot_ppi(self.img, autoext=True)
        with self.assertWarns(DeprecationWarning):
            ax, pm = vis.plot_ppi(self.img, autoext=False)
        with self.assertWarns(DeprecationWarning):
            ax, pm = vis.plot_ppi(self.img, refrac=True)
        with self.assertWarns(DeprecationWarning):
            ax, pm = vis.plot_ppi(self.img, refrac=False)

        ax, pm = vis.plot_ppi(self.img, re=6371000., ke=(4. / 3.))
        ax, pm = vis.plot_ppi(self.img, self.r, self.az,
                              re=6371000., ke=(4. / 3.))
        ax, pm = vis.plot_ppi(self.img, self.r, self.az,
                              re=6371000., ke=(4. / 3.), ax=ax)
        ax, pm = vis.plot_ppi(self.img, self.r, self.az,
                              re=6371000., ke=(4. / 3.), ax=212)
        ax, pm = vis.plot_ppi(self.img)
        vis.plot_ppi_crosshair(site=(0, 0), ranges=[2, 4, 8])
        vis.plot_ppi_crosshair(site=(0, 0),
                               ranges=[2, 4, 8],
                               angles=[0, 45, 90, 180, 270],
                               line=dict(color='white',
                                         linestyle='solid'))
        ax, pm = vis.plot_ppi(self.img, site=(10., 45., 0.),
                              proj=self.proj)
        vis.plot_ppi_crosshair(site=(0, 0),
                               ranges=[2, 4, 8],
                               angles=[0, 45, 90, 180, 270],
                               proj=self.proj,
                               line=dict(color='white',
                                         linestyle='solid'))
        ax, pm = vis.plot_ppi(self.img, func='contour')
        ax, pm = vis.plot_ppi(self.img, func='contourf')
        with self.assertRaises(TypeError):
            ax, pm = vis.plot_ppi(self.img, proj=self.proj)
        with self.assertWarns(UserWarning):
            ax, pm = vis.plot_ppi(self.img, proj=None,
                                  site=(0, 0, 0))
        with self.assertWarns(UserWarning):
            ax, pm = vis.plot_ppi(self.img, proj=None,
                                  site=(0, 0))
        ax, pm = vis.plot_ppi(self.img, self.r, self.az, proj=self.proj,
                              site=(0, 0, 0))
Beispiel #22
0
 def test_plot_cg_ppi(self):
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, proj='cg')
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, proj='cg', site=(0, 0, 0))
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, proj='cg', ax=cgax)
     fig, ax = pl.subplots(2, 2)
     with self.assertRaises(TypeError):
         vis.plot_ppi(self.img, elev=2.0, proj='cg', ax=ax[0, 0])
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, proj='cg', ax=111)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, proj='cg', ax=121)
     cgax, pm = vis.plot_ppi(self.img, proj='cg')
     cgax, pm = vis.plot_ppi(self.img, func='contour', proj='cg')
     cgax, pm = vis.plot_ppi(self.img, func='contourf', proj='cg')
     cgax, pm = vis.plot_ppi(self.img, func='contourf', proj='cg')
Beispiel #23
0
def ex_clutter_cloud():
    # read the radar volume scan
    path = os.path.dirname(__file__) + '/'
    pvol = io.read_OPERA_hdf5(
        path + 'data/20130429043000.rad.bewid.pvol.dbzh.scan1.hdf')

    # Count the number of dataset

    ntilt = 1
    for i in range(100):
        try:
            pvol["dataset%d/what" % ntilt]
            ntilt += 1
        except Exception:
            ntilt -= 1
            break

    # Construct radar values

    nrays = int(pvol["dataset1/where"]["nrays"])
    nbins = int(pvol["dataset1/where"]["nbins"])
    val = np.empty((ntilt, nrays, nbins))
    for t in range(ntilt):
        val[t, ...] = pvol["dataset%d/data1/data" % (t + 1)]
    gain = float(pvol["dataset1/data1/what"]["gain"])
    offset = float(pvol["dataset1/data1/what"]["offset"])
    val = val * gain + offset

    # Construct radar coordinates

    rscale = int(pvol["dataset1/where"]["rscale"])
    coord = np.empty((ntilt, nrays, nbins, 3))
    for t in range(ntilt):
        elangle = pvol["dataset%d/where" % (t + 1)]["elangle"]
        coord[t, ...] = georef.sweep_centroids(nrays, rscale, nbins, elangle)
    ascale = math.pi / nrays
    sitecoords = (pvol["where"]["lon"], pvol["where"]["lat"],
                  pvol["where"]["height"])
    proj_radar = georef.create_osr("aeqd",
                                   lat_0=pvol["where"]["lat"],
                                   lon_0=pvol["where"]["lon"])
    coord[..., 0], coord[..., 1], coord[..., 2] = georef.polar2lonlatalt_n(
        coord[..., 0],
        np.degrees(coord[..., 1]),
        coord[..., 2],
        sitecoords,
        re=6370040.,
        ke=4. / 3.)
    coord = georef.reproject(coord, projection_target=proj_radar)

    # Construct collocated satellite data

    sat_gdal = io.read_safnwc(
        path + 'data/SAFNWC_MSG3_CT___201304290415_BEL_________.h5')
    val_sat = georef.read_gdal_values(sat_gdal)
    coord_sat = georef.read_gdal_coordinates(sat_gdal)
    proj_sat = georef.read_gdal_projection(sat_gdal)
    coord_sat = georef.reproject(coord_sat,
                                 projection_source=proj_sat,
                                 projection_target=proj_radar)
    coord_radar = coord
    interp = ipol.Nearest(coord_sat[..., 0:2].reshape(-1, 2),
                          coord_radar[..., 0:2].reshape(-1, 2))
    val_sat = interp(val_sat.ravel()).reshape(val.shape)

    # Estimate localisation errors

    timelag = 9 * 60
    wind = 10
    error = np.absolute(timelag) * wind

    # Identify clutter based on collocated cloudtype
    clutter = cl.filter_cloudtype(val[0, ...],
                                  val_sat[0, ...],
                                  scale=rscale,
                                  smoothing=error)
    # visualize the result
    plt.figure()
    vis.plot_ppi(clutter)
    plt.suptitle('clutter')
    plt.savefig('clutter_cloud_example_1.png')
    plt.figure()
    vis.plot_ppi(val_sat[0, ...])
    plt.suptitle('satellite')
    plt.savefig('clutter_cloud_example_2.png')
    plt.show()
Beispiel #24
0
 def test_plot_cg_ppi_py3k(self):
     with self.assertWarns(UserWarning):
         cgax, pm = vis.plot_ppi(self.img, func='contourf',
                                 proj=self.proj, cg=True)
Beispiel #25
0
 def test_plot_ppi(self):
     ax, pm = vis.plot_ppi(self.img, re=6371000., ke=(4. / 3.))
     ax, pm = vis.plot_ppi(self.img,
                           self.r,
                           self.az,
                           re=6371000.,
                           ke=(4. / 3.))
     ax, pm = vis.plot_ppi(self.img,
                           self.r,
                           self.az,
                           re=6371000.,
                           ke=(4. / 3.),
                           ax=ax)
     ax, pm = vis.plot_ppi(self.img,
                           self.r,
                           self.az,
                           re=6371000.,
                           ke=(4. / 3.),
                           ax=212)
     ax, pm = vis.plot_ppi(self.img)
     vis.plot_ppi_crosshair(site=(0, 0, 0), ranges=[2, 4, 8])
     vis.plot_ppi_crosshair(site=(0, 0, 0),
                            ranges=[2, 4, 8],
                            angles=[0, 45, 90, 180, 270],
                            line=dict(color='white', linestyle='solid'))
     ax, pm = vis.plot_ppi(self.img,
                           self.r,
                           site=(10., 45., 0.),
                           proj=self.proj)
     vis.plot_ppi_crosshair(site=(10., 45., 0.),
                            ranges=[2, 4, 8],
                            angles=[0, 45, 90, 180, 270],
                            proj=self.proj,
                            line=dict(color='white', linestyle='solid'))
     ax, pm = vis.plot_ppi(self.img, func='contour')
     ax, pm = vis.plot_ppi(self.img, func='contourf')
     ax, pm = vis.plot_ppi(self.img,
                           self.r,
                           self.az,
                           proj=self.proj,
                           site=(0, 0, 0))
     with self.assertWarns(UserWarning):
         ax, pm = vis.plot_ppi(self.img,
                               site=(10., 45., 0.),
                               proj=self.proj)
     with self.assertWarns(UserWarning):
         ax, pm = vis.plot_ppi(self.img, proj=None, site=(0, 0, 0))
     with self.assertRaises(TypeError):
         ax, pm = vis.plot_ppi(self.img, proj=self.proj)
     with self.assertRaises(ValueError):
         ax, pm = vis.plot_ppi(self.img, site=(0, 0), proj=self.proj)
     with self.assertRaises(ValueError):
         vis.plot_ppi_crosshair(site=(0, 0), ranges=[2, 4, 8])
Beispiel #26
0
 def test_plot_cg_ppi(self):
     # DeprecationTests
     with self.assertWarns(DeprecationWarning):
         cgax, pm = vis.plot_ppi(self.img, autoext=True, cg=True)
     with self.assertWarns(DeprecationWarning):
         cgax, pm = vis.plot_ppi(self.img, autoext=False, cg=True)
     with self.assertWarns(DeprecationWarning):
         cgax, pm = vis.plot_ppi(self.img, refrac=True, cg=True)
     with self.assertWarns(DeprecationWarning):
         cgax, pm = vis.plot_ppi(self.img, refrac=False, cg=True)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, proj=self.proj,
                             site=(0, 0, 0))
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, proj='cg')
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=cgax)
     fig, ax = pl.subplots(2, 2)
     self.assertRaises(TypeError,
                       lambda: vis.plot_ppi(self.img, elev=2.0,
                                            cg=True, ax=ax[0, 0]))
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=111)
     cgax, pm = vis.plot_ppi(self.img, elev=2.0, cg=True, ax=121)
     cgax, pm = vis.plot_ppi(self.img, cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contour', cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contourf', cg=True)
     cgax, pm = vis.plot_ppi(self.img, func='contourf', cg=True)
     with self.assertWarns(DeprecationWarning):
         cgax, pm = vis.plot_ppi(self.img, func='contourf',
                                 proj=self.proj, site=(0, 0, 0),
                                 cg=True)