Exemple #1
0
def ex_coord():

    pvol = io.read_OPERA_hdf5(os.path.dirname(__file__) + '/' + '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

    nrays = int(pvol["dataset1/where"]["nrays"])
    nbins = int(pvol["dataset1/where"]["nbins"])
    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"])
    radius = georef.get_earth_radius(pvol["where"]["lat"], proj_radar)

    lon, lat, height = georef.polar2lonlatalt_n(coord[..., 0], np.degrees(coord[..., 1]), coord[..., 2], sitecoords,
                                                re=radius, ke=4. / 3.)

    x, y = georef.reproject(lon, lat, projection_target=proj_radar)

    test = x[0, 90, 0:960:60]
    print(test)
Exemple #2
0
 def test_polar2lonlatalt_n(self):
     self.assertTrue(np.allclose(georef.polar2lonlatalt_n(self.r, self.az, self.th, self.csite),
                                 self.result_n, rtol=1e-04))
Exemple #3
0
 def test_polar2lonlatalt_n(self):
     self.assertTrue(np.allclose(
         georef.polar2lonlatalt_n(self.r, self.az, self.th, self.csite),
         self.result_n, rtol=1e-04))
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()
Exemple #5
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()
Exemple #6
0
 def test_polar2lonlatalt_n(self):
     lon, lat, alt = georef.polar2lonlatalt_n(self.r, self.az,
                                              self.th, self.csite)
     self.assertTrue(np.allclose(lon, self.result_n[0]))
     self.assertTrue(np.allclose(lat, self.result_n[1]))
     self.assertTrue(np.allclose(alt, self.result_n[2]))