Пример #1
0
 def tmatrix(self, wl, pluvio_filter=True, pip_filter=False, density=None):
     """Calculate radar reflectivity at requested wavelength wl [mm] using
     T-matrix"""
     name = switch_wl(wl) + "reflTM"
     if density is None:
         density = self.density(pluvio_filter=pluvio_filter,
                                pip_filter=pip_filter)
     z_serie = pd.Series(density)
     dBin = self.instr['dsd'].bin_width()
     edges = self.instr['dsd'].bin_cen() + 0.5 * dBin
     grp = self.instr['dsd'].grouped(rule=self.rule,
                                     varinterval=self.varinterval,
                                     col=self.dsd.bin_cen())
     psd_values = grp.mean()
     for item in density.iteritems():
         if item[1] > 0.0:
             ref = refractive.mi(wl, 0.001 * item[1])
             print(ref)
             flake = tmatrix.Scatterer(wavelength=wl,
                                       m=ref,
                                       axis_ratio=1.0 / 1.0)
             flake.psd_integrator = psd.PSDIntegrator()
             flake.psd_integrator.D_max = 35.0
             flake.psd = psd.BinnedPSD(
                 bin_edges=edges, bin_psd=psd_values.loc[item[0]].values)
             flake.psd_integrator.init_scatter_table(flake)
             Z = 10.0 * np.log10(radar.refl(flake))
         else:
             Z = np.nan
         z_serie.loc[item[0]] = Z
     z_serie.name = name
     return z_serie
Пример #2
0
def tm_reflectivity(size, wl, n, ar=1.0):  # Takes size and wl in meters
    scatt = tmatrix.Scatterer(
        radius=0.5e3 * size,  # conversion to millimeter radius
        radius_type=tmatrix.Scatterer.RADIUS_MAXIMUM,
        wavelength=wl * 1.0e3,  # conversion to millimeters
        m=n,
        axis_ratio=1.0 / ar)
    scatt.set_geometry(tmatrix_aux.geom_vert_back)
    return radar.radar_xsect(
        scatt
    )  # mm**2 ... need just to integrate and multiply by Rayleigh factor
Пример #3
0
def tmatrix_stuffses(dsd):
    drops = tmatrix.Scatterer(wavelength=aux.wl_C, m=ref.m_w_10C[aux.wl_C])
    drops.Kw_sqr = aux.K_w_sqr[aux.wl_C]
    drops.or_pdf = ori.gaussian_pdf(std=7.0)
    drops.orient = ori.orient_averaged_fixed
    drops.psd_integrator = psd.PSDIntegrator()
    drops.psd_integrator.D_max = 10.0
    drops.psd_integrator.axis_ratio_func = read.ar

    back = aux.geom_horiz_back
    forw = aux.geom_horiz_forw
    drops.psd_integrator.geometries = (back, forw)

    drops.psd_integrator.init_scatter_table(drops)

    psds = dsd.to_tm_series(resample=None)

    drops.set_geometry(back)

    zh = []
    zv = []
    zdr = []
    rho_hv = []
    ldr = []

    for tm_psd in psds:
        drops.psd = tm_psd
        zh.append(db(radar.refl(drops)))
        zv.append(db(radar.refl(drops, False)))
        zdr.append(db(radar.Zdr(drops)))
        rho_hv.append(radar.rho_hv(drops))
        ldr.append(db(radar.ldr(drops)))

    d = {
        'R': dsd.intensity(),
        'Zh': zh,
        'Zv': zv,
        'Zdr': zdr,
        'rho_hv': rho_hv,
        'LDR': ldr
    }
    return pd.DataFrame(data=d, index=psds.index)
Dmass, _, _ = snowScatt.snowMassVelocityArea(Dmax, 'vonTerzi_needle')

reff_sph = mass2reff(Dmass)
volume_fractions = 6.0 * Dmass / (ice_density * np.pi * aspect_ratio * Dmax**3
                                  )  # ar

ones = np.ones_like(volume_fractions)
ref_soft = snowScatt.refractiveIndex.mixing.eps(
    [ref_index**2 * ones, complex(1.0, 0.0) * ones],
    [volume_fractions, 1.0 - volume_fractions])
ref_soft = np.sqrt(ref_soft)

for iD, D in enumerate(Dmax):
    spheroid = tmatrix.Scatterer(radius=0.5 * D,
                                 radius_type=tmatrix.Scatterer.RADIUS_MAXIMUM,
                                 wavelength=wavelength,
                                 m=ref_soft[iD],
                                 axis_ratio=1.0 / aspect_ratio)
    spheroid.set_geometry(tmatrix_aux.geom_vert_back)
    spheroidCs[iD] = scatter.sca_xsect(spheroid)
    spheroidCb[iD] = radar.radar_xsect(spheroid)

