# Clutter detection by using space-born cloud images¶

In [1]:

import numpy as np

import matplotlib.pyplot as plt
try:
get_ipython().magic("matplotlib inline")
except:
plt.ion()


In [2]:

# read the radar volume scan

# 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


In [3]:

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 the corresponding radar coordinates¶

In [4]:

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"])

np.degrees(coord[..., 1]),
coord[..., 2], sitecoords,
re=6370040.,
ke=4./3.)


## Construct collocated satellite data¶

In [5]:

filename = 'hdf5/SAFNWC_MSG3_CT___201304290415_BEL_________.h5'
coord_sat = georef.reproject(coord_sat, projection_source=proj_sat,
interp = ipol.Nearest(coord_sat[..., 0:2].reshape(-1, 2),
val_sat = interp(val_sat.ravel()).reshape(val.shape)


## Estimate localisation errors¶

In [6]:

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


## Identify clutter based on collocated cloudtype¶

In [7]:

clutter = cl.filter_cloudtype(val[0, ...], val_sat[0, ...],
scale=rscale, smoothing=error)


## Plot the results¶

In [8]:

fig = plt.figure(figsize=(16,8))

ax, pm = vis.plot_ppi(val[0, ...], ax=ax)
plt.colorbar(pm, shrink=0.5)


Out[8]:

Text(0.5,1,'Detected clutter')