spheroidQb = spheroidCb / (np.pi * reff_sph**2)
spheroidQs = spheroidCs / (np.pi * reff_sph**2)
spheroid_x = 2.0 * np.pi * reff_sph / wavelength

axs[0].plot(spheroid_x, spheroidQb, c='m', label='soft-spheroid')
axs[1].plot(spheroid_x, spheroidQs, c='m', label='soft-spheroid')
###############################################################################

for ipt, (particle_type, ssrga_particle) in enumerate(
Пример #5
0
            'wl',  # [31.557101, 8.565499, 3.155710]
            'elv',  # always 90
            'meanAngle',  # it is used only for prolate
            'cantingStd',  # always 1.0
            'radius',  # 8660
            'rho',  # 8706
            'as_ratio'  # 8769
        ]

        data = pd.read_csv('/home/dori/table_McRadar.txt',
                           delim_whitespace=True,
                           header=None,
                           names=column_names)  # 26463 lines
        data = data[np.abs((data.wl - wls[fi]) / wls[fi]) < 0.05]
        data = data[data.elv == e]
        scatterer = tmatrix.Scatterer(wavelength=1.0)
        scatterer.radius_type = tmatrix.Scatterer.RADIUS_MAXIMUM
        scatterer.ndgs = 30
        scatterer.ddelta = 1e-6
        i = 0
        if len(data):
            for index, row in data.iterrows():
                coords = Z11.sel(wavelength=row.wl,
                                 size=row.radius,
                                 aspect=row.as_ratio,
                                 density=row.rho,
                                 elevation=row.elv,
                                 canting=row.cantingStd,
                                 method='nearest').coords
                if np.isnan(Z11.loc[coords]):
                    print(index, i)
Пример #6
0
        den = rhoD(D)        
        return refractive.mi(w,den)
    return m_func

lambdas = np.linspace(1,10,20)
D0s = 3.67/lambdas

fig, (ax1,ax2,ax3) = plt.subplots(3,1)#,sharex=True)

Zdr_array = []
Z_array = []
for wl in wavelengths:
    ref_func = m_rho_func(wl)
    for lamb in lambdas:
        scatterer = tmatrix.Scatterer(wavelength=wl,
                              axis_ratio=1.0/ar,
                              Kw_sqr=tmatrix_aux.K_w_sqr[wl])
        scatterer.psd_integrator = psd.PSDIntegrator()
        scatterer.psd_integrator.m_func = ref_func
        scatterer.psd_integrator.geometries=[tmatrix_aux.geom_horiz_back,tmatrix_aux.geom_horiz_forw,]
        scatterer.set_geometry(tmatrix_aux.geom_horiz_back)
        scatterer.psd = psd.ExponentialPSD(N0=1.0,Lambda=lamb,D_max=20.0)
        scatterer.psd_integrator.D_max = 20.0
        scatterer.psd_integrator.init_scatter_table(scatterer)
        Zdr = 10.0*np.log10(radar.Zdr(scatterer))
        scatterer.set_geometry(tmatrix_aux.geom_horiz_forw)
        W = np.pi*1e3*(1.0/lamb)**4
        Kdp = 1.0e6*radar.Kdp(scatterer)/W
        Zdr_array.append(Zdr)
        Z_array.append(Kdp)
    ax1.plot(D0s,Zdr_array,label=wl)
Пример #7
0
@author: dori
"""
import sys
sys.path.append('/work/DBs/scattnlay')
from scattnlay import scattnlay
from pytmatrix import tmatrix, scatter, radar

import numpy as np

r = 2.0
wl = 100.0
m = complex(1.5, 0.5)
x = 2. * np.pi * r / wl
k = 2. * np.pi / wl

scatterer = tmatrix.Scatterer(radius=r, wavelength=wl, m=m, axis_ratio=1.0)
S, Z = scatterer.get_SZ()
print(S[0, 0], S[1, 1])

Nc = 1
Nl = 1
xr = np.ndarray((Nc, Nl), dtype=np.float64)
mr = np.ndarray((Nc, Nl), dtype=np.complex128)
xr[:, 0] = x
mr[:, 0] = m
thetas = np.linspace(0.0, np.pi, 180)
terms, Qe, Qs, Qa, Qb, Qp, g, ssa, S1, S2 = scattnlay(xr, mr, theta=thetas)
print(S1[0, -1] / k, S2[0, -1] / k)
s1 = S1[0, 0] / k
s2 = S2[0, 0] / k
SM = 0.0 * S
Пример #8
0
import numpy as np
from pytmatrix import refractive, scatter, tmatrix, tmatrix_aux

sys.path.append('../')

wl = tmatrix_aux.wl_S
m = refractive.mi(tmatrix_aux.wl_S,refractive.ice_density)

pi5 = np.pi**5.0
wl4 = wl**4.0
K = (m**2+1.0)/(m**2-2)
K2 = (K*K.conj()).real
pref = pi5*K2/wl4

scatt = tmatrix.Scatterer(radius=1.0,
                          wavelength=wl,
                          m=m,
                          axis_ratio=1.0)

plt.figure()
ax = plt.gca()
for th in np.linspace(0.0,180):
    scatt.thet = th
    [[S11,S12],[S21,S22]] = scatt.get_S()
    sig = scatter.sca_xsect(scatt)
#    ax.scatter(th,1e6*sig,c='m')
    ax.scatter(th,S11,c='b')
    ax.scatter(th,S12,c='r')
    ax.scatter(th,S21,c='g',marker='x')
    ax.scatter(th,S22,c='k')
ax.set_ylim([-0.0015,0.0015])
ax.set_ylim([-0.001355,-0.00135])
            -Lambda * D) / gamma(mu + 4.0)


#Lambda = (3.67+mu)/D0
D0s = np.linspace(0.75, 2.2, 10)
Zhh = 0.0 * D0s
Ai = 0.0 * D0s

wl = tmatrix_aux.wl_W
el = 0.

scatterer = tmatrix.Scatterer(
    wavelength=wl,
    m=refractive.m_w_10C[wl],
    #kw_sqr=tmatrix_aux.K_w_sqr[wl],
    radius_type=tmatrix.Scatterer.RADIUS_MAXIMUM,
    #or_pdf=orientation.gaussian_pdf(std=1.0),
    #orient=orientation.orient_averaged_fixed,
    thet0=90.0 - el,
    thet=90.0 + el)
Nw = 8000.0  # mm-2 m-3
mu = 5
scatterer.psd_integrator = psd.PSDIntegrator(
    D_max=8.0,
    geometries=(tmatrix_aux.geom_horiz_back, tmatrix_aux.geom_horiz_forw))
scatterer.psd_integrator.init_scatter_table(scatterer)
for i, D0 in enumerate(D0s):
    scatterer.psd = genGamma(Nw, D0, mu)  #psd.GammaPSD(D0=D0, mu=mu, Nw=Nw)
    scatterer.set_geometry(tmatrix_aux.geom_horiz_back)
    Zhh[i] = 10.0 * np.log10(radar.refl(scatterer))
    scatterer.set_geometry(tmatrix_aux.geom_horiz_forw)
Пример #10
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Sep  7 16:30:05 2018

@author: dori
"""

from pytmatrix import tmatrix

scatt = tmatrix.Scatterer(radius=0.01)

def Sorinet(scatt, t0=None, t=None, p0=None, p=None):
  if t0 is not None:
    scatt.thet0 = t0
  if p0 is not None:
    scatt.p0 = p0
  if t is not None:
    scatt.thet = t
  if p is not None:
    scatt.phi = p
  return scatt.get_S()[0,0]
Пример #11
0
import matplotlib.pyplot as plt

from pytmatrix import tmatrix
from pytmatrix import tmatrix_aux
from pytmatrix import radar
from pytmatrix import refractive
from pytmatrix import orientation

# Reference Mie calculation

wl = tmatrix_aux.wl_W
el = 0.
m = refractive.m_w_10C[wl]
scatterer = tmatrix.Scatterer(wavelength=wl,
                              m=m,
                              axis_ratio=1.0,
                              radius_type=tmatrix.Scatterer.RADIUS_MAXIMUM,
                              thet0=90.0 - el,
                              thet=90.0 + el)

Dmax = np.linspace(0.1, 2.7, 100)
Zhh = 0.0 * Dmax
Zvv = 0.0 * Dmax
Zdr = 0.0 * Dmax
for i, D in enumerate(Dmax):
    scatterer.radius = 0.5 * D
    Zdr[i] = 10.0 * np.log10(radar.Zdr(scatterer))
    Zhh[i] = 10.0 * np.log10(radar.refl(scatterer, h_pol=True))
    Zvv[i] = 10.0 * np.log10(radar.refl(scatterer, h_pol=False))

plt.figure()
ax0 = plt.gca